Whlabel.php 251 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249
  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_fullorder_smt', 'fullorder_smt');
  15. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  16. $this->load->_model('Model_express', 'express');
  17. $this->load->_model('Model_shop', 'shop');
  18. $this->load->_model('Model_typeclass', 'typeclass');
  19. $this->load->_model('Model_country', 'country');
  20. $this->load->_model('Model_warehouse', 'warehouse');
  21. $this->load->_model('Model_kdniao', 'kdniao');
  22. $this->load->_model('Model_notice', 'notice');
  23. $this->load->_model('Model_dhl', 'dhl');
  24. $this->load->_model('Model_shop', 'shop');
  25. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  26. $this->load->_model('Model_ljg', 'ljg');
  27. $this->load->_model('Model_usps', 'usps');
  28. $this->load->_model('Model_specialstock', 'specialstock');
  29. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  30. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  31. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  32. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  33. $this->load->_model('Model_orderurl', 'orderurl');
  34. $this->load->_model('Model_brand', 'brand');
  35. $this->load->_model('Model_classid', 'classid');
  36. $this->load->_model('Model_apiyy', 'apiyy');
  37. $this->load->_model('Model_power', 'power');
  38. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  39. $this->load->_model('Model_company', 'company');
  40. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  41. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  42. }
  43. //定义方法的调用规则 获取URI第二段值
  44. public function _remap($arg, $arg_array)
  45. {
  46. if ($arg == 'existence') //在库标签
  47. {
  48. $this->_existence();
  49. } else if ($arg == 'cpbqdc') //在库标签
  50. {
  51. $this->_cpbqdc();
  52. } else if ($arg == 'type') //进销存浏览
  53. {
  54. $this->_type();
  55. } else if ($arg == 'typedy') //进销存浏览店员页面
  56. {
  57. $this->_typedy($arg_array);
  58. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  59. {
  60. $this->_typedy_ck($arg_array);
  61. } else if ($arg == 'typeck') {
  62. $this->_typeck($arg_array);
  63. } else if ($arg == 'whlabeckdc') {
  64. $this->_whlabeckdc($arg_array);
  65. } else if ($arg == 'usatype') //美仓进销存浏览
  66. {
  67. $this->_usatype();
  68. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  69. {
  70. $this->_usatypeapp();
  71. } else if ($arg == 'enteradd') //入库操作
  72. {
  73. $this->_enteradd();
  74. } else if ($arg == 'enteredit') //修改
  75. {
  76. $this->_enteredit($arg_array);
  77. } else if ($arg == 'enter') //入库浏览
  78. {
  79. $this->_enter();
  80. } else if ($arg == 'out') //出库浏览
  81. {
  82. $this->_out();
  83. } else if ($arg == 'label') //出库标签浏览
  84. {
  85. $this->_label();
  86. } else if ($arg == 'outorder') //独立站出库订单
  87. {
  88. $this->_outorder();
  89. } else if ($arg == 'soutorder') //速卖通出库订单
  90. {
  91. $this->_soutorder();
  92. } else if ($arg == 'toutorder') //TT出库订单
  93. {
  94. $this->_toutorder();
  95. } else if ($arg == 'retreat') //退库订单
  96. {
  97. $this->_retreat();
  98. } else if ($arg == 'retreatlk') //退库订单
  99. {
  100. $this->_retreatlk();
  101. } else if ($arg == 'change') //更换标签
  102. {
  103. $this->_change();
  104. } else if ($arg == 'del') //删除
  105. {
  106. $this->_del();
  107. } else if ($arg == 'exceljxc') //进销存信息导出
  108. {
  109. $this->_exceljxc();
  110. } else if ($arg == 'excelr') //入库信息导出
  111. {
  112. $this->_excelr();
  113. } else if ($arg == 'excelct') //出库、退库信息导出
  114. {
  115. $this->_excelct();
  116. } else if ($arg == 'dccrtype') //根据出入库类型导出
  117. {
  118. $this->_dccrtype();
  119. } else if ($arg == 'excelcr') //出库、退库信息导出
  120. {
  121. $this->_excelcr();
  122. } else if ($arg == 'kcyz') //库存验证
  123. {
  124. $this->_kcyz();
  125. } else if ($arg == 'kj') //库存扣减
  126. {
  127. $this->_kj($arg_array);
  128. } else if ($arg == 'presetout') //预设库存导入
  129. {
  130. $this->_presetout($arg_array);
  131. } else if ($arg == 'presetedit') //预设库存导入
  132. {
  133. $this->_presetedit($arg_array);
  134. } else if ($arg == 'summary') //汇总导出
  135. {
  136. $this->_summary($arg_array);
  137. } else if ($arg == 'manifest') //usps发货清单
  138. {
  139. $this->_manifest();
  140. } else if ($arg == 'abnormal') //占单异常
  141. {
  142. $this->_abnormal();
  143. } else if ($arg == 'error') //0库存SKU
  144. {
  145. $this->_error();
  146. } else if ($arg == 'errorexcel') //0库存SKU导出
  147. {
  148. $this->_errorexcel();
  149. } else if ($arg == 'db') {
  150. $this->_db();
  151. } else if ($arg == 'dbrk') {
  152. $this->_dbrk();
  153. } else if ($arg == 'whlabelczdc') {
  154. $this->_whlabelczdc();
  155. } else if ($arg == 'print') {
  156. $this->_print($arg_array);
  157. } else if ($arg == 'usaprint') {
  158. $this->_usaprint($arg_array);
  159. } else if ($arg == 'printck') {
  160. $this->_printck($arg_array);
  161. } else if ($arg == 'printrk') {
  162. $this->_printrk($arg_array);
  163. } else if ($arg == 'printxzrk') {
  164. $this->_printxzrk($arg_array);
  165. } else if ($arg == 'printexcel') {
  166. $this->_printexcel($arg_array);
  167. } else if ($arg == 'uck') {
  168. $this->_uck();
  169. } else if ($arg == 'whlabelexcelzh') {
  170. $this->_whlabelexcelzh();
  171. } else if ($arg == 'fc') {
  172. $this->_fc();
  173. } else if ($arg == 'fcmb') {
  174. $this->_fcmb();
  175. } else if ($arg == 'fcexcel') {
  176. $this->_fcexcel();
  177. } else if ($arg == 'fcjxc') {
  178. $this->_fcjxc($arg_array);
  179. } else if ($arg == '0kcdel') {
  180. $this->_0kcdel(); //导表删除0库存
  181. } else if ($arg == 'gbhtype') {
  182. $this->_gbhtype(); //更改备货状态
  183. } else {
  184. $this->_index();
  185. }
  186. }
  187. //管理
  188. public function _index()
  189. {
  190. $post = $this->input->post(NULL, TRUE);
  191. if (isset($post['page'])) {
  192. $page = $this->input->post('page', true);
  193. $perpage = $this->input->post('perpage', true);
  194. $sku = $this->input->post('sku', true);
  195. $number = $this->input->post('number', true);
  196. $warehouse = $this->input->post('warehouse', true);
  197. $purchase = $this->input->post('purchase', true);
  198. $orderinfo = $this->input->post('orderinfo', true);
  199. $waybill = $this->input->post('waybill', true);
  200. $category = $this->input->post('category', true);
  201. $size = $this->input->post('size', true);
  202. $grade = $this->input->post('grade', true);
  203. $color = $this->input->post('color', true);
  204. $lowe = $this->input->post('lowe', true);
  205. $state = $this->input->post('state', true);
  206. $label = $this->input->post('label', true);
  207. $timetk = $this->input->post('timetkk', true);
  208. $timetj = $this->input->post('timetjj', true);
  209. $timetk = strtotime($timetk);
  210. $timetj = strtotime($timetj);
  211. $where = "1=1 ";
  212. if ($timetk && $timetj) {
  213. $where .= " and time > '$timetk' and time < '$timetj'";
  214. }
  215. if ($sku) {
  216. $where .= " and sku = '$sku'";
  217. }
  218. if ($number) {
  219. $where .= " and number = '$number'";
  220. }
  221. if ($warehouse) {
  222. $where .= " and warehouse = '$warehouse'";
  223. }
  224. if ($purchase) {
  225. $where .= " and purchase = '$purchase'";
  226. }
  227. if ($orderinfo) {
  228. $where .= " and orderinfo = '$orderinfo'";
  229. }
  230. if ($waybill) {
  231. $where .= " and waybill = '$waybill'";
  232. }
  233. if ($category) {
  234. $where .= " and features like '%-$category-%'";
  235. }
  236. if ($size) {
  237. $where .= " and features like '%-$size-%'";
  238. }
  239. if ($grade) {
  240. $where .= " and features like '%-$grade-%'";
  241. }
  242. if ($color) {
  243. $where .= " and features like '%-$color-%'";
  244. }
  245. if ($lowe) {
  246. $where .= " and features like '%-$lowe-%'";
  247. }
  248. if ($label) {
  249. $where .= " and label = '$label'";
  250. }
  251. if ($state != '') {
  252. $where .= " and state = '$state'";
  253. }
  254. //数据排序
  255. $order_str = "time desc";
  256. if (empty($page)) {
  257. $start = 0;
  258. $perpage = 1;
  259. } else {
  260. $start = ($page - 1) * $perpage;
  261. }
  262. //取得信息列表
  263. $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);
  264. foreach ($info_list as $key => $value) {
  265. $warehouse = $this->warehouse->read($value['warehouse']);
  266. $info_list[$key]['warehouse'] = $warehouse['title'];
  267. $purchase = $this->purchase->read($value['purchase']);
  268. $info_list[$key]['purchase'] = $purchase['title'];
  269. if ($value['enter'] != 0) {
  270. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  271. } else {
  272. $info_list[$key]['enter'] = "";
  273. }
  274. if ($value['outk'] != 0) {
  275. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  276. } else {
  277. $info_list[$key]['outk'] = "";
  278. }
  279. if ($value['printing'] != 0) {
  280. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  281. } else {
  282. $info_list[$key]['printing'] = "";
  283. }
  284. if ($value['orderinfo'] == 0) {
  285. $info_list[$key]['orderinfo'] = "";
  286. }
  287. if ($value['waybill'] == 0) {
  288. $info_list[$key]['waybill'] = "";
  289. }
  290. if ($value['state'] == 0) {
  291. $info_list[$key]['state'] = "在库";
  292. } else if ($value['state'] == 1) {
  293. $info_list[$key]['state'] = "出库";
  294. } else if ($value['state'] == 2) {
  295. $info_list[$key]['state'] = "退库";
  296. } else if ($value['state'] == 3) {
  297. $info_list[$key]['state'] = "调拨中";
  298. } else if ($value['state'] == 4) {
  299. $info_list[$key]['state'] = "再加工";
  300. } else if ($value['state'] == 5) {
  301. $info_list[$key]['state'] = "维修中";
  302. } else if ($value['state'] == 6) {
  303. $info_list[$key]['state'] = "盘亏";
  304. } else if ($value['state'] == 7) {
  305. $info_list[$key]['state'] = "更换标签";
  306. } else if ($value['state'] == 8) {
  307. $info_list[$key]['state'] = "其它";
  308. } else if ($value['state'] == 9) {
  309. $info_list[$key]['state'] = "预设";
  310. } else if ($value['state'] == 10) {
  311. $info_list[$key]['state'] = "美店零售";
  312. }
  313. if ($value['text'] == "") {
  314. $info_list[$key]['text'] = "";
  315. }
  316. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  317. }
  318. $total = $this->whlabel->find_count($where);
  319. $pagenum = ceil($total / $perpage);
  320. $over = $total - ($start + $perpage);
  321. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  322. echo json_encode($rows);
  323. exit;
  324. }
  325. if (isset($post['outsku'])) {
  326. $cz = $this->input->post('cz', true);
  327. if ($cz == '1') {
  328. $sku = $this->input->post('outsku', true);
  329. if ($sku) {
  330. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  331. if (count($data) < 1) {
  332. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  333. exit;
  334. }
  335. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  336. echo json_encode(array('success' => true));
  337. exit;
  338. }
  339. } else {
  340. $sku = $this->input->post('outsku', true);
  341. if ($sku) {
  342. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  343. if (count($data) < 1) {
  344. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  345. exit;
  346. }
  347. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  348. echo json_encode(array('success' => true));
  349. exit;
  350. }
  351. }
  352. }
  353. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  354. $this->_Template('whlabel', $this->data);
  355. }
  356. //在库标签
  357. public function _existence()
  358. {
  359. $post = $this->input->post(NULL, TRUE);
  360. if (isset($post['s'])) {
  361. $id_arr = $this->input->post('s');
  362. $id_arr = explode(',', $id_arr);
  363. if (!$id_arr) {
  364. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  365. exit;
  366. }
  367. //循环删除记录
  368. foreach ($id_arr as $v) {
  369. $sid = $this->whlabel->read($v);
  370. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  371. if ($count > 0) {
  372. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  373. exit;
  374. }
  375. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  376. if (count($zt) > 0) {
  377. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  378. exit;
  379. }
  380. $this->whlabel->remove($v);
  381. }
  382. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  383. exit;
  384. }
  385. if (isset($post['page'])) {
  386. $page = $this->input->post('page', true);
  387. $perpage = $this->input->post('perpage', true);
  388. $warehouse = $this->input->post('warehouse', true);
  389. $label = $this->input->post('label', true);
  390. $where = "1=1 and state = 0";
  391. if ($warehouse) {
  392. $where .= " and warehouse = '$warehouse'";
  393. }
  394. if ($label) {
  395. $where .= " and label = '$label'";
  396. }
  397. //数据排序
  398. $order_str = "time asc";
  399. if (empty($page)) {
  400. $start = 0;
  401. $perpage = 1;
  402. } else {
  403. $start = ($page - 1) * $perpage;
  404. }
  405. //取得信息列表
  406. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  407. foreach ($info_list as $key => $value) {
  408. if ($value['enter'] != 0) {
  409. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  410. } else {
  411. $info_list[$key]['enter'] = "";
  412. }
  413. if ($value['printing'] != 0) {
  414. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  415. } else {
  416. $info_list[$key]['printing'] = "";
  417. }
  418. }
  419. $total = $this->whlabel->find_count($where);
  420. $pagenum = ceil($total / $perpage);
  421. $over = $total - ($start + $perpage);
  422. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  423. echo json_encode($rows);
  424. exit;
  425. }
  426. $this->_Template('whlabel_existence', $this->data);
  427. }
  428. //进销存浏览
  429. public function _typedy($arg_array)
  430. {
  431. $prc = array();
  432. $purchase = $this->purchase->find_all();
  433. foreach ($purchase as $k => $v) {
  434. $prc[$v['id']] = $v['title'];
  435. }
  436. $post = $this->input->post(NULL, TRUE);
  437. if (isset($post['page'])) {
  438. $page = $this->input->post('page', true);
  439. $perpage = $this->input->post('perpage', true);
  440. $category = $this->input->post('category', true);
  441. $size = $this->input->post('size', true);
  442. $grade = $this->input->post('grade', true);
  443. $color = $this->input->post('color', true);
  444. $lowe = $this->input->post('lowe', true);
  445. $sku = $this->input->post('sku');
  446. $title = $this->input->post('title');
  447. $warehouse = $this->input->post('warehouse', true);
  448. $usa = $this->input->post('usa', true);
  449. $purchase = $this->input->post('purchase', true);
  450. $lacetype = $this->input->post('lacetype', true);
  451. $haircap = $this->input->post('haircap', true);
  452. $density = $this->input->post('density', true);
  453. $details = $this->input->post('details', true);
  454. $state = $this->input->post('state', true);
  455. $lacecolor = $this->input->post('lacecolor', true);
  456. $hairnumber = $this->input->post('hairnumber', true);
  457. $cklx = $this->input->post('cklx', true);
  458. $ktime = $this->input->post('ktime', true);
  459. $jtime = $this->input->post('jtime', true);
  460. $ktime = strtotime($ktime);
  461. $jtime = strtotime($jtime);
  462. $where = "1=1";
  463. $gj = "";
  464. $ck = "";
  465. if ($usa) {
  466. if (!$warehouse) {
  467. $where .= " and (warehouse = '5' or warehouse = '8')";
  468. }
  469. }
  470. if ($warehouse) {
  471. $where .= " and warehouse = '$warehouse'";
  472. }
  473. if ($details) {
  474. $where .= " and details = '$details'";
  475. }
  476. if ($purchase) {
  477. $where .= " and purchase = '$purchase'";
  478. }
  479. if ($state) {
  480. $where .= " and state = '$state'";
  481. }
  482. if ($lacetype) {
  483. $where .= " and features like '%-$lacetype-%'";
  484. }
  485. if ($category) {
  486. $where .= " and features like '%-$category-%'";
  487. }
  488. if ($size) {
  489. $where .= " and features like '%-$size-%'";
  490. }
  491. if ($grade) {
  492. $where .= " and features like '%-$grade-%'";
  493. }
  494. if ($color) {
  495. $where .= " and features like '%-$color-%'";
  496. }
  497. if ($lowe) {
  498. $where .= " and features like '%-$lowe-%'";
  499. }
  500. if ($haircap) {
  501. $where .= " and features like '%-$haircap-%'";
  502. }
  503. if ($density) {
  504. $where .= " and features like '%-$density-%'";
  505. }
  506. if ($lacecolor) {
  507. $where .= " and features like '%-$lacecolor-%'";
  508. }
  509. if (!empty($hairnumber)) {
  510. $where .= " and features like '%-128-%' ";
  511. if ($hairnumber < 0) {
  512. $class_list = $this->typeclass->find_all('classid = 43');
  513. foreach ($class_list as $v) {
  514. $where .= " and features not like '%-" . $v['id'] . "-%'";
  515. }
  516. } else {
  517. $where .= " and features like '%-$hairnumber-%'";
  518. }
  519. }
  520. $where_add = '';
  521. if ($cklx) {
  522. $shop = $this->shop->read($cklx);
  523. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  524. }
  525. if ($ktime && $jtime) {
  526. $gj = " and enter > '$ktime' and enter < '$jtime'";
  527. $ck = " and outk > '$ktime' and outk < '$jtime'";
  528. }
  529. //数据排序
  530. $order_str = "id desc";
  531. if (empty($page)) {
  532. $start = 0;
  533. $perpage = 1;
  534. } else {
  535. $start = ($page - 1) * $perpage;
  536. }
  537. if ($sku) {
  538. $sku = trim($sku, ' ');
  539. $sku = trim($sku, ' ');
  540. $where .= " and sku like '%$sku%'";
  541. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  542. } else if ($title) {
  543. $title = trim($title, ' ');
  544. $title = trim($title, ' ');
  545. $where .= " and title like '%$title%'";
  546. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  547. } else {
  548. //$where .= " and time > '$ktime' and time < '$jtime'";
  549. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  550. }
  551. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  552. foreach ($info_list as $k => $v) {
  553. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  554. unset($info_list[$k]['pm']);
  555. unset($info_list[$k]['jm']);
  556. unset($info_list[$k]['bm']);
  557. }
  558. //取得信息列表
  559. $rows = array();
  560. $list = array();
  561. foreach ($info_list as $key => $value) {
  562. $warehouse = $this->warehouse->read($value['warehouse']);
  563. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  564. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  565. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  566. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  567. $number = $value['number'];
  568. $ftime = time() - 15 * 24 * 3600;
  569. $info_list[$key]['warehouse'] = $warehouse['title'];
  570. $info_list[$key]['features'] = count($c);
  571. $z = count($z); //查看订单号
  572. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  573. $ztdata = '';
  574. if (count($zt) > 0) {
  575. foreach ($zt as $vv) {
  576. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  577. }
  578. }
  579. $info_list[$key]['number'] = $ztdata;
  580. $info_list[$key]['sm'] = $z;
  581. $details = array();
  582. $cpid = array();
  583. foreach ($c as $k => $v) {
  584. $details[$v['details']] = $v['details'];
  585. if ($v['cpid'] != 0) {
  586. $cpid[$v['cpid']] = $v['cpid'];
  587. }
  588. }
  589. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  590. if ($value['shop'] != '') {
  591. $shop = explode(',', trim($value['shop'], ','));
  592. $shop = $this->shop->read($shop[0]);
  593. $info_list[$key]['shop'] = $shop['shopname'];
  594. }
  595. }
  596. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  597. $pagenum = ceil($total / $perpage);
  598. $over = $total - ($start + $perpage);
  599. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  600. echo json_encode($rows);
  601. exit;
  602. }
  603. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  604. $this->_Template('whlabel_typedy', $this->data);
  605. }
  606. //进销存浏览
  607. public function _typedy_ck($arg_array)
  608. {
  609. $prc = array();
  610. $purchase = $this->purchase->find_all();
  611. foreach ($purchase as $k => $v) {
  612. $prc[$v['id']] = $v['title'];
  613. }
  614. $post = $this->input->post(NULL, TRUE);
  615. if (isset($post['page'])) {
  616. $page = $this->input->post('page', true);
  617. $perpage = $this->input->post('perpage', true);
  618. $category = $this->input->post('category', true);
  619. $size = $this->input->post('size', true);
  620. $grade = $this->input->post('grade', true);
  621. $color = $this->input->post('color', true);
  622. $lowe = $this->input->post('lowe', true);
  623. $sku = $this->input->post('sku');
  624. $title = $this->input->post('title');
  625. $warehouse = $this->input->post('warehouse', true);
  626. $usa = $this->input->post('usa', true);
  627. $purchase = $this->input->post('purchase', true);
  628. $lacetype = $this->input->post('lacetype', true);
  629. $haircap = $this->input->post('haircap', true);
  630. $density = $this->input->post('density', true);
  631. $details = $this->input->post('details', true);
  632. $state = $this->input->post('state', true);
  633. $lacecolor = $this->input->post('lacecolor', true);
  634. $cklx = $this->input->post('cklx', true);
  635. $ktime = $this->input->post('ktime', true);
  636. $jtime = $this->input->post('jtime', true);
  637. $ktime = strtotime($ktime);
  638. $jtime = strtotime($jtime);
  639. $where = "1=1";
  640. $gj = "";
  641. $ck = "";
  642. if ($lacetype) {
  643. $where .= " and features like '%-$lacetype-%'";
  644. }
  645. if ($category) {
  646. $where .= " and features like '%-$category-%'";
  647. }
  648. if ($size) {
  649. $where .= " and features like '%-$size-%'";
  650. }
  651. if ($grade) {
  652. $where .= " and features like '%-$grade-%'";
  653. }
  654. if ($color) {
  655. $where .= " and features like '%-$color-%'";
  656. }
  657. if ($lowe) {
  658. $where .= " and features like '%-$lowe-%'";
  659. }
  660. if ($haircap) {
  661. $where .= " and features like '%-$haircap-%'";
  662. }
  663. if ($density) {
  664. $where .= " and features like '%-$density-%'";
  665. }
  666. if ($lacecolor) {
  667. $where .= " and features like '%-$lacecolor-%'";
  668. }
  669. if ($usa) {
  670. if (!$warehouse) {
  671. $where .= " and (warehouse = '5' or warehouse = '8')";
  672. }
  673. }
  674. if ($warehouse) {
  675. $where .= " and warehouse = '$warehouse'";
  676. }
  677. if ($details) {
  678. $where .= " and details = '$details'";
  679. }
  680. if ($purchase) {
  681. $where .= " and purchase = '$purchase'";
  682. }
  683. if ($state) {
  684. $where .= " and state = '$state'";
  685. }
  686. $where_add = '';
  687. if ($cklx) {
  688. $shop = $this->shop->read($cklx);
  689. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  690. }
  691. if ($ktime && $jtime) {
  692. $gj = " and enter > '$ktime' and enter < '$jtime'";
  693. $ck = " and outk > '$ktime' and outk < '$jtime'";
  694. }
  695. //数据排序
  696. $order_str = "id desc";
  697. if (empty($page)) {
  698. $start = 0;
  699. $perpage = 1;
  700. } else {
  701. $start = ($page - 1) * $perpage;
  702. }
  703. if ($sku) {
  704. $sku = trim($sku, ' ');
  705. $sku = trim($sku, ' ');
  706. $where .= " and sku like '%$sku%'";
  707. $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);
  708. } else if ($title) {
  709. $title = trim($title, ' ');
  710. $title = trim($title, ' ');
  711. $where .= " and title like '%$title%'";
  712. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  713. } else {
  714. //$where .= " and time > '$ktime' and time < '$jtime'";
  715. $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);
  716. }
  717. //取得信息列表
  718. $rows = array();
  719. $list = array();
  720. foreach ($info_list as $key => $value) {
  721. $warehouse = $this->warehouse->read($value['warehouse']);
  722. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  723. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  724. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  725. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  726. $ftime = time() - 15 * 24 * 3600;
  727. $info_list[$key]['warehouse'] = $warehouse['title'];
  728. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  729. //$z = count($z);//查看订单号
  730. //$info_list[$key]['zd'] = $z;
  731. $details = array();
  732. $cpid = array();
  733. foreach ($c as $k => $v) {
  734. $details[$v['details']] = $v['details'];
  735. if ($v['cpid'] != 0) {
  736. $cpid[$v['cpid']] = $v['cpid'];
  737. }
  738. }
  739. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  740. if ($value['shop'] != '') {
  741. $shop = explode(',', trim($value['shop'], ','));
  742. $shop = $this->shop->read($shop[0]);
  743. $info_list[$key]['shop'] = $shop['shopname'];
  744. }
  745. }
  746. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  747. $pagenum = ceil($total / $perpage);
  748. $over = $total - ($start + $perpage);
  749. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  750. echo json_encode($rows);
  751. exit;
  752. }
  753. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  754. $this->_Template('whlabel_typedy_ck', $this->data);
  755. }
  756. public function _typeck($arg_array)
  757. {
  758. $prc = array();
  759. $purchase = $this->purchase->find_all();
  760. foreach ($purchase as $k => $v) {
  761. $prc[$v['id']] = $v['title'];
  762. }
  763. $post = $this->input->post(NULL, TRUE);
  764. if (isset($post['page'])) {
  765. $page = $this->input->post('page', true);
  766. $perpage = $this->input->post('perpage', true);
  767. $category = $this->input->post('category', true);
  768. $size = $this->input->post('size', true);
  769. $grade = $this->input->post('grade', true);
  770. $color = $this->input->post('color', true);
  771. $lacecolor = $this->input->post('lacecolor', true);
  772. $lowe = $this->input->post('lowe', true);
  773. $sku = $this->input->post('sku');
  774. $title = $this->input->post('title');
  775. $warehouse = 13;
  776. $usa = $this->input->post('usa', true);
  777. $purchase = $this->input->post('purchase', true);
  778. $lacetype = $this->input->post('lacetype', true);
  779. $haircap = $this->input->post('haircap', true);
  780. $density = $this->input->post('density', true);
  781. $details = $this->input->post('details', true);
  782. $state = $this->input->post('state', true);
  783. $ktime = $this->input->post('ktime', true);
  784. $jtime = $this->input->post('jtime', true);
  785. $ktime = strtotime($ktime);
  786. $jtime = strtotime($jtime);
  787. $where = "1=1";
  788. $gj = "";
  789. $ck = "";
  790. if ($lacetype) {
  791. $where .= " and features like '%-$lacetype-%'";
  792. }
  793. if ($category) {
  794. $where .= " and features like '%-$category-%'";
  795. }
  796. if ($size) {
  797. $where .= " and features like '%-$size-%'";
  798. }
  799. if ($grade) {
  800. $where .= " and features like '%-$grade-%'";
  801. }
  802. if ($color) {
  803. $where .= " and features like '%-$color-%'";
  804. }
  805. if ($lacecolor) {
  806. $where .= " and features like '%-$lacecolor-%'";
  807. }
  808. if ($lowe) {
  809. $where .= " and features like '%-$lowe-%'";
  810. }
  811. if ($haircap) {
  812. $where .= " and features like '%-$haircap-%'";
  813. }
  814. if ($density) {
  815. $where .= " and features like '%-$density-%'";
  816. }
  817. if ($warehouse) {
  818. $where .= " and warehouse = '$warehouse'";
  819. }
  820. if ($details) {
  821. $where .= " and details = '$details'";
  822. }
  823. if ($purchase) {
  824. $where .= " and purchase = '$purchase'";
  825. }
  826. if ($state) {
  827. $where .= " and state = '$state'";
  828. }
  829. if ($ktime && $jtime) {
  830. $gj = " and enter > '$ktime' and enter < '$jtime'";
  831. $ck = " and outk > '$ktime' and outk < '$jtime'";
  832. }
  833. //数据排序
  834. $order_str = "id desc";
  835. if (empty($page)) {
  836. $start = 0;
  837. $perpage = 1;
  838. } else {
  839. $start = ($page - 1) * $perpage;
  840. }
  841. if ($sku) {
  842. $sku = trim($sku, ' ');
  843. $sku = trim($sku, ' ');
  844. $where .= " and sku like '%$sku%'";
  845. } else if ($title) {
  846. $title = trim($title, ' ');
  847. $title = trim($title, ' ');
  848. $where .= " and title like '%$title%'";
  849. }
  850. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  851. //取得信息列表
  852. $t = array();
  853. $typeclass = $this->typeclass->find_all();
  854. foreach ($typeclass as $v) {
  855. $t[$v['id']] = $v;
  856. }
  857. $rows = array();
  858. $list = array();
  859. foreach ($info_list as $key => $value) {
  860. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  861. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  862. $warehouse = $this->warehouse->read($value['warehouse']);
  863. $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');
  864. $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'] . '"');
  865. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  866. $number = $value['number'];
  867. $ftime = time() - 15 * 24 * 3600;
  868. $z = count($z); //查看订单号
  869. $info_list[$key]['warehouse'] = $warehouse['title'];
  870. $info_list[$key]['features'] = count($c);
  871. $info_list[$key]['number'] = $z;
  872. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  873. $details = array();
  874. $cpid = array();
  875. foreach ($c as $k => $v) {
  876. $details[$v['details']] = $v['details'];
  877. if ($v['cpid'] != 0) {
  878. $cpid[$v['cpid']] = $v['cpid'];
  879. }
  880. }
  881. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  882. $classid = $this->classid->sku();
  883. $pm = $classid;
  884. $features = explode('-', trim($value['features'], '-'));
  885. foreach ($features as $v) {
  886. $zh = explode('|', trim($t[$v]['zh'], '|'));
  887. $pm[$t[$v]['classid']] = $zh[0];
  888. }
  889. $zh = implode(" ", $pm);
  890. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  891. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  892. $info_list[$key]['sm'] = $zh;
  893. }
  894. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  895. $pagenum = ceil($total / $perpage);
  896. $over = $total - ($start + $perpage);
  897. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  898. echo json_encode($rows);
  899. exit;
  900. }
  901. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  902. $this->_Template('whlabel_typeck', $this->data);
  903. }
  904. //进销存导出
  905. public function _whlabeckdc()
  906. {
  907. $prc = array();
  908. $purchase = $this->purchase->find_all();
  909. foreach ($purchase as $k => $v) {
  910. $prc[$v['id']] = $v['title'];
  911. }
  912. if (isset($_GET['excel'])) {
  913. $where = "sku != 'Preset'";
  914. //数据排序
  915. $order_str = "id desc";
  916. if (empty($page)) {
  917. $start = 0;
  918. $perpage = 1;
  919. } else {
  920. $start = ($page - 1) * $perpage;
  921. }
  922. $category = $this->input->get('category', true);
  923. $color = $this->input->get('color', true);
  924. $lowe = $this->input->get('lowe', true);
  925. $lacetype = $this->input->get('lacetype', true);
  926. $size = $this->input->get('size', true);
  927. $density = $this->input->get('density', true);
  928. $haircap = $this->input->get('haircap', true);
  929. $sku = $this->input->get('sku', true);
  930. $details = $this->input->get('details', true);
  931. $warehouse = 13;
  932. $excelid = $this->input->get('sid', true);
  933. if ($category) {
  934. $where .= " and features like '%-$category-%'";
  935. }
  936. if ($color) {
  937. $where .= " and features like '%-$color-%'";
  938. }
  939. if ($lowe) {
  940. $where .= " and features like '%-$lowe-%'";
  941. }
  942. if ($lacetype) {
  943. $where .= " and features like '%-$lacetype-%'";
  944. }
  945. if ($size) {
  946. $where .= " and features like '%-$size-%'";
  947. }
  948. if ($density) {
  949. $where .= " and features like '%-$density-%'";
  950. }
  951. if ($haircap) {
  952. $where .= " and features like '%-$haircap-%'";
  953. }
  954. if ($warehouse) {
  955. $where .= " and warehouse = '$warehouse'";
  956. }
  957. if ($sku) {
  958. $where .= " and sku like '%$sku%'";
  959. }
  960. if ($details) {
  961. $where .= " and details = '$details'";
  962. }
  963. $xzid = '';
  964. if ($excelid) {
  965. $excelid = explode(',', trim($excelid, ','));
  966. foreach ($excelid as $key => $value) {
  967. $xzid .= " id = " . $value . " or";
  968. }
  969. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  970. }
  971. //取得信息列表
  972. /**
  973. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  974. $rows = array();$list = array();
  975. foreach ($info_list as $key=>$value)
  976. {
  977. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  978. }
  979. **/
  980. $wh = array();
  981. $w = $this->warehouse->find_all('1=1', 'id,title');
  982. foreach ($w as $v) {
  983. $wh[$v['id']] = $v['title'];
  984. }
  985. $tc = array();
  986. $tcdata = array();
  987. $typeclass = $this->typeclass->find_all();
  988. foreach ($typeclass as $v) {
  989. $tc[$v['id']] = $v;
  990. }
  991. $list = array();
  992. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  993. foreach ($rows as $key => $value) {
  994. $bm = '03';
  995. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  996. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  997. $classid = $this->classid->sku();
  998. $pm = $classid;
  999. $jm = $classid;
  1000. $features = explode('-', trim($value['features'], '-'));
  1001. foreach ($features as $v) {
  1002. if (isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']])) {
  1003. if ($tc[$v]['bm'] != '') {
  1004. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1005. }
  1006. }
  1007. if (isset($tc[$v])) {
  1008. $zh = explode('|', trim($tc[$v]['zh'], '|'));
  1009. $pm[$tc[$v]['classid']] = $zh[0];
  1010. }
  1011. if (isset($tc[$v])) {
  1012. if (isset($jm[$tc[$v]['classid']])) {
  1013. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1014. }
  1015. }
  1016. }
  1017. $zh = implode(" ", $pm);
  1018. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1019. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1020. $rows[$key]['dbcontent'] = $zh;
  1021. $rows[$key]['cpbz'] = $bm . implode("", $bmpx);
  1022. $jm = array_filter($jm);
  1023. $rows[$key]['cs'] = implode("-", $jm);
  1024. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1025. $details = array();
  1026. $cpid = array();
  1027. $cpbz = array();
  1028. $c = 0;
  1029. $g = 0;
  1030. $x = 0;
  1031. $t = 0;
  1032. $s = 0;
  1033. $q = 0;
  1034. foreach ($sd as $k => $v) {
  1035. if ($v['state'] == 0) {
  1036. $c++;
  1037. }
  1038. if ($v['state'] != 9) {
  1039. $g++;
  1040. }
  1041. if ($v['state'] == 1) {
  1042. $x++;
  1043. }
  1044. if ($v['state'] == 2) {
  1045. $t++;
  1046. }
  1047. if ($v['state'] == 8) {
  1048. $s++;
  1049. }
  1050. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1051. $q++;
  1052. }
  1053. $details[$v['details']] = $v['details'];
  1054. if ($v['cpid'] != 0) {
  1055. $cpid[$v['cpid']] = $v['cpid'];
  1056. }
  1057. if ($v['cpbz'] != '') {
  1058. $cpbz[$v['cpbz']] = $v['cpbz'];
  1059. }
  1060. }
  1061. $rows[$key]['details'] = implode("、", $details);
  1062. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1063. $number = $value['number'];
  1064. $ftime = time() - 15 * 24 * 3600;
  1065. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1066. $rows[$key]['number'] = $g;
  1067. $rows[$key]['features'] = $c;
  1068. $rows[$key]['x'] = $x;
  1069. $rows[$key]['t'] = $t;
  1070. $rows[$key]['s'] = $s;
  1071. $rows[$key]['q'] = $q;
  1072. $rows[$key]['wzsl'] = count($details);
  1073. }
  1074. $title = "进销存统计表" . date('Y-m-d', time());
  1075. $titlename = "<table border=1>
  1076. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1077. <tr align='center'>
  1078. <td>仓库</td>
  1079. <td>供应商</td>
  1080. <td>位置</td>
  1081. <td>库存编码</td>
  1082. <td>SKU</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. <td>位置数量</td>
  1094. </tr>
  1095. </table>";
  1096. $filename = $title . ".xls";
  1097. $tail = "";
  1098. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1099. }
  1100. }
  1101. public function _type()
  1102. {
  1103. $vip = 0;
  1104. if (isset($_SESSION['api'])) {
  1105. $user = $this->user->get_api($_SESSION['api']);
  1106. $fgshop = "";
  1107. $sid = "";
  1108. $usersp = explode('|', trim($user['shop'], '|'));
  1109. foreach ($usersp as $value) {
  1110. $fgshop .= " shop = " . $value . " or";
  1111. $sid .= " id = " . $value . " or";
  1112. }
  1113. if ($user['vip'] == 1) {
  1114. $vip = 1;
  1115. }
  1116. } else {
  1117. header('Location: /');
  1118. exit;
  1119. }
  1120. $prc = array();
  1121. $purchase = $this->purchase->find_all();
  1122. foreach ($purchase as $k => $v) {
  1123. $prc[$v['id']] = $v['title'];
  1124. }
  1125. $company = array();
  1126. $ct = $this->company->find_all();
  1127. foreach ($ct as $k => $v) {
  1128. $company[$v['id']] = $v['title'];
  1129. }
  1130. $sp = array();
  1131. $s = $this->shop->find_all('1=1', 'id,shopname');
  1132. foreach ($s as $v) {
  1133. $sp[$v['id']] = $v['shopname'];
  1134. }
  1135. $wh = array();
  1136. $w = $this->warehouse->find_all('1=1', 'id,title');
  1137. foreach ($w as $v) {
  1138. $wh[$v['id']] = $v['title'];
  1139. }
  1140. $post = $this->input->post(NULL, TRUE);
  1141. if (isset($post['page'])) {
  1142. $page = $this->input->post('page', true);
  1143. $perpage = $this->input->post('perpage', true);
  1144. $category = $this->input->post('category', true);
  1145. $size = $this->input->post('size', true);
  1146. $grade = $this->input->post('grade', true);
  1147. $color = $this->input->post('color', true);
  1148. $lowe = $this->input->post('lowe', true);
  1149. $sku = $this->input->post('sku');
  1150. $title = $this->input->post('title');
  1151. $warehouse = $this->input->post('warehouse', true);
  1152. $usa = $this->input->post('usa', true);
  1153. $purchase = $this->input->post('purchase', true);
  1154. $lacetype = $this->input->post('lacetype', true);
  1155. $haircap = $this->input->post('haircap', true);
  1156. $density = $this->input->post('density', true);
  1157. $details = $this->input->post('details', true);
  1158. $state = $this->input->post('state', true);
  1159. $shop = $this->input->post('shop', true);
  1160. $lacecolor = $this->input->post('lacecolor', true);
  1161. $hairnumber = $this->input->post('hairnumber', true);
  1162. $type = $this->input->post('type', true);
  1163. $ktime = $this->input->post('ktime', true);
  1164. $jtime = $this->input->post('jtime', true);
  1165. $ktime = strtotime($ktime);
  1166. $jtime = strtotime($jtime);
  1167. $cpbz = $this->input->post('cpbz', 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 ($lacecolor) {
  1202. $where .= " and features like '%-$lacecolor-%'";
  1203. }
  1204. if ($lacetype) {
  1205. $where .= " and features like '%-$lacetype-%'";
  1206. }
  1207. if ($category) {
  1208. $where .= " and features like '%-$category-%'";
  1209. }
  1210. if ($size) {
  1211. $where .= " and features like '%-$size-%'";
  1212. }
  1213. if ($grade) {
  1214. $where .= " and features like '%-$grade-%'";
  1215. }
  1216. if ($color) {
  1217. $where .= " and features like '%-$color-%'";
  1218. }
  1219. if ($lowe) {
  1220. $where .= " and features like '%-$lowe-%'";
  1221. }
  1222. if ($haircap) {
  1223. $where .= " and features like '%-$haircap-%'";
  1224. }
  1225. if ($density) {
  1226. $where .= " and features like '%-$density-%'";
  1227. }
  1228. if (!empty($hairnumber)) {
  1229. $where .= " and features like '%-128-%' ";
  1230. if ($hairnumber < 0) {
  1231. $class_list = $this->typeclass->find_all('classid = 43');
  1232. foreach ($class_list as $v) {
  1233. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1234. }
  1235. } else {
  1236. $where .= " and features like '%-$hairnumber-%'";
  1237. }
  1238. }
  1239. //数据排序
  1240. $order_str = "id desc";
  1241. if (empty($page)) {
  1242. $start = 0;
  1243. $perpage = 1;
  1244. } else {
  1245. $start = ($page - 1) * $perpage;
  1246. }
  1247. $fjnr = '';
  1248. if ($sku) {
  1249. $sku = trim($sku, ' ');
  1250. $sku = trim($sku, ' ');
  1251. $fjnr .= " and sku like '%$sku%'";
  1252. }
  1253. if ($title) {
  1254. $title = trim($title, ' ');
  1255. $title = trim($title, ' ');
  1256. $fjnr .= " and title like '%$title%'";
  1257. }
  1258. $wt = array();
  1259. $whlabel_type = $this->whlabel_type->find_all();
  1260. foreach ($whlabel_type as $v) {
  1261. $wt[$v['id']] = $v['title'];
  1262. }
  1263. //$where .= " and time > '$ktime' and time < '$jtime'";
  1264. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1265. //取得信息列表
  1266. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1267. $rows = array();
  1268. $list = array();
  1269. foreach ($info_list as $key => $value) {
  1270. if (isset($wt[$value['type']])) {
  1271. $info_list[$key]['type'] = $wt[$value['type']];
  1272. } else {
  1273. $info_list[$key]['type'] = '未设置';
  1274. }
  1275. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1276. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1277. $ztdata = '';
  1278. if (count($zt) > 0) {
  1279. foreach ($zt as $vv) {
  1280. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1281. }
  1282. }
  1283. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1284. $cdata = array_filter($qbdata, function ($item) {
  1285. return $item['state'] < 1;
  1286. });
  1287. $c = array_sum(array_column($cdata, 'jnum'));
  1288. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1289. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1290. });
  1291. $g = array_sum(array_column($gdata, 'jnum'));
  1292. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1293. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1294. });
  1295. $x = array_sum(array_column($xdata, 'jnum'));
  1296. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1297. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1298. });
  1299. $t = array_sum(array_column($tdata, 'jnum'));
  1300. $zdata = array_filter($qbdata, function ($item) {
  1301. return $item['zd'] != "" && $item['state'] < 1;
  1302. });
  1303. $z = array_sum(array_column($zdata, 'jnum'));
  1304. $zdata = array_filter($qbdata, function ($item) {
  1305. return $item['zd'] != "" && $item['state'] < 1;
  1306. });
  1307. $z = array_sum(array_column($zdata, 'jnum'));
  1308. //$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');
  1309. //$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'].'"');
  1310. //$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'].'"');
  1311. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1312. //$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'].'"');
  1313. $details = array();
  1314. $cpid = array();
  1315. $od = array();
  1316. $odid = '';
  1317. $companytitle = '';
  1318. foreach ($qbdata as $v) {
  1319. if ($v['zd'] != "" && $v['state'] < 1) {
  1320. if (!isset($od[$v['zd']])) {
  1321. $od[$v['zd']] = 1; //所有数据sku
  1322. } else {
  1323. $od[$v['zd']] = $od[$v['zd']] + 1;
  1324. }
  1325. }
  1326. if ($v['state'] < 1) {
  1327. $details[$v['details']] = $v['details'];
  1328. if ($v['cpid'] != 0) {
  1329. $cpid[$v['cpid']] = $v['cpid'];
  1330. }
  1331. }
  1332. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1333. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1334. }
  1335. }
  1336. foreach ($od as $k => $vv) {
  1337. $odid .= $k . '数量' . $vv;
  1338. }
  1339. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1340. $number = $value['number'];
  1341. $ftime = time() - 15 * 24 * 3600;
  1342. $z = $z . '(' . $odid . ')'; //查看订单号
  1343. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1344. $info_list[$key]['features'] = $c;
  1345. $info_list[$key]['number'] = $ztdata;
  1346. $info_list[$key]['sm'] = $g;
  1347. $info_list[$key]['x'] = $x;
  1348. $info_list[$key]['t'] = $t;
  1349. $info_list[$key]['z'] = $z;
  1350. /**
  1351. foreach ($cdata as $k=>$v)
  1352. {
  1353. $details[$v['details']] = $v['details'];
  1354. if($v['cpid'] != 0)
  1355. {
  1356. $cpid[$v['cpid']] = $v['cpid'];
  1357. }
  1358. }
  1359. **/
  1360. $info_list[$key]['shop'] = '';
  1361. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1362. if ($value['shop'] != '') {
  1363. $shop = explode(',', trim($value['shop'], ','));
  1364. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1365. }
  1366. $info_list[$key]['shop'] .= $companytitle;
  1367. /**
  1368. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1369. if(isset($companytitle[0]))
  1370. {
  1371. foreach ($companytitle as $k=>$v)
  1372. {
  1373. if($v['companytitle'] != '')
  1374. {
  1375. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1376. }
  1377. }
  1378. }
  1379. **/
  1380. }
  1381. $final_all_list = [];
  1382. foreach ($info_list as $k => $v) {
  1383. $final_all_list[] = [
  1384. 'id' => $v['id'],
  1385. "warehouse" => $v["warehouse"],
  1386. "purchase" => $v["purchase"],
  1387. "sku" => $v["sku"],
  1388. "title" => $v["title"] . "<br/>" . $v["pm"],
  1389. "details" => $v["details"],
  1390. "shop" => $v["shop"],
  1391. "cpbz" => $v["cpbz"],
  1392. "type" => $v["type"],
  1393. "features" => $v["features"],
  1394. "number" => $v["number"],
  1395. "sm" => $v["sm"],
  1396. "x" => $v["x"],
  1397. "t" => $v["t"],
  1398. "z" => $v["z"]
  1399. ];
  1400. }
  1401. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1402. $pagenum = ceil($total / $perpage);
  1403. $over = $total - ($start + $perpage);
  1404. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1405. echo json_encode($rows);
  1406. exit;
  1407. }
  1408. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1409. $this->data['shop'] = $wlshop;
  1410. $this->data['vip'] = $vip;
  1411. $this->_Template('whlabel_type', $this->data);
  1412. }
  1413. //美仓进销存浏览
  1414. public function _usatype()
  1415. {
  1416. if (isset($_SESSION['api'])) {
  1417. $user = $this->user->get_api($_SESSION['api']);
  1418. $usp = $user;
  1419. $fgshop = "";
  1420. $sid = "";
  1421. $wid = "";
  1422. $wtype = "";
  1423. $userwh = explode('|', trim($user['warehouse'], '|'));
  1424. foreach ($userwh as $value) {
  1425. $wid .= " id = " . $value . " or";
  1426. $wtype .= " type = " . $value . " or";
  1427. }
  1428. }
  1429. $prc = array();
  1430. $purchase = $this->purchase->find_all();
  1431. foreach ($purchase as $k => $v) {
  1432. $prc[$v['id']] = $v['title'];
  1433. }
  1434. $post = $this->input->post(NULL, TRUE);
  1435. if (isset($post['page'])) {
  1436. $page = $this->input->post('page', true);
  1437. $perpage = $this->input->post('perpage', true);
  1438. $category = $this->input->post('category', true);
  1439. $size = $this->input->post('size', true);
  1440. $grade = $this->input->post('grade', true);
  1441. $color = $this->input->post('color', true);
  1442. $lowe = $this->input->post('lowe', true);
  1443. $sku = $this->input->post('sku');
  1444. $title = $this->input->post('title');
  1445. $warehouse = $this->input->post('warehouse', true);
  1446. $usa = $this->input->post('usa', true);
  1447. $purchase = $this->input->post('purchase', true);
  1448. $lacetype = $this->input->post('lacetype', true);
  1449. $haircap = $this->input->post('haircap', true);
  1450. $density = $this->input->post('density', true);
  1451. $details = $this->input->post('details', true);
  1452. $state = $this->input->post('state', true);
  1453. $lacecolor = $this->input->post('lacecolor', true);
  1454. $cklx = $this->input->post('cklx', true);
  1455. $ktime = $this->input->post('ktime', true);
  1456. $jtime = $this->input->post('jtime', true);
  1457. $ktime = strtotime($ktime);
  1458. $jtime = strtotime($jtime);
  1459. $where = "1=1";
  1460. $gj = "";
  1461. $ck = "";
  1462. if ($lacetype) {
  1463. $where .= " and features like '%-$lacetype-%'";
  1464. }
  1465. if ($category) {
  1466. $where .= " and features like '%-$category-%'";
  1467. }
  1468. if ($size) {
  1469. $where .= " and features like '%-$size-%'";
  1470. }
  1471. if ($grade) {
  1472. $where .= " and features like '%-$grade-%'";
  1473. }
  1474. if ($color) {
  1475. $where .= " and features like '%-$color-%'";
  1476. }
  1477. if ($lowe) {
  1478. $where .= " and features like '%-$lowe-%'";
  1479. }
  1480. if ($haircap) {
  1481. $where .= " and features like '%-$haircap-%'";
  1482. }
  1483. if ($density) {
  1484. $where .= " and features like '%-$density-%'";
  1485. }
  1486. if ($lacecolor) {
  1487. $where .= " and features like '%-$lacecolor-%'";
  1488. }
  1489. if ($usa) {
  1490. if (!$warehouse) {
  1491. $where .= " and (warehouse = '5' or warehouse = '8')";
  1492. }
  1493. }
  1494. if ($warehouse) {
  1495. $where .= " and warehouse = '$warehouse'";
  1496. }
  1497. if ($details) {
  1498. $where .= " and details = '$details'";
  1499. }
  1500. if ($purchase) {
  1501. $where .= " and purchase = '$purchase'";
  1502. }
  1503. if ($state) {
  1504. $where .= " and state = '$state'";
  1505. }
  1506. $where_add = '';
  1507. if ($cklx) {
  1508. $shop = $this->shop->read($cklx);
  1509. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1510. }
  1511. if ($ktime && $jtime) {
  1512. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1513. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1514. }
  1515. //数据排序
  1516. $order_str = "id desc";
  1517. if (empty($page)) {
  1518. $start = 0;
  1519. $perpage = 1;
  1520. } else {
  1521. $start = ($page - 1) * $perpage;
  1522. }
  1523. if ($sku) {
  1524. $sku = trim($sku, ' ');
  1525. $sku = trim($sku, ' ');
  1526. $where .= " and sku like '%$sku%'";
  1527. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1528. } else if ($title) {
  1529. $title = trim($title, ' ');
  1530. $title = trim($title, ' ');
  1531. $where .= " and title like '%$title%'";
  1532. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1533. } else {
  1534. //$where .= " and time > '$ktime' and time < '$jtime'";
  1535. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1536. }
  1537. //取得信息列表
  1538. $rows = array();
  1539. $list = array();
  1540. foreach ($info_list as $key => $value) {
  1541. $warehouse = $this->warehouse->read($value['warehouse']);
  1542. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1543. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1544. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1545. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1546. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1547. $od = array();
  1548. $odid = '';
  1549. foreach ($z as $v) {
  1550. if (!isset($od[$v['zd']])) {
  1551. $od[$v['zd']] = 1; //所有数据sku
  1552. } else {
  1553. $od[$v['zd']] = $od[$v['zd']] + 1;
  1554. }
  1555. }
  1556. foreach ($od as $k => $vv) {
  1557. $odid .= $k . '数量' . $vv . ' ';
  1558. }
  1559. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1560. $info_list[$key]['features'] = $c;
  1561. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1562. $ztdata = '';
  1563. if (count($zt) > 0) {
  1564. foreach ($zt as $vv) {
  1565. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1566. }
  1567. }
  1568. $info_list[$key]['warehouse'] = $ztdata;
  1569. $info_list[$key]['g'] = $g;
  1570. $info_list[$key]['x'] = $x;
  1571. $info_list[$key]['t'] = $t;
  1572. $info_list[$key]['z'] = $z;
  1573. }
  1574. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1575. $pagenum = ceil($total / $perpage);
  1576. $over = $total - ($start + $perpage);
  1577. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1578. echo json_encode($rows);
  1579. exit;
  1580. }
  1581. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1582. $this->data['warehouse'] = $warehouse;
  1583. $this->_Template('whlabel_typeusa', $this->data);
  1584. }
  1585. //美仓进销存浏览
  1586. public function _usatypeapp()
  1587. {
  1588. $post = $this->input->post(NULL, TRUE);
  1589. if (isset($post['page'])) {
  1590. $page = $this->input->post('page', true);
  1591. $perpage = $this->input->post('perpage', true);
  1592. $sku = $this->input->post('sku', true);
  1593. $warehouse = 5;
  1594. $title = $this->input->post('title', true);
  1595. $state = $this->input->post('state', true);
  1596. $ktime = $this->input->post('ktime', true);
  1597. $jtime = $this->input->post('jtime', true);
  1598. $ktime = strtotime($ktime);
  1599. $jtime = strtotime($jtime);
  1600. $where = "1=1";
  1601. $gj = "";
  1602. $ck = "";
  1603. if ($title) {
  1604. $st = explode(' ', trim($title, ' '));
  1605. foreach ($st as $v) {
  1606. $where .= " and title like '%$v%'";
  1607. }
  1608. }
  1609. if ($warehouse) {
  1610. $where .= " and warehouse = '$warehouse'";
  1611. }
  1612. if ($state) {
  1613. $where .= " and state = '$state'";
  1614. }
  1615. if ($sku) {
  1616. $where .= " and sku like '%$sku%'";
  1617. }
  1618. if ($ktime && $jtime) {
  1619. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1620. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1621. }
  1622. //数据排序
  1623. $order_str = "id desc";
  1624. if (empty($page)) {
  1625. $start = 0;
  1626. $perpage = 1;
  1627. } else {
  1628. $start = ($page - 1) * $perpage;
  1629. }
  1630. //取得信息列表
  1631. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1632. $rows = array();
  1633. $list = array();
  1634. foreach ($info_list as $key => $value) {
  1635. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1636. }
  1637. $rowsdq = array_slice($rows, $start, $perpage);
  1638. foreach ($rowsdq as $value) {
  1639. $warehouse = $this->warehouse->read($value['warehouse']);
  1640. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1641. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1642. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1643. $od = array();
  1644. $odid = '';
  1645. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1646. }
  1647. $total = count($rows);
  1648. $pagenum = ceil($total / $perpage);
  1649. $over = $total - ($start + $perpage);
  1650. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1651. echo json_encode($rows);
  1652. exit;
  1653. }
  1654. $this->_Template('phone/p_usatypeapp', $this->data);
  1655. }
  1656. //入库操作
  1657. public function _enteradd()
  1658. {
  1659. $dt = 0;
  1660. if (isset($_SESSION['api'])) {
  1661. $user = $this->user->get_api($_SESSION['api']);
  1662. $usp = $user;
  1663. $fgshop = "";
  1664. $sid = "";
  1665. $user = explode('|', trim($user['shop'], '|'));
  1666. foreach ($user as $value) {
  1667. $fgshop .= " shop = " . $value . " or";
  1668. $sid .= " id = " . $value . " or";
  1669. }
  1670. }
  1671. $tc = $this->typeclass->find_all();
  1672. $typeclass = array();
  1673. foreach ($tc as $v) {
  1674. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1675. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1676. }
  1677. $post = $this->input->post(NULL, TRUE);
  1678. if (isset($post['sku'])) {
  1679. $list = array();
  1680. $num = "";
  1681. $title = "";
  1682. $features = "";
  1683. $order = $this->input->post('order', true);
  1684. $shop = $this->input->post('shop', true);
  1685. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1686. $sku = $this->input->post('sku', true);
  1687. $post['sm'] = $this->input->post('sm', true);
  1688. $post['warehouse'] = $this->input->post('warehouse', true);
  1689. $post['purchase'] = $this->input->post('purchase', true);
  1690. $post['retreatwarehouse'] = $post['warehouse'];
  1691. $post['state'] = $this->input->post('state', true);
  1692. $post['rktype'] = $this->input->post('rktype', true);
  1693. $post['text'] = $this->input->post('text', true);
  1694. $category = $this->input->post('category', true);
  1695. $list['category'] = $category;
  1696. $list['hairtype'] = $this->input->post('hairtype', true);
  1697. $list['grade'] = $this->input->post('grade', true);
  1698. $size = $this->input->post('size', true);
  1699. $xzsku = $this->input->post('xzsku', true);
  1700. $list['size'] = rtrim($size, ',');
  1701. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1702. $list['extension'] = $this->input->post('extension', true);
  1703. if ($category == 1297) {
  1704. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1705. }
  1706. if ($category == 1702) {
  1707. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1708. $list['syother'] = $this->input->post('syother', true);
  1709. }
  1710. if ($category == 133) {
  1711. $list['fittype'] = $this->input->post('fittype', true);
  1712. $list['acother'] = $this->input->post('acother', true);
  1713. }
  1714. $list['color'] = $this->input->post('color', true);
  1715. $list['lowe'] = $this->input->post('lowe', true);
  1716. if (!$post['purchase']) {
  1717. $post['purchase'] = 1;
  1718. }
  1719. if ($category == 127) {
  1720. $list['type'] = $this->input->post('type', true);
  1721. $list['headroad'] = $this->input->post('headroad', true);
  1722. $list['density'] = $this->input->post('density', true);
  1723. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1724. $list['lacesize'] = $this->input->post('lacesize', true);
  1725. }
  1726. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1727. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1728. }
  1729. if ($category == 128) {
  1730. $list['lacetype'] = $this->input->post('lacetype', true);
  1731. $list['haircap'] = $this->input->post('haircap', true);
  1732. $list['density'] = $this->input->post('density', true);
  1733. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1734. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1735. $list['wigother'] = $this->input->post('wigother', true);
  1736. $list['wigother2'] = $this->input->post('wigother2', true);
  1737. }
  1738. if ($category == 129) {
  1739. $list['wide'] = $this->input->post('wide', true);
  1740. }
  1741. if ($category == 131) {
  1742. $list['gifttype'] = $this->input->post('gifttype', true);
  1743. $list['giftother'] = $this->input->post('giftother', true);
  1744. }
  1745. if ($category == 134) {
  1746. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1747. }
  1748. if ($category == 1297) {
  1749. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1750. $list['sywigother'] = $this->input->post('sywigother', true);
  1751. }
  1752. if ($category == 130 || $category == 133 || $category == 1702) {
  1753. $list['items'] = $this->input->post('items', true);
  1754. $list['weight'] = $this->input->post('weight', true);
  1755. }
  1756. if ($category == 1702) {
  1757. $list['syhairther'] = $this->input->post('syhairther', true);
  1758. }
  1759. $classid = $this->classid->sku();
  1760. $scsku = $classid;
  1761. $pm = $classid;
  1762. foreach ($list as $k => $v) {
  1763. if ($v != 0) {
  1764. $num .= $v;
  1765. $features .= $v . '-';
  1766. $post[$k] = $v;
  1767. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1768. if ($k != 'size') {
  1769. $title .= $typeclass[$v]['title'] . " ";
  1770. }
  1771. if (isset($pm[$typeclass[$v]['classid']])) {
  1772. if ($typeclass[$v]['title'] == '9A') {
  1773. $pm[$typeclass[$v]['classid']] = '9A';
  1774. } else if ($typeclass[$v]['title'] == '10A') {
  1775. $pm[$typeclass[$v]['classid']] = '10A';
  1776. } else {
  1777. $clzh = $typeclass[$v]['zh'];
  1778. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1779. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1780. $clzh = $clzh[0];
  1781. }
  1782. $pm[$typeclass[$v]['classid']] = $clzh;
  1783. }
  1784. }
  1785. }
  1786. }
  1787. $zh = implode(" ", $pm);
  1788. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1789. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1790. if ($list['size']) {
  1791. $typeclass = $this->typeclass->read($list['size']);
  1792. $title .= $typeclass['title'];
  1793. }
  1794. $time = time();
  1795. if ($xzsku) {
  1796. $scsku = implode("-", $scsku);
  1797. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1798. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1799. $post['sku'] = trim($scsku, ' ');
  1800. } else {
  1801. $post['sku'] = $sku;
  1802. }
  1803. //$post['sku'] = trim($sku,' ');
  1804. $post['title'] = rtrim($title, ' ');
  1805. $post['number'] = $num;
  1806. $post['features'] = '-' . $features;
  1807. $post['enter'] = $time;
  1808. $post['time'] = $time; //操作时间
  1809. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1810. if ($yza) {
  1811. if ($post['features'] != $yza[0]['features']) {
  1812. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1813. exit;
  1814. }
  1815. }
  1816. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1817. if ($yzb) {
  1818. if ($post['sku'] != $yzb[0]['sku']) {
  1819. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1820. exit;
  1821. }
  1822. }
  1823. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1824. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1825. exit;
  1826. }
  1827. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1828. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1829. exit;
  1830. }
  1831. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1832. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1833. exit;
  1834. }
  1835. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1836. if (isset($yz[0]['type'])) {
  1837. $post['type'] = $yz[0]['type'];
  1838. }
  1839. if ($post['state'] == 9) //如果选择预设库存
  1840. {
  1841. $this->whlabel->insert($post);
  1842. } else {
  1843. /**
  1844. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1845. if($ljg == 1)
  1846. {
  1847. for($i=0;$i<$order;$i++)
  1848. {
  1849. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1850. $this->whlabel->insert($post);
  1851. }
  1852. }
  1853. **/
  1854. //if($post['warehouse'] == '5')
  1855. //{
  1856. //}
  1857. $yydata = $post;
  1858. $yydata['zh'] = $zh;
  1859. /**
  1860. $wl = $this->apiyy->get_cjlp($yydata);
  1861. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1862. {
  1863. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1864. }
  1865. if($wl['Data'][0]['m_isSucess'] != 1)
  1866. {
  1867. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1868. }
  1869. **/
  1870. for ($i = 0; $i < $order; $i++) {
  1871. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1872. $this->whlabel->insert($post);
  1873. }
  1874. }
  1875. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1876. exit;
  1877. }
  1878. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1879. $this->data['wlshop'] = $wlshop;
  1880. $this->_Template('whlabel_enteradd', $this->data);
  1881. }
  1882. //修改产品
  1883. public function _enteredit($arg_array)
  1884. {
  1885. $dt = 0;
  1886. if (isset($_SESSION['api'])) {
  1887. $user = $this->user->get_api($_SESSION['api']);
  1888. $usp = $user;
  1889. $fgshop = "";
  1890. $sid = "";
  1891. $user = explode('|', trim($user['shop'], '|'));
  1892. foreach ($user as $value) {
  1893. $fgshop .= " shop = " . $value . " or";
  1894. $sid .= " id = " . $value . " or";
  1895. }
  1896. }
  1897. $post = $this->input->post(NULL, TRUE);
  1898. if (isset($post['sku'])) {
  1899. $list = array();
  1900. $num = "";
  1901. $title = "";
  1902. $features = "";
  1903. $id = $this->input->post('id', true);
  1904. $order = $this->input->post('order', true);
  1905. $shop = $this->input->post('shop', true);
  1906. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1907. $post['sku'] = $this->input->post('sku', true);
  1908. $post['sm'] = $this->input->post('sm', true);
  1909. $post['warehouse'] = $this->input->post('warehouse', true);
  1910. $post['purchase'] = $this->input->post('purchase', true);
  1911. $post['retreatwarehouse'] = $post['warehouse'];
  1912. $category = $this->input->post('category', true);
  1913. $list['category'] = $category;
  1914. $list['hairtype'] = $this->input->post('hairtype', true);
  1915. $list['grade'] = $this->input->post('grade', true);
  1916. $size = $this->input->post('size', true);
  1917. $list['size'] = rtrim($size, ',');
  1918. $post['rktype'] = $this->input->post('rktype', true);
  1919. $post['text'] = $this->input->post('text', true);
  1920. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1921. $list['extension'] = $this->input->post('extension', true);
  1922. if ($category == 1297) {
  1923. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1924. }
  1925. if ($category == 1702) {
  1926. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1927. $list['syother'] = $this->input->post('syother', true);
  1928. }
  1929. if ($category == 133) {
  1930. $list['fittype'] = $this->input->post('fittype', true);
  1931. $list['acother'] = $this->input->post('acother', true);
  1932. }
  1933. $list['color'] = $this->input->post('color', true);
  1934. $list['lowe'] = $this->input->post('lowe', true);
  1935. if (!$post['purchase']) {
  1936. $post['purchase'] = 1;
  1937. }
  1938. if ($category == 127) {
  1939. $list['type'] = $this->input->post('type', true);
  1940. $list['headroad'] = $this->input->post('headroad', true);
  1941. $list['density'] = $this->input->post('density', true);
  1942. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1943. $list['lacesize'] = $this->input->post('lacesize', true);
  1944. }
  1945. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1946. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1947. }
  1948. if ($category == 128) {
  1949. $list['lacetype'] = $this->input->post('lacetype', true);
  1950. $list['haircap'] = $this->input->post('haircap', true);
  1951. $list['density'] = $this->input->post('density', true);
  1952. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1953. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1954. $list['wigother'] = $this->input->post('wigother', true);
  1955. $list['wigother2'] = $this->input->post('wigother2', true);
  1956. }
  1957. if ($category == 129) {
  1958. $list['wide'] = $this->input->post('wide', true);
  1959. }
  1960. if ($category == 131) {
  1961. $list['gifttype'] = $this->input->post('gifttype', true);
  1962. $list['giftother'] = $this->input->post('giftother', true);
  1963. }
  1964. if ($category == 134) {
  1965. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1966. }
  1967. if ($category == 1297) {
  1968. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1969. $list['sywigother'] = $this->input->post('sywigother', true);
  1970. }
  1971. if ($category == 130 || $category == 133 || $category == 1702) {
  1972. $list['items'] = $this->input->post('items', true);
  1973. $list['weight'] = $this->input->post('weight', true);
  1974. }
  1975. if ($category == 1702) {
  1976. $list['syhairther'] = $this->input->post('syhairther', true);
  1977. }
  1978. foreach ($list as $k => $v) {
  1979. if ($v != 0) {
  1980. $num .= $v;
  1981. $features .= $v . '-';
  1982. $typeclass = $this->typeclass->read($v);
  1983. if ($k != 'size') {
  1984. $title .= $typeclass['title'] . " ";
  1985. }
  1986. }
  1987. }
  1988. $typeclass = $this->typeclass->read($list['size']);
  1989. $title .= $typeclass['title'];
  1990. $time = time();
  1991. $post['title'] = rtrim($title, ' ');
  1992. $post['number'] = $num;
  1993. $post['features'] = '-' . $features;
  1994. $post['time'] = $time; //操作时间
  1995. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1996. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1997. exit;
  1998. }
  1999. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2000. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2001. exit;
  2002. }
  2003. $uid = $this->whlabel->read($id);
  2004. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2005. if ($datanum > 0) {
  2006. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2007. exit;
  2008. }
  2009. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2010. {
  2011. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2012. if ($yza) {
  2013. if ($post['features'] != $yza[0]['features']) {
  2014. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2015. exit;
  2016. }
  2017. }
  2018. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2019. if ($yzb) {
  2020. if ($post['sku'] != $yzb[0]['sku']) {
  2021. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2022. exit;
  2023. }
  2024. }
  2025. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2026. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2027. exit;
  2028. }
  2029. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2030. foreach ($data as $v) {
  2031. $post['id'] = $v['id'];
  2032. $this->whlabel->save($post, $v['id']);
  2033. }
  2034. } else {
  2035. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2036. if ($data > 0) {
  2037. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2038. exit;
  2039. } else {
  2040. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2041. foreach ($data as $v) {
  2042. $post['id'] = $v['id'];
  2043. $this->whlabel->save($post, $v['id']);
  2044. }
  2045. }
  2046. }
  2047. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2048. exit;
  2049. }
  2050. $uid = $this->whlabel->read($arg_array[0]);
  2051. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2052. $this->data['enter'] = $uid;
  2053. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2054. $this->data['wlshop'] = $wlshop;
  2055. $this->_Template('whlabel_enteredit', $this->data);
  2056. }
  2057. //入库浏览
  2058. public function _enter()
  2059. {
  2060. $post = $this->input->post(NULL, TRUE);
  2061. if (isset($post['s'])) {
  2062. $id_arr = $this->input->post('s');
  2063. $id_arr = explode(',', $id_arr);
  2064. if (!$id_arr) {
  2065. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2066. exit;
  2067. }
  2068. //循环删除记录
  2069. foreach ($id_arr as $v) {
  2070. $sid = $this->whlabel->read($v);
  2071. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2072. if ($count > 0) {
  2073. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2074. exit;
  2075. }
  2076. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2077. foreach ($info_list as $va) {
  2078. $this->whlabel->remove($va['id']);
  2079. }
  2080. }
  2081. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2082. exit;
  2083. }
  2084. $sp = array();
  2085. $s = $this->shop->find_all('1=1', 'id,shopname');
  2086. foreach ($s as $v) {
  2087. $sp[$v['id']] = $v['shopname'];
  2088. }
  2089. $wh = array();
  2090. $w = $this->warehouse->find_all('1=1', 'id,title');
  2091. foreach ($w as $v) {
  2092. $wh[$v['id']] = $v['title'];
  2093. }
  2094. if (isset($post['page'])) {
  2095. $page = $this->input->post('page', true);
  2096. $perpage = $this->input->post('perpage', true);
  2097. $category = $this->input->post('category', true);
  2098. $size = $this->input->post('size', true);
  2099. $grade = $this->input->post('grade', true);
  2100. $color = $this->input->post('color', true);
  2101. $lowe = $this->input->post('lowe', true);
  2102. $sku = $this->input->post('sku', true);
  2103. $warehouse = $this->input->post('warehouse', true);
  2104. $purchase = $this->input->post('purchase', true);
  2105. $ktime = $this->input->post('ktime', true);
  2106. $jtime = $this->input->post('jtime', true);
  2107. $ktime = strtotime($ktime);
  2108. $jtime = strtotime($jtime);
  2109. $where = "1=1";
  2110. $gj = "";
  2111. $ck = "";
  2112. if ($category) {
  2113. $where .= " and features like '%-$category-%'";
  2114. }
  2115. if ($size) {
  2116. $where .= " and features like '%-$size-%'";
  2117. }
  2118. if ($grade) {
  2119. $where .= " and features like '%-$grade-%'";
  2120. }
  2121. if ($color) {
  2122. $where .= " and features like '%-$color-%'";
  2123. }
  2124. if ($lowe) {
  2125. $where .= " and features like '%-$lowe-%'";
  2126. }
  2127. if ($warehouse) {
  2128. $where .= " and warehouse = '$warehouse'";
  2129. }
  2130. if ($purchase) {
  2131. $where .= " and purchase = '$purchase'";
  2132. }
  2133. if ($sku) {
  2134. $where .= " and sku like '%$sku%'";
  2135. }
  2136. if ($ktime && $jtime) {
  2137. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2138. }
  2139. //数据排序
  2140. $order_str = "enter desc";
  2141. if (empty($page)) {
  2142. $start = 0;
  2143. $perpage = 1;
  2144. } else {
  2145. $start = ($page - 1) * $perpage;
  2146. }
  2147. //取得信息列表
  2148. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2149. foreach ($info_list as $k => $v) {
  2150. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2151. if ($v['shop'] == '') {
  2152. $s = '通用';
  2153. } else {
  2154. $info_list[$k]['shop'] = '';
  2155. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2156. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2157. }
  2158. }
  2159. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2160. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2161. $info_list[$k]['g'] = $g;
  2162. }
  2163. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2164. $pagenum = ceil($total / $perpage);
  2165. $over = $total - ($start + $perpage);
  2166. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2167. echo json_encode($rows);
  2168. exit;
  2169. }
  2170. $this->_Template('whlabel_enter', $this->data);
  2171. }
  2172. //出库浏览
  2173. public function _out()
  2174. {
  2175. $post = $this->input->post(NULL, TRUE);
  2176. if (isset($post['page'])) {
  2177. $page = $this->input->post('page', true);
  2178. $perpage = $this->input->post('perpage', true);
  2179. $category = $this->input->post('category', true);
  2180. $size = $this->input->post('size', true);
  2181. $grade = $this->input->post('grade', true);
  2182. $color = $this->input->post('color', true);
  2183. $lowe = $this->input->post('lowe', true);
  2184. $sku = $this->input->post('sku', true);
  2185. $warehouse = $this->input->post('warehouse', true);
  2186. $purchase = $this->input->post('purchase', true);
  2187. $state = $this->input->post('state', true);
  2188. $ktime = $this->input->post('ktime', true);
  2189. $jtime = $this->input->post('jtime', true);
  2190. $ktime = strtotime($ktime);
  2191. $jtime = strtotime($jtime);
  2192. $where = "state=3";
  2193. $gj = "";
  2194. $ck = "";
  2195. if ($category) {
  2196. $where .= " and features like '%-$category-%'";
  2197. }
  2198. if ($size) {
  2199. $where .= " and features like '%-$size-%'";
  2200. }
  2201. if ($grade) {
  2202. $where .= " and features like '%-$grade-%'";
  2203. }
  2204. if ($color) {
  2205. $where .= " and features like '%-$color-%'";
  2206. }
  2207. if ($lowe) {
  2208. $where .= " and features like '%-$lowe-%'";
  2209. }
  2210. if ($state) {
  2211. $where .= " and state = '$state'";
  2212. }
  2213. if ($warehouse) {
  2214. $where .= " and warehouse = '$warehouse'";
  2215. }
  2216. if ($purchase) {
  2217. $where .= " and purchase = '$purchase'";
  2218. }
  2219. if ($sku) {
  2220. $where .= " and sku = '$sku'";
  2221. }
  2222. if ($ktime && $jtime) {
  2223. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2224. }
  2225. //数据排序
  2226. $order_str = "id desc";
  2227. if (empty($page)) {
  2228. $start = 0;
  2229. $perpage = 1;
  2230. } else {
  2231. $start = ($page - 1) * $perpage;
  2232. }
  2233. //取得信息列表
  2234. $info_list = $this->whlabel->find_all($where, 'sku');
  2235. $rows = array();
  2236. $list = array();
  2237. foreach ($info_list as $key => $value) {
  2238. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2239. }
  2240. $rows = array_unique($rows); //删除重复记录
  2241. foreach ($rows as $key => $value) {
  2242. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2243. $ck = $this->warehouse->read($data['warehouse']);
  2244. $warehouse = $ck['title'];
  2245. $gy = $this->purchase->read($data['purchase']);
  2246. $purchase = $gy['purchase'];
  2247. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2248. $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);
  2249. }
  2250. $total = count($list);
  2251. $pagenum = ceil($total / $perpage);
  2252. $over = $total - ($start + $perpage);
  2253. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2254. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2255. echo json_encode($rows);
  2256. exit;
  2257. }
  2258. $this->_Template('whlabel_out', $this->data);
  2259. }
  2260. //出库标签浏览
  2261. public function _label()
  2262. {
  2263. $post = $this->input->post(NULL, TRUE);
  2264. if (isset($post['page'])) {
  2265. $page = $this->input->post('page', true);
  2266. $perpage = $this->input->post('perpage', true);
  2267. $sku = $this->input->post('sku', true);
  2268. $warehouse = $this->input->post('warehouse', true);
  2269. $purchase = $this->input->post('purchase', true);
  2270. $orderinfo = $this->input->post('orderinfo', true);
  2271. $waybill = $this->input->post('waybill', true);
  2272. $category = $this->input->post('category', true);
  2273. $size = $this->input->post('size', true);
  2274. $grade = $this->input->post('grade', true);
  2275. $color = $this->input->post('color', true);
  2276. $lowe = $this->input->post('lowe', true);
  2277. $where = "state=1";
  2278. if ($sku) {
  2279. $where .= " and sku = '$sku'";
  2280. }
  2281. if ($warehouse) {
  2282. $where .= " and warehouse = '$warehouse'";
  2283. }
  2284. if ($purchase) {
  2285. $where .= " and purchase = '$purchase'";
  2286. }
  2287. if ($orderinfo) {
  2288. $where .= " and orderinfo = '$orderinfo'";
  2289. }
  2290. if ($waybill) {
  2291. $where .= " and waybill = '$waybill'";
  2292. }
  2293. if ($category) {
  2294. $where .= " and features like '%-$category-%'";
  2295. }
  2296. if ($size) {
  2297. $where .= " and features like '%-$size-%'";
  2298. }
  2299. if ($grade) {
  2300. $where .= " and features like '%-$grade-%'";
  2301. }
  2302. if ($color) {
  2303. $where .= " and features like '%-$color-%'";
  2304. }
  2305. if ($lowe) {
  2306. $where .= " and features like '%-$lowe-%'";
  2307. }
  2308. //数据排序
  2309. $order_str = "outk desc";
  2310. if (empty($page)) {
  2311. $start = 0;
  2312. $perpage = 1;
  2313. } else {
  2314. $start = ($page - 1) * $perpage;
  2315. }
  2316. //取得信息列表
  2317. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2318. foreach ($info_list as $key => $value) {
  2319. $warehouse = $this->warehouse->read($value['warehouse']);
  2320. $info_list[$key]['warehouse'] = $warehouse['title'];
  2321. $purchase = $this->purchase->read($value['purchase']);
  2322. $info_list[$key]['purchase'] = $purchase['title'];
  2323. if ($value['outk'] != 0) {
  2324. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2325. } else {
  2326. $info_list[$key]['outk'] = "";
  2327. }
  2328. if ($value['orderinfo'] == 0) {
  2329. $info_list[$key]['orderinfo'] = "";
  2330. }
  2331. if ($value['waybill'] == 0) {
  2332. $info_list[$key]['waybill'] = "";
  2333. }
  2334. }
  2335. $total = $this->whlabel->find_count($where);
  2336. $pagenum = ceil($total / $perpage);
  2337. $over = $total - ($start + $perpage);
  2338. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2339. echo json_encode($rows);
  2340. exit;
  2341. }
  2342. $this->_Template('whlabel_label', $this->data);
  2343. }
  2344. //独立站出库订单
  2345. public function _outorder()
  2346. {
  2347. if (isset($_SESSION['api'])) {
  2348. $user = $this->user->get_api($_SESSION['api']);
  2349. $usp = $user;
  2350. $fgshop = "";
  2351. $sid = "";
  2352. $user = explode('|', trim($user['shop'], '|'));
  2353. foreach ($user as $value) {
  2354. $fgshop .= " shop = " . $value . " or";
  2355. $sid .= " id = " . $value . " or";
  2356. }
  2357. } else {
  2358. echo "请重新登录";
  2359. }
  2360. $post = $this->input->post(NULL, TRUE);
  2361. if (isset($post['page'])) {
  2362. $page = $this->input->post('page', true);
  2363. $perpage = $this->input->post('perpage', true);
  2364. $warehouse = $this->input->post('warehouse', true);
  2365. $xztime = $this->input->post('xztime', true);
  2366. $timetk = $this->input->post('timetkk', true);
  2367. $timetj = $this->input->post('timetjj', true);
  2368. $shop = $this->input->post('shop', true);
  2369. $source = $this->input->post('source', true);
  2370. $orderinfo = $this->input->post('orderinfo', true);
  2371. $number = $this->input->post('number', true);
  2372. $sfxh = $this->input->post('sfxh', true);
  2373. $express = $this->input->post('express', true);
  2374. $waybill = $this->input->post('waybill', true);
  2375. $library = $this->input->post('library', true);
  2376. $country = $this->input->post('country', true);
  2377. $so = $this->input->post('so', true);
  2378. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2379. $print = $this->input->post('print', true);
  2380. $state = $this->input->post('state', true);
  2381. $orderurl = $this->input->post('orderurl', true);
  2382. $timetk = strtotime($timetk);
  2383. $timetj = strtotime($timetj);
  2384. /**
  2385. $sj = $this->input->post('sj',true);
  2386. if($sj)
  2387. {
  2388. $sj = $this->input->post('sj',true);
  2389. }
  2390. else
  2391. {
  2392. $sj = "fullorder";
  2393. }
  2394. **/
  2395. $sj = "fullorder";
  2396. $where = "1=1";
  2397. if ($warehouse) {
  2398. $where .= " and type = '$warehouse'";
  2399. }
  2400. if ($timetk && $timetj) {
  2401. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2402. }
  2403. if ($orderinfo) {
  2404. $where .= " and orderinfo = '$orderinfo'";
  2405. }
  2406. if ($number) {
  2407. $where .= " and number = '$number'";
  2408. }
  2409. if ($express) {
  2410. $where .= " and express = '$express'";
  2411. }
  2412. if ($waybill) {
  2413. $where .= " and waybill = '$waybill'";
  2414. }
  2415. if ($library) {
  2416. $where .= " and library = '$library'";
  2417. }
  2418. if ($print) {
  2419. $where .= " and print = '$print'";
  2420. }
  2421. if ($libraryconfirm) {
  2422. $where .= " and libraryconfirm = '$libraryconfirm'";
  2423. }
  2424. if ($state) {
  2425. $where .= " and state = '$state'";
  2426. }
  2427. if ($shop) {
  2428. $where .= " and shop = '$shop'";
  2429. }
  2430. if ($country) {
  2431. $where .= " and country = '$country'";
  2432. }
  2433. if ($sfxh != '') {
  2434. $where .= " and sfxh = '$sfxh'";
  2435. }
  2436. if ($so) {
  2437. $where .= " and shipremarks like '%$so%'";
  2438. }
  2439. if ($source) {
  2440. if ($source == '2d') {
  2441. $where .= " and source >= '2'";
  2442. } else {
  2443. $where .= " and source = '$source'";
  2444. }
  2445. }
  2446. if (isset($_SESSION['api'])) {
  2447. foreach ($user as $value) {
  2448. $fgshop .= " shop = " . $value . " or";
  2449. }
  2450. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2451. }
  2452. if ($orderurl) {
  2453. $url = $this->orderurl->read($orderurl);
  2454. $where .= " and link like '%" . $url['url'] . "%'";
  2455. }
  2456. //数据排序
  2457. $order_str = "librarytime desc";
  2458. if (empty($page)) {
  2459. $start = 0;
  2460. $perpage = 1;
  2461. } else {
  2462. $start = ($page - 1) * $perpage;
  2463. }
  2464. //取得信息列表
  2465. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2466. //格式化数据
  2467. foreach ($info_list as $key => $value) {
  2468. $shop = $this->shop->read($value['shop']);
  2469. $info_list[$key]['shop'] = $shop['shopname'];
  2470. $express = $this->express->read($value['express']);
  2471. $info_list[$key]['express'] = $express['servicename'];
  2472. $warehouse = $this->warehouse->read($value['type']);
  2473. $info_list[$key]['type'] = $warehouse['title'];
  2474. if ($value['librarytime'] == '0') {
  2475. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2476. } else {
  2477. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2478. }
  2479. }
  2480. $total = $this->$sj->find_count($where);
  2481. $pagenum = ceil($total / $perpage);
  2482. $over = $total - ($start + $perpage);
  2483. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2484. echo json_encode($rows);
  2485. exit;
  2486. }
  2487. $this->data['express'] = $this->express->find_all();
  2488. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2489. $this->data['wlshop'] = $wlshop;
  2490. $user = $this->user->get_api($_SESSION['api']);
  2491. $powerid = $this->power->read($user['power']);
  2492. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2493. $pid = '';
  2494. foreach ($powertext as $v) {
  2495. $pid .= " id = " . $v . " or";
  2496. }
  2497. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2498. $this->data['fullorderexcel'] = $fullorderexcel;
  2499. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2500. $this->data['orderurl'] = $orderurl;
  2501. $this->_Template('whlabel_outorder', $this->data);
  2502. }
  2503. //tt出库
  2504. public function _toutorder()
  2505. {
  2506. if (isset($_SESSION['api'])) {
  2507. $user = $this->user->get_api($_SESSION['api']);
  2508. $usp = $user;
  2509. $fgshop = "";
  2510. $sid = "";
  2511. $user = explode('|', trim($user['shop'], '|'));
  2512. foreach ($user as $value) {
  2513. $fgshop .= " shop = " . $value . " or";
  2514. $sid .= " id = " . $value . " or";
  2515. }
  2516. } else {
  2517. echo "请重新登录";
  2518. }
  2519. $post = $this->input->post(NULL, TRUE);
  2520. if (isset($post['page'])) {
  2521. $page = $this->input->post('page', true);
  2522. $perpage = $this->input->post('perpage', true);
  2523. $warehouse = $this->input->post('warehouse', true);
  2524. $xztime = $this->input->post('xztime', true);
  2525. $timetk = $this->input->post('timetkk', true);
  2526. $timetj = $this->input->post('timetjj', true);
  2527. $shop = $this->input->post('shop', true);
  2528. $source = $this->input->post('source', true);
  2529. $orderinfo = $this->input->post('orderinfo', true);
  2530. $number = $this->input->post('number', true);
  2531. $sfxh = $this->input->post('sfxh', true);
  2532. $express = $this->input->post('express', true);
  2533. $waybill = $this->input->post('waybill', true);
  2534. $library = $this->input->post('library', true);
  2535. $country = $this->input->post('country', true);
  2536. $so = $this->input->post('so', true);
  2537. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2538. $print = $this->input->post('print', true);
  2539. $state = $this->input->post('state', true);
  2540. $orderurl = $this->input->post('orderurl', true);
  2541. $timetk = strtotime($timetk);
  2542. $timetj = strtotime($timetj);
  2543. /**
  2544. $sj = $this->input->post('sj',true);
  2545. if($sj)
  2546. {
  2547. $sj = $this->input->post('sj',true);
  2548. }
  2549. else
  2550. {
  2551. $sj = "fullorder";
  2552. }
  2553. **/
  2554. $sj = "fullordertt";
  2555. $where = "1=1";
  2556. if ($warehouse) {
  2557. $where .= " and type = '$warehouse'";
  2558. }
  2559. if ($timetk && $timetj) {
  2560. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2561. }
  2562. if ($orderinfo) {
  2563. $where .= " and orderinfo = '$orderinfo'";
  2564. }
  2565. if ($number) {
  2566. $where .= " and number = '$number'";
  2567. }
  2568. if ($express) {
  2569. $where .= " and express = '$express'";
  2570. }
  2571. if ($waybill) {
  2572. $where .= " and waybill = '$waybill'";
  2573. }
  2574. if ($library) {
  2575. $where .= " and library = '$library'";
  2576. }
  2577. if ($print) {
  2578. $where .= " and print = '$print'";
  2579. }
  2580. if ($libraryconfirm) {
  2581. $where .= " and libraryconfirm = '$libraryconfirm'";
  2582. }
  2583. if ($state) {
  2584. $where .= " and state = '$state'";
  2585. }
  2586. if ($shop) {
  2587. $where .= " and shop = '$shop'";
  2588. }
  2589. if ($country) {
  2590. $where .= " and country = '$country'";
  2591. }
  2592. if ($sfxh != '') {
  2593. $where .= " and sfxh = '$sfxh'";
  2594. }
  2595. if ($so) {
  2596. $where .= " and shipremarks like '%$so%'";
  2597. }
  2598. if ($source) {
  2599. if ($source == '2d') {
  2600. $where .= " and source >= '2'";
  2601. } else {
  2602. $where .= " and source = '$source'";
  2603. }
  2604. }
  2605. if (isset($_SESSION['api'])) {
  2606. foreach ($user as $value) {
  2607. $fgshop .= " shop = " . $value . " or";
  2608. }
  2609. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2610. }
  2611. if ($orderurl) {
  2612. $url = $this->orderurl->read($orderurl);
  2613. $where .= " and link like '%" . $url['url'] . "%'";
  2614. }
  2615. //数据排序
  2616. $order_str = "librarytime desc";
  2617. if (empty($page)) {
  2618. $start = 0;
  2619. $perpage = 1;
  2620. } else {
  2621. $start = ($page - 1) * $perpage;
  2622. }
  2623. //取得信息列表
  2624. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2625. //格式化数据
  2626. foreach ($info_list as $key => $value) {
  2627. $shop = $this->shop->read($value['shop']);
  2628. $info_list[$key]['shop'] = $shop['shopname'];
  2629. $express = $this->express->read($value['express']);
  2630. $info_list[$key]['express'] = $express['servicename'];
  2631. $warehouse = $this->warehouse->read($value['type']);
  2632. $info_list[$key]['type'] = $warehouse['title'];
  2633. if ($value['librarytime'] == '0') {
  2634. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2635. } else {
  2636. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2637. }
  2638. }
  2639. $total = $this->$sj->find_count($where);
  2640. $pagenum = ceil($total / $perpage);
  2641. $over = $total - ($start + $perpage);
  2642. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2643. echo json_encode($rows);
  2644. exit;
  2645. }
  2646. $this->data['express'] = $this->express->find_all();
  2647. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2648. $this->data['wlshop'] = $wlshop;
  2649. $user = $this->user->get_api($_SESSION['api']);
  2650. $powerid = $this->power->read($user['power']);
  2651. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2652. $pid = '';
  2653. foreach ($powertext as $v) {
  2654. $pid .= " id = " . $v . " or";
  2655. }
  2656. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2657. $this->data['fullorderexcel'] = $fullorderexcel;
  2658. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2659. $this->data['orderurl'] = $orderurl;
  2660. $this->_Template('whlabel_toutorder', $this->data);
  2661. }
  2662. //速卖通出库订单
  2663. public function _soutorder()
  2664. {
  2665. if (isset($_SESSION['api'])) {
  2666. $user = $this->user->get_api($_SESSION['api']);
  2667. $usp = $user;
  2668. $fgshop = "";
  2669. $sid = "";
  2670. $user = explode('|', trim($user['shop'], '|'));
  2671. foreach ($user as $value) {
  2672. $sid .= " id = " . $value . " or";
  2673. }
  2674. }
  2675. $post = $this->input->post(NULL, TRUE);
  2676. if (isset($post['page'])) {
  2677. $page = $this->input->post('page', true);
  2678. $perpage = $this->input->post('perpage', true);
  2679. $warehouse = $this->input->post('warehouse', true);
  2680. $xztime = $this->input->post('xztime', true);
  2681. $timetk = $this->input->post('timetkk', true);
  2682. $timetj = $this->input->post('timetjj', true);
  2683. $shop = $this->input->post('shop', true);
  2684. $source = $this->input->post('source', true);
  2685. $orderinfo = $this->input->post('orderinfo', true);
  2686. $number = $this->input->post('number', true);
  2687. $express = $this->input->post('express', true);
  2688. $waybill = $this->input->post('waybill', true);
  2689. $library = $this->input->post('library', true);
  2690. $country = $this->input->post('country', true);
  2691. $sfxh = $this->input->post('sfxh', true);
  2692. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2693. $print = $this->input->post('print', true);
  2694. $state = $this->input->post('state', true);
  2695. $so = $this->input->post('so', true);
  2696. $timetk = strtotime($timetk);
  2697. $timetj = strtotime($timetj);
  2698. /**
  2699. $sj = $this->input->post('sj',true);
  2700. if($sj)
  2701. {
  2702. $sj = $this->input->post('sj',true);
  2703. }
  2704. else
  2705. {
  2706. $sj = "fullorder";
  2707. }
  2708. **/
  2709. $sj = "fullordersmt";
  2710. $where = "1=1";
  2711. if ($warehouse) {
  2712. $where .= " and type = '$warehouse'";
  2713. }
  2714. if ($timetk && $timetj) {
  2715. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2716. }
  2717. if ($orderinfo) {
  2718. $where .= " and orderinfo = '$orderinfo'";
  2719. }
  2720. if ($number) {
  2721. $where .= " and number = '$number'";
  2722. }
  2723. if ($express) {
  2724. $where .= " and express = '$express'";
  2725. }
  2726. if ($waybill) {
  2727. $where .= " and waybill = '$waybill'";
  2728. }
  2729. if ($library) {
  2730. $where .= " and library = '$library'";
  2731. }
  2732. if ($print) {
  2733. $where .= " and print = '$print'";
  2734. }
  2735. if ($libraryconfirm) {
  2736. $where .= " and libraryconfirm = '$libraryconfirm'";
  2737. }
  2738. if ($state) {
  2739. $where .= " and state = '$state'";
  2740. }
  2741. if ($shop) {
  2742. $where .= " and shop = '$shop'";
  2743. }
  2744. if ($sfxh != '') {
  2745. $where .= " and sfxh = '$sfxh'";
  2746. }
  2747. if ($so) {
  2748. $where .= " and shipremarks like '%$so%'";
  2749. }
  2750. if ($source) {
  2751. $where .= " and source = '$source'";
  2752. }
  2753. if ($country) {
  2754. $where .= " and country = '$country'";
  2755. } else {
  2756. if (isset($_SESSION['api'])) {
  2757. foreach ($user as $value) {
  2758. $fgshop .= " shop = " . $value . " or";
  2759. }
  2760. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2761. }
  2762. }
  2763. //数据排序
  2764. $order_str = "librarytime desc";
  2765. if (empty($page)) {
  2766. $start = 0;
  2767. $perpage = 1;
  2768. } else {
  2769. $start = ($page - 1) * $perpage;
  2770. }
  2771. //取得信息列表
  2772. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2773. //格式化数据
  2774. foreach ($info_list as $key => $value) {
  2775. $shop = $this->shop->read($value['shop']);
  2776. $info_list[$key]['shop'] = $shop['shopname'];
  2777. $express = $this->express->read($value['express']);
  2778. $info_list[$key]['express'] = $express['servicename'];
  2779. $warehouse = $this->warehouse->read($value['type']);
  2780. $info_list[$key]['type'] = $warehouse['title'];
  2781. if ($value['librarytime'] == '0') {
  2782. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2783. } else {
  2784. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2785. }
  2786. }
  2787. $total = $this->$sj->find_count($where);
  2788. $pagenum = ceil($total / $perpage);
  2789. $over = $total - ($start + $perpage);
  2790. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2791. echo json_encode($rows);
  2792. exit;
  2793. }
  2794. $this->data['express'] = $this->express->find_all();
  2795. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2796. $this->data['wlshop'] = $wlshop;
  2797. $user = $this->user->get_api($_SESSION['api']);
  2798. $powerid = $this->power->read($user['power']);
  2799. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2800. $pid = '';
  2801. foreach ($powertext as $v) {
  2802. $pid .= " id = " . $v . " or";
  2803. }
  2804. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2805. $this->data['fullorderexcel'] = $fullorderexcel;
  2806. $this->_Template('whlabel_soutorder', $this->data);
  2807. }
  2808. //订单退库
  2809. public function _retreat()
  2810. {
  2811. $post = $this->input->post(NULL, TRUE);
  2812. if (isset($post['page'])) {
  2813. $page = $this->input->post('page', true);
  2814. $perpage = $this->input->post('perpage', true);
  2815. $warehouse = $this->input->post('warehouse', true);
  2816. $timetk = $this->input->post('timetk', true);
  2817. $timetj = $this->input->post('timetj', true);
  2818. $shop = $this->input->post('shop', true);
  2819. $source = $this->input->post('source', true);
  2820. $state = $this->input->post('state', true);
  2821. $review = $this->input->post('review', true);
  2822. $state = $this->input->post('state', true);
  2823. $express = $this->input->post('express', true);
  2824. $orderinfo = $this->input->post('orderinfo', true);
  2825. $user = $this->input->post('user', true);
  2826. $name = $this->input->post('name', true);
  2827. $waybill = $this->input->post('waybill', true);
  2828. $timetk = strtotime($timetk);
  2829. $timetj = strtotime($timetj);
  2830. $where = "(state=206 or state=210) and mergeid = 0";
  2831. if ($warehouse) {
  2832. $where .= " and state = '$warehouse'";
  2833. }
  2834. if ($timetk && $timetj) {
  2835. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2836. }
  2837. if ($shop) {
  2838. $where .= " and shop = '$shop'";
  2839. }
  2840. if ($source) {
  2841. $where .= " and source = '$source'";
  2842. }
  2843. if ($state) {
  2844. $where .= " and state = '$state'";
  2845. }
  2846. if ($review) {
  2847. $where .= " and review = '$review'";
  2848. }
  2849. if ($state) {
  2850. $where .= " and state = '$state'";
  2851. }
  2852. if ($express) {
  2853. $where .= " and express = '$express'";
  2854. }
  2855. if ($orderinfo) {
  2856. $where .= " and orderinfo = '$orderinfo'";
  2857. }
  2858. if ($user) {
  2859. $where .= " and user = '$user'";
  2860. }
  2861. if ($name) {
  2862. $where .= " and name = '$name'";
  2863. }
  2864. if ($waybill) {
  2865. $where .= " and waybill = '$waybill'";
  2866. }
  2867. //数据排序
  2868. $order_str = "id desc";
  2869. if (empty($page)) {
  2870. $start = 0;
  2871. $perpage = 1;
  2872. } else {
  2873. $start = ($page - 1) * $perpage;
  2874. }
  2875. //取得信息列表
  2876. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  2877. //格式化数据
  2878. foreach ($info_list as $key => $value) {
  2879. $shop = $this->shop->read($value['shop']);
  2880. $info_list[$key]['shop'] = $shop['shopname'];
  2881. $warehouse = $this->warehouse->read($value['warehouse']);
  2882. $info_list[$key]['warehouse'] = $warehouse['title'];
  2883. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  2884. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  2885. if ($value['waybill'] == 0) {
  2886. $info_list[$key]['waybill'] = "";
  2887. }
  2888. $express = $this->express->read($value['express']);
  2889. $info_list[$key]['express'] = $express['title'];
  2890. $typeclass = $this->typeclass->read($value['state']);
  2891. $info_list[$key]['state'] = $typeclass['title'];
  2892. }
  2893. $total = $this->fullorder->find_count($where);
  2894. $pagenum = ceil($total / $perpage);
  2895. $over = $total - ($start + $perpage);
  2896. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2897. echo json_encode($rows);
  2898. exit;
  2899. }
  2900. $this->data['express'] = $this->express->find_all();
  2901. $this->_Template('whlabel_retreat', $this->data);
  2902. }
  2903. //退库标签浏览
  2904. public function _retreatlk()
  2905. {
  2906. $post = $this->input->post(NULL, TRUE);
  2907. if (isset($post['page'])) {
  2908. $page = $this->input->post('page', true);
  2909. $perpage = $this->input->post('perpage', true);
  2910. $timetk = $this->input->post('timetk', true);
  2911. $timetj = $this->input->post('timetj', true);
  2912. $sku = $this->input->post('sku', true);
  2913. $warehouse = $this->input->post('warehouse', true);
  2914. $purchase = $this->input->post('purchase', true);
  2915. $orderinfo = $this->input->post('orderinfo', true);
  2916. $waybill = $this->input->post('waybill', true);
  2917. $category = $this->input->post('category', true);
  2918. $size = $this->input->post('size', true);
  2919. $grade = $this->input->post('grade', true);
  2920. $color = $this->input->post('color', true);
  2921. $lowe = $this->input->post('lowe', true);
  2922. $state = $this->input->post('state', true);
  2923. $timetk = strtotime($timetk);
  2924. $timetj = strtotime($timetj);
  2925. $where = "state=2";
  2926. if ($timetk && $timetj) {
  2927. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  2928. }
  2929. if ($sku) {
  2930. $where .= " and sku = '$sku'";
  2931. }
  2932. if ($warehouse) {
  2933. $where .= " and warehouse = '$warehouse'";
  2934. }
  2935. if ($purchase) {
  2936. $where .= " and purchase = '$purchase'";
  2937. }
  2938. if ($orderinfo) {
  2939. $where .= " and orderinfo = '$orderinfo'";
  2940. }
  2941. if ($waybill) {
  2942. $where .= " and waybill = '$waybill'";
  2943. }
  2944. if ($category) {
  2945. $where .= " and features like '%-$category-%'";
  2946. }
  2947. if ($size) {
  2948. $where .= " and features like '%-$size-%'";
  2949. }
  2950. if ($grade) {
  2951. $where .= " and features like '%-$grade-%'";
  2952. }
  2953. if ($color) {
  2954. $where .= " and features like '%-$color-%'";
  2955. }
  2956. if ($lowe) {
  2957. $where .= " and features like '%-$lowe-%'";
  2958. }
  2959. //数据排序
  2960. $order_str = "time desc";
  2961. if (empty($page)) {
  2962. $start = 0;
  2963. $perpage = 1;
  2964. } else {
  2965. $start = ($page - 1) * $perpage;
  2966. }
  2967. //取得信息列表
  2968. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  2969. foreach ($info_list as $key => $value) {
  2970. $warehouse = $this->warehouse->read($value['warehouse']);
  2971. $info_list[$key]['warehouse'] = $warehouse['title'];
  2972. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  2973. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  2974. $purchase = $this->purchase->read($value['purchase']);
  2975. $info_list[$key]['purchase'] = $purchase['title'];
  2976. if ($value['outk'] != 0) {
  2977. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2978. } else {
  2979. $info_list[$key]['outk'] = "";
  2980. }
  2981. if ($value['retreat'] != 0) {
  2982. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  2983. } else {
  2984. $info_list[$key]['retreat'] = "";
  2985. }
  2986. if ($value['orderinfo'] == 0) {
  2987. $info_list[$key]['orderinfo'] = "";
  2988. }
  2989. if ($value['waybill'] == 0) {
  2990. $info_list[$key]['waybill'] = "";
  2991. }
  2992. }
  2993. $total = $this->whlabel->find_count($where);
  2994. $pagenum = ceil($total / $perpage);
  2995. $over = $total - ($start + $perpage);
  2996. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2997. echo json_encode($rows);
  2998. exit;
  2999. }
  3000. $this->_Template('whlabel_retreatlk', $this->data);
  3001. }
  3002. //更换标签及浏览
  3003. public function _change()
  3004. {
  3005. $post = $this->input->post(NULL, TRUE);
  3006. if (isset($post['page'])) {
  3007. $page = $this->input->post('page', true);
  3008. $perpage = $this->input->post('perpage', true);
  3009. $timetk = $this->input->post('timetk', true);
  3010. $timetj = $this->input->post('timetj', true);
  3011. $label = $this->input->post('label', true);
  3012. $oldlabel = $this->input->post('oldlabel', true);
  3013. $timetk = strtotime($timetk);
  3014. $timetj = strtotime($timetj);
  3015. $where = "state=10 ";
  3016. if ($timetk && $timetj) {
  3017. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3018. }
  3019. if ($label) {
  3020. $where .= " and label = '$label'";
  3021. }
  3022. if ($oldlabel) {
  3023. $where .= " and oldlabel = '$oldlabel'";
  3024. }
  3025. //数据排序
  3026. $order_str = "time asc";
  3027. if (empty($page)) {
  3028. $start = 0;
  3029. $perpage = 1;
  3030. } else {
  3031. $start = ($page - 1) * $perpage;
  3032. }
  3033. //取得信息列表
  3034. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3035. foreach ($info_list as $key => $value) {
  3036. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3037. }
  3038. $total = $this->whlabel->find_count($where);
  3039. $pagenum = ceil($total / $perpage);
  3040. $over = $total - ($start + $perpage);
  3041. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3042. echo json_encode($rows);
  3043. exit;
  3044. }
  3045. $this->_Template('whlabel_change', $this->data);
  3046. }
  3047. //产品标签
  3048. public function _cpbqdc()
  3049. {
  3050. if (isset($_GET['excel'])) {
  3051. $where = "1=1";
  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. $warehouse = $this->input->get('warehouse', true);
  3061. $state = $this->input->get('state', true);
  3062. $timetk = $this->input->get('timetkk', true);
  3063. $timetj = $this->input->get('timetjj', true);
  3064. $timetk = strtotime($timetk);
  3065. $timetj = strtotime($timetj);
  3066. if ($warehouse) {
  3067. $where .= " and warehouse = '$warehouse'";
  3068. }
  3069. if ($state || $state == 0) {
  3070. $where .= " and state = '$state'";
  3071. }
  3072. if ($timetk && $timetj) {
  3073. $where .= " and time > '$timetk' and time < '$timetj'";
  3074. }
  3075. //取得信息列表
  3076. $info_list = $this->whlabel->find_all($where, '*');
  3077. $rows = array();
  3078. $list = array();
  3079. foreach ($info_list as $key => $value) {
  3080. $rows[$value['time']] = $value; //所有数据sku
  3081. }
  3082. foreach ($rows as $value) {
  3083. $warehouse = $this->warehouse->read($value['warehouse']);
  3084. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3085. $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);
  3086. }
  3087. $title = "产品标签统计表";
  3088. $titlename = "<table border=1>
  3089. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3090. <tr align='center'>
  3091. <td>仓库</td>
  3092. <td>SKU</td>
  3093. <td>产品</td>
  3094. <td>入库时间</td>
  3095. <td>操作时间</td>
  3096. <td>备注</td>
  3097. <td>数量</td>
  3098. </tr>
  3099. </table>";
  3100. $filename = $title . ".xls";
  3101. $tail = "";
  3102. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3103. }
  3104. }
  3105. //进销存导出
  3106. public function _exceljxc()
  3107. {
  3108. $classid = $this->classid->sku();
  3109. $pm = $classid;
  3110. $typeclass = array();
  3111. $tc = $this->typeclass->find_all();
  3112. foreach ($tc as $v) {
  3113. $typeclass[$v['id']] = $v;
  3114. }
  3115. $prc = array();
  3116. $purchase = $this->purchase->find_all();
  3117. foreach ($purchase as $k => $v) {
  3118. $prc[$v['id']] = $v['title'];
  3119. }
  3120. if (isset($_GET['excel'])) {
  3121. $where = "sku != 'Preset'";
  3122. //数据排序
  3123. $order_str = "id desc";
  3124. if (empty($page)) {
  3125. $start = 0;
  3126. $perpage = 1;
  3127. } else {
  3128. $start = ($page - 1) * $perpage;
  3129. }
  3130. $category = $this->input->get('category', true);
  3131. $warehouse = $this->input->get('warehouse', true);
  3132. $excelid = $this->input->get('sid', true);
  3133. if ($category) {
  3134. $where .= " and features like '%-$category-%'";
  3135. }
  3136. if ($warehouse) {
  3137. $where .= " and warehouse = '$warehouse'";
  3138. }
  3139. $xzid = '';
  3140. if ($excelid) {
  3141. $excelid = explode(',', trim($excelid, ','));
  3142. foreach ($excelid as $key => $value) {
  3143. $xzid .= " id = " . $value . " or";
  3144. }
  3145. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3146. }
  3147. //取得信息列表
  3148. /**
  3149. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3150. $rows = array();$list = array();
  3151. foreach ($info_list as $key=>$value)
  3152. {
  3153. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3154. }
  3155. **/
  3156. $wt = array();
  3157. $whlabel_type = $this->whlabel_type->find_all();
  3158. foreach ($whlabel_type as $v) {
  3159. $wt[$v['id']] = $v['title'];
  3160. }
  3161. $wh = array();
  3162. $w = $this->warehouse->find_all('1=1', 'id,title');
  3163. foreach ($w as $v) {
  3164. $wh[$v['id']] = $v['title'];
  3165. }
  3166. $list = array();
  3167. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3168. foreach ($rows as $key => $value) {
  3169. if (isset($wt[$value['type']])) {
  3170. $rows[$key]['type'] = $wt[$value['type']];
  3171. } else {
  3172. $rows[$key]['type'] = '未设置';
  3173. }
  3174. $bm = '03';
  3175. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3176. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3177. $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');
  3178. $details = array();
  3179. $cpid = array();
  3180. $cpbz = array();
  3181. $c = 0;
  3182. $g = 0;
  3183. $x = 0;
  3184. $t = 0;
  3185. $s = 0;
  3186. $q = 0;
  3187. foreach ($sd as $k => $v) {
  3188. if ($v['state'] == 0) {
  3189. $c++;
  3190. if ($v['cpid'] != 0) {
  3191. $cpid[$v['cpid']] = $v['cpid'];
  3192. }
  3193. if ($v['cpbz'] != '') {
  3194. $cpbz[$v['cpbz']] = $v['cpbz'];
  3195. }
  3196. }
  3197. if ($v['state'] != 9) {
  3198. $g++;
  3199. }
  3200. if ($v['state'] == 1) {
  3201. $x++;
  3202. }
  3203. if ($v['state'] == 2) {
  3204. $t++;
  3205. }
  3206. if ($v['state'] == 8) {
  3207. $s++;
  3208. }
  3209. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3210. $q++;
  3211. }
  3212. $details[$v['details']] = $v['details'];
  3213. }
  3214. $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'] . '"');
  3215. $rows[$key]['details'] = implode("、", $details);
  3216. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3217. $number = $value['number'];
  3218. $ftime = time() - 15 * 24 * 3600;
  3219. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3220. $rows[$key]['number'] = $g;
  3221. $rows[$key]['c'] = $c;
  3222. $rows[$key]['x'] = $x;
  3223. $rows[$key]['t'] = $t;
  3224. $rows[$key]['s'] = $s;
  3225. $rows[$key]['q'] = $q;
  3226. $rows[$key]['z'] = $z;
  3227. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3228. $features = explode('-', trim($features, '-'));
  3229. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3230. // $pm = $classid;
  3231. // $jm = $classid;
  3232. // foreach($features as $k=>$v)
  3233. // {
  3234. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3235. // {
  3236. // if($typeclass[$v]['bm'] != '')
  3237. // {
  3238. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3239. // }
  3240. // }
  3241. // if($v != 0)
  3242. // {
  3243. // if(!isset($typeclass[$v]))
  3244. // {
  3245. // continue;
  3246. // }
  3247. // if(isset($pm[$typeclass[$v]['classid']]))
  3248. // {
  3249. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3250. // {
  3251. // $tz = explode('|',$typeclass[$v]['zh']);
  3252. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3253. // }
  3254. // else
  3255. // {
  3256. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3257. // }
  3258. // }
  3259. // if(isset($jm[$typeclass[$v]['classid']]))
  3260. // {
  3261. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3262. // }
  3263. // }
  3264. // }
  3265. // $jm = array_filter($jm);
  3266. // $rows[$key]['bs'] = implode("-",$jm);
  3267. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3268. // $zh = implode(" ",$pm);
  3269. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3270. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3271. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3272. // $rows[$key]['features'] = $zh;
  3273. }
  3274. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3275. $final_list = [];
  3276. foreach ($list as $k => $v) {
  3277. if (empty($v['sku'])) {
  3278. continue;
  3279. }
  3280. $final_list[] = [
  3281. "warehouse" => $v["warehouse"],
  3282. "purchase" => $v["purchase"],
  3283. "details" => $v["details"],
  3284. "cpid" => $v["cpid"],
  3285. "dbcontent" => $v["dbcontent"],
  3286. "sku" => $v["sku"],
  3287. "cs" => $v["bm"],
  3288. "bs" => $v["jm"],
  3289. "title" => $v["title"],
  3290. "features" => $v["pm"],
  3291. "cpbz" => $v["cpbz"],
  3292. "sm" => $v["sm"],
  3293. "type" => $v["type"],
  3294. "number" => $v["number"],
  3295. "c" => $v["c"],
  3296. "x" => $v["x"],
  3297. "t" => $v["t"],
  3298. "s" => $v["s"],
  3299. "q" => $v["q"],
  3300. "z" => $v["z"],
  3301. "weight" => $v['weight'],
  3302. ];
  3303. }
  3304. $title = "总进销存统计表";
  3305. $titlename = "<table border=1>
  3306. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3307. <tr align='center'>
  3308. <td>仓库</td>
  3309. <td>供应商</td>
  3310. <td>位置</td>
  3311. <td>库存编码</td>
  3312. <td>类目</td>
  3313. <td>SKU</td>
  3314. <td>用友编码</td>
  3315. <td>用友料号</td>
  3316. <td>商品名称</td>
  3317. <td>商品中文</td>
  3318. <td>产品备注</td>
  3319. <td>说明</td>
  3320. <td>类型</td>
  3321. <td>入库总量</td>
  3322. <td>库存数量</td>
  3323. <td>销售数量</td>
  3324. <td>退货数量</td>
  3325. <td>删除数量</td>
  3326. <td>其它操作</td>
  3327. <td>占单数量</td>
  3328. <td>重量(g)</td>
  3329. </tr>
  3330. </table>";
  3331. $filename = $title . ".xls";
  3332. $tail = "";
  3333. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3334. }
  3335. }
  3336. //入库导出
  3337. public function _excelr()
  3338. {
  3339. if (isset($_GET['excel'])) {
  3340. $category = $this->input->get('category', true);
  3341. $size = $this->input->get('size', true);
  3342. $grade = $this->input->get('grade', true);
  3343. $color = $this->input->get('color', true);
  3344. $lowe = $this->input->get('lowe', true);
  3345. $sku = $this->input->get('sku', true);
  3346. $warehouse = $this->input->get('warehouse', true);
  3347. $purchase = $this->input->get('purchase', true);
  3348. $ktime = $this->input->get('ktime', true);
  3349. $jtime = $this->input->get('jtime', true);
  3350. $ktime = strtotime($ktime);
  3351. $jtime = strtotime($jtime);
  3352. $where = "1=1";
  3353. $gj = "";
  3354. $ck = "";
  3355. if ($category) {
  3356. $where .= " and features like '%-$category-%'";
  3357. }
  3358. if ($size) {
  3359. $where .= " and features like '%-$size-%'";
  3360. }
  3361. if ($grade) {
  3362. $where .= " and features like '%-$grade-%'";
  3363. }
  3364. if ($color) {
  3365. $where .= " and features like '%-$color-%'";
  3366. }
  3367. if ($lowe) {
  3368. $where .= " and features like '%-$lowe-%'";
  3369. }
  3370. if ($warehouse) {
  3371. $where .= " and warehouse = '$warehouse'";
  3372. }
  3373. if ($purchase) {
  3374. $where .= " and purchase = '$purchase'";
  3375. }
  3376. if ($sku) {
  3377. $where .= " and sku = '$sku'";
  3378. }
  3379. if ($ktime && $jtime) {
  3380. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3381. }
  3382. //数据排序
  3383. $order_str = "id desc";
  3384. if (empty($page)) {
  3385. $start = 0;
  3386. $perpage = 1;
  3387. } else {
  3388. $start = ($page - 1) * $perpage;
  3389. }
  3390. $list = array();
  3391. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3392. foreach ($rows as $value) {
  3393. $ck = $this->warehouse->read($value['warehouse']);
  3394. $warehouse = $ck['title'];
  3395. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3396. $retreatwarehouse = $tkck['title'];
  3397. $gy = $this->purchase->read($value['purchase']);
  3398. $purchase = $gy['title'];
  3399. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3400. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3401. }
  3402. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3403. $titlename = "<table border=1>
  3404. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3405. <tr align='center'>
  3406. <td>仓库</td>
  3407. <td>SKU</td>
  3408. <td>产品</td>
  3409. <td>时间</td>
  3410. <td>数量</td>
  3411. </tr>
  3412. </table>";
  3413. $filename = $title . ".xls";
  3414. $tail = "";
  3415. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3416. }
  3417. }
  3418. //出库、退库导出
  3419. public function _excelct()
  3420. {
  3421. $classid = $this->classid->sku();
  3422. $pm = $classid;
  3423. $typeclass = array();
  3424. $tc = $this->typeclass->find_all();
  3425. foreach ($tc as $v) {
  3426. $typeclass[$v['id']] = $v;
  3427. }
  3428. $prc = array();
  3429. $purchase = $this->purchase->find_all();
  3430. foreach ($purchase as $k => $v) {
  3431. $prc[$v['id']] = $v['title'];
  3432. }
  3433. if (isset($_GET['excel'])) {
  3434. $wh = array();
  3435. $w = $this->warehouse->find_all('1=1', 'id,title');
  3436. foreach ($w as $v) {
  3437. $wh[$v['id']] = $v['title'];
  3438. }
  3439. $type = $this->input->get('excel', true);
  3440. $category = $this->input->get('category', true);
  3441. $size = $this->input->get('size', true);
  3442. $grade = $this->input->get('grade', true);
  3443. $color = $this->input->get('color', true);
  3444. $lowe = $this->input->get('lowe', true);
  3445. $sku = $this->input->get('sku', true);
  3446. $warehouse = $this->input->get('warehouse', true);
  3447. $lacetype = $this->input->get('lacetype', true);
  3448. $lacecolor = $this->input->get('lacecolor', true);
  3449. $density = $this->input->get('density', true);
  3450. $haircap = $this->input->get('haircap', true);
  3451. $purchase = $this->input->get('purchase', true);
  3452. $title = $this->input->get('title', true);
  3453. $state = $this->input->get('state', true);
  3454. $sid = $this->input->get('sid', true);
  3455. $ktime = $this->input->get('ktime', true);
  3456. $jtime = $this->input->get('jtime', true);
  3457. $ktime = strtotime($ktime);
  3458. $jtime = strtotime($jtime);
  3459. $where = "1=1";
  3460. $gj = "";
  3461. $ck = "";
  3462. if ($category) {
  3463. $where .= " and features like '%-$category-%'";
  3464. }
  3465. if ($size) {
  3466. $where .= " and features like '%-$size-%'";
  3467. }
  3468. if ($grade) {
  3469. $where .= " and features like '%-$grade-%'";
  3470. }
  3471. if ($color) {
  3472. $where .= " and features like '%-$color-%'";
  3473. }
  3474. if ($lowe) {
  3475. $where .= " and features like '%-$lowe-%'";
  3476. }
  3477. if ($warehouse) {
  3478. $where .= " and warehouse = '$warehouse'";
  3479. }
  3480. if ($purchase) {
  3481. $where .= " and purchase = '$purchase'";
  3482. }
  3483. if ($state) {
  3484. $where .= " and state = '$state'";
  3485. }
  3486. if ($lacetype) {
  3487. $where .= " and features like '%-$lacetype-%'";
  3488. }
  3489. if ($lacecolor) {
  3490. $where .= " and features like '%-$lacecolor-%'";
  3491. }
  3492. if ($density) {
  3493. $where .= " and features like '%-$density-%'";
  3494. }
  3495. if ($haircap) {
  3496. $where .= " and features like '%-$haircap-%'";
  3497. }
  3498. if ($title) {
  3499. $title = trim($title, ' ');
  3500. $title = trim($title, ' ');
  3501. $where .= " and title like '%$title%'";
  3502. }
  3503. if ($sku) {
  3504. $sku = trim($sku, ' ');
  3505. $sku = trim($sku, ' ');
  3506. $where .= " and sku like '%$sku%'";
  3507. }
  3508. if ($ktime && $jtime) {
  3509. if ($type == 1) {
  3510. $tl = '出库';
  3511. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3512. } else if ($type == 2) {
  3513. $tl = '退库';
  3514. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3515. } else if ($type == 3) {
  3516. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3517. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3518. } else if ($type == 4) {
  3519. $tl = '出库+零售';
  3520. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3521. } else if ($type == 5) {
  3522. $tl = '零售';
  3523. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3524. }
  3525. }
  3526. $sidwhere = '';
  3527. if ($sid) {
  3528. $sd = "";
  3529. $s = explode(',', trim($sid, ','));
  3530. foreach ($s as $value) {
  3531. $sd .= " id = " . $value . " or";
  3532. }
  3533. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3534. }
  3535. //数据排序
  3536. $order_str = "time desc";
  3537. if (empty($page)) {
  3538. $start = 0;
  3539. $perpage = 1;
  3540. } else {
  3541. $start = ($page - 1) * $perpage;
  3542. }
  3543. //取得信息列表
  3544. if ($type != 3 && $type != 5) {
  3545. if ($type == 1 || $type == 4) {
  3546. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3547. foreach ($info_list as $key => $value) {
  3548. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3549. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3550. $warehouse = $this->warehouse->read($value['warehouse']);
  3551. $info_list[$key]['warehouse'] = $warehouse['title'];
  3552. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3553. $features = explode('-', trim($features, '-'));
  3554. $pm = $classid;
  3555. foreach ($features as $k => $v) {
  3556. if ($v != 0) {
  3557. if (!isset($typeclass[$v])) {
  3558. continue;
  3559. }
  3560. if (isset($pm[$typeclass[$v]['classid']])) {
  3561. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3562. $tz = explode('|', $typeclass[$v]['zh']);
  3563. $pm[$typeclass[$v]['classid']] = $tz[0];
  3564. } else {
  3565. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3566. }
  3567. }
  3568. }
  3569. }
  3570. $zh = implode(" ", $pm);
  3571. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3572. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3573. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3574. $info_list[$key]['features'] = $zh;
  3575. }
  3576. } else {
  3577. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3578. foreach ($info_list as $key => $value) {
  3579. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3580. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3581. $warehouse = $this->warehouse->read($value['warehouse']);
  3582. $info_list[$key]['warehouse'] = $warehouse['title'];
  3583. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3584. $features = explode('-', trim($features, '-'));
  3585. $pm = $classid;
  3586. foreach ($features as $k => $v) {
  3587. if ($v != 0) {
  3588. if (!isset($typeclass[$v])) {
  3589. continue;
  3590. }
  3591. if (isset($pm[$typeclass[$v]['classid']])) {
  3592. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3593. $tz = explode('|', $typeclass[$v]['zh']);
  3594. $pm[$typeclass[$v]['classid']] = $tz[0];
  3595. } else {
  3596. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3597. }
  3598. }
  3599. }
  3600. }
  3601. $zh = implode(" ", $pm);
  3602. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3603. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3604. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3605. $info_list[$key]['features'] = $zh;
  3606. }
  3607. }
  3608. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3609. $titlename = "<table border=1>
  3610. <tr><th colspan='8' align='center'><h3>" . $title . "<h3></th></tr>
  3611. <tr align='center'>
  3612. <td>仓库</td>
  3613. <td>供应商</td>
  3614. <td>SKU</td>
  3615. <td>商品名称</td>
  3616. <td>商品中文</td>
  3617. <td>标签</td>
  3618. <td>订单号</td>
  3619. <td>运单号</td>
  3620. <td>" . $tl . "时间(中国时间)</td>
  3621. </tr>
  3622. </table>";
  3623. $filename = $title . ".xls";
  3624. $tail = "";
  3625. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3626. } else if ($type == 5) {
  3627. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3628. foreach ($info_list as $key => $value) {
  3629. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3630. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3631. $warehouse = $this->warehouse->read($value['warehouse']);
  3632. $info_list[$key]['warehouse'] = $warehouse['title'];
  3633. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3634. $features = explode('-', trim($features, '-'));
  3635. $pm = $classid;
  3636. foreach ($features as $k => $v) {
  3637. if ($v != 0) {
  3638. if (!isset($typeclass[$v])) {
  3639. continue;
  3640. }
  3641. if (isset($pm[$typeclass[$v]['classid']])) {
  3642. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3643. $tz = explode('|', $typeclass[$v]['zh']);
  3644. $pm[$typeclass[$v]['classid']] = $tz[0];
  3645. } else {
  3646. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3647. }
  3648. }
  3649. }
  3650. }
  3651. $zh = implode(" ", $pm);
  3652. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3653. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3654. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3655. $info_list[$key]['features'] = $zh;
  3656. }
  3657. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3658. $titlename = "<table border=1>
  3659. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3660. <tr align='center'>
  3661. <td>仓库</td>
  3662. <td>供应商</td>
  3663. <td>SKU</td>
  3664. <td>商品名称</td>
  3665. <td>商品中文</td>
  3666. <td>标签</td>
  3667. <td>" . $tl . "时间(中国时间)</td>
  3668. </tr>
  3669. </table>";
  3670. $filename = $title . ".xls";
  3671. $tail = "";
  3672. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3673. } else {
  3674. /**
  3675. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3676. $rows = array();$list = array();
  3677. foreach ($info_list as $key=>$value)
  3678. {
  3679. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3680. }
  3681. **/
  3682. $wh = array();
  3683. $w = $this->warehouse->find_all('1=1', 'id,title');
  3684. foreach ($w as $v) {
  3685. $wh[$v['id']] = $v['title'];
  3686. }
  3687. $wt = array();
  3688. $whlabel_type = $this->whlabel_type->find_all();
  3689. foreach ($whlabel_type as $v) {
  3690. $wt[$v['id']] = $v['title'];
  3691. }
  3692. $classid = $this->classid->sku();
  3693. $list = array();
  3694. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3695. foreach ($rows as $key => $value) {
  3696. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3697. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3698. $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');
  3699. $details = array();
  3700. $cpid = array();
  3701. $cpbz = array();
  3702. $c = 0;
  3703. $g = 0;
  3704. $x = 0;
  3705. $t = 0;
  3706. $s = 0;
  3707. $q = 0;
  3708. foreach ($sd as $k => $v) {
  3709. if ($v['state'] == 0) {
  3710. $c++;
  3711. }
  3712. if ($v['state'] != 9) {
  3713. $g++;
  3714. }
  3715. if ($v['outk'] > 1) {
  3716. $x++;
  3717. }
  3718. if ($v['retreat'] > 0) {
  3719. $t++;
  3720. }
  3721. if ($v['state'] == 8) {
  3722. $s++;
  3723. }
  3724. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3725. $q++;
  3726. }
  3727. $details[$v['details']] = $v['details'];
  3728. if ($v['cpid'] != 0) {
  3729. $cpid[$v['cpid']] = $v['cpid'];
  3730. }
  3731. if ($v['cpbz'] != '') {
  3732. $cpbz[$v['cpbz']] = $v['cpbz'];
  3733. }
  3734. }
  3735. if (isset($wt[$value['type']])) {
  3736. $rows[$key]['type'] = $wt[$value['type']];
  3737. } else {
  3738. $rows[$key]['type'] = '未设置';
  3739. }
  3740. $rows[$key]['details'] = implode("、", $details);
  3741. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3742. $ftime = time() - 15 * 24 * 3600;
  3743. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3744. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3745. $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);
  3746. $rows[$key]['c'] = $c;
  3747. $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);
  3748. $rows[$key]['t'] = $t;
  3749. $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'] . '"');
  3750. $rows[$key]['z'] = $z;
  3751. // $jm = $classid;
  3752. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3753. $features = explode('-', trim($features, '-'));
  3754. // $pm = $classid;
  3755. // foreach ($features as $k => $v) {
  3756. // if ($v != 0) {
  3757. // if (!isset($typeclass[$v])) {
  3758. // continue;
  3759. // }
  3760. // if (isset($pm[$typeclass[$v]['classid']])) {
  3761. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3762. // $tz = explode('|', $typeclass[$v]['zh']);
  3763. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3764. // } else {
  3765. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3766. // }
  3767. // if (isset($jm[$typeclass[$v]['classid']])) {
  3768. // if ($typeclass[$v]['jm']) {
  3769. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3770. // }
  3771. // }
  3772. // }
  3773. // }
  3774. // }
  3775. // $zh = implode(" ", $pm);
  3776. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3777. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3778. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3779. // $rows[$key]['features'] = $zh;
  3780. // $jm = array_filter($jm); //去除空值
  3781. // $jm = implode("-", $jm);
  3782. // $rows[$key]['jm'] = $jm;
  3783. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3784. }
  3785. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3786. // echo "<pre>";
  3787. // print_r($tmp_list);
  3788. // die;
  3789. $final_list =[];
  3790. foreach($tmp_list as $k=>$v){
  3791. $final_list[] = [
  3792. "warehouse"=>$v['warehouse'],
  3793. "purchase"=>$v['purchase'],
  3794. "details"=>$v['details'],
  3795. "cpid"=>$v['cpid'],
  3796. "sku"=>$v['sku'],
  3797. "title"=>$v['title'],
  3798. "features"=>$v['pm'],
  3799. "cpbz"=>$v['cpbz'],
  3800. "sm"=>$v['sm'],
  3801. "type"=>$v['type'],
  3802. "g"=>$v["g"],
  3803. "c"=>$v["c"],
  3804. "x"=>$v["x"],
  3805. "t"=>$v["t"],
  3806. "z"=>$v["z"],
  3807. "jm"=>$v["jm"],
  3808. "weight"=>$v["weight"],
  3809. "asd"=>$v["asd"],
  3810. ];
  3811. }
  3812. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  3813. $titlename = "<table border=1>
  3814. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  3815. <tr align='center'>
  3816. <td>仓库</td>
  3817. <td>供应商</td>
  3818. <td>位置</td>
  3819. <td>库存编码</td>
  3820. <td>SKU</td>
  3821. <td>商品名称</td>
  3822. <td>商品中文</td>
  3823. <td>产品备注</td>
  3824. <td>说明</td>
  3825. <td>类型</td>
  3826. <td>入库总量</td>
  3827. <td>库存数量</td>
  3828. <td>销售数量</td>
  3829. <td>退货数量</td>
  3830. <td>占单数量</td>
  3831. <td>料号</td>
  3832. <td>重量</td>
  3833. <td>类目</td>
  3834. </tr>
  3835. </table>";
  3836. $filename = $title . ".xls";
  3837. $tail = "";
  3838. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3839. }
  3840. }
  3841. }
  3842. //出库+入库数据整合
  3843. public function _excelcr()
  3844. {
  3845. if (isset($_GET['excel'])) {
  3846. $type = $this->input->get('excel', true);
  3847. $category = $this->input->get('category', true);
  3848. $size = $this->input->get('size', true);
  3849. $grade = $this->input->get('grade', true);
  3850. $color = $this->input->get('color', true);
  3851. $lowe = $this->input->get('lowe', true);
  3852. $sku = $this->input->get('sku', true);
  3853. $warehouse = $this->input->get('warehouse', true);
  3854. $purchase = $this->input->get('purchase', true);
  3855. $state = $this->input->get('state', true);
  3856. $sid = $this->input->get('sid', true);
  3857. $ktime = $this->input->get('ktime', true);
  3858. $jtime = $this->input->get('jtime', true);
  3859. $ktime = strtotime($ktime);
  3860. $jtime = strtotime($jtime);
  3861. $where = "1=1";
  3862. $gj = "";
  3863. $ck = "";
  3864. if ($category) {
  3865. $where .= " and features like '%-$category-%'";
  3866. }
  3867. if ($size) {
  3868. $where .= " and features like '%-$size-%'";
  3869. }
  3870. if ($grade) {
  3871. $where .= " and features like '%-$grade-%'";
  3872. }
  3873. if ($color) {
  3874. $where .= " and features like '%-$color-%'";
  3875. }
  3876. if ($lowe) {
  3877. $where .= " and features like '%-$lowe-%'";
  3878. }
  3879. if ($warehouse) {
  3880. $where .= " and warehouse = '$warehouse'";
  3881. }
  3882. if ($purchase) {
  3883. $where .= " and purchase = '$purchase'";
  3884. }
  3885. if ($state) {
  3886. $where .= " and state = '$state'";
  3887. }
  3888. if ($sku) {
  3889. $where .= " and sku like '%$sku%'";
  3890. }
  3891. if ($ktime && $jtime) {
  3892. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  3893. }
  3894. $sidwhere = '';
  3895. if ($sid) {
  3896. $sd = "";
  3897. $s = explode(',', trim($sid, ','));
  3898. foreach ($s as $value) {
  3899. $sd .= " id = " . $value . " or";
  3900. }
  3901. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  3902. }
  3903. //取得信息列表
  3904. $timeread = $ktime;
  3905. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  3906. $timelist = array();
  3907. for ($i = 0; $i < $timenum; $i++) {
  3908. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  3909. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  3910. }
  3911. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  3912. //echo "<pre>";
  3913. //print_r($info_list);
  3914. //exit();
  3915. $rows = array();
  3916. $list = array();
  3917. foreach ($info_list as $key => $value) {
  3918. $thistime = $timelist;
  3919. if (isset($rows[strtolower($value['sku'])])) {
  3920. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  3921. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  3922. }
  3923. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  3924. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  3925. }
  3926. } else {
  3927. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  3928. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  3929. }
  3930. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  3931. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  3932. }
  3933. $rows[strtolower($value['sku'])] = $thistime;
  3934. }
  3935. }
  3936. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  3937. <head>
  3938. <!--[if gte mso 9]><xml>
  3939. <x:ExcelWorkbook>
  3940. <x:ExcelWorksheets>
  3941. <x:ExcelWorksheet>
  3942. <x:Name>EXCEL</x:Name>
  3943. <x:WorksheetOptions>
  3944. <x:Print>
  3945. <x:ValidPrinterInfo />
  3946. </x:Print>
  3947. </x:WorksheetOptions>
  3948. </x:ExcelWorksheet>
  3949. </x:ExcelWorksheets>
  3950. </x:ExcelWorkbook>
  3951. </xml>
  3952. <![endif]-->
  3953. </head><body>";
  3954. $str .= "<table border=1><tr><td>SKU</td>";
  3955. foreach ($timelist as $k => $v) {
  3956. $str .= "<td>" . $k . "出库</td>";
  3957. $str .= "<td>" . $k . "入库</td>";
  3958. }
  3959. $str .= "</tr></table>";
  3960. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  3961. foreach ($rows as $key => $val) {
  3962. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  3963. foreach ($val as $k => $v) {
  3964. $str .= "<td>" . $val[$k]['c'] . "</td>";
  3965. if ($val[$k]['r'] > 0) {
  3966. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  3967. } else {
  3968. $str .= "<td>" . $val[$k]['r'] . "</td>";
  3969. }
  3970. }
  3971. $str .= "</tr>";
  3972. }
  3973. $str .= "</table>";
  3974. $str .= "</body></html>";
  3975. header("Content-Type: application/vnd.ms-excel; name='excel'");
  3976. header("Content-type: application/octet-stream");
  3977. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  3978. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  3979. header("Pragma: no-cache");
  3980. header("Expires: 0");
  3981. exit($str);
  3982. }
  3983. }
  3984. //数量调整模板导出
  3985. public function _presetout()
  3986. {
  3987. if (isset($_GET['excel'])) {
  3988. $where = "sku != 'Preset' and purchase != 0";
  3989. //数据排序
  3990. $order_str = "id desc";
  3991. if (empty($page)) {
  3992. $start = 0;
  3993. $perpage = 1;
  3994. } else {
  3995. $start = ($page - 1) * $perpage;
  3996. }
  3997. //取得信息列表
  3998. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  3999. $rows = array();
  4000. $list = array();
  4001. foreach ($info_list as $value) {
  4002. $warehouse = $this->warehouse->read($value['warehouse']);
  4003. $number = $value['number'];
  4004. $ftime = time() - 15 * 24 * 3600;
  4005. $purchase = $this->purchase->read($value['purchase']);
  4006. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4007. }
  4008. $title = "库存模板";
  4009. $titlename = "<table border=1>
  4010. <tr align='center'>
  4011. <td>仓库</td>
  4012. <td>供应商编码</td>
  4013. <td>SKU</td>
  4014. <td>增减数量(正数或负数)</td>
  4015. <td>增减备注</td>
  4016. <td>扣减方式:0减少库存1删除库存</td>
  4017. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4018. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4019. </tr>
  4020. </table>";
  4021. $filename = $title . ".xls";
  4022. $tail = "";
  4023. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4024. }
  4025. }
  4026. //数量调整模板导入
  4027. public function _presetedit()
  4028. {
  4029. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4030. $config['upload_path'] = '.' . $dir;
  4031. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4032. $config['allowed_types'] = 'xls|xlsx|csv';
  4033. $config['max_size'] = 10240;
  4034. $this->load->library('upload', $config);
  4035. $this->upload->initialize($config);
  4036. if ($this->upload->do_upload('userfile')) {
  4037. $full_path = $dir . $this->upload->data('file_name');
  4038. $fileName = '.' . $full_path;
  4039. if (!file_exists($fileName)) {
  4040. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4041. exit;
  4042. } else {
  4043. require_once "./data/excel/PHPExcel/IOFactory.php";
  4044. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4045. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4046. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4047. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4048. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4049. ++$column; //如果列数大于26行
  4050. $list = array();
  4051. for ($i = 2; $i <= $row; $i++) // 行数循环
  4052. {
  4053. $data = array();
  4054. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4055. {
  4056. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4057. }
  4058. $list[] = $data;
  4059. }
  4060. }
  4061. $i = 0;
  4062. $j = 0;
  4063. $ed = array();
  4064. foreach ($list as $key => $value) {
  4065. $time = time();
  4066. if ($value['0'] == "") {
  4067. continue;
  4068. }
  4069. $warehouse = $this->warehouse->get_title($value['0']);
  4070. $purchase = $this->purchase->get_bm($value['1']);
  4071. $sku = $value['2'];
  4072. $num = $value['3']; //调整数量
  4073. $text = $value['4']; //扣减说明
  4074. $type = $value['5']; //调整方式0扣减1删除
  4075. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4076. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4077. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4078. if (!$purchase) //如果没有这个SKU
  4079. {
  4080. $ed[] = array($purchase . '-不存在此供应商编码');
  4081. $j++;
  4082. continue;
  4083. }
  4084. if (!$d) //如果没有这个SKU
  4085. {
  4086. $ed[] = array($sku . '-库存中不存在此SKU');
  4087. $j++;
  4088. continue;
  4089. }
  4090. if (!isset($warehouse['id'])) {
  4091. $ed[] = array($sku . '-仓库名错误!');
  4092. $j++;
  4093. continue;
  4094. }
  4095. if ($type != '0' && $type != '1') {
  4096. $ed[] = array($sku . '-扣减方式填写错误!');
  4097. $j++;
  4098. continue;
  4099. }
  4100. if ($num < 0) //扣减库存
  4101. {
  4102. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4103. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4104. $j++;
  4105. continue;
  4106. }
  4107. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4108. if (count($data) < abs($num)) {
  4109. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4110. $j++;
  4111. continue;
  4112. }
  4113. if ($type == 0) //如果扣减方式为 扣减库存
  4114. {
  4115. for ($i = 0; $i < abs($num); $i++) {
  4116. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4117. }
  4118. } else if ($type == 1) {
  4119. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4120. if (count($zt) > 0) {
  4121. $ed[] = array($sku . '-有在途库存无法删除!');
  4122. $j++;
  4123. continue;
  4124. }
  4125. for ($i = 0; $i < abs($num); $i++) {
  4126. $this->whlabel->remove($data[$i]['id']);
  4127. }
  4128. }
  4129. } else if ($num > 0) //增加库存
  4130. {
  4131. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4132. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4133. $j++;
  4134. continue;
  4135. }
  4136. $post['sku'] = $d['sku'];
  4137. $post['shop'] = $d['shop'];
  4138. $post['warehouse'] = $warehouse['id'];
  4139. $post['purchase'] = $purchase['id'];
  4140. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4141. $post['state'] = 0;
  4142. $post['title'] = $d['title'];
  4143. $post['number'] = $d['number'];
  4144. $post['features'] = $d['features'];
  4145. $post['enter'] = $time;
  4146. $post['time'] = $time; //操作时间
  4147. $post['rktype'] = $rktype;
  4148. for ($i = 0; $i < $num; $i++) {
  4149. $post['label'] = time() . rand(100, 999) . $i;
  4150. $this->whlabel->insert($post);
  4151. }
  4152. }
  4153. sleep(1); //防止入库时间一样,需要延迟1秒
  4154. }
  4155. if ($j > 0) {
  4156. $tt = date('Ymd', time());
  4157. $title = '库存导入错误信息-' . $tt;
  4158. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4159. $tail = "\n";
  4160. $filename = $title . ".xls";
  4161. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4162. $dir = '/data/excel/' . $time . '/';
  4163. $file_name = 'error_' . $time . rand(1000, 9999);
  4164. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4165. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4166. fwrite($myfile, $ecl);
  4167. fclose($myfile);
  4168. $error = $dir . $file_name . '.xls';
  4169. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4170. exit;
  4171. } else {
  4172. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4173. exit;
  4174. }
  4175. }
  4176. }
  4177. //笛卡儿积
  4178. function cp($ps, $sets, $list)
  4179. {
  4180. $result = array();
  4181. $j = 0;
  4182. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4183. if ($i == 0) {
  4184. $result = $sets[$i];
  4185. }
  4186. $tmp = array();
  4187. foreach ($result as $res) {
  4188. foreach ($sets[$i + 1] as $set) {
  4189. $tmp[] = $res . ',' . $set;
  4190. }
  4191. }
  4192. $result = $tmp;
  4193. }
  4194. $this->db->trans_begin();
  4195. foreach ($result as $v) {
  4196. $post = array();
  4197. $title = "";
  4198. $num = "";
  4199. $data = explode(',', $v);
  4200. for ($i = 0; $i < count($list); $i++) {
  4201. $post[$list[$i]] = $data[$i];
  4202. $typeclass = $this->typeclass->read($data[$i]);
  4203. $title = $title . $typeclass['title'] . " ";
  4204. if ($data[$i] != 0) {
  4205. $num .= $data[$i]; //所有数据ID拼接
  4206. }
  4207. }
  4208. foreach ($ps as $kp => $vp) {
  4209. $post[$kp] = $vp;
  4210. }
  4211. $post['number'] = $num;
  4212. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4213. if ($info_list) {
  4214. $j++;
  4215. } else {
  4216. $skunum = $this->whlabel->find_count();
  4217. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4218. $post['title'] = rtrim($title, ' ');
  4219. $this->whlabel->insert($post);
  4220. }
  4221. }
  4222. if ($this->db->trans_status() === FALSE) {
  4223. $this->db->trans_commit();
  4224. return NULL;
  4225. } else {
  4226. $this->db->trans_commit();
  4227. return $j;
  4228. }
  4229. }
  4230. public function _kj($arg_array)
  4231. {
  4232. if (isset($_POST['sku'])) {
  4233. $time = time();
  4234. $sku = $this->input->post('sku', true);
  4235. $warehouse = $this->input->post('warehouse', true);
  4236. $num = $this->input->post('num', true);
  4237. $text = $this->input->post('text', true);
  4238. $purchase = $this->input->post('purchase', true);
  4239. $cktype = $this->input->post('cktype', true);
  4240. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4241. if ($cktype != 1 && $text == '') {
  4242. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4243. exit;
  4244. }
  4245. if ($num > count($order)) {
  4246. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4247. exit;
  4248. } else {
  4249. for ($i = 0; $i < $num; $i++) {
  4250. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4251. }
  4252. }
  4253. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4254. exit;
  4255. }
  4256. $uid = $this->whlabel->read($arg_array[0]);
  4257. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4258. $this->data['data'] = $uid;
  4259. $this->_Template('whlabel_kj', $this->data);
  4260. }
  4261. public function _summary($arg_array)
  4262. {
  4263. $prc = array();
  4264. $purchase = $this->purchase->find_all();
  4265. foreach ($purchase as $k => $v) {
  4266. $prc[$v['id']] = $v['title'];
  4267. }
  4268. if (isset($_GET['excel'])) {
  4269. $ktime = $this->input->get('ktime', true);
  4270. $jtime = $this->input->get('jtime', true);
  4271. $ktime = strtotime($ktime);
  4272. $jtime = strtotime($jtime);
  4273. $where = "1=1";
  4274. if ($ktime && $jtime) {
  4275. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4276. }
  4277. //数据排序
  4278. $order_str = "time desc";
  4279. if (empty($page)) {
  4280. $start = 0;
  4281. $perpage = 1;
  4282. } else {
  4283. $start = ($page - 1) * $perpage;
  4284. }
  4285. //取得信息列表
  4286. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4287. foreach ($info_list as $key => $value) {
  4288. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4289. $warehouse = $this->warehouse->read($value['warehouse']);
  4290. $info_list[$key]['warehouse'] = $warehouse['title'];
  4291. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4292. $details = array();
  4293. $cpid = array();
  4294. foreach ($x as $k => $v) {
  4295. if ($v['details'] != '') {
  4296. $details[$v['details']] = $v['details'];
  4297. }
  4298. if ($v['cpid'] != 0) {
  4299. $cpid[$v['cpid']] = $v['cpid'];
  4300. }
  4301. }
  4302. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4303. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4304. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4305. $info_list[$key]['s'] = $s;
  4306. $info_list[$key]['x'] = count($x);
  4307. }
  4308. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4309. $titlename = "<table border=1>
  4310. <tr align='center'>
  4311. <td>仓库</td>
  4312. <td>供应商</td>
  4313. <td>出库位置</td>
  4314. <td>出库编码</td>
  4315. <td>SKU</td>
  4316. <td>产品名</td>
  4317. <td>总剩余库存</td>
  4318. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4319. </tr>
  4320. </table>";
  4321. $filename = $title . ".xls";
  4322. $tail = "";
  4323. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4324. }
  4325. }
  4326. //usps发货清单
  4327. public function _manifest()
  4328. {
  4329. if (isset($_POST['manifest'])) {
  4330. $wltext = $this->input->post('wltext', true);
  4331. $time = time() - 16 * 3600;
  4332. $ptime = strtotime(date('Y-m-d', $time));
  4333. $waybill = array();
  4334. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4335. foreach ($fullorder as $v) {
  4336. $waybill[$v['waybill']] = $v['waybill'];
  4337. }
  4338. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4339. foreach ($fullordersmt as $v) {
  4340. $waybill[$v['waybill']] = $v['waybill'];
  4341. }
  4342. $wltext = explode(';', $wltext);
  4343. foreach ($wltext as $v) {
  4344. if (isset($waybill[$v])) {
  4345. unset($waybill[$v]);
  4346. }
  4347. }
  4348. $data = $this->usps->get_manifest($waybill);
  4349. if (isset($data['Description'])) {
  4350. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4351. exit;
  4352. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4353. $bctime = date('Ymd', time());
  4354. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4355. echo json_encode(array('msg' => $pdf, 'success' => true));
  4356. exit;
  4357. } else {
  4358. echo json_encode(array('msg' => $data, 'success' => false));
  4359. exit;
  4360. }
  4361. }
  4362. }
  4363. public function _pdf($pdf, $title, $bctime)
  4364. {
  4365. $pdf_path = './data/pdf/' . $bctime . '/';
  4366. $file_base64 = $pdf;
  4367. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4368. $file_base64 = base64_decode($file_base64);
  4369. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4370. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4371. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4372. }
  4373. /**
  4374. *
  4375. *
  4376. *
  4377. 进销存占单异常索引
  4378. *
  4379. *
  4380. *
  4381. **/
  4382. public function _abnormal()
  4383. {
  4384. $post = $this->input->post(NULL, TRUE);
  4385. if (isset($post['page'])) {
  4386. $page = $this->input->post('page', true);
  4387. $perpage = $this->input->post('perpage', true);
  4388. $sku = $this->input->post('sku', true);
  4389. $where = "1=1";
  4390. //数据排序
  4391. $order_str = "id desc";
  4392. if (empty($page)) {
  4393. $start = 0;
  4394. $perpage = 1;
  4395. } else {
  4396. $start = ($page - 1) * $perpage;
  4397. }
  4398. //取得信息列表
  4399. $info_list = $this->whlabel->find_all($where, '*');
  4400. $rows = array();
  4401. $list = array();
  4402. foreach ($info_list as $key => $value) {
  4403. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4404. }
  4405. foreach ($rows as $value) {
  4406. $warehouse = $this->warehouse->read($value['warehouse']);
  4407. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4408. $number = $value['number'];
  4409. $ftime = time() - 15 * 24 * 3600;
  4410. if ($value['shop'] != '') {
  4411. $shop = $value['shop'];
  4412. $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');
  4413. $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');
  4414. $order = array_merge($orderdlz, $ordersmt);
  4415. $od = 0;
  4416. $a = '';
  4417. $orid = '';
  4418. foreach ($order as $v) {
  4419. $or = explode('|', ltrim($v['whlabel'], '|'));
  4420. for ($i = 0; $i < count($or); $i++) {
  4421. $orod = explode('-', $or[$i]);
  4422. if ($orod[0] == $number) {
  4423. $od += $orod[1];
  4424. }
  4425. }
  4426. $orid .= $v['number'] . '-';
  4427. }
  4428. } else {
  4429. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4430. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4431. $order = array_merge($orderdlz, $ordersmt);
  4432. $od = 0;
  4433. $a = '';
  4434. $orid = '';
  4435. $qt = array();
  4436. foreach ($order as $v) {
  4437. $or = explode('|', ltrim($v['whlabel'], '|'));
  4438. for ($i = 0; $i < count($or); $i++) {
  4439. $orod = explode('-', $or[$i]);
  4440. if ($orod[0] == $number) {
  4441. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4442. if ($czzs > 0) {
  4443. if (isset($qt[$v['shop']])) {
  4444. if ($qt[$v['shop']] < $orod[1]) {
  4445. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4446. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4447. } else {
  4448. $qt[$v['shop']] -= $orod[1];
  4449. }
  4450. } else {
  4451. $qt[$v['shop']] = $czzs;
  4452. }
  4453. } else {
  4454. $od += $orod[1];
  4455. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4456. }
  4457. }
  4458. }
  4459. }
  4460. }
  4461. $z = $od . '(' . $orid . ')'; //查看订单号
  4462. //$z = $od;
  4463. if ($od > $c) {
  4464. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4465. }
  4466. }
  4467. $listdata = array_slice($list, $start, $perpage);
  4468. $total = count($list);
  4469. $pagenum = ceil($total / $perpage);
  4470. $over = $total - ($start + $perpage);
  4471. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4472. echo json_encode($rows);
  4473. exit;
  4474. }
  4475. $this->_Template('whlabel_abnormal', $this->data);
  4476. }
  4477. /**
  4478. *
  4479. *
  4480. *
  4481. 进销存占单异常索引
  4482. *
  4483. *
  4484. *
  4485. **/
  4486. public function _error()
  4487. {
  4488. $post = $this->input->post(NULL, TRUE);
  4489. if (isset($post['page'])) {
  4490. $page = $this->input->post('page', true);
  4491. $perpage = $this->input->post('perpage', true);
  4492. $sku = $this->input->post('sku', true);
  4493. $warehouse = $this->input->post('warehouse', true);
  4494. $ktime = $this->input->post('ktime', true);
  4495. $jtime = $this->input->post('jtime', true);
  4496. $ktime = strtotime($ktime);
  4497. $jtime = strtotime($jtime);
  4498. $where = "sku != 'Preset'";
  4499. $gj = '';
  4500. if ($sku) {
  4501. $where .= " and sku like '%$sku%'";
  4502. } else {
  4503. if ($ktime && $jtime) {
  4504. $gj = " and time > '$ktime' and time < '$jtime'";
  4505. }
  4506. }
  4507. if ($warehouse) {
  4508. $where .= " and warehouse = '$warehouse'";
  4509. }
  4510. //数据排序
  4511. $order_str = "id desc";
  4512. if (empty($page)) {
  4513. $start = 0;
  4514. $perpage = 1;
  4515. } else {
  4516. $start = ($page - 1) * $perpage;
  4517. }
  4518. //取得信息列表
  4519. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4520. $rows = array();
  4521. $list = array();
  4522. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4523. // foreach ($info_list as $value)
  4524. // {
  4525. // $warehouse = $this->warehouse->read($value['warehouse']);
  4526. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4527. // $number = $value['number'];$ftime = time()-15*24*3600;
  4528. // if($c < 1)
  4529. // {
  4530. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4531. // }
  4532. // }
  4533. $warehouse_list = $this->warehouse->find_all();
  4534. $warehouse_list = array_column($warehouse_list, null, 'id');
  4535. foreach ($info_list as $value) {
  4536. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4537. 'title' => "",
  4538. ];
  4539. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4540. $number = $value['number'];
  4541. $ftime = time() - 15 * 24 * 3600;
  4542. if ($c < 1) {
  4543. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4544. }
  4545. }
  4546. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4547. // $query = $this->db->query($sql);
  4548. // $info_list = $query->result_array();
  4549. // $sql_two = "select title,id from crowd_warehouse";
  4550. // $query_two = $this->db->query($sql_two);
  4551. // $warehouse_list = $query_two->result_array();
  4552. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4553. // foreach ($info_list as $value)
  4554. // {
  4555. // if(isset($warehouse_arr[$value['warehouse']])){
  4556. // $warehouse = $warehouse_arr[$value['warehouse']];
  4557. // }else{
  4558. // $warehouse = [
  4559. // 'id'=>0,
  4560. // 'title'=>"异常",
  4561. // ];
  4562. // }
  4563. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4564. // $number = $value['number'];$ftime = time()-15*24*3600;
  4565. // if($c < 1)
  4566. // {
  4567. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4568. // }
  4569. // }
  4570. $listdata = array_slice($list, $start, $perpage);
  4571. $total = count($list);
  4572. $pagenum = ceil($total / $perpage);
  4573. $over = $total - ($start + $perpage);
  4574. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4575. echo json_encode($rows);
  4576. exit;
  4577. }
  4578. if (isset($post['s'])) {
  4579. $id_arr = $this->input->post('s');
  4580. $id_arr = explode(',', trim($id_arr, ','));
  4581. if (!$id_arr) {
  4582. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4583. exit;
  4584. }
  4585. //循环删除记录
  4586. foreach ($id_arr as $v) {
  4587. $dd = $this->whlabel->read($v);
  4588. if (!isset($dd['id'])) {
  4589. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4590. exit;
  4591. }
  4592. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4593. if (isset($zt[0])) {
  4594. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4595. exit;
  4596. }
  4597. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4598. foreach ($deldd as $vv) {
  4599. $this->whlabel->remove($vv['id']);
  4600. }
  4601. }
  4602. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4603. exit;
  4604. }
  4605. $this->_Template('whlabel_error', $this->data);
  4606. }
  4607. public function _errorexcel()
  4608. {
  4609. $post = $this->input->post(NULL, TRUE);
  4610. if (isset($_GET['page'])) {
  4611. $page = $this->input->get('page', true);
  4612. $perpage = $this->input->get('perpage', true);
  4613. $sku = $this->input->get('sku', true);
  4614. $warehouse = $this->input->get('warehouse', true);
  4615. $ktime = $this->input->get('ktime', true);
  4616. $jtime = $this->input->get('jtime', true);
  4617. $ktime = strtotime($ktime);
  4618. $jtime = strtotime($jtime);
  4619. $where = "sku != 'Preset'";
  4620. $gj = '';
  4621. if ($sku) {
  4622. $where .= " and sku like '%$sku%'";
  4623. } else {
  4624. if ($ktime && $jtime) {
  4625. $gj = " and time > '$ktime' and time < '$jtime'";
  4626. }
  4627. }
  4628. if ($warehouse) {
  4629. $where .= " and warehouse = '$warehouse'";
  4630. }
  4631. //数据排序
  4632. $order_str = "id desc";
  4633. if (empty($page)) {
  4634. $start = 0;
  4635. $perpage = 1;
  4636. } else {
  4637. $start = ($page - 1) * $perpage;
  4638. }
  4639. //取得信息列表
  4640. $rows = array();
  4641. $list = array();
  4642. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4643. foreach ($info_list as $value) {
  4644. $warehouse = $this->warehouse->read($value['warehouse']);
  4645. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4646. $number = $value['number'];
  4647. $ftime = time() - 15 * 24 * 3600;
  4648. if ($c < 1) {
  4649. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4650. }
  4651. }
  4652. $title = "0库存汇总";
  4653. $titlename = "<table border=1>
  4654. <tr align='center'>
  4655. <td>仓库</td>
  4656. <td>SKU</td>
  4657. <td>产品</td>
  4658. <td>当前库存</td>
  4659. </tr>
  4660. </table>";
  4661. $filename = $title . ".xls";
  4662. $tail = "";
  4663. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4664. }
  4665. }
  4666. /**
  4667. *
  4668. *
  4669. * 占单
  4670. *
  4671. *
  4672. **/
  4673. public function _kcyz()
  4674. {
  4675. $post = $this->input->post(NULL, TRUE);
  4676. if (isset($post['warehouse'])) {
  4677. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4678. exit; //不再使用
  4679. $warehouse = $this->input->post('warehouse', true);
  4680. $whlabel = $this->input->post('whlabel', true);
  4681. $id = $this->input->post('id', true);
  4682. $shop = $this->input->post('shop', true);
  4683. $number = $this->input->post('number', true);
  4684. if (!$whlabel || $whlabel == '|') {
  4685. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4686. exit;
  4687. }
  4688. $pp = explode('|', trim($whlabel, '|'));
  4689. $x = 0;
  4690. $save = array();
  4691. foreach ($pp as $va) {
  4692. $num = explode('-', $va);
  4693. if ($number) {
  4694. $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 = '')"); //通用
  4695. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4696. } else {
  4697. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4698. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4699. }
  4700. $x++;
  4701. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4702. $save[] = $x - 1;
  4703. continue; //提前先加X不然出错,所以要减1
  4704. }
  4705. }
  4706. if (isset($save[0])) {
  4707. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4708. exit;
  4709. } else {
  4710. echo json_encode(array('success' => true));
  4711. exit;
  4712. }
  4713. }
  4714. }
  4715. public function _db()
  4716. {
  4717. $post = $this->input->post(NULL, TRUE);
  4718. if (isset($post['page'])) {
  4719. $page = $this->input->post('page', true);
  4720. $perpage = $this->input->post('perpage', true);
  4721. $sku = $this->input->post('sku', true);
  4722. $number = $this->input->post('number', true);
  4723. $warehouse = $this->input->post('warehouse', true);
  4724. $purchase = $this->input->post('purchase', true);
  4725. $orderinfo = $this->input->post('orderinfo', true);
  4726. $waybill = $this->input->post('waybill', true);
  4727. $category = $this->input->post('category', true);
  4728. $size = $this->input->post('size', true);
  4729. $grade = $this->input->post('grade', true);
  4730. $color = $this->input->post('color', true);
  4731. $lowe = $this->input->post('lowe', true);
  4732. $state = $this->input->post('state', true);
  4733. $label = $this->input->post('label', true);
  4734. $timetk = $this->input->post('timetkk', true);
  4735. $timetj = $this->input->post('timetjj', true);
  4736. $timetk = strtotime($timetk);
  4737. $timetj = strtotime($timetj);
  4738. $where = "dbtime > 0";
  4739. if ($timetk && $timetj) {
  4740. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4741. }
  4742. if ($sku) {
  4743. $where .= " and sku = '$sku'";
  4744. }
  4745. if ($warehouse) {
  4746. $where .= " and warehouse = '$warehouse'";
  4747. if ($warehouse == 12) {
  4748. $w = 'specialstock';
  4749. } else {
  4750. $w = 'whlabel';
  4751. }
  4752. }
  4753. if ($purchase) {
  4754. $where .= " and purchase = '$purchase'";
  4755. }
  4756. if ($category) {
  4757. $where .= " and features like '%-$category-%'";
  4758. }
  4759. if ($size) {
  4760. $where .= " and features like '%-$size-%'";
  4761. }
  4762. if ($grade) {
  4763. $where .= " and features like '%-$grade-%'";
  4764. }
  4765. if ($color) {
  4766. $where .= " and features like '%-$color-%'";
  4767. }
  4768. if ($lowe) {
  4769. $where .= " and features like '%-$lowe-%'";
  4770. }
  4771. if ($state != '') {
  4772. $where .= " and state = '$state'";
  4773. }
  4774. //数据排序
  4775. $order_str = "dbtime desc";
  4776. if (empty($page)) {
  4777. $start = 0;
  4778. $perpage = 1;
  4779. } else {
  4780. $start = ($page - 1) * $perpage;
  4781. }
  4782. //取得信息列表
  4783. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4784. foreach ($info_list as $key => $value) {
  4785. $warehouse = $this->$w->read($value['warehouse']);
  4786. $info_list[$key]['warehouse'] = $warehouse['title'];
  4787. $purchase = $this->purchase->read($value['purchase']);
  4788. $info_list[$key]['purchase'] = $purchase['title'];
  4789. if ($value['enter'] != 0) {
  4790. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4791. } else {
  4792. $info_list[$key]['enter'] = "";
  4793. }
  4794. if ($value['dbtime'] != 0) {
  4795. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  4796. } else {
  4797. $info_list[$key]['dbtime'] = "";
  4798. }
  4799. if ($value['state'] == 0) {
  4800. $info_list[$key]['state'] = "在库";
  4801. } else if ($value['state'] == 1) {
  4802. $info_list[$key]['state'] = "出库";
  4803. } else if ($value['state'] == 2) {
  4804. $info_list[$key]['state'] = "退库";
  4805. } else if ($value['state'] == 3) {
  4806. $info_list[$key]['state'] = "调拨中";
  4807. } else if ($value['state'] == 4) {
  4808. $info_list[$key]['state'] = "再加工";
  4809. } else if ($value['state'] == 5) {
  4810. $info_list[$key]['state'] = "维修中";
  4811. } else if ($value['state'] == 6) {
  4812. $info_list[$key]['state'] = "盘亏";
  4813. } else if ($value['state'] == 7) {
  4814. $info_list[$key]['state'] = "更换标签";
  4815. } else if ($value['state'] == 8) {
  4816. $info_list[$key]['state'] = "其它";
  4817. } else if ($value['state'] == 9) {
  4818. $info_list[$key]['state'] = "预设";
  4819. }
  4820. }
  4821. $total = $this->whlabel->find_count($where);
  4822. $pagenum = ceil($total / $perpage);
  4823. $over = $total - ($start + $perpage);
  4824. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  4825. echo json_encode($rows);
  4826. exit;
  4827. }
  4828. if (isset($post['outsku'])) {
  4829. $time = time();
  4830. $cz = $this->input->post('cz', true);
  4831. $label = $this->input->post('outsku', true);
  4832. $sl = $this->input->post('sl', true);
  4833. $num = $this->input->post('num', true);
  4834. //$warehouse = $this->input->post('warehouse',true);
  4835. if (!$sl) {
  4836. $sl = 1;
  4837. }
  4838. if (!$warehouse) {
  4839. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  4840. exit;
  4841. }
  4842. $dblabel = $this->whlabellabel->get_label($label);
  4843. if ($dblabel) {
  4844. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  4845. if (count($data) < 1) {
  4846. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  4847. exit;
  4848. }
  4849. if (count($data) < $num) {
  4850. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  4851. exit;
  4852. }
  4853. for ($i = 0; $i < $sl; $i++) {
  4854. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  4855. }
  4856. echo json_encode(array('success' => true));
  4857. exit;
  4858. } else {
  4859. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  4860. exit;
  4861. }
  4862. }
  4863. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  4864. $this->_Template('whlabel_db', $this->data);
  4865. }
  4866. public function _dbrk()
  4867. {
  4868. $post = $this->input->post(NULL, TRUE);
  4869. if (isset($post['page'])) {
  4870. $page = $this->input->post('page', true);
  4871. $perpage = $this->input->post('perpage', true);
  4872. $sku = $this->input->post('sku', true);
  4873. $number = $this->input->post('number', true);
  4874. $warehouse = $this->input->post('warehouse', true);
  4875. $purchase = $this->input->post('purchase', true);
  4876. $orderinfo = $this->input->post('orderinfo', true);
  4877. $waybill = $this->input->post('waybill', true);
  4878. $category = $this->input->post('category', true);
  4879. $size = $this->input->post('size', true);
  4880. $grade = $this->input->post('grade', true);
  4881. $color = $this->input->post('color', true);
  4882. $lowe = $this->input->post('lowe', true);
  4883. $state = $this->input->post('state', true);
  4884. $label = $this->input->post('label', true);
  4885. $ctime = $this->input->post('ctime', true);
  4886. $timetk = $this->input->post('timetkk', true);
  4887. $timetj = $this->input->post('timetjj', true);
  4888. $timetk = strtotime($timetk);
  4889. $timetj = strtotime($timetj);
  4890. $where = "dbtime > 0";
  4891. if ($timetk && $timetj) {
  4892. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  4893. }
  4894. if ($sku) {
  4895. $where .= " and sku = '$sku'";
  4896. }
  4897. if ($warehouse) {
  4898. $where .= " and warehouse = '$warehouse'";
  4899. }
  4900. if ($purchase) {
  4901. $where .= " and purchase = '$purchase'";
  4902. }
  4903. if ($category) {
  4904. $where .= " and features like '%-$category-%'";
  4905. }
  4906. if ($size) {
  4907. $where .= " and features like '%-$size-%'";
  4908. }
  4909. if ($grade) {
  4910. $where .= " and features like '%-$grade-%'";
  4911. }
  4912. if ($color) {
  4913. $where .= " and features like '%-$color-%'";
  4914. }
  4915. if ($lowe) {
  4916. $where .= " and features like '%-$lowe-%'";
  4917. }
  4918. if ($state != '') {
  4919. $where .= " and state = '$state'";
  4920. }
  4921. //数据排序
  4922. $order_str = "dbtime desc";
  4923. if (empty($page)) {
  4924. $start = 0;
  4925. $perpage = 1;
  4926. } else {
  4927. $start = ($page - 1) * $perpage;
  4928. }
  4929. //取得信息列表
  4930. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4931. foreach ($info_list as $key => $value) {
  4932. $warehouse = $this->warehouse->read($value['warehouse']);
  4933. $info_list[$key]['warehouse'] = $warehouse['title'];
  4934. $purchase = $this->purchase->read($value['purchase']);
  4935. $info_list[$key]['purchase'] = $purchase['title'];
  4936. if ($value['enter'] != 0) {
  4937. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4938. } else {
  4939. $info_list[$key]['enter'] = "";
  4940. }
  4941. if ($value['dbtime'] != 0) {
  4942. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  4943. } else {
  4944. $info_list[$key]['dbtime'] = "";
  4945. }
  4946. if ($value['state'] == 0) {
  4947. $info_list[$key]['state'] = "在库";
  4948. } else if ($value['state'] == 1) {
  4949. $info_list[$key]['state'] = "出库";
  4950. } else if ($value['state'] == 2) {
  4951. $info_list[$key]['state'] = "退库";
  4952. } else if ($value['state'] == 3) {
  4953. $info_list[$key]['state'] = "调拨中";
  4954. } else if ($value['state'] == 4) {
  4955. $info_list[$key]['state'] = "再加工";
  4956. } else if ($value['state'] == 5) {
  4957. $info_list[$key]['state'] = "维修中";
  4958. } else if ($value['state'] == 6) {
  4959. $info_list[$key]['state'] = "盘亏";
  4960. } else if ($value['state'] == 7) {
  4961. $info_list[$key]['state'] = "更换标签";
  4962. } else if ($value['state'] == 8) {
  4963. $info_list[$key]['state'] = "其它";
  4964. } else if ($value['state'] == 9) {
  4965. $info_list[$key]['state'] = "预设";
  4966. }
  4967. }
  4968. $total = $this->whlabel->find_count($where);
  4969. $pagenum = ceil($total / $perpage);
  4970. $over = $total - ($start + $perpage);
  4971. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  4972. echo json_encode($rows);
  4973. exit;
  4974. }
  4975. if (isset($post['rsku'])) {
  4976. $cz = $this->input->post('cz', true);
  4977. $label = $this->input->post('rsku', true);
  4978. $sl = $this->input->post('sl', true);
  4979. $warehouse = $this->input->post('warehouse', true);
  4980. if (!$sl) {
  4981. $sl = 1;
  4982. }
  4983. if (!$warehouse) {
  4984. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  4985. exit;
  4986. }
  4987. $dblabel = $this->whlabellabel->get_label($label);
  4988. if ($dblabel) {
  4989. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  4990. if (count($data) < 1) {
  4991. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  4992. exit;
  4993. }
  4994. if ($sl > count($data)) {
  4995. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  4996. exit;
  4997. }
  4998. $time = time();
  4999. for ($i = 0; $i < $sl; $i++) {
  5000. $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']);
  5001. }
  5002. echo json_encode(array('success' => true));
  5003. exit;
  5004. } else {
  5005. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5006. exit;
  5007. }
  5008. }
  5009. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5010. $this->_Template('whlabel_dbrk', $this->data);
  5011. }
  5012. public function _whlabelczdc()
  5013. {
  5014. if (isset($_GET['excel'])) {
  5015. //数据排序
  5016. $order_str = "id desc";
  5017. if (empty($page)) {
  5018. $start = 0;
  5019. $perpage = 1;
  5020. } else {
  5021. $start = ($page - 1) * $perpage;
  5022. }
  5023. $state = $this->input->get('state', true);
  5024. $sku = $this->input->get('sku', true);
  5025. $ctime = $this->input->get('ctime', true);
  5026. $category = $this->input->get('category', true);
  5027. $size = $this->input->get('size', true);
  5028. $grade = $this->input->get('grade', true);
  5029. $color = $this->input->get('color', true);
  5030. $lowe = $this->input->get('lowe', true);
  5031. $timetk = $this->input->get('timetkk', true);
  5032. $timetj = $this->input->get('timetjj', true);
  5033. $timetk = strtotime($timetk);
  5034. $timetj = strtotime($timetj);
  5035. $where = "dbtime > 0";
  5036. if ($timetk && $timetj) {
  5037. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5038. }
  5039. if ($category) {
  5040. $where .= " and features like '%-$category-%'";
  5041. }
  5042. if ($size) {
  5043. $where .= " and features like '%-$size-%'";
  5044. }
  5045. if ($grade) {
  5046. $where .= " and features like '%-$grade-%'";
  5047. }
  5048. if ($color) {
  5049. $where .= " and features like '%-$color-%'";
  5050. }
  5051. if ($lowe) {
  5052. $where .= " and features like '%-$lowe-%'";
  5053. }
  5054. //取得信息列表
  5055. $info_list = $this->whlabel->find_all($where, '*');
  5056. $rows = array();
  5057. $list = array();
  5058. foreach ($info_list as $key => $value) {
  5059. $rows[$value['sku']] = $value; //所有数据sku
  5060. }
  5061. foreach ($rows as $value) {
  5062. $warehouse = $this->warehouse->read($value['warehouse']);
  5063. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5064. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5065. if ($value['orderinfo'] == 0) {
  5066. $info_list[$key]['orderinfo'] = "";
  5067. }
  5068. if ($value['waybill'] == 0) {
  5069. $info_list[$key]['waybill'] = "";
  5070. }
  5071. if ($value['state'] == 0) {
  5072. $value['state'] = "在库";
  5073. } else if ($value['state'] == 3) {
  5074. $value['state'] = "调拨中";
  5075. }
  5076. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5077. }
  5078. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5079. $titlename = "<table border=1>
  5080. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5081. <tr align='center'>
  5082. <td>SKU</td>
  5083. <td>产品</td>
  5084. <td>调拨数量</td>
  5085. <td>入库数量</td>
  5086. </tr>
  5087. </table>";
  5088. $filename = $title . ".xls";
  5089. $tail = "";
  5090. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5091. }
  5092. }
  5093. public function _print($arg_array)
  5094. {
  5095. if (isset($_SESSION['api'])) {
  5096. $user = $this->user->get_api($_SESSION['api']);
  5097. $usp = $user;
  5098. $fgshop = "";
  5099. $sid = "";
  5100. $wid = "";
  5101. $wtype = "";
  5102. $usersp = explode('|', trim($user['shop'], '|'));
  5103. $userwh = explode('|', trim($user['warehouse'], '|'));
  5104. foreach ($usersp as $value) {
  5105. $fgshop .= " shop = " . $value . " or";
  5106. $sid .= " id = " . $value . " or";
  5107. }
  5108. foreach ($userwh as $value) {
  5109. $wid .= " id = " . $value . " or";
  5110. $wtype .= " type = " . $value . " or";
  5111. }
  5112. }
  5113. $post = $this->input->post(NULL, TRUE);
  5114. if (isset($post['tmsku'])) {
  5115. $tmsku = $this->input->post('tmsku', true);
  5116. if (is_numeric($tmsku)) {
  5117. $yyh = $this->whlabellabel->get_label($tmsku);
  5118. } else {
  5119. $yyh = $this->whlabellabel->get_sku($tmsku);
  5120. }
  5121. if ($yyh) {
  5122. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5123. exit;
  5124. } else {
  5125. echo json_encode(array('success' => false));
  5126. exit;
  5127. }
  5128. }
  5129. $classid = $this->classid->sku();
  5130. $pm = $classid;
  5131. $scsku = $classid;
  5132. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5133. if (isset($post['warehouse'])) {
  5134. if ($post['warehouse']) {
  5135. $list = array();
  5136. $num = "";
  5137. $title = "";
  5138. $features = "";
  5139. $order = 0;
  5140. $post['shop'] = '';
  5141. $brand = $this->input->post('brand', true);
  5142. if ($brand != '0,') {
  5143. $b = $this->brand->read(rtrim($brand, ','));
  5144. if ($b) {
  5145. $post['shop'] = str_replace('|', ',', $b['shop']);
  5146. }
  5147. }
  5148. $post['details'] = $this->input->post('details', true); //打印数量
  5149. $xbqnum = $this->input->post('xbqnum', true);
  5150. $post['purchase'] = $this->input->post('purchase', true);
  5151. $post['warehouse'] = $this->input->post('warehouse', true);
  5152. $post['purchase'] = $this->input->post('purchase', true);
  5153. $post['retreatwarehouse'] = $post['warehouse'];
  5154. $post['cpbz'] = $this->input->post('cpbz', true);
  5155. $post['state'] = 9;
  5156. $category = $this->input->post('category', true);
  5157. $list['category'] = $category;
  5158. $list['hairtype'] = $this->input->post('hairtype', true);
  5159. $list['grade'] = $this->input->post('grade', true);
  5160. $size = $this->input->post('size', true);
  5161. $list['size'] = rtrim($size, ',');
  5162. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5163. $list['extension'] = $this->input->post('extension', true);
  5164. if ($category == 1297) {
  5165. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5166. }
  5167. if ($category == 1702) {
  5168. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5169. $list['syother'] = $this->input->post('syother', true);
  5170. }
  5171. if ($category == 133) {
  5172. $list['fittype'] = $this->input->post('fittype', true);
  5173. $list['acother'] = $this->input->post('acother', true);
  5174. }
  5175. $list['color'] = $this->input->post('color', true);
  5176. $list['lowe'] = $this->input->post('lowe', true);
  5177. if ($category == 127) {
  5178. $list['type'] = $this->input->post('type', true);
  5179. $list['headroad'] = $this->input->post('headroad', true);
  5180. $list['density'] = $this->input->post('density', true);
  5181. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5182. $list['lacesize'] = $this->input->post('lacesize', true);
  5183. }
  5184. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5185. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5186. }
  5187. if ($category == 128) {
  5188. $list['lacetype'] = $this->input->post('lacetype', true);
  5189. $list['haircap'] = $this->input->post('haircap', true);
  5190. $list['density'] = $this->input->post('density', true);
  5191. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5192. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5193. $list['wigother'] = $this->input->post('wigother', true);
  5194. $list['wigother2'] = $this->input->post('wigother2', true);
  5195. }
  5196. if ($category == 129) {
  5197. $list['wide'] = $this->input->post('wide', true);
  5198. }
  5199. if ($category == 131) {
  5200. $list['gifttype'] = $this->input->post('gifttype', true);
  5201. $list['giftother'] = $this->input->post('giftother', true);
  5202. }
  5203. if ($category == 134) {
  5204. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5205. }
  5206. if ($category == 1297) {
  5207. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5208. $list['sywigother'] = $this->input->post('sywigother', true);
  5209. }
  5210. if ($category == 130 || $category == 133 || $category == 1702) {
  5211. $list['items'] = $this->input->post('items', true);
  5212. $list['weight'] = $this->input->post('weight', true);
  5213. }
  5214. if ($category == 1702) {
  5215. $list['syhairther'] = $this->input->post('syhairther', true);
  5216. }
  5217. foreach ($list as $k => $v) {
  5218. if ($v != 0) {
  5219. $num .= $v;
  5220. $features .= $v . '-';
  5221. $post[$k] = $v;
  5222. $typeclass = $this->typeclass->read($v);
  5223. if (isset($pm[$typeclass['classid']])) {
  5224. if (stripos($typeclass['zh'], '|') !== false) {
  5225. $exzh = explode('|', $typeclass['zh']);
  5226. $pm[$typeclass['classid']] = $exzh[0];
  5227. } else {
  5228. $pm[$typeclass['classid']] = $typeclass['zh'];
  5229. }
  5230. }
  5231. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5232. if ($k != 'size') {
  5233. $title .= $typeclass['title'] . " ";
  5234. }
  5235. }
  5236. }
  5237. $typeclass = $this->typeclass->read($list['size']);
  5238. $title .= $typeclass['title'];
  5239. $time = time();
  5240. $post['title'] = rtrim($title, ' ');
  5241. $post['number'] = $num;
  5242. $post['features'] = '-' . $features;
  5243. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5244. $featurespp = explode('-', trim($featurespp, '-'));
  5245. if (isset($featurespp[5])) {
  5246. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5247. } else {
  5248. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5249. }
  5250. $post['enter'] = $time;
  5251. $post['time'] = $time; //操作时间
  5252. $scsku = implode("-", $scsku);
  5253. $zh = implode(" ", $pm);
  5254. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5255. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5256. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5257. $post['sku'] = $bqsku;
  5258. $label = time() . rand(0, 9);
  5259. $post['label'] = $label;
  5260. $cpid = $this->whlabellabel->find_count();
  5261. $post['cpid'] = $cpid + 1;
  5262. $cpid = $post['cpid'];
  5263. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5264. //if($whlabelbarcode)
  5265. //{
  5266. //$post['label'] = $whlabelbarcode['label'];
  5267. //if(!$this->whlabellabel->insert($post))
  5268. //{
  5269. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5270. //}
  5271. //}
  5272. //else
  5273. //{
  5274. $this->db->trans_begin();
  5275. $this->whlabellabel->insert($post);
  5276. //$this->whlabelbarcode->insert($post);
  5277. if ($this->db->trans_status() === TRUE) {
  5278. $this->db->trans_commit();
  5279. } else {
  5280. $this->db->trans_rollback();
  5281. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5282. exit;
  5283. }
  5284. //}
  5285. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5286. $purchase = $this->purchase->read($post['purchase']);
  5287. 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));
  5288. exit; //特殊仓目前不需要仓库选项
  5289. }
  5290. }
  5291. if (isset($_SESSION['api'])) {
  5292. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5293. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5294. $this->data['wlshop'] = $wlshop;
  5295. $this->data['warehouse'] = $warehouse;
  5296. }
  5297. $whlabelwz = $this->whlabelwz->find_all();
  5298. $this->data['whlabelwz'] = $whlabelwz;
  5299. $this->_Template('whlabel_print', $this->data);
  5300. }
  5301. public function _usaprint($arg_array)
  5302. {
  5303. if (isset($_SESSION['api'])) {
  5304. $user = $this->user->get_api($_SESSION['api']);
  5305. $usp = $user;
  5306. $fgshop = "";
  5307. $sid = "";
  5308. $wid = "";
  5309. $wtype = "";
  5310. $usersp = explode('|', trim($user['shop'], '|'));
  5311. $userwh = explode('|', trim($user['warehouse'], '|'));
  5312. foreach ($usersp as $value) {
  5313. $fgshop .= " shop = " . $value . " or";
  5314. $sid .= " id = " . $value . " or";
  5315. }
  5316. foreach ($userwh as $value) {
  5317. $wid .= " id = " . $value . " or";
  5318. $wtype .= " type = " . $value . " or";
  5319. }
  5320. }
  5321. $post = $this->input->post(NULL, TRUE);
  5322. if (isset($post['tmsku'])) {
  5323. $tmsku = $this->input->post('tmsku', true);
  5324. if (is_numeric($tmsku)) {
  5325. $yyh = $this->whlabellabel->get_label($tmsku);
  5326. } else {
  5327. $yyh = $this->whlabellabel->get_sku($tmsku);
  5328. }
  5329. if ($yyh) {
  5330. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5331. exit;
  5332. } else {
  5333. echo json_encode(array('success' => false));
  5334. exit;
  5335. }
  5336. }
  5337. $classid = $this->classid->sku();
  5338. $pm = $classid;
  5339. $scsku = $classid;
  5340. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5341. if (isset($post['warehouse'])) {
  5342. if ($post['warehouse']) {
  5343. $list = array();
  5344. $num = "";
  5345. $title = "";
  5346. $features = "";
  5347. $order = 0;
  5348. $post['shop'] = '';
  5349. $brand = $this->input->post('brand', true);
  5350. if ($brand != '0,') {
  5351. $b = $this->brand->read(rtrim($brand, ','));
  5352. if ($b) {
  5353. $post['shop'] = str_replace('|', ',', $b['shop']);
  5354. }
  5355. }
  5356. $post['details'] = $this->input->post('details', true); //打印数量
  5357. $xbqnum = $this->input->post('xbqnum', true);
  5358. $post['purchase'] = $this->input->post('purchase', true);
  5359. $post['warehouse'] = $this->input->post('warehouse', true);
  5360. $post['purchase'] = $this->input->post('purchase', true);
  5361. $post['retreatwarehouse'] = $post['warehouse'];
  5362. $post['cpbz'] = $this->input->post('cpbz', true);
  5363. $post['state'] = 9;
  5364. $category = $this->input->post('category', true);
  5365. $list['category'] = $category;
  5366. $list['hairtype'] = $this->input->post('hairtype', true);
  5367. $list['grade'] = $this->input->post('grade', true);
  5368. $size = $this->input->post('size', true);
  5369. $list['size'] = rtrim($size, ',');
  5370. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5371. $list['extension'] = $this->input->post('extension', true);
  5372. if ($category == 1297) {
  5373. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5374. }
  5375. if ($category == 1702) {
  5376. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5377. $list['syother'] = $this->input->post('syother', true);
  5378. }
  5379. if ($category == 133) {
  5380. $list['fittype'] = $this->input->post('fittype', true);
  5381. $list['acother'] = $this->input->post('acother', true);
  5382. }
  5383. $list['color'] = $this->input->post('color', true);
  5384. $list['lowe'] = $this->input->post('lowe', true);
  5385. if ($category == 127) {
  5386. $list['type'] = $this->input->post('type', true);
  5387. $list['headroad'] = $this->input->post('headroad', true);
  5388. $list['density'] = $this->input->post('density', true);
  5389. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5390. $list['lacesize'] = $this->input->post('lacesize', true);
  5391. }
  5392. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5393. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5394. }
  5395. if ($category == 128) {
  5396. $list['lacetype'] = $this->input->post('lacetype', true);
  5397. $list['haircap'] = $this->input->post('haircap', true);
  5398. $list['density'] = $this->input->post('density', true);
  5399. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5400. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5401. $list['wigother'] = $this->input->post('wigother', true);
  5402. $list['wigother2'] = $this->input->post('wigother2', true);
  5403. }
  5404. if ($category == 129) {
  5405. $list['wide'] = $this->input->post('wide', true);
  5406. }
  5407. if ($category == 131) {
  5408. $list['gifttype'] = $this->input->post('gifttype', true);
  5409. $list['giftother'] = $this->input->post('giftother', true);
  5410. }
  5411. if ($category == 134) {
  5412. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5413. }
  5414. if ($category == 1297) {
  5415. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5416. $list['sywigother'] = $this->input->post('sywigother', true);
  5417. }
  5418. if ($category == 130 || $category == 133 || $category == 1702) {
  5419. $list['items'] = $this->input->post('items', true);
  5420. $list['weight'] = $this->input->post('weight', true);
  5421. }
  5422. if ($category == 1702) {
  5423. $list['syhairther'] = $this->input->post('syhairther', true);
  5424. }
  5425. foreach ($list as $k => $v) {
  5426. if ($v != 0) {
  5427. $num .= $v;
  5428. $features .= $v . '-';
  5429. $post[$k] = $v;
  5430. $typeclass = $this->typeclass->read($v);
  5431. if (isset($pm[$typeclass['classid']])) {
  5432. if (stripos($typeclass['zh'], '|') !== false) {
  5433. $exzh = explode('|', $typeclass['zh']);
  5434. $pm[$typeclass['classid']] = $exzh[0];
  5435. } else {
  5436. $pm[$typeclass['classid']] = $typeclass['zh'];
  5437. }
  5438. }
  5439. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5440. if ($k != 'size') {
  5441. $title .= $typeclass['title'] . " ";
  5442. }
  5443. }
  5444. }
  5445. $typeclass = $this->typeclass->read($list['size']);
  5446. $title .= $typeclass['title'];
  5447. $time = time();
  5448. $post['title'] = rtrim($title, ' ');
  5449. $post['number'] = $num;
  5450. $post['features'] = '-' . $features;
  5451. $fp = $this->whlabel->get_features($post['features']);
  5452. if (!$fp) {
  5453. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5454. exit;
  5455. }
  5456. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5457. $featurespp = explode('-', trim($featurespp, '-'));
  5458. if (isset($featurespp[5])) {
  5459. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5460. } else {
  5461. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5462. }
  5463. $post['enter'] = $time;
  5464. $post['time'] = $time; //操作时间
  5465. $scsku = implode("-", $scsku);
  5466. $zh = implode(" ", $pm);
  5467. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5468. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5469. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5470. $post['sku'] = $fp['sku'];
  5471. $post['label'] = $fp['sku'];
  5472. $cpid = $this->whlabellabel->find_count();
  5473. $post['cpid'] = $cpid + 1;
  5474. $cpid = $post['cpid'];
  5475. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5476. //if($whlabelbarcode)
  5477. //{
  5478. //$post['label'] = $whlabelbarcode['label'];
  5479. //if(!$this->whlabellabel->insert($post))
  5480. //{
  5481. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5482. //}
  5483. //}
  5484. //else
  5485. //{
  5486. $this->db->trans_begin();
  5487. $this->whlabellabel->insert($post);
  5488. //$this->whlabelbarcode->insert($post);
  5489. if ($this->db->trans_status() === TRUE) {
  5490. $this->db->trans_commit();
  5491. } else {
  5492. $this->db->trans_rollback();
  5493. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5494. exit;
  5495. }
  5496. //}
  5497. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5498. $purchase = $this->purchase->read($post['purchase']);
  5499. 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));
  5500. exit; //特殊仓目前不需要仓库选项
  5501. }
  5502. }
  5503. if (isset($_SESSION['api'])) {
  5504. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5505. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5506. $this->data['wlshop'] = $wlshop;
  5507. $this->data['warehouse'] = $warehouse;
  5508. }
  5509. $whlabelwz = $this->whlabelwz->find_all();
  5510. $this->data['whlabelwz'] = $whlabelwz;
  5511. $this->_Template('whlabel_usaprint', $this->data);
  5512. }
  5513. public function _printrk($arg_array)
  5514. {
  5515. $prc = array();
  5516. $purchase = $this->purchase->find_all();
  5517. foreach ($purchase as $k => $v) {
  5518. $prc[$v['id']] = $v['title'];
  5519. }
  5520. $post = $this->input->post(NULL, TRUE);
  5521. if (isset($post['page'])) {
  5522. $page = $this->input->post('page', true);
  5523. $perpage = $this->input->post('perpage', true);
  5524. $sku = $this->input->post('sku', true);
  5525. $bs = $this->input->post('bs', true);
  5526. $number = $this->input->post('number', true);
  5527. $warehouse = $this->input->post('warehouse', true);
  5528. $purchase = $this->input->post('purchase', true);
  5529. $orderinfo = $this->input->post('orderinfo', true);
  5530. $waybill = $this->input->post('waybill', true);
  5531. $category = $this->input->post('category', true);
  5532. $size = $this->input->post('size', true);
  5533. $grade = $this->input->post('grade', true);
  5534. $color = $this->input->post('color', true);
  5535. $lowe = $this->input->post('lowe', true);
  5536. $state = $this->input->post('state', true);
  5537. $label = $this->input->post('label', true);
  5538. $timetk = $this->input->post('ktime', true);
  5539. $timetj = $this->input->post('jtime', true);
  5540. $timetk = strtotime($timetk);
  5541. $timetj = strtotime($timetj);
  5542. $where = "1=1 ";
  5543. if ($timetk && $timetj) {
  5544. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5545. }
  5546. if ($sku) {
  5547. $where .= " and sku = '$sku'";
  5548. }
  5549. if ($bs != '') {
  5550. $where .= " and bs = '$bs'";
  5551. }
  5552. if ($number) {
  5553. $where .= " and number = '$number'";
  5554. }
  5555. if ($warehouse) {
  5556. $where .= " and warehouse = '$warehouse'";
  5557. }
  5558. if ($purchase) {
  5559. $where .= " and purchase = '$purchase'";
  5560. }
  5561. if ($orderinfo) {
  5562. $where .= " and orderinfo = '$orderinfo'";
  5563. }
  5564. if ($waybill) {
  5565. $where .= " and waybill = '$waybill'";
  5566. }
  5567. if ($category) {
  5568. $where .= " and features like '%-$category-%'";
  5569. }
  5570. if ($size) {
  5571. $where .= " and features like '%-$size-%'";
  5572. }
  5573. if ($grade) {
  5574. $where .= " and features like '%-$grade-%'";
  5575. }
  5576. if ($color) {
  5577. $where .= " and features like '%-$color-%'";
  5578. }
  5579. if ($lowe) {
  5580. $where .= " and features like '%-$lowe-%'";
  5581. }
  5582. if ($label) {
  5583. $where .= " and label = '$label'";
  5584. }
  5585. if ($state || $state == 0) {
  5586. $where .= " and state = '$state'";
  5587. }
  5588. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5589. //数据排序
  5590. $order_str = "enter desc";
  5591. if (empty($page)) {
  5592. $start = 0;
  5593. $perpage = 1;
  5594. } else {
  5595. $start = ($page - 1) * $perpage;
  5596. }
  5597. //取得信息列表
  5598. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5599. foreach ($info_list as $key => $value) {
  5600. $warehouse = $this->warehouse->read($value['warehouse']);
  5601. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5602. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5603. if ($value['state'] == 0) {
  5604. $info_list[$key]['state'] = "在库";
  5605. } else if ($value['state'] == 1) {
  5606. $info_list[$key]['state'] = "出库";
  5607. } else if ($value['state'] == 2) {
  5608. $info_list[$key]['state'] = "退库";
  5609. } else if ($value['state'] == 3) {
  5610. $info_list[$key]['state'] = "调拨中";
  5611. } else if ($value['state'] == 4) {
  5612. $info_list[$key]['state'] = "再加工";
  5613. } else if ($value['state'] == 5) {
  5614. $info_list[$key]['state'] = "维修中";
  5615. } else if ($value['state'] == 6) {
  5616. $info_list[$key]['state'] = "盘亏";
  5617. } else if ($value['state'] == 7) {
  5618. $info_list[$key]['state'] = "更换标签";
  5619. } else if ($value['state'] == 8) {
  5620. $info_list[$key]['state'] = "其它";
  5621. } else if ($value['state'] == 9) {
  5622. $info_list[$key]['state'] = "预设";
  5623. } else if ($value['state'] == 10) {
  5624. $info_list[$key]['state'] = "美店零售";
  5625. }
  5626. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5627. }
  5628. $total = $this->$ck->find_count($where);
  5629. $pagenum = ceil($total / $perpage);
  5630. $over = $total - ($start + $perpage);
  5631. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5632. echo json_encode($rows);
  5633. exit;
  5634. }
  5635. if (isset($post['tmsku'])) {
  5636. $time = time();
  5637. $tmsku = $this->input->post('tmsku', true);
  5638. //$post['shop'] = $this->input->post('shop',true);
  5639. $num = $this->input->post('num', true);
  5640. $rktype = $this->input->post('rktype', true);
  5641. if ($num > 200) {
  5642. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5643. exit;
  5644. }
  5645. if (!$rktype) {
  5646. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5647. }
  5648. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5649. /**
  5650. $wz = array();
  5651. foreach ($rk as $key=>$value)
  5652. {
  5653. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5654. }
  5655. if(count($wz) > 1)
  5656. {
  5657. $wz = array_values($wz);
  5658. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5659. }
  5660. **/
  5661. if (isset($rk[0]['purchase'])) {
  5662. $rk = $rk[0];
  5663. $j = 0;
  5664. $post['purchase'] = $rk['purchase'];
  5665. $post['warehouse'] = $rk['warehouse'];
  5666. $post['retreatwarehouse'] = $rk['warehouse'];
  5667. $post['sku'] = $rk['sku'];
  5668. $post['number'] = $rk['number'];
  5669. $post['features'] = $rk['features'];
  5670. $post['title'] = $rk['title'];
  5671. $post['enter'] = $time;
  5672. $post['time'] = $time;
  5673. $post['bs'] = 1;
  5674. $post['shop'] = $rk['shop'];
  5675. $post['details'] = $rk['details'];
  5676. $post['cpid'] = $rk['cpid'];
  5677. $post['cpbz'] = $rk['cpbz'];
  5678. //$post['rktype'] = $rktype;
  5679. $warehouse = $this->warehouse->read($rk['warehouse']);
  5680. if ($warehouse['bdck'] == '') {
  5681. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5682. exit;
  5683. } else {
  5684. $bdck = $warehouse['bdck'];
  5685. }
  5686. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5687. if (isset($pdwz['details'])) {
  5688. if ($pdwz['details'] != $post['details']) {
  5689. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5690. exit;
  5691. }
  5692. }
  5693. $post['featurespp'] = $rk['featurespp'];
  5694. if ($post['warehouse'] == '5') {
  5695. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5696. if ($yza) {
  5697. if ($post['features'] != $yza[0]['features']) {
  5698. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5699. exit;
  5700. }
  5701. }
  5702. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5703. if ($yzb) {
  5704. if ($post['sku'] != $yzb[0]['sku']) {
  5705. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5706. exit;
  5707. }
  5708. }
  5709. }
  5710. for ($i = 0; $i < $num; $i++) {
  5711. $post['label'] = time() . rand(100, 999) . $i;
  5712. if ($this->$bdck->insert($post)) {
  5713. $j++;
  5714. }
  5715. }
  5716. /**
  5717. if($post['warehouse'] != 12)
  5718. {
  5719. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5720. }
  5721. **/
  5722. if ($j == $num) {
  5723. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5724. exit;
  5725. } else {
  5726. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5727. exit;
  5728. }
  5729. } else {
  5730. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5731. exit;
  5732. }
  5733. }
  5734. $this->_Template('whlabel_printrk', $this->data);
  5735. }
  5736. public function _printxzrk($arg_array)
  5737. {
  5738. $post = $this->input->post(NULL, TRUE);
  5739. if (isset($post['wzid'])) {
  5740. $time = time();
  5741. $id = $this->input->post('wzid', true);
  5742. //$post['shop'] = $this->input->post('shop',true);
  5743. $num = 1;
  5744. $rk = $this->whlabellabel->read($id);
  5745. if (isset($rk['purchase'])) {
  5746. $x = 0;
  5747. $post['purchase'] = $rk['purchase'];
  5748. $post['warehouse'] = $rk['warehouse'];
  5749. $post['retreatwarehouse'] = $rk['warehouse'];
  5750. $post['sku'] = $rk['sku'];
  5751. $post['number'] = $rk['number'];
  5752. $post['features'] = $rk['features'];
  5753. $post['title'] = $rk['title'];
  5754. $post['enter'] = $time;
  5755. $post['time'] = $time;
  5756. $post['bs'] = 1;
  5757. $post['shop'] = $rk['shop'];
  5758. $post['details'] = $rk['details'];
  5759. $post['cpid'] = $rk['cpid'];
  5760. $post['cpbz'] = $rk['cpbz'];
  5761. $warehouse = $this->warehouse->read($rk['warehouse']);
  5762. if ($warehouse['bdck'] == '') {
  5763. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5764. exit;
  5765. } else {
  5766. $bdck = $warehouse['bdck'];
  5767. }
  5768. $post['featurespp'] = $rk['featurespp'];
  5769. $this->db->trans_begin();
  5770. for ($i = 0; $i < $num; $i++) {
  5771. $post['label'] = time() . rand(100, 999) . $i;
  5772. $this->$bdck->insert($post);
  5773. }
  5774. /**
  5775. if($post['warehouse'] != 12)
  5776. {
  5777. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5778. }
  5779. **/
  5780. if ($this->db->trans_status() === TRUE) {
  5781. $this->db->trans_commit();
  5782. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  5783. exit;
  5784. } else {
  5785. $this->db->trans_rollback();
  5786. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  5787. exit;
  5788. }
  5789. } else {
  5790. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5791. exit;
  5792. }
  5793. }
  5794. }
  5795. public function _printck($arg_array)
  5796. {
  5797. $prc = array();
  5798. $purchase = $this->purchase->find_all();
  5799. foreach ($purchase as $k => $v) {
  5800. $prc[$v['id']] = $v['title'];
  5801. }
  5802. $post = $this->input->post(NULL, TRUE);
  5803. if (isset($post['page'])) {
  5804. $page = $this->input->post('page', true);
  5805. $perpage = $this->input->post('perpage', true);
  5806. $sku = $this->input->post('sku', true);
  5807. $bs = $this->input->post('bs', true);
  5808. $number = $this->input->post('number', true);
  5809. $warehouse = $this->input->post('warehouse', true);
  5810. $purchase = $this->input->post('purchase', true);
  5811. $orderinfo = $this->input->post('orderinfo', true);
  5812. $waybill = $this->input->post('waybill', true);
  5813. $category = $this->input->post('category', true);
  5814. $size = $this->input->post('size', true);
  5815. $grade = $this->input->post('grade', true);
  5816. $color = $this->input->post('color', true);
  5817. $lowe = $this->input->post('lowe', true);
  5818. $state = $this->input->post('state', true);
  5819. $label = $this->input->post('label', true);
  5820. $timetk = $this->input->post('ktime', true);
  5821. $timetj = $this->input->post('jtime', true);
  5822. $timetk = strtotime($timetk);
  5823. $timetj = strtotime($timetj);
  5824. $where = "state=1 ";
  5825. if ($timetk && $timetj) {
  5826. $where .= " and outk > '$timetk' and outk < '$timetj'";
  5827. }
  5828. if ($sku) {
  5829. $where .= " and sku = '$sku'";
  5830. }
  5831. if ($bs != '') {
  5832. $where .= " and bs = '$bs'";
  5833. }
  5834. if ($number) {
  5835. $where .= " and number = '$number'";
  5836. }
  5837. if ($warehouse) {
  5838. $where .= " and warehouse = '$warehouse'";
  5839. }
  5840. if ($purchase) {
  5841. $where .= " and purchase = '$purchase'";
  5842. }
  5843. if ($orderinfo) {
  5844. $where .= " and orderinfo = '$orderinfo'";
  5845. }
  5846. if ($waybill) {
  5847. $where .= " and waybill = '$waybill'";
  5848. }
  5849. if ($category) {
  5850. $where .= " and features like '%-$category-%'";
  5851. }
  5852. if ($size) {
  5853. $where .= " and features like '%-$size-%'";
  5854. }
  5855. if ($grade) {
  5856. $where .= " and features like '%-$grade-%'";
  5857. }
  5858. if ($color) {
  5859. $where .= " and features like '%-$color-%'";
  5860. }
  5861. if ($lowe) {
  5862. $where .= " and features like '%-$lowe-%'";
  5863. }
  5864. if ($label) {
  5865. $where .= " and label = '$label'";
  5866. }
  5867. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5868. //数据排序
  5869. $order_str = "outk desc";
  5870. if (empty($page)) {
  5871. $start = 0;
  5872. $perpage = 1;
  5873. } else {
  5874. $start = ($page - 1) * $perpage;
  5875. }
  5876. //取得信息列表
  5877. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  5878. foreach ($info_list as $key => $value) {
  5879. $warehouse = $this->warehouse->read($value['warehouse']);
  5880. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5881. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5882. if ($value['state'] == 0) {
  5883. $info_list[$key]['state'] = "在库";
  5884. } else if ($value['state'] == 1) {
  5885. $info_list[$key]['state'] = "出库";
  5886. } else if ($value['state'] == 2) {
  5887. $info_list[$key]['state'] = "退库";
  5888. } else if ($value['state'] == 3) {
  5889. $info_list[$key]['state'] = "调拨中";
  5890. } else if ($value['state'] == 4) {
  5891. $info_list[$key]['state'] = "再加工";
  5892. } else if ($value['state'] == 5) {
  5893. $info_list[$key]['state'] = "维修中";
  5894. } else if ($value['state'] == 6) {
  5895. $info_list[$key]['state'] = "盘亏";
  5896. } else if ($value['state'] == 7) {
  5897. $info_list[$key]['state'] = "更换标签";
  5898. } else if ($value['state'] == 8) {
  5899. $info_list[$key]['state'] = "其它";
  5900. } else if ($value['state'] == 9) {
  5901. $info_list[$key]['state'] = "预设";
  5902. } else if ($value['state'] == 10) {
  5903. $info_list[$key]['state'] = "美店零售";
  5904. }
  5905. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  5906. }
  5907. $total = $this->$ck->find_count($where);
  5908. $pagenum = ceil($total / $perpage);
  5909. $over = $total - ($start + $perpage);
  5910. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5911. echo json_encode($rows);
  5912. exit;
  5913. }
  5914. if (isset($post['tmsku'])) {
  5915. $time = time();
  5916. $tmsku = $this->input->post('tmsku', true);
  5917. //$post['shop'] = $this->input->post('shop',true);
  5918. $num = $this->input->post('num', true);
  5919. $cktype = $this->input->post('cktype', true);
  5920. $label = $this->whlabellabel->get_label($tmsku);
  5921. if (!$cktype) {
  5922. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  5923. }
  5924. if (!isset($label['warehouse'])) {
  5925. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  5926. exit;
  5927. }
  5928. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  5929. if (stripos($label['features'], '-126-') !== false) {
  5930. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  5931. } else {
  5932. $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 = ''");
  5933. }
  5934. $j = 0;
  5935. if (count($ck) >= $num) {
  5936. for ($i = 0; $i < $num; $i++) {
  5937. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  5938. {
  5939. $j++;
  5940. }
  5941. }
  5942. if ($j == $num) {
  5943. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  5944. exit;
  5945. } else {
  5946. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5947. exit;
  5948. }
  5949. } else {
  5950. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  5951. exit;
  5952. }
  5953. }
  5954. $this->_Template('whlabel_printck', $this->data);
  5955. }
  5956. public function _printexcel()
  5957. {
  5958. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  5959. $config['upload_path'] = '.' . $dir;
  5960. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  5961. $config['allowed_types'] = 'xls|xlsx|csv';
  5962. $config['max_size'] = 10240;
  5963. $this->load->library('upload', $config);
  5964. $this->upload->initialize($config);
  5965. if ($this->upload->do_upload('userfile')) {
  5966. $full_path = $dir . $this->upload->data('file_name');
  5967. $fileName = '.' . $full_path;
  5968. if (!file_exists($fileName)) {
  5969. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  5970. exit;
  5971. } else {
  5972. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  5973. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  5974. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  5975. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  5976. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  5977. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  5978. ++$column; //如果列数大于26行
  5979. $list = array();
  5980. for ($i = 2; $i <= $row; $i++) // 行数循环
  5981. {
  5982. $data = array();
  5983. for ($c = 'A'; $c != $column; $c++) // 列数循环
  5984. {
  5985. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  5986. }
  5987. $list[] = $data;
  5988. }
  5989. }
  5990. $ed = array();
  5991. $i = 0;
  5992. $j = 0;
  5993. $dcdata = array();
  5994. $yc = '';
  5995. $cmf_arr = array_column($list, '1');
  5996. array_multisort($cmf_arr, SORT_ASC, $list);
  5997. foreach ($list as $key => $value) {
  5998. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  5999. if ($typeclass) {
  6000. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6001. } else {
  6002. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6003. $i++;
  6004. continue;
  6005. }
  6006. }
  6007. if ($i > 0) {
  6008. $yc = $i . '条异常';
  6009. }
  6010. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6011. exit;
  6012. }
  6013. }
  6014. public function _uck()
  6015. {
  6016. if (isset($_GET['excel'])) {
  6017. $tc = array();
  6018. $typeclass = $this->typeclass->find_all();
  6019. foreach ($typeclass as $v) {
  6020. $tc[$v['id']] = $v['zh'];
  6021. }
  6022. $data = array();
  6023. $t = array();
  6024. $rq = '';
  6025. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6026. $ts = $ts / (24 * 3600);
  6027. for ($i = 0; $i < $ts; $i++) {
  6028. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6029. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6030. }
  6031. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6032. foreach ($info_list as $k => $v) {
  6033. $features = explode('-', trim($v['features'], '-'));
  6034. if (!isset($features[3]) || !isset($features[4])) {
  6035. continue;
  6036. }
  6037. $data[$k][0] = $tc[$features[0]]; //类型
  6038. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6039. $data[$k][2] = $tc[$features[4]]; //曲度
  6040. $data[$k][3] = '';
  6041. if (isset($data[$k][1])) {
  6042. $data[$k][3] .= $data[$k][1];
  6043. }
  6044. if (isset($data[$k][2])) {
  6045. $data[$k][3] .= $data[$k][2];
  6046. }
  6047. if (isset($features[5])) {
  6048. $data[$k][3] .= $tc[$features[5]];
  6049. }
  6050. if (isset($features[2])) {
  6051. $data[$k][3] .= $tc[$features[2]];
  6052. }
  6053. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6054. $data[$k][4] = $v['sku'];
  6055. $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())) . '))'); //月初库存
  6056. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6057. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6058. $ztrq = '';
  6059. $ztsl = '';
  6060. if (count($zt) > 0) {
  6061. foreach ($zt as $vv) {
  6062. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6063. $ztsl .= $vv['num'] . '<br>';
  6064. }
  6065. }
  6066. $data[$k][] = trim($ztsl, '<br>');
  6067. $data[$k][] = trim($ztrq, '<br>');
  6068. $byck = 0;
  6069. foreach ($t as $vv) {
  6070. $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));
  6071. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6072. $byck += $sl;
  6073. }
  6074. $data[$k][] = ($byck > 0) ? $byck : '';
  6075. }
  6076. $title = "详情 " . date("Y-m-d", time());
  6077. $titlename = "<table border=1>
  6078. <tr align='center'>
  6079. <td>类别</td>
  6080. <td>颜色</td>
  6081. <td>曲度</td>
  6082. <td>名称</td>
  6083. <td>SKU</td>
  6084. <td>月初库存</td>
  6085. <td>剩余库存</td>
  6086. <td>在途数量</td>
  6087. <td>预达日期</td>" .
  6088. $rq
  6089. . "<td>本月出库</td></tr>
  6090. </table>";
  6091. $filename = $title . ".xls";
  6092. $tail = "";
  6093. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6094. }
  6095. }
  6096. public function _whlabelexcelzh()
  6097. {
  6098. if (isset($_GET['excel'])) {
  6099. $where = "sku != 'Preset'";
  6100. //数据排序
  6101. $order_str = "id desc";
  6102. if (empty($page)) {
  6103. $start = 0;
  6104. $perpage = 1;
  6105. } else {
  6106. $start = ($page - 1) * $perpage;
  6107. }
  6108. $category = $this->input->get('category', true);
  6109. $warehouse = $this->input->get('warehouse', true);
  6110. $excelid = $this->input->get('sid', true);
  6111. if ($category) {
  6112. $where .= " and features like '%-$category-%'";
  6113. }
  6114. if ($warehouse) {
  6115. $where .= " and warehouse = '$warehouse'";
  6116. }
  6117. $xzid = '';
  6118. if ($excelid) {
  6119. $excelid = explode(',', trim($excelid, ','));
  6120. foreach ($excelid as $key => $value) {
  6121. $xzid .= " id = " . $value . " or";
  6122. }
  6123. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6124. }
  6125. //取得信息列表
  6126. /**
  6127. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6128. $rows = array();$list = array();
  6129. foreach ($info_list as $key=>$value)
  6130. {
  6131. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6132. }
  6133. **/
  6134. $list = array();
  6135. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6136. foreach ($rows as $key => $value) {
  6137. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6138. $zh = '';
  6139. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6140. foreach ($zt as $v) {
  6141. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6142. }
  6143. $zt = array_sum(array_column($zt, 'num'));
  6144. $number = $value['number'];
  6145. $ftime = time() - 15 * 24 * 3600;
  6146. $warehouse = $this->warehouse->read($value['warehouse']);
  6147. $rows[$key]['warehouse'] = $warehouse['title'];
  6148. $rows[$key]['number'] = $c;
  6149. $rows[$key]['features'] = $zh;
  6150. $rows[$key]['hb'] = $c + $zt;
  6151. }
  6152. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6153. $titlename = "<table border=1>
  6154. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6155. <tr align='center'>
  6156. <td>仓库</td>
  6157. <td>SKU</td>
  6158. <td>产品</td>
  6159. <td>库存数量</td>
  6160. <td>在途数量及预达日期</td>
  6161. <td>在途+库存数量</td>
  6162. </tr>
  6163. </table>";
  6164. $filename = $title . ".xls";
  6165. $tail = "";
  6166. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6167. }
  6168. if (isset($_GET['excel'])) {
  6169. $warehouse = $this->input->get('warehouse', true);
  6170. $sku = $this->input->get('sku', true);
  6171. $cz = $this->input->get('cz', true);
  6172. $text = $this->input->post('text', true);
  6173. $xztime = $this->input->get('xztime', true);
  6174. $timetk = $this->input->get('timetk', true);
  6175. $timetj = $this->input->get('timetj', true);
  6176. $timetk = strtotime($timetk);
  6177. $timetj = strtotime($timetj);
  6178. $where = "time = '0' ";
  6179. if ($warehouse) {
  6180. $where .= " and warehouse = '$warehouse'";
  6181. }
  6182. if ($sku) {
  6183. $where .= " and sku = '$sku'";
  6184. }
  6185. if ($text) {
  6186. $where .= " and text like '%$text%'";
  6187. }
  6188. if ($cz != '') {
  6189. $where .= " and cz = '$cz'";
  6190. }
  6191. if ($timetk && $timetj) {
  6192. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6193. }
  6194. //数据排序
  6195. $order_str = $xztime . " desc";
  6196. //取得信息列表
  6197. $zh = array();
  6198. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6199. foreach ($info_list as $v) {
  6200. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6201. $warehouse = $this->warehouse->read($v['warehouse']);
  6202. $v['warehouse'] = $warehouse['title'];
  6203. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6204. $v['stime'] = date('Y-m-d', $v['stime']);
  6205. if (isset($zh[$v['features']])) {
  6206. $zh[$v['features']]['num'] += $v['num'];
  6207. } else {
  6208. $zh[$v['features']] = $v;
  6209. }
  6210. $zh[$v['features']]['features'] = $c;
  6211. }
  6212. $title = "在途数据" . date('Y-m-d', time());
  6213. $titlename = "<table border=1>
  6214. <tr align='center'>
  6215. <td>仓库</td>
  6216. <td>SKU</td>
  6217. <td>名称</td>
  6218. <td>在途数量</td>
  6219. <td>库存数量</td>
  6220. <td>添加在途日期</td>
  6221. <td>预达日期</td>
  6222. <td>备注</td>
  6223. </tr>
  6224. </table>";
  6225. $filename = $title . ".xls";
  6226. $tail = "";
  6227. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6228. }
  6229. }
  6230. public function _fc()
  6231. {
  6232. $vip = 0;
  6233. if (isset($_SESSION['api'])) {
  6234. $user = $this->user->get_api($_SESSION['api']);
  6235. if ($user['vip'] == 1) {
  6236. $vip = 1;
  6237. }
  6238. } else {
  6239. header('Location: /');
  6240. exit;
  6241. }
  6242. $post = $this->input->post(NULL, TRUE);
  6243. if (isset($post['page'])) {
  6244. $page = $this->input->post('page', true);
  6245. $perpage = $this->input->post('perpage', true);
  6246. $category = $this->input->post('category', true);
  6247. $size = $this->input->post('size', true);
  6248. $grade = $this->input->post('grade', true);
  6249. $color = $this->input->post('color', true);
  6250. $lowe = $this->input->post('lowe', true);
  6251. $sku = $this->input->post('sku');
  6252. $title = $this->input->post('title');
  6253. $warehouse = $this->input->post('warehouse', true);
  6254. $usa = $this->input->post('usa', true);
  6255. $purchase = $this->input->post('purchase', true);
  6256. $lacetype = $this->input->post('lacetype', true);
  6257. $haircap = $this->input->post('haircap', true);
  6258. $density = $this->input->post('density', true);
  6259. $details = $this->input->post('details', true);
  6260. $state = $this->input->post('state', true);
  6261. $ktime = $this->input->post('ktime', true);
  6262. $jtime = $this->input->post('jtime', true);
  6263. $ktime = strtotime($ktime);
  6264. $jtime = strtotime($jtime);
  6265. $where = "state = '11'";
  6266. $gj = "";
  6267. $ck = "";
  6268. if ($lacetype) {
  6269. $where .= " and features like '%-$lacetype-%'";
  6270. }
  6271. if ($category) {
  6272. $where .= " and features like '%-$category-%'";
  6273. }
  6274. if ($size) {
  6275. $where .= " and features like '%-$size-%'";
  6276. }
  6277. if ($grade) {
  6278. $where .= " and features like '%-$grade-%'";
  6279. }
  6280. if ($color) {
  6281. $where .= " and features like '%-$color-%'";
  6282. }
  6283. if ($lowe) {
  6284. $where .= " and features like '%-$lowe-%'";
  6285. }
  6286. if ($haircap) {
  6287. $where .= " and features like '%-$haircap-%'";
  6288. }
  6289. if ($density) {
  6290. $where .= " and features like '%-$density-%'";
  6291. }
  6292. if ($usa) {
  6293. if (!$warehouse) {
  6294. $where .= " and (warehouse = '5' or warehouse = '8')";
  6295. }
  6296. }
  6297. if ($warehouse) {
  6298. $where .= " and warehouse = '$warehouse'";
  6299. }
  6300. if ($details) {
  6301. $where .= " and details = '$details'";
  6302. }
  6303. if ($purchase) {
  6304. $where .= " and purchase = '$purchase'";
  6305. }
  6306. if ($state) {
  6307. $where .= " and state = '$state'";
  6308. }
  6309. if ($ktime && $jtime) {
  6310. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6311. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6312. }
  6313. //数据排序
  6314. $order_str = "id desc";
  6315. if (empty($page)) {
  6316. $start = 0;
  6317. $perpage = 1;
  6318. } else {
  6319. $start = ($page - 1) * $perpage;
  6320. }
  6321. if ($sku) {
  6322. $sku = trim($sku, ' ');
  6323. $sku = trim($sku, ' ');
  6324. $where .= " and sku like '%$sku%'";
  6325. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6326. } else if ($title) {
  6327. $title = trim($title, ' ');
  6328. $title = trim($title, ' ');
  6329. $where .= " and title like '%$title%'";
  6330. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6331. } else {
  6332. //$where .= " and time > '$ktime' and time < '$jtime'";
  6333. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6334. }
  6335. //取得信息列表
  6336. $rows = array();
  6337. $list = array();
  6338. foreach ($info_list as $key => $value) {
  6339. $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'] . '"');
  6340. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6341. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6342. $warehouse = $this->warehouse->read($value['warehouse']);
  6343. $info_list[$key]['warehouse'] = $warehouse['title'];
  6344. $info_list[$key]['number'] = $g;
  6345. $info_list[$key]['features'] = $x;
  6346. $info_list[$key]['x'] = $s;
  6347. }
  6348. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6349. $pagenum = ceil($total / $perpage);
  6350. $over = $total - ($start + $perpage);
  6351. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6352. echo json_encode($rows);
  6353. exit;
  6354. }
  6355. $this->data['vip'] = $vip;
  6356. $this->_Template('whlabel_fc', $this->data);
  6357. }
  6358. public function _fcmb()
  6359. {
  6360. $where = "sku != 'Preset'";
  6361. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6362. foreach ($rows as $k => $v) {
  6363. $warehouse = $this->warehouse->read($v['warehouse']);
  6364. $rows[$k]['warehouse'] = $warehouse['title'];
  6365. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6366. $rows[$k]['t'] = '';
  6367. $rows[$k]['n'] = '';
  6368. }
  6369. $title = "封货产品数据导入模板";
  6370. $titlename = "<table border=1>
  6371. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6372. <tr align='center'>
  6373. <td>仓库</td>
  6374. <td>SKU</td>
  6375. <td>产品</td>
  6376. <td>封存产品总数量</td>
  6377. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6378. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6379. </tr>
  6380. </table>";
  6381. $filename = $title . ".xls";
  6382. $tail = "";
  6383. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6384. }
  6385. public function _fcexcel()
  6386. {
  6387. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6388. $config['upload_path'] = '.' . $dir;
  6389. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6390. $config['allowed_types'] = 'xls|xlsx|csv';
  6391. $config['max_size'] = 10240;
  6392. $this->load->library('upload', $config);
  6393. $this->upload->initialize($config);
  6394. if ($this->upload->do_upload('userfile')) {
  6395. $full_path = $dir . $this->upload->data('file_name');
  6396. $fileName = '.' . $full_path;
  6397. if (!file_exists($fileName)) {
  6398. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6399. exit;
  6400. } else {
  6401. libxml_use_internal_errors(true);
  6402. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6403. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6404. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6405. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6406. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6407. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6408. ++$column; //如果列数大于26行
  6409. $list = array();
  6410. for ($i = 2; $i <= $row; $i++) // 行数循环
  6411. {
  6412. $data = array();
  6413. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6414. {
  6415. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6416. }
  6417. $list[] = $data;
  6418. }
  6419. }
  6420. $i = 0;
  6421. $j = 0;
  6422. $ed = array();
  6423. foreach ($list as $key => $value) {
  6424. $time = time();
  6425. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6426. continue;
  6427. }
  6428. $warehouse = $this->warehouse->get_title($value['0']);
  6429. $sku = $value['1'];
  6430. $type = $value['4']; //调整方式0扣减1删除
  6431. $num = $value['5']; //调整数量
  6432. //$text = $value['4'];//扣减说明
  6433. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6434. if (!$d) //如果没有这个SKU
  6435. {
  6436. $ed[] = array($sku . '-库存中不存在此SKU');
  6437. $j++;
  6438. continue;
  6439. }
  6440. if (!isset($warehouse['id'])) {
  6441. $ed[] = array($sku . '-仓库名错误!');
  6442. $j++;
  6443. continue;
  6444. }
  6445. if ($type == 1 || $type == 2) //扣减库存
  6446. {
  6447. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6448. if (count($data) < abs($num)) {
  6449. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6450. $j++;
  6451. continue;
  6452. }
  6453. if ($type == 1) //转入库存
  6454. {
  6455. for ($i = 0; $i < abs($num); $i++) {
  6456. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6457. }
  6458. } else if ($type == 2) //删除
  6459. {
  6460. for ($i = 0; $i < abs($num); $i++) {
  6461. $this->whlabel->remove($data[$i]['id']);
  6462. }
  6463. }
  6464. } else if ($type == 0) //增加库存
  6465. {
  6466. $post['sku'] = $d['sku'];
  6467. $post['shop'] = '';
  6468. $post['warehouse'] = $warehouse['id'];
  6469. $post['purchase'] = $d['purchase'];
  6470. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6471. $post['state'] = 11;
  6472. $post['title'] = $d['title'];
  6473. $post['number'] = $d['number'];
  6474. $post['features'] = $d['features'];
  6475. $post['enter'] = $time;
  6476. $post['time'] = $time; //操作时间
  6477. for ($i = 0; $i < $num; $i++) {
  6478. $post['label'] = time() . rand(100, 999) . $i;
  6479. $this->whlabel->insert($post);
  6480. }
  6481. }
  6482. sleep(1); //防止入库时间一样,需要延迟1秒
  6483. }
  6484. if ($j > 0) {
  6485. $tt = date('Ymd', time());
  6486. $title = '库存导入错误信息-' . $tt;
  6487. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6488. $tail = "\n";
  6489. $filename = $title . ".xls";
  6490. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6491. $dir = '/data/excel/' . $time . '/';
  6492. $file_name = 'error_' . $time . rand(1000, 9999);
  6493. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6494. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6495. fwrite($myfile, $ecl);
  6496. fclose($myfile);
  6497. $error = $dir . $file_name . '.xls';
  6498. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6499. exit;
  6500. } else {
  6501. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6502. exit;
  6503. }
  6504. }
  6505. }
  6506. public function _fcjxc($arg_array)
  6507. {
  6508. if (isset($_GET['excel'])) {
  6509. $category = $this->input->get('category', true);
  6510. $size = $this->input->get('size', true);
  6511. $grade = $this->input->get('grade', true);
  6512. $color = $this->input->get('color', true);
  6513. $lowe = $this->input->get('lowe', true);
  6514. $sku = $this->input->get('sku');
  6515. $title = $this->input->get('title');
  6516. $warehouse = $arg_array[0];
  6517. $usa = $this->input->get('usa', true);
  6518. $purchase = $this->input->get('purchase', true);
  6519. $lacetype = $this->input->get('lacetype', true);
  6520. $haircap = $this->input->get('haircap', true);
  6521. $density = $this->input->get('density', true);
  6522. $title = $this->input->get('title', true);
  6523. $state = $this->input->get('state', true);
  6524. $ktime = $this->input->get('ktime', true);
  6525. $jtime = $this->input->get('jtime', true);
  6526. $where = "state=11";
  6527. $gj = "";
  6528. $ck = "";
  6529. if ($lacetype) {
  6530. $where .= " and features like '%-$lacetype-%'";
  6531. }
  6532. if ($category) {
  6533. $where .= " and features like '%-$category-%'";
  6534. }
  6535. if ($size) {
  6536. $where .= " and features like '%-$size-%'";
  6537. }
  6538. if ($grade) {
  6539. $where .= " and features like '%-$grade-%'";
  6540. }
  6541. if ($color) {
  6542. $where .= " and features like '%-$color-%'";
  6543. }
  6544. if ($lowe) {
  6545. $where .= " and features like '%-$lowe-%'";
  6546. }
  6547. if ($haircap) {
  6548. $where .= " and features like '%-$haircap-%'";
  6549. }
  6550. if ($density) {
  6551. $where .= " and features like '%-$density-%'";
  6552. }
  6553. if ($usa) {
  6554. if (!$warehouse) {
  6555. $where .= " and (warehouse = '5' or warehouse = '8')";
  6556. }
  6557. }
  6558. if ($warehouse) {
  6559. $where .= " and warehouse = '$warehouse'";
  6560. }
  6561. if ($purchase) {
  6562. $where .= " and purchase = '$purchase'";
  6563. }
  6564. if ($state) {
  6565. $where .= " and state = '$state'";
  6566. }
  6567. $order_str = "id desc";
  6568. if ($sku) {
  6569. $sku = trim($sku, ' ');
  6570. $sku = trim($sku, ' ');
  6571. $where .= " and sku like '%$sku%'";
  6572. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6573. } else if ($title) {
  6574. $title = trim($title, ' ');
  6575. $title = trim($title, ' ');
  6576. $where .= " and title like '%$title%'";
  6577. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6578. } else {
  6579. //$where .= " and time > '$ktime' and time < '$jtime'";
  6580. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6581. }
  6582. //取得信息列表
  6583. $rows = array();
  6584. $list = array();
  6585. foreach ($info_list as $key => $value) {
  6586. $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'] . '"');
  6587. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6588. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6589. $rows[$key] = $value;
  6590. $warehouse = $this->warehouse->read($value['warehouse']);
  6591. $rows[$key]['warehouse'] = $warehouse['title'];
  6592. $rows[$key]['features'] = $g;
  6593. $rows[$key]['a'] = $x;
  6594. $rows[$key]['b'] = $s;
  6595. }
  6596. $title = "总统计表";
  6597. $titlename = "<table border=1>
  6598. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6599. <tr align='center'>
  6600. <td>仓库</td>
  6601. <td>SKU</td>
  6602. <td>产品名称</td>
  6603. <td>录入总量</td>
  6604. <td>取出总量</td>
  6605. <td>剩余总量</td>
  6606. </tr>
  6607. </table>";
  6608. $filename = $title . ".xls";
  6609. $tail = "";
  6610. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6611. }
  6612. $vip = 0;
  6613. if (isset($_SESSION['api'])) {
  6614. $user = $this->user->get_api($_SESSION['api']);
  6615. if ($user['vip'] == 1) {
  6616. $vip = 1;
  6617. }
  6618. } else {
  6619. header('Location: /');
  6620. exit;
  6621. }
  6622. $post = $this->input->post(NULL, TRUE);
  6623. if (isset($post['page'])) {
  6624. $page = $this->input->post('page', true);
  6625. $perpage = $this->input->post('perpage', true);
  6626. $category = $this->input->post('category', true);
  6627. $size = $this->input->post('size', true);
  6628. $grade = $this->input->post('grade', true);
  6629. $color = $this->input->post('color', true);
  6630. $lowe = $this->input->post('lowe', true);
  6631. $sku = $this->input->post('sku');
  6632. $title = $this->input->post('title');
  6633. $warehouse = $arg_array[0];
  6634. $usa = $this->input->post('usa', true);
  6635. $purchase = $this->input->post('purchase', true);
  6636. $lacetype = $this->input->post('lacetype', true);
  6637. $haircap = $this->input->post('haircap', true);
  6638. $density = $this->input->post('density', true);
  6639. $title = $this->input->post('title', true);
  6640. $state = $this->input->post('state', true);
  6641. $ktime = $this->input->post('ktime', true);
  6642. $jtime = $this->input->post('jtime', true);
  6643. $ktime = strtotime($ktime);
  6644. $jtime = strtotime($jtime);
  6645. $where = "state=11";
  6646. $gj = "";
  6647. $ck = "";
  6648. if ($lacetype) {
  6649. $where .= " and features like '%-$lacetype-%'";
  6650. }
  6651. if ($category) {
  6652. $where .= " and features like '%-$category-%'";
  6653. }
  6654. if ($size) {
  6655. $where .= " and features like '%-$size-%'";
  6656. }
  6657. if ($grade) {
  6658. $where .= " and features like '%-$grade-%'";
  6659. }
  6660. if ($color) {
  6661. $where .= " and features like '%-$color-%'";
  6662. }
  6663. if ($lowe) {
  6664. $where .= " and features like '%-$lowe-%'";
  6665. }
  6666. if ($haircap) {
  6667. $where .= " and features like '%-$haircap-%'";
  6668. }
  6669. if ($density) {
  6670. $where .= " and features like '%-$density-%'";
  6671. }
  6672. if ($usa) {
  6673. if (!$warehouse) {
  6674. $where .= " and (warehouse = '5' or warehouse = '8')";
  6675. }
  6676. }
  6677. if ($warehouse) {
  6678. $where .= " and warehouse = '$warehouse'";
  6679. }
  6680. if ($purchase) {
  6681. $where .= " and purchase = '$purchase'";
  6682. }
  6683. if ($state) {
  6684. $where .= " and state = '$state'";
  6685. }
  6686. if ($ktime && $jtime) {
  6687. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6688. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6689. }
  6690. //数据排序
  6691. $order_str = "id desc";
  6692. $xs = 0;
  6693. $rows = array();
  6694. $list = array();
  6695. if (empty($page)) {
  6696. $start = 0;
  6697. $perpage = 1;
  6698. } else {
  6699. $start = ($page - 1) * $perpage;
  6700. }
  6701. if ($sku || $title) {
  6702. if ($title) {
  6703. $title = trim($title, ' ');
  6704. $title = trim($title, ' ');
  6705. $where .= " and title like '%$title%'";
  6706. } else {
  6707. $sku = trim($sku, ' ');
  6708. $sku = trim($sku, ' ');
  6709. $where .= " and sku like '%$sku%'";
  6710. }
  6711. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6712. foreach ($info_list as $key => $value) {
  6713. $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'] . '"');
  6714. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6715. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6716. $rows[$key] = $value;
  6717. $warehouse = $this->warehouse->read($value['warehouse']);
  6718. $rows[$key]['warehouse'] = $warehouse['title'];
  6719. $rows[$key]['features'] = $g;
  6720. $rows[$key]['a'] = $x;
  6721. $rows[$key]['b'] = $s;
  6722. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6723. $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天销量
  6724. $yj = $c / ($xl / 30);
  6725. if ($yj < 7) {
  6726. $rows[$key]['y'] = round($yj) . '天销量';
  6727. } else {
  6728. $rows[$key]['y'] = '正常';
  6729. }
  6730. }
  6731. } else {
  6732. //$where .= " and time > '$ktime' and time < '$jtime'";
  6733. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6734. foreach ($info_list as $key => $value) {
  6735. $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'] . '"');
  6736. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6737. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6738. $zs[$key] = $value;
  6739. $warehouse = $this->warehouse->read($value['warehouse']);
  6740. $zs[$key]['warehouse'] = $warehouse['title'];
  6741. $zs[$key]['features'] = $g;
  6742. $zs[$key]['a'] = $x;
  6743. $zs[$key]['b'] = $s;
  6744. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6745. $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天销量
  6746. $yj = $c / ($xl / 30);
  6747. if ($yj < 7) {
  6748. $zs[$key]['y'] = round($yj) . '天销量';
  6749. $rows[$key] = $zs[$key];
  6750. }
  6751. }
  6752. }
  6753. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6754. $pagenum = ceil($total / $perpage);
  6755. $over = $total - ($start + $perpage);
  6756. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6757. echo json_encode($rows);
  6758. exit;
  6759. }
  6760. $this->data['arg_array'] = $arg_array[0];
  6761. $this->_Template('whlabel_fcjxc', $this->data);
  6762. }
  6763. public function _0kcdel()
  6764. {
  6765. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6766. $config['upload_path'] = '.' . $dir;
  6767. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6768. $config['allowed_types'] = 'xls|xlsx|csv';
  6769. $config['max_size'] = 10240;
  6770. $this->load->library('upload', $config);
  6771. $this->upload->initialize($config);
  6772. if ($this->upload->do_upload('userfile')) {
  6773. $full_path = $dir . $this->upload->data('file_name');
  6774. $fileName = '.' . $full_path;
  6775. if (!file_exists($fileName)) {
  6776. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6777. exit;
  6778. } else {
  6779. require_once "./data/excel/PHPExcel/IOFactory.php";
  6780. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6781. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6782. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6783. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6784. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6785. ++$column; //如果列数大于26行
  6786. $list = array();
  6787. for ($i = 2; $i <= $row; $i++) // 行数循环
  6788. {
  6789. $data = array();
  6790. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6791. {
  6792. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6793. }
  6794. $list[] = $data;
  6795. }
  6796. }
  6797. $i = 0;
  6798. $j = 0;
  6799. $ed = array();
  6800. foreach ($list as $key => $value) {
  6801. $time = time();
  6802. if ($value['0'] == "" || $value['1'] == "") {
  6803. continue;
  6804. }
  6805. $warehouse = $this->warehouse->get_title($value['0']);
  6806. $sku = $value['1'];
  6807. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6808. if (!$d) //如果没有这个SKU
  6809. {
  6810. $ed[] = array($sku . '-库存中不存在此SKU');
  6811. $j++;
  6812. continue;
  6813. }
  6814. if (!isset($warehouse['id'])) {
  6815. $ed[] = array($sku . '-仓库名错误!');
  6816. $j++;
  6817. continue;
  6818. }
  6819. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  6820. if ($z < 1) {
  6821. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  6822. foreach ($z as $v) {
  6823. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  6824. if (count($zt) > 0) {
  6825. $ed[] = array($sku . '-有在途库存无法删除!');
  6826. $j++;
  6827. continue;
  6828. }
  6829. $this->whlabel->remove($v['id']);
  6830. }
  6831. } else {
  6832. $ed[] = array($sku . '-非0库存!');
  6833. $j++;
  6834. continue;
  6835. }
  6836. }
  6837. if ($j > 0) {
  6838. $tt = date('Ymd', time());
  6839. $title = '删除0库存错误信息-' . $tt;
  6840. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6841. $tail = "\n";
  6842. $filename = $title . ".xls";
  6843. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6844. $dir = '/data/excel/' . $time . '/';
  6845. $file_name = 'error_' . $time . rand(1000, 9999);
  6846. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6847. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6848. fwrite($myfile, $ecl);
  6849. fclose($myfile);
  6850. $error = $dir . $file_name . '.xls';
  6851. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6852. exit;
  6853. } else {
  6854. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6855. exit;
  6856. }
  6857. }
  6858. }
  6859. public function _gbhtype()
  6860. {
  6861. $post = $this->input->post(NULL, TRUE);
  6862. if (isset($post['s'])) {
  6863. $n = $this->input->post('n');
  6864. $d = $this->input->post('s');
  6865. if (!$d) {
  6866. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  6867. exit;
  6868. }
  6869. $d = explode(',', trim($d, ','));
  6870. $t = $this->whlabel_type->read($n);
  6871. //循环删除记录
  6872. foreach ($d as $v) {
  6873. $u = $this->whlabel->read($v);
  6874. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  6875. foreach ($data as $val) {
  6876. $this->whlabel->save(array('type' => $n), $val['id']);
  6877. }
  6878. }
  6879. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  6880. }
  6881. }
  6882. //出库、退库导出
  6883. public function _dccrtype()
  6884. {
  6885. $classid = $this->classid->sku();
  6886. $pm = $classid;
  6887. $typeclass = array();
  6888. $tc = $this->typeclass->find_all();
  6889. foreach ($tc as $v) {
  6890. $typeclass[$v['id']] = $v;
  6891. }
  6892. $prc = array();
  6893. $purchase = $this->purchase->find_all();
  6894. foreach ($purchase as $k => $v) {
  6895. $prc[$v['id']] = $v['title'];
  6896. }
  6897. if (isset($_GET['sid'])) {
  6898. $wh = array();
  6899. $w = $this->warehouse->find_all('1=1', 'id,title');
  6900. foreach ($w as $v) {
  6901. $wh[$v['id']] = $v['title'];
  6902. }
  6903. $type = $this->input->get('excel', true);
  6904. $category = $this->input->get('category', true);
  6905. $size = $this->input->get('size', true);
  6906. $grade = $this->input->get('grade', true);
  6907. $color = $this->input->get('color', true);
  6908. $lowe = $this->input->get('lowe', true);
  6909. $sku = $this->input->get('sku', true);
  6910. $warehouse = $this->input->get('warehouse', true);
  6911. $lacetype = $this->input->get('lacetype', true);
  6912. $lacecolor = $this->input->get('lacecolor', true);
  6913. $density = $this->input->get('density', true);
  6914. $haircap = $this->input->get('haircap', true);
  6915. $purchase = $this->input->get('purchase', true);
  6916. $title = $this->input->get('title', true);
  6917. $state = $this->input->get('state', true);
  6918. $sid = $this->input->get('sid', true);
  6919. $ktime = $this->input->get('ktime', true);
  6920. $jtime = $this->input->get('jtime', true);
  6921. $ktime = strtotime($ktime);
  6922. $jtime = strtotime($jtime);
  6923. $where = "1=1";
  6924. $gj = "";
  6925. $ck = "";
  6926. if ($category) {
  6927. $where .= " and features like '%-$category-%'";
  6928. }
  6929. if ($size) {
  6930. $where .= " and features like '%-$size-%'";
  6931. }
  6932. if ($grade) {
  6933. $where .= " and features like '%-$grade-%'";
  6934. }
  6935. if ($color) {
  6936. $where .= " and features like '%-$color-%'";
  6937. }
  6938. if ($lowe) {
  6939. $where .= " and features like '%-$lowe-%'";
  6940. }
  6941. if ($warehouse) {
  6942. $where .= " and warehouse = '$warehouse'";
  6943. }
  6944. if ($purchase) {
  6945. $where .= " and purchase = '$purchase'";
  6946. }
  6947. if ($state) {
  6948. $where .= " and state = '$state'";
  6949. }
  6950. if ($lacetype) {
  6951. $where .= " and features like '%-$lacetype-%'";
  6952. }
  6953. if ($lacecolor) {
  6954. $where .= " and features like '%-$lacecolor-%'";
  6955. }
  6956. if ($density) {
  6957. $where .= " and features like '%-$density-%'";
  6958. }
  6959. if ($haircap) {
  6960. $where .= " and features like '%-$haircap-%'";
  6961. }
  6962. if ($title) {
  6963. $title = trim($title, ' ');
  6964. $title = trim($title, ' ');
  6965. $where .= " and title like '%$title%'";
  6966. }
  6967. if ($sku) {
  6968. $sku = trim($sku, ' ');
  6969. $sku = trim($sku, ' ');
  6970. $where .= " and sku like '%$sku%'";
  6971. }
  6972. if ($ktime && $jtime) {
  6973. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  6974. }
  6975. $sidwhere = '';
  6976. if ($sid) {
  6977. $sd = "";
  6978. $s = explode(',', trim($sid, ','));
  6979. foreach ($s as $value) {
  6980. $sd .= " id = " . $value . " or";
  6981. }
  6982. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  6983. }
  6984. //数据排序
  6985. $order_str = "time desc";
  6986. if (empty($page)) {
  6987. $start = 0;
  6988. $perpage = 1;
  6989. } else {
  6990. $start = ($page - 1) * $perpage;
  6991. }
  6992. $wh = array();
  6993. $w = $this->warehouse->find_all('1=1', 'id,title');
  6994. foreach ($w as $v) {
  6995. $wh[$v['id']] = $v['title'];
  6996. }
  6997. $wt = array();
  6998. $whlabel_type = $this->whlabel_type->find_all();
  6999. foreach ($whlabel_type as $v) {
  7000. $wt[$v['id']] = $v['title'];
  7001. }
  7002. $classid = $this->classid->sku();
  7003. $list = array();
  7004. $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');
  7005. foreach ($rows_r as $key => $value) {
  7006. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7007. $pm = $classid;
  7008. $jm = $classid;
  7009. $rows_r[$key]['enter'] = '入库';
  7010. $rows_r[$key]['time'] = $value['enter'];
  7011. if ($value['rktype'] == 1) {
  7012. $rows_r[$key]['rktype'] = '采购入库';
  7013. } else if ($value['rktype'] == 2) {
  7014. $rows_r[$key]['rktype'] = '盘盈调整';
  7015. } else if ($value['rktype'] == 3) {
  7016. $rows_r[$key]['rktype'] = '其他调整入库';
  7017. } else if ($value['rktype'] == 4) {
  7018. $rows_r[$key]['rktype'] = '其他调整入库';
  7019. } else if ($value['rktype'] == 5) {
  7020. $rows_r[$key]['rktype'] = '退库入库';
  7021. } else if ($value['rktype'] == 6) {
  7022. $rows_r[$key]['rktype'] = '退货可用入库';
  7023. } else if ($value['rktype'] == 7) {
  7024. $rows_r[$key]['rktype'] = '形态转换入库';
  7025. } else {
  7026. $rows_r[$key]['rktype'] = '';
  7027. }
  7028. $features = explode('-', trim($value['features'], '-'));
  7029. foreach ($features as $v) {
  7030. if (isset($typeclass[$v])) {
  7031. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7032. $pm[$typeclass[$v]['classid']] = $zh[0];
  7033. }
  7034. if (isset($typeclass[$v])) {
  7035. if (isset($jm[$typeclass[$v]['classid']])) {
  7036. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7037. }
  7038. }
  7039. }
  7040. $zh = implode(" ", $pm);
  7041. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7042. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7043. $rows_r[$key]['zh'] = $zh;
  7044. $jm = array_filter($jm);
  7045. $rows_r[$key]['features'] = implode("-", $jm);
  7046. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7047. }
  7048. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7049. foreach ($rows_c as $key => $value) {
  7050. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7051. $pm = $classid;
  7052. $jm = $classid;
  7053. $rows_c[$key]['time'] = $value['outk'];
  7054. $rows_c[$key]['outk'] = '出库';
  7055. if ($value['cktype'] == 1) {
  7056. $rows_c[$key]['cktype'] = '销售出库';
  7057. } else if ($value['cktype'] == 2) {
  7058. $rows_c[$key]['cktype'] = '销售美国出库';
  7059. } else if ($value['cktype'] == 3) {
  7060. $rows_c[$key]['cktype'] = '盘亏调整';
  7061. } else if ($value['cktype'] == 4) {
  7062. $rows_c[$key]['cktype'] = '其他调整出库';
  7063. } else if ($value['cktype'] == 5) {
  7064. $rows_c[$key]['cktype'] = '形态转换出库';
  7065. } else {
  7066. $rows_c[$key]['cktype'] = '';
  7067. }
  7068. $features = explode('-', trim($value['features'], '-'));
  7069. foreach ($features as $v) {
  7070. if (isset($typeclass[$v])) {
  7071. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7072. $pm[$typeclass[$v]['classid']] = $zh[0];
  7073. }
  7074. if (isset($typeclass[$v])) {
  7075. if (isset($jm[$typeclass[$v]['classid']])) {
  7076. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7077. }
  7078. }
  7079. }
  7080. $zh = implode(" ", $pm);
  7081. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7082. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7083. $rows_c[$key]['zh'] = $zh;
  7084. $jm = array_filter($jm);
  7085. $rows_c[$key]['features'] = implode("-", $jm);
  7086. $rows_c[$key]['number'] = 1;
  7087. }
  7088. $merged = $rows_r;
  7089. foreach ($rows_c as $key => $value) {
  7090. if (isset($merged[$key])) {
  7091. $merged[] = $value;
  7092. } else {
  7093. $merged[$key] = $value;
  7094. }
  7095. }
  7096. usort($merged, function ($a, $b) {
  7097. return $a['time'] - $b['time'];
  7098. });
  7099. foreach ($merged as $key => $value) {
  7100. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7101. }
  7102. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7103. $titlename = "<table border=1>
  7104. <tr align='center'>
  7105. <td>仓库</td>
  7106. <td>SKU</td>
  7107. <td>商品名称</td>
  7108. <td>仓库品名</td>
  7109. <td>料号</td>
  7110. <td>时间</td>
  7111. <td>操作</td>
  7112. <td>类型</td>
  7113. <td>数量</td>
  7114. <td>备注</td>
  7115. </tr>
  7116. </table>";
  7117. $filename = $title . ".xlsx";
  7118. $tail = "";
  7119. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7120. }
  7121. }
  7122. }