Whlabel.php 331 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. }else if ($arg == 'typev1') //进销存浏览
  62. {
  63. $this->_typev1();
  64. } else if ($arg == 'typedy') //进销存浏览店员页面
  65. {
  66. $this->_typedy($arg_array);
  67. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  68. {
  69. $this->_typedy_ck($arg_array);
  70. } else if ($arg == 'typeck') {
  71. $this->_typeck($arg_array);
  72. } else if ($arg == 'whlabeckdc') {
  73. $this->_whlabeckdc($arg_array);
  74. } else if ($arg == 'usatype') //美仓进销存浏览
  75. {
  76. $this->_usatype();
  77. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  78. {
  79. $this->_usatypeapp();
  80. } else if ($arg == 'enteradd') //入库操作
  81. {
  82. $this->_enteradd();
  83. } else if ($arg == 'enteredit') //修改
  84. {
  85. $this->_enteredit($arg_array);
  86. } else if ($arg == 'enter') //入库浏览
  87. {
  88. $this->_enter();
  89. } else if ($arg == 'out') //出库浏览
  90. {
  91. $this->_out();
  92. } else if ($arg == 'label') //出库标签浏览
  93. {
  94. $this->_label();
  95. } else if ($arg == 'outorder') //独立站出库订单
  96. {
  97. $this->_outorder();
  98. } else if ($arg == 'soutorder') //速卖通出库订单
  99. {
  100. $this->_soutorder();
  101. } else if ($arg == 'toutorder') //TT出库订单
  102. {
  103. $this->_toutorder();
  104. }else if ($arg == 'aoutorder') //amz出库订单
  105. {
  106. $this->_aoutorder();
  107. } else if ($arg == 'retreat') //退库订单
  108. {
  109. $this->_retreat();
  110. } else if ($arg == 'retreatlk') //退库订单
  111. {
  112. $this->_retreatlk();
  113. } else if ($arg == 'change') //更换标签
  114. {
  115. $this->_change();
  116. } else if ($arg == 'del') //删除
  117. {
  118. $this->_del();
  119. } else if ($arg == 'exceljxc') //进销存信息导出
  120. {
  121. $this->_exceljxc();
  122. } else if ($arg == 'excelr') //入库信息导出
  123. {
  124. $this->_excelr();
  125. } else if ($arg == 'excelct') //出库、退库信息导出
  126. {
  127. $this->_excelct();
  128. } else if ($arg == 'dccrtype') //根据出入库类型导出
  129. {
  130. $this->_dccrtype();
  131. } else if ($arg == 'excelcr') //出库、退库信息导出
  132. {
  133. $this->_excelcr();
  134. } else if ($arg == 'kcyz') //库存验证
  135. {
  136. $this->_kcyz();
  137. } else if ($arg == 'kj') //库存扣减
  138. {
  139. $this->_kj($arg_array);
  140. } else if ($arg == 'presetout') //预设库存导入
  141. {
  142. $this->_presetout($arg_array);
  143. } else if ($arg == 'presetedit') //预设库存导入
  144. {
  145. $this->_presetedit($arg_array);
  146. }else if ($arg == 'presetedittwo') //预设库存导入
  147. {
  148. $this->_presetedittwo($arg_array);
  149. } else if ($arg == 'summary') //汇总导出
  150. {
  151. $this->_summary($arg_array);
  152. } else if ($arg == 'manifest') //usps发货清单
  153. {
  154. $this->_manifest();
  155. } else if ($arg == 'abnormal') //占单异常
  156. {
  157. $this->_abnormal();
  158. } else if ($arg == 'error') //0库存SKU
  159. {
  160. $this->_error();
  161. } else if ($arg == 'errorexcel') //0库存SKU导出
  162. {
  163. $this->_errorexcel();
  164. } else if ($arg == 'db') {
  165. $this->_db();
  166. } else if ($arg == 'dbrk') {
  167. $this->_dbrk();
  168. } else if ($arg == 'whlabelczdc') {
  169. $this->_whlabelczdc();
  170. } else if ($arg == 'print') {
  171. $this->_print($arg_array);
  172. } else if ($arg == 'usaprint') {
  173. $this->_usaprint($arg_array);
  174. } else if ($arg == 'printck') {
  175. $this->_printck($arg_array);
  176. } else if ($arg == 'printrk') {
  177. $this->_printrk($arg_array);
  178. } else if ($arg == 'printxzrk') {
  179. $this->_printxzrk($arg_array);
  180. } else if ($arg == 'printexcel') {
  181. $this->_printexcel($arg_array);
  182. } else if ($arg == 'uck') {
  183. $this->_uck();
  184. } else if ($arg == 'whlabelexcelzh') {
  185. $this->_whlabelexcelzh();
  186. } else if ($arg == 'fc') {
  187. $this->_fc();
  188. } else if ($arg == 'fcmb') {
  189. $this->_fcmb();
  190. } else if ($arg == 'fcexcel') {
  191. $this->_fcexcel();
  192. } else if ($arg == 'fcjxc') {
  193. $this->_fcjxc($arg_array);
  194. } else if ($arg == '0kcdel') {
  195. $this->_0kcdel(); //导表删除0库存
  196. } else if ($arg == 'gbhtype') {
  197. $this->_gbhtype(); //更改备货状态
  198. } else if($arg == 'excelrjs'){
  199. $this->_excelrjs();
  200. } else if($arg == 'excelctjs'){
  201. $this->_excelctjs();
  202. }else if ($arg == 'exceljxcjs') //进销存信息导出
  203. {
  204. $this->_exceljxcjs();
  205. } else if ($arg == 'summaryjs') //汇总导出
  206. {
  207. $this->_summaryjs($arg_array);
  208. }else if($arg == 'uckjs'){
  209. $this->_uckjs();
  210. }else if ($arg == 'whlabelexcelzhjs') {
  211. $this->_whlabelexcelzhjs();
  212. }else if($arg == 'dccrtypejs'){
  213. $this->_dccrtypejs();
  214. }else if($arg == 'errorexceljs'){
  215. $this->_errorexceljs();
  216. }else if($arg == "w_t_cs"){
  217. $this->_w_t_cs(); //首页
  218. }else {
  219. $this->_index();
  220. }
  221. }
  222. public function _w_t_cs(){
  223. $vip = 0;
  224. if (isset($_SESSION['api'])) {
  225. $user = $this->user->get_api($_SESSION['api']);
  226. $fgshop = "";
  227. $sid = "";
  228. $usersp = explode('|', trim($user['shop'], '|'));
  229. foreach ($usersp as $value) {
  230. $fgshop .= " shop = " . $value . " or";
  231. $sid .= " id = " . $value . " or";
  232. }
  233. if ($user['vip'] == 1) {
  234. $vip = 1;
  235. }
  236. } else {
  237. header('Location: /');
  238. exit;
  239. }
  240. $prc = array();
  241. $purchase = $this->purchase->find_all();
  242. foreach ($purchase as $k => $v) {
  243. $prc[$v['id']] = $v['title'];
  244. }
  245. $company = array();
  246. $ct = $this->company->find_all();
  247. foreach ($ct as $k => $v) {
  248. $company[$v['id']] = $v['title'];
  249. }
  250. $sp = array();
  251. $s = $this->shop->find_all('1=1', 'id,shopname');
  252. foreach ($s as $v) {
  253. $sp[$v['id']] = $v['shopname'];
  254. }
  255. $wh = array();
  256. $w = $this->warehouse->find_all('1=1', 'id,title');
  257. foreach ($w as $v) {
  258. $wh[$v['id']] = $v['title'];
  259. }
  260. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  261. $this->data['shop'] = $wlshop;
  262. $this->data['vip'] = $vip;
  263. $this->_Template('whlabel_typejs', $this->data);
  264. }
  265. //管理
  266. public function _index()
  267. {
  268. $post = $this->input->post(NULL, TRUE);
  269. if (isset($post['page'])) {
  270. $page = $this->input->post('page', true);
  271. $perpage = $this->input->post('perpage', true);
  272. $sku = $this->input->post('sku', true);
  273. $number = $this->input->post('number', true);
  274. $warehouse = $this->input->post('warehouse', true);
  275. $purchase = $this->input->post('purchase', true);
  276. $orderinfo = $this->input->post('orderinfo', true);
  277. $waybill = $this->input->post('waybill', true);
  278. $category = $this->input->post('category', true);
  279. $size = $this->input->post('size', true);
  280. $grade = $this->input->post('grade', true);
  281. $color = $this->input->post('color', true);
  282. $lowe = $this->input->post('lowe', true);
  283. $state = $this->input->post('state', true);
  284. $label = $this->input->post('label', true);
  285. $timetk = $this->input->post('timetkk', true);
  286. $timetj = $this->input->post('timetjj', true);
  287. $timetk = strtotime($timetk);
  288. $timetj = strtotime($timetj);
  289. $where = "1=1 ";
  290. if ($timetk && $timetj) {
  291. $where .= " and time > '$timetk' and time < '$timetj'";
  292. }
  293. if ($sku) {
  294. $where .= " and sku = '$sku'";
  295. }
  296. if ($number) {
  297. $where .= " and number = '$number'";
  298. }
  299. if ($warehouse) {
  300. $where .= " and warehouse = '$warehouse'";
  301. }
  302. if ($purchase) {
  303. $where .= " and purchase = '$purchase'";
  304. }
  305. if ($orderinfo) {
  306. $where .= " and orderinfo = '$orderinfo'";
  307. }
  308. if ($waybill) {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if ($category) {
  312. $where .= " and features like '%-$category-%'";
  313. }
  314. if ($size) {
  315. $where .= " and features like '%-$size-%'";
  316. }
  317. if ($grade) {
  318. $where .= " and features like '%-$grade-%'";
  319. }
  320. if ($color) {
  321. $where .= " and features like '%-$color-%'";
  322. }
  323. if ($lowe) {
  324. $where .= " and features like '%-$lowe-%'";
  325. }
  326. if ($label) {
  327. $where .= " and label = '$label'";
  328. }
  329. if ($state != '') {
  330. $where .= " and state = '$state'";
  331. }
  332. //数据排序
  333. $order_str = "time desc";
  334. if (empty($page)) {
  335. $start = 0;
  336. $perpage = 1;
  337. } else {
  338. $start = ($page - 1) * $perpage;
  339. }
  340. //取得信息列表
  341. $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);
  342. foreach ($info_list as $key => $value) {
  343. $warehouse = $this->warehouse->read($value['warehouse']);
  344. $info_list[$key]['warehouse'] = $warehouse['title'];
  345. $purchase = $this->purchase->read($value['purchase']);
  346. $info_list[$key]['purchase'] = $purchase['title'];
  347. if ($value['enter'] != 0) {
  348. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  349. } else {
  350. $info_list[$key]['enter'] = "";
  351. }
  352. if ($value['outk'] != 0) {
  353. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  354. } else {
  355. $info_list[$key]['outk'] = "";
  356. }
  357. if ($value['printing'] != 0) {
  358. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  359. } else {
  360. $info_list[$key]['printing'] = "";
  361. }
  362. if ($value['orderinfo'] == 0) {
  363. $info_list[$key]['orderinfo'] = "";
  364. }
  365. if ($value['waybill'] == 0) {
  366. $info_list[$key]['waybill'] = "";
  367. }
  368. if ($value['state'] == 0) {
  369. $info_list[$key]['state'] = "在库";
  370. } else if ($value['state'] == 1) {
  371. $info_list[$key]['state'] = "出库";
  372. } else if ($value['state'] == 2) {
  373. $info_list[$key]['state'] = "退库";
  374. } else if ($value['state'] == 3) {
  375. $info_list[$key]['state'] = "调拨中";
  376. } else if ($value['state'] == 4) {
  377. $info_list[$key]['state'] = "再加工";
  378. } else if ($value['state'] == 5) {
  379. $info_list[$key]['state'] = "维修中";
  380. } else if ($value['state'] == 6) {
  381. $info_list[$key]['state'] = "盘亏";
  382. } else if ($value['state'] == 7) {
  383. $info_list[$key]['state'] = "更换标签";
  384. } else if ($value['state'] == 8) {
  385. $info_list[$key]['state'] = "其它";
  386. } else if ($value['state'] == 9) {
  387. $info_list[$key]['state'] = "预设";
  388. } else if ($value['state'] == 10) {
  389. $info_list[$key]['state'] = "美店零售";
  390. }
  391. if ($value['text'] == "") {
  392. $info_list[$key]['text'] = "";
  393. }
  394. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  395. }
  396. $total = $this->whlabel->find_count($where);
  397. $pagenum = ceil($total / $perpage);
  398. $over = $total - ($start + $perpage);
  399. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  400. echo json_encode($rows);
  401. exit;
  402. }
  403. if (isset($post['outsku'])) {
  404. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  405. $cz = $this->input->post('cz', true);
  406. if ($cz == '1') {
  407. $sku = $this->input->post('outsku', true);
  408. if ($sku) {
  409. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  410. if (count($data) < 1) {
  411. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  412. exit;
  413. }
  414. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  415. echo json_encode(array('success' => true));
  416. exit;
  417. }
  418. } else {
  419. $sku = $this->input->post('outsku', true);
  420. if ($sku) {
  421. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  422. if (count($data) < 1) {
  423. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  424. exit;
  425. }
  426. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  427. echo json_encode(array('success' => true));
  428. exit;
  429. }
  430. }
  431. }
  432. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  433. $this->_Template('whlabel', $this->data);
  434. }
  435. //在库标签
  436. public function _existence()
  437. {
  438. $post = $this->input->post(NULL, TRUE);
  439. if (isset($post['s'])) {
  440. $id_arr = $this->input->post('s');
  441. $id_arr = explode(',', $id_arr);
  442. if (!$id_arr) {
  443. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  444. exit;
  445. }
  446. //循环删除记录
  447. foreach ($id_arr as $v) {
  448. $sid = $this->whlabel->read($v);
  449. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  450. if ($count > 0) {
  451. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  452. exit;
  453. }
  454. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  455. if (count($zt) > 0) {
  456. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  457. exit;
  458. }
  459. $this->whlabel->remove($v);
  460. }
  461. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  462. exit;
  463. }
  464. if (isset($post['page'])) {
  465. $page = $this->input->post('page', true);
  466. $perpage = $this->input->post('perpage', true);
  467. $warehouse = $this->input->post('warehouse', true);
  468. $label = $this->input->post('label', true);
  469. $where = "1=1 and state = 0";
  470. if ($warehouse) {
  471. $where .= " and warehouse = '$warehouse'";
  472. }
  473. if ($label) {
  474. $where .= " and label = '$label'";
  475. }
  476. //数据排序
  477. $order_str = "time asc";
  478. if (empty($page)) {
  479. $start = 0;
  480. $perpage = 1;
  481. } else {
  482. $start = ($page - 1) * $perpage;
  483. }
  484. //取得信息列表
  485. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  486. foreach ($info_list as $key => $value) {
  487. if ($value['enter'] != 0) {
  488. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  489. } else {
  490. $info_list[$key]['enter'] = "";
  491. }
  492. if ($value['printing'] != 0) {
  493. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  494. } else {
  495. $info_list[$key]['printing'] = "";
  496. }
  497. }
  498. $total = $this->whlabel->find_count($where);
  499. $pagenum = ceil($total / $perpage);
  500. $over = $total - ($start + $perpage);
  501. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  502. echo json_encode($rows);
  503. exit;
  504. }
  505. $this->_Template('whlabel_existence', $this->data);
  506. }
  507. //进销存浏览
  508. public function _typedy($arg_array)
  509. {
  510. $prc = array();
  511. $purchase = $this->purchase->find_all();
  512. foreach ($purchase as $k => $v) {
  513. $prc[$v['id']] = $v['title'];
  514. }
  515. $post = $this->input->post(NULL, TRUE);
  516. if (isset($post['page'])) {
  517. $page = $this->input->post('page', true);
  518. $perpage = $this->input->post('perpage', true);
  519. $category = $this->input->post('category', true);
  520. $size = $this->input->post('size', true);
  521. $grade = $this->input->post('grade', true);
  522. $color = $this->input->post('color', true);
  523. $lowe = $this->input->post('lowe', true);
  524. $sku = $this->input->post('sku');
  525. $title = $this->input->post('title');
  526. $warehouse = $this->input->post('warehouse', true);
  527. $usa = $this->input->post('usa', true);
  528. $purchase = $this->input->post('purchase', true);
  529. $lacetype = $this->input->post('lacetype', true);
  530. $haircap = $this->input->post('haircap', true);
  531. $density = $this->input->post('density', true);
  532. $details = $this->input->post('details', true);
  533. $state = $this->input->post('state', true);
  534. $lacecolor = $this->input->post('lacecolor', true);
  535. $hairnumber = $this->input->post('hairnumber', true);
  536. $cklx = $this->input->post('cklx', true);
  537. $ktime = $this->input->post('ktime', true);
  538. $jtime = $this->input->post('jtime', true);
  539. $sm = $this->input->post('sm', true);
  540. $cpbz = $this->input->post('cpbz', true);
  541. $type = $this->input->post('type', true);
  542. $ktime = strtotime($ktime);
  543. $jtime = strtotime($jtime);
  544. $where = "1=1";
  545. $gj = "";
  546. $ck = "";
  547. if ($usa) {
  548. if (!$warehouse) {
  549. $where .= " and (warehouse = '5' or warehouse = '8')";
  550. }
  551. }
  552. if ($warehouse) {
  553. $where .= " and warehouse = '$warehouse'";
  554. }
  555. if ($details) {
  556. $where .= " and details = '$details'";
  557. }
  558. if ($purchase) {
  559. $where .= " and purchase = '$purchase'";
  560. }
  561. if (isset($state)) {
  562. if($state >-1){
  563. $where .= " and state = '$state'";
  564. }
  565. }
  566. if ($lacetype) {
  567. $where .= " and features like '%-$lacetype-%'";
  568. }
  569. if ($category) {
  570. $where .= " and features like '%-$category-%'";
  571. }
  572. if ($size) {
  573. $where .= " and features like '%-$size-%'";
  574. }
  575. if ($grade) {
  576. $where .= " and features like '%-$grade-%'";
  577. }
  578. if ($color) {
  579. $where .= " and features like '%-$color-%'";
  580. }
  581. if ($lowe) {
  582. $where .= " and features like '%-$lowe-%'";
  583. }
  584. if ($haircap) {
  585. $where .= " and features like '%-$haircap-%'";
  586. }
  587. if ($density) {
  588. $where .= " and features like '%-$density-%'";
  589. }
  590. if ($lacecolor) {
  591. $where .= " and features like '%-$lacecolor-%'";
  592. }
  593. if($sm){
  594. $where .= " and sm like '%".$sm."%'";
  595. }
  596. if($cpbz){
  597. $where .= " and cpbz like '%".$cpbz."%'";
  598. }
  599. if($type){
  600. $where .= " and type = ".$type."";
  601. }
  602. if (!empty($hairnumber)) {
  603. $where .= " and features like '%-128-%' ";
  604. if ($hairnumber < 0) {
  605. $class_list = $this->typeclass->find_all('classid = 43');
  606. foreach ($class_list as $v) {
  607. $where .= " and features not like '%-" . $v['id'] . "-%'";
  608. }
  609. } else {
  610. $where .= " and features like '%-$hairnumber-%'";
  611. }
  612. }
  613. $where_add = '';
  614. if ($cklx) {
  615. $shop = $this->shop->read($cklx);
  616. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  617. }
  618. if ($ktime && $jtime) {
  619. $gj = " and enter > '$ktime' and enter < '$jtime'";
  620. $ck = " and outk > '$ktime' and outk < '$jtime'";
  621. }
  622. //数据排序
  623. $order_str = "id desc";
  624. if (empty($page)) {
  625. $start = 0;
  626. $perpage = 1;
  627. } else {
  628. $start = ($page - 1) * $perpage;
  629. }
  630. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  631. if ($sku) {
  632. $sku = trim($sku, ' ');
  633. $sku = trim($sku, ' ');
  634. $where .= " and sku like '%$sku%'";
  635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  636. } else if ($title) {
  637. $title = trim($title, ' ');
  638. $title = trim($title, ' ');
  639. $where .= " and title like '%$title%'";
  640. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  641. } else {
  642. //$where .= " and time > '$ktime' and time < '$jtime'";
  643. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  644. }
  645. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  646. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  647. foreach ($info_list as $k => $v) {
  648. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  649. unset($info_list[$k]['pm']);
  650. unset($info_list[$k]['jm']);
  651. unset($info_list[$k]['bm']);
  652. }
  653. //取得信息列表
  654. $rows = array();
  655. $list = array();
  656. foreach ($info_list as $key => $value) {
  657. $warehouse = $this->warehouse->read($value['warehouse']);
  658. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  659. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  660. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  661. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  662. $info_list[$key]['label'] = $value['sm'];
  663. $number = $value['number'];
  664. $ftime = time() - 15 * 24 * 3600;
  665. $info_list[$key]['warehouse'] = $warehouse['title'];
  666. $info_list[$key]['features'] = count($c);
  667. $z = count($z); //查看订单号
  668. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  669. $ztdata = '';
  670. if (count($zt) > 0) {
  671. foreach ($zt as $vv) {
  672. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  673. }
  674. }
  675. $info_list[$key]['number'] = $ztdata;
  676. $info_list[$key]['sm'] = $z;
  677. $details = array();
  678. $cpid = array();
  679. foreach ($c as $k => $v) {
  680. $details[$v['details']] = $v['details'];
  681. if ($v['cpid'] != 0) {
  682. $cpid[$v['cpid']] = $v['cpid'];
  683. }
  684. }
  685. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  686. if ($value['shop'] != '') {
  687. $shop = explode(',', trim($value['shop'], ','));
  688. $shop = $this->shop->read($shop[0]);
  689. $info_list[$key]['shop'] = $shop['shopname'];
  690. }
  691. }
  692. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  693. $pagenum = ceil($total / $perpage);
  694. $over = $total - ($start + $perpage);
  695. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  696. echo json_encode($rows);
  697. exit;
  698. }
  699. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  700. $this->_Template('whlabel_typedy', $this->data);
  701. }
  702. //进销存浏览
  703. public function _typedy_ck($arg_array)
  704. {
  705. $prc = array();
  706. $purchase = $this->purchase->find_all();
  707. foreach ($purchase as $k => $v) {
  708. $prc[$v['id']] = $v['title'];
  709. }
  710. $post = $this->input->post(NULL, TRUE);
  711. if (isset($post['page'])) {
  712. $page = $this->input->post('page', true);
  713. $perpage = $this->input->post('perpage', true);
  714. $category = $this->input->post('category', true);
  715. $size = $this->input->post('size', true);
  716. $grade = $this->input->post('grade', true);
  717. $color = $this->input->post('color', true);
  718. $lowe = $this->input->post('lowe', true);
  719. $sku = $this->input->post('sku');
  720. $title = $this->input->post('title');
  721. $warehouse = $this->input->post('warehouse', true);
  722. $usa = $this->input->post('usa', true);
  723. $purchase = $this->input->post('purchase', true);
  724. $lacetype = $this->input->post('lacetype', true);
  725. $haircap = $this->input->post('haircap', true);
  726. $density = $this->input->post('density', true);
  727. $details = $this->input->post('details', true);
  728. $state = $this->input->post('state', true);
  729. $lacecolor = $this->input->post('lacecolor', true);
  730. $cklx = $this->input->post('cklx', true);
  731. $ktime = $this->input->post('ktime', true);
  732. $jtime = $this->input->post('jtime', true);
  733. $ktime = strtotime($ktime);
  734. $jtime = strtotime($jtime);
  735. $where = "1=1";
  736. $gj = "";
  737. $ck = "";
  738. if ($lacetype) {
  739. $where .= " and features like '%-$lacetype-%'";
  740. }
  741. if ($category) {
  742. $where .= " and features like '%-$category-%'";
  743. }
  744. if ($size) {
  745. $where .= " and features like '%-$size-%'";
  746. }
  747. if ($grade) {
  748. $where .= " and features like '%-$grade-%'";
  749. }
  750. if ($color) {
  751. $where .= " and features like '%-$color-%'";
  752. }
  753. if ($lowe) {
  754. $where .= " and features like '%-$lowe-%'";
  755. }
  756. if ($haircap) {
  757. $where .= " and features like '%-$haircap-%'";
  758. }
  759. if ($density) {
  760. $where .= " and features like '%-$density-%'";
  761. }
  762. if ($lacecolor) {
  763. $where .= " and features like '%-$lacecolor-%'";
  764. }
  765. if ($usa) {
  766. if (!$warehouse) {
  767. $where .= " and (warehouse = '5' or warehouse = '8')";
  768. }
  769. }
  770. if ($warehouse) {
  771. $where .= " and warehouse = '$warehouse'";
  772. }
  773. if ($details) {
  774. $where .= " and details = '$details'";
  775. }
  776. if ($purchase) {
  777. $where .= " and purchase = '$purchase'";
  778. }
  779. if ($state) {
  780. $where .= " and state = '$state'";
  781. }
  782. $where_add = '';
  783. if ($cklx) {
  784. $shop = $this->shop->read($cklx);
  785. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  786. }
  787. if ($ktime && $jtime) {
  788. $gj = " and enter > '$ktime' and enter < '$jtime'";
  789. $ck = " and outk > '$ktime' and outk < '$jtime'";
  790. }
  791. //数据排序
  792. $order_str = "id desc";
  793. if (empty($page)) {
  794. $start = 0;
  795. $perpage = 1;
  796. } else {
  797. $start = ($page - 1) * $perpage;
  798. }
  799. if ($sku) {
  800. $sku = trim($sku, ' ');
  801. $sku = trim($sku, ' ');
  802. $where .= " and sku like '%$sku%'";
  803. $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);
  804. } else if ($title) {
  805. $title = trim($title, ' ');
  806. $title = trim($title, ' ');
  807. $where .= " and title like '%$title%'";
  808. $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);
  809. } else {
  810. //$where .= " and time > '$ktime' and time < '$jtime'";
  811. $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);
  812. }
  813. //取得信息列表
  814. $rows = array();
  815. $list = array();
  816. foreach ($info_list as $key => $value) {
  817. $warehouse = $this->warehouse->read($value['warehouse']);
  818. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  819. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  820. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  821. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  822. $ftime = time() - 15 * 24 * 3600;
  823. $info_list[$key]['warehouse'] = $warehouse['title'];
  824. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  825. //$z = count($z);//查看订单号
  826. //$info_list[$key]['zd'] = $z;
  827. $details = array();
  828. $cpid = array();
  829. foreach ($c as $k => $v) {
  830. $details[$v['details']] = $v['details'];
  831. if ($v['cpid'] != 0) {
  832. $cpid[$v['cpid']] = $v['cpid'];
  833. }
  834. }
  835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  836. if ($value['shop'] != '') {
  837. $shop = explode(',', trim($value['shop'], ','));
  838. $shop = $this->shop->read($shop[0]);
  839. $info_list[$key]['shop'] = $shop['shopname'];
  840. }
  841. }
  842. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  843. $pagenum = ceil($total / $perpage);
  844. $over = $total - ($start + $perpage);
  845. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  846. echo json_encode($rows);
  847. exit;
  848. }
  849. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  850. $this->_Template('whlabel_typedy_ck', $this->data);
  851. }
  852. public function _typeck($arg_array)
  853. {
  854. $prc = array();
  855. $purchase = $this->purchase->find_all();
  856. foreach ($purchase as $k => $v) {
  857. $prc[$v['id']] = $v['title'];
  858. }
  859. $post = $this->input->post(NULL, TRUE);
  860. if (isset($post['page'])) {
  861. $page = $this->input->post('page', true);
  862. $perpage = $this->input->post('perpage', true);
  863. $category = $this->input->post('category', true);
  864. $size = $this->input->post('size', true);
  865. $grade = $this->input->post('grade', true);
  866. $color = $this->input->post('color', true);
  867. $lacecolor = $this->input->post('lacecolor', true);
  868. $lowe = $this->input->post('lowe', true);
  869. $sku = $this->input->post('sku');
  870. $title = $this->input->post('title');
  871. $warehouse = 13;
  872. $usa = $this->input->post('usa', true);
  873. $purchase = $this->input->post('purchase', true);
  874. $lacetype = $this->input->post('lacetype', true);
  875. $haircap = $this->input->post('haircap', true);
  876. $density = $this->input->post('density', true);
  877. $details = $this->input->post('details', true);
  878. $state = $this->input->post('state', true);
  879. $ktime = $this->input->post('ktime', true);
  880. $jtime = $this->input->post('jtime', true);
  881. $ktime = strtotime($ktime);
  882. $jtime = strtotime($jtime);
  883. $where = "1=1";
  884. $gj = "";
  885. $ck = "";
  886. if ($lacetype) {
  887. $where .= " and features like '%-$lacetype-%'";
  888. }
  889. if ($category) {
  890. $where .= " and features like '%-$category-%'";
  891. }
  892. if ($size) {
  893. $where .= " and features like '%-$size-%'";
  894. }
  895. if ($grade) {
  896. $where .= " and features like '%-$grade-%'";
  897. }
  898. if ($color) {
  899. $where .= " and features like '%-$color-%'";
  900. }
  901. if ($lacecolor) {
  902. $where .= " and features like '%-$lacecolor-%'";
  903. }
  904. if ($lowe) {
  905. $where .= " and features like '%-$lowe-%'";
  906. }
  907. if ($haircap) {
  908. $where .= " and features like '%-$haircap-%'";
  909. }
  910. if ($density) {
  911. $where .= " and features like '%-$density-%'";
  912. }
  913. if ($warehouse) {
  914. $where .= " and warehouse = '$warehouse'";
  915. }
  916. if ($details) {
  917. $where .= " and details = '$details'";
  918. }
  919. if ($purchase) {
  920. $where .= " and purchase = '$purchase'";
  921. }
  922. if ($state) {
  923. $where .= " and state = '$state'";
  924. }
  925. if ($ktime && $jtime) {
  926. $gj = " and enter > '$ktime' and enter < '$jtime'";
  927. $ck = " and outk > '$ktime' and outk < '$jtime'";
  928. }
  929. //数据排序
  930. $order_str = "id desc";
  931. if (empty($page)) {
  932. $start = 0;
  933. $perpage = 1;
  934. } else {
  935. $start = ($page - 1) * $perpage;
  936. }
  937. if ($sku) {
  938. $sku = trim($sku, ' ');
  939. $sku = trim($sku, ' ');
  940. $where .= " and sku like '%$sku%'";
  941. } else if ($title) {
  942. $title = trim($title, ' ');
  943. $title = trim($title, ' ');
  944. $where .= " and title like '%$title%'";
  945. }
  946. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  947. //取得信息列表
  948. $t = array();
  949. $typeclass = $this->typeclass->find_all();
  950. foreach ($typeclass as $v) {
  951. $t[$v['id']] = $v;
  952. }
  953. $rows = array();
  954. $list = array();
  955. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  956. foreach ($info_list as $key => $value) {
  957. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  958. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  959. $warehouse = $this->warehouse->read($value['warehouse']);
  960. $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');
  961. $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'] . '"');
  962. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  963. $number = $value['number'];
  964. $ftime = time() - 15 * 24 * 3600;
  965. $z = count($z); //查看订单号
  966. $info_list[$key]['warehouse'] = $warehouse['title'];
  967. $info_list[$key]['features'] = count($c);
  968. $info_list[$key]['number'] = $z;
  969. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  970. $details = array();
  971. $cpid = array();
  972. foreach ($c as $k => $v) {
  973. $details[$v['details']] = $v['details'];
  974. if ($v['cpid'] != 0) {
  975. $cpid[$v['cpid']] = $v['cpid'];
  976. }
  977. }
  978. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  979. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  980. unset($info_list[$key]['pm']);
  981. unset($info_list[$key]['jm']);
  982. unset($info_list[$key]['bm']);
  983. }
  984. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  985. $pagenum = ceil($total / $perpage);
  986. $over = $total - ($start + $perpage);
  987. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  988. echo json_encode($rows);
  989. exit;
  990. }
  991. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  992. $this->_Template('whlabel_typeck', $this->data);
  993. }
  994. //进销存导出
  995. public function _whlabeckdc()
  996. {
  997. $prc = array();
  998. $purchase = $this->purchase->find_all();
  999. foreach ($purchase as $k => $v) {
  1000. $prc[$v['id']] = $v['title'];
  1001. }
  1002. if (isset($_GET['excel'])) {
  1003. $where = "sku != 'Preset'";
  1004. //数据排序
  1005. $order_str = "id desc";
  1006. if (empty($page)) {
  1007. $start = 0;
  1008. $perpage = 1;
  1009. } else {
  1010. $start = ($page - 1) * $perpage;
  1011. }
  1012. $category = $this->input->get('category', true);
  1013. $color = $this->input->get('color', true);
  1014. $lowe = $this->input->get('lowe', true);
  1015. $lacetype = $this->input->get('lacetype', true);
  1016. $size = $this->input->get('size', true);
  1017. $density = $this->input->get('density', true);
  1018. $haircap = $this->input->get('haircap', true);
  1019. $sku = $this->input->get('sku', true);
  1020. $details = $this->input->get('details', true);
  1021. $warehouse = 13;
  1022. $excelid = $this->input->get('sid', true);
  1023. if ($category) {
  1024. $where .= " and features like '%-$category-%'";
  1025. }
  1026. if ($color) {
  1027. $where .= " and features like '%-$color-%'";
  1028. }
  1029. if ($lowe) {
  1030. $where .= " and features like '%-$lowe-%'";
  1031. }
  1032. if ($lacetype) {
  1033. $where .= " and features like '%-$lacetype-%'";
  1034. }
  1035. if ($size) {
  1036. $where .= " and features like '%-$size-%'";
  1037. }
  1038. if ($density) {
  1039. $where .= " and features like '%-$density-%'";
  1040. }
  1041. if ($haircap) {
  1042. $where .= " and features like '%-$haircap-%'";
  1043. }
  1044. if ($warehouse) {
  1045. $where .= " and warehouse = '$warehouse'";
  1046. }
  1047. if ($sku) {
  1048. $where .= " and sku like '%$sku%'";
  1049. }
  1050. if ($details) {
  1051. $where .= " and details = '$details'";
  1052. }
  1053. $xzid = '';
  1054. if ($excelid) {
  1055. $excelid = explode(',', trim($excelid, ','));
  1056. foreach ($excelid as $key => $value) {
  1057. $xzid .= " id = " . $value . " or";
  1058. }
  1059. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1060. }
  1061. //取得信息列表
  1062. /**
  1063. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1064. $rows = array();$list = array();
  1065. foreach ($info_list as $key=>$value)
  1066. {
  1067. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1068. }
  1069. **/
  1070. $wh = array();
  1071. $w = $this->warehouse->find_all('1=1', 'id,title');
  1072. foreach ($w as $v) {
  1073. $wh[$v['id']] = $v['title'];
  1074. }
  1075. $tc = array();
  1076. $tcdata = array();
  1077. $list = array();
  1078. $classid = $this->classid->sku();
  1079. $tcall = $this->typeclass->find_all();
  1080. $typeclass = array();
  1081. foreach ($tcall as $v)
  1082. {
  1083. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1084. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1085. }
  1086. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1087. foreach ($rows as $key => $value) {
  1088. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1089. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1090. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1091. $rows[$key]['cpbz'] = $u9_info['bm'];
  1092. $rows[$key]['cs'] = $u9_info['jm'];
  1093. if(empty($value['details'])){
  1094. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1095. }else{
  1096. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1097. }
  1098. $details = array();
  1099. $cpid = array();
  1100. $cpbz = array();
  1101. $c = 0;
  1102. $g = 0;
  1103. $x = 0;
  1104. $t = 0;
  1105. $s = 0;
  1106. $q = 0;
  1107. foreach ($sd as $k => $v) {
  1108. if ($v['state'] == 0) {
  1109. $c++;
  1110. }
  1111. if ($v['state'] != 9) {
  1112. $g++;
  1113. }
  1114. if ($v['state'] == 1) {
  1115. $x++;
  1116. }
  1117. if ($v['state'] == 2) {
  1118. $t++;
  1119. }
  1120. if ($v['state'] == 8) {
  1121. $s++;
  1122. }
  1123. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1124. $q++;
  1125. }
  1126. $details[$v['details']] = $v['details'];
  1127. if ($v['cpid'] != 0) {
  1128. $cpid[$v['cpid']] = $v['cpid'];
  1129. }
  1130. if ($v['cpbz'] != '') {
  1131. $cpbz[$v['cpbz']] = $v['cpbz'];
  1132. }
  1133. }
  1134. $rows[$key]['details'] = implode("、", $details);
  1135. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1136. $number = $value['number'];
  1137. $ftime = time() - 15 * 24 * 3600;
  1138. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1139. $rows[$key]['number'] = $g;
  1140. $rows[$key]['features'] = $c;
  1141. $rows[$key]['x'] = $x;
  1142. $rows[$key]['t'] = $t;
  1143. $rows[$key]['s'] = $s;
  1144. $rows[$key]['q'] = $q;
  1145. $rows[$key]['wzsl'] = count($details);
  1146. //cpbzs
  1147. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1148. $unique_arr = array_unique($tmp_cpbzs);
  1149. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1150. }
  1151. $title = "进销存统计表" . date('Y-m-d', time());
  1152. $titlename = "<table border=1>
  1153. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1154. <tr align='center'>
  1155. <td>仓库</td>
  1156. <td>供应商</td>
  1157. <td>位置</td>
  1158. <td>库存编码</td>
  1159. <td>SKU</td>
  1160. <td>用友编码</td>
  1161. <td>用友料号</td>
  1162. <td>产品英文名</td>
  1163. <td>产品中文名</td>
  1164. <td>备注</td>
  1165. <td>入库总量</td>
  1166. <td>库存数量</td>
  1167. <td>销售数量</td>
  1168. <td>退货数量</td>
  1169. <td>删除数量</td>
  1170. <td>其它操作</td>
  1171. <td>位置数量</td>
  1172. </tr>
  1173. </table>";
  1174. $filename = $title . ".xls";
  1175. $tail = "";
  1176. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1177. }
  1178. }
  1179. public function _type()
  1180. {
  1181. $vip = 0;
  1182. if (isset($_SESSION['api'])) {
  1183. $user = $this->user->get_api($_SESSION['api']);
  1184. $fgshop = "";
  1185. $sid = "";
  1186. $usersp = explode('|', trim($user['shop'], '|'));
  1187. foreach ($usersp as $value) {
  1188. $fgshop .= " shop = " . $value . " or";
  1189. $sid .= " id = " . $value . " or";
  1190. }
  1191. if ($user['vip'] == 1) {
  1192. $vip = 1;
  1193. }
  1194. } else {
  1195. header('Location: /');
  1196. exit;
  1197. }
  1198. $prc = array();
  1199. $purchase = $this->purchase->find_all();
  1200. foreach ($purchase as $k => $v) {
  1201. $prc[$v['id']] = $v['title'];
  1202. }
  1203. $company = array();
  1204. $ct = $this->company->find_all();
  1205. foreach ($ct as $k => $v) {
  1206. $company[$v['id']] = $v['title'];
  1207. }
  1208. $sp = array();
  1209. $s = $this->shop->find_all('1=1', 'id,shopname');
  1210. foreach ($s as $v) {
  1211. $sp[$v['id']] = $v['shopname'];
  1212. }
  1213. $wh = array();
  1214. $w = $this->warehouse->find_all('1=1', 'id,title');
  1215. foreach ($w as $v) {
  1216. $wh[$v['id']] = $v['title'];
  1217. }
  1218. $post = $this->input->post(NULL, TRUE);
  1219. if (isset($post['page'])) {
  1220. $page = $this->input->post('page', true);
  1221. $perpage = $this->input->post('perpage', true);
  1222. $category = $this->input->post('category', true);
  1223. $size = $this->input->post('size', true);
  1224. $grade = $this->input->post('grade', true);
  1225. $color = $this->input->post('color', true);
  1226. $lowe = $this->input->post('lowe', true);
  1227. $sku = $this->input->post('sku');
  1228. $title = $this->input->post('title');
  1229. $warehouse = $this->input->post('warehouse', true);
  1230. $usa = $this->input->post('usa', true);
  1231. $purchase = $this->input->post('purchase', true);
  1232. $lacetype = $this->input->post('lacetype', true);
  1233. $haircap = $this->input->post('haircap', true);
  1234. $density = $this->input->post('density', true);
  1235. $details = $this->input->post('details', true);
  1236. $state = $this->input->post('state', true);
  1237. $shop = $this->input->post('shop', true);
  1238. $lacecolor = $this->input->post('lacecolor', true);
  1239. $hairnumber = $this->input->post('hairnumber', true);
  1240. $type = $this->input->post('type', true);
  1241. $ktime = $this->input->post('ktime', true);
  1242. $jtime = $this->input->post('jtime', true);
  1243. $ktime = strtotime($ktime);
  1244. $jtime = strtotime($jtime);
  1245. $cpbz = $this->input->post('cpbz', true);
  1246. $sm = $this->input->post('sm', true);
  1247. $where = "1=1";
  1248. $gj = "";
  1249. $ck = "";
  1250. if ($usa) {
  1251. if (!$warehouse) {
  1252. $where .= " and (warehouse = '5' or warehouse = '8')";
  1253. }
  1254. }
  1255. if ($warehouse) {
  1256. $where .= " and warehouse = '$warehouse'";
  1257. }
  1258. if ($details) {
  1259. $where .= " and details = '$details'";
  1260. }
  1261. if ($purchase) {
  1262. $where .= " and purchase = '$purchase'";
  1263. }
  1264. if ($state) {
  1265. $where .= " and state = '$state'";
  1266. }
  1267. if ($shop) {
  1268. $where .= " and shop like '%$shop%'";
  1269. }
  1270. if ($type) {
  1271. $where .= " and type = '$type'";
  1272. }
  1273. if ($ktime && $jtime) {
  1274. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1275. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1276. }
  1277. if ($cpbz) {
  1278. $where .= " and cpbz like '%$cpbz%' ";
  1279. }
  1280. if ($sm) {
  1281. $where .= " and sm like '%$sm%' ";
  1282. }
  1283. if ($lacecolor) {
  1284. $where .= " and features like '%-$lacecolor-%'";
  1285. }
  1286. if ($lacetype) {
  1287. $where .= " and features like '%-$lacetype-%'";
  1288. }
  1289. if ($category) {
  1290. $where .= " and features like '%-$category-%'";
  1291. }
  1292. if ($size) {
  1293. $where .= " and features like '%-$size-%'";
  1294. }
  1295. if ($grade) {
  1296. $where .= " and features like '%-$grade-%'";
  1297. }
  1298. if ($color) {
  1299. $where .= " and features like '%-$color-%'";
  1300. }
  1301. if ($lowe) {
  1302. $where .= " and features like '%-$lowe-%'";
  1303. }
  1304. if ($haircap) {
  1305. $where .= " and features like '%-$haircap-%'";
  1306. }
  1307. if ($density) {
  1308. $where .= " and features like '%-$density-%'";
  1309. }
  1310. if (!empty($hairnumber)) {
  1311. $where .= " and features like '%-128-%' ";
  1312. if ($hairnumber < 0) {
  1313. $class_list = $this->typeclass->find_all('classid = 43');
  1314. foreach ($class_list as $v) {
  1315. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1316. }
  1317. } else {
  1318. $where .= " and features like '%-$hairnumber-%'";
  1319. }
  1320. }
  1321. //数据排序
  1322. $order_str = "id desc";
  1323. if (empty($page)) {
  1324. $start = 0;
  1325. $perpage = 1;
  1326. } else {
  1327. $start = ($page - 1) * $perpage;
  1328. }
  1329. $fjnr = '';
  1330. if ($sku) {
  1331. $sku = trim($sku, ' ');
  1332. $sku = trim($sku, ' ');
  1333. $fjnr .= " and sku like '%$sku%'";
  1334. }
  1335. if ($title) {
  1336. $title = trim($title, ' ');
  1337. $title = trim($title, ' ');
  1338. $fjnr .= " and title like '%$title%'";
  1339. }
  1340. $wt = array();
  1341. $whlabel_type = $this->whlabel_type->find_all();
  1342. foreach ($whlabel_type as $v) {
  1343. $wt[$v['id']] = $v['title'];
  1344. }
  1345. //$where .= " and time > '$ktime' and time < '$jtime'";
  1346. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1347. //取得信息列表
  1348. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1349. $rows = array();
  1350. $list = array();
  1351. foreach ($info_list as $key => $value) {
  1352. if (isset($wt[$value['type']])) {
  1353. $info_list[$key]['type'] = $wt[$value['type']];
  1354. } else {
  1355. $info_list[$key]['type'] = '未设置';
  1356. }
  1357. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1358. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1359. $ztdata = '';
  1360. if (count($zt) > 0) {
  1361. foreach ($zt as $vv) {
  1362. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1363. }
  1364. }
  1365. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1366. $cdata = array_filter($qbdata, function ($item) {
  1367. return $item['state'] < 1;
  1368. });
  1369. $c = array_sum(array_column($cdata, 'jnum'));
  1370. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1371. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1372. });
  1373. $g = array_sum(array_column($gdata, 'jnum'));
  1374. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1375. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1376. });
  1377. $x = array_sum(array_column($xdata, 'jnum'));
  1378. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1379. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1380. });
  1381. $t = array_sum(array_column($tdata, 'jnum'));
  1382. // $zdata = array_filter($qbdata, function ($item) {
  1383. // return $item['zd'] != "" && $item['state'] < 1;
  1384. // });
  1385. // $z = array_sum(array_column($zdata, 'jnum'));
  1386. $zdata = array_filter($qbdata, function ($item) {
  1387. return $item['zd'] != "" && $item['state'] < 1;
  1388. });
  1389. $z = array_sum(array_column($zdata, 'jnum'));
  1390. //$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');
  1391. //$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'].'"');
  1392. //$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'].'"');
  1393. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1394. //$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'].'"');
  1395. $details = array();
  1396. $cpid = array();
  1397. $od = array();
  1398. $odid = '';
  1399. $companytitle = '';
  1400. $shop_list = [];
  1401. foreach ($qbdata as $v) {
  1402. if ($v['zd'] != "" && $v['state'] < 1) {
  1403. if (!isset($od[$v['zd']])) {
  1404. $od[$v['zd']] = 1; //所有数据sku
  1405. } else {
  1406. $od[$v['zd']] = $od[$v['zd']] + 1;
  1407. }
  1408. }
  1409. if($v['state'] == 0){
  1410. $details[$v['details']] = $v['details'];
  1411. }
  1412. if ($v['state'] < 1) {
  1413. //$details[$v['details']] = $v['details'];
  1414. if ($v['cpid'] != 0) {
  1415. $cpid[$v['cpid']] = $v['cpid'];
  1416. }
  1417. }
  1418. if($v['state'] == 0){
  1419. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1420. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1421. }
  1422. if ($v['shop'] != '') {
  1423. $shop = explode(',', trim($v['shop'], ','));
  1424. foreach ($shop as $vv) {
  1425. if (!in_array($vv, $shop_list)) {
  1426. $shop_list[] = $vv;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. foreach ($od as $k => $vv) {
  1433. $odid .= $k . '数量' . $vv;
  1434. }
  1435. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1436. $info_list[$key]['label'] = $value['sm'];
  1437. $number = $value['number'];
  1438. $ftime = time() - 15 * 24 * 3600;
  1439. $z = $z . '(' . $odid . ')'; //查看订单号
  1440. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1441. $info_list[$key]['features'] = $c;
  1442. $info_list[$key]['number'] = $ztdata;
  1443. $info_list[$key]['sm'] = $g;
  1444. $info_list[$key]['x'] = $x;
  1445. $info_list[$key]['t'] = $t;
  1446. $info_list[$key]['z'] = $z;
  1447. /**
  1448. foreach ($cdata as $k=>$v)
  1449. {
  1450. $details[$v['details']] = $v['details'];
  1451. if($v['cpid'] != 0)
  1452. {
  1453. $cpid[$v['cpid']] = $v['cpid'];
  1454. }
  1455. }
  1456. **/
  1457. $info_list[$key]['shop'] = '';
  1458. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1459. // if ($value['shop'] != '') {
  1460. // $shop = explode(',', trim($value['shop'], ','));
  1461. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1462. // }
  1463. $shop_list = array_unique($shop_list);
  1464. $shop_str = '';
  1465. foreach ($shop_list as $v) {
  1466. if(isset($sp[$v])){
  1467. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1468. }
  1469. }
  1470. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1471. /**
  1472. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1473. if(isset($companytitle[0]))
  1474. {
  1475. foreach ($companytitle as $k=>$v)
  1476. {
  1477. if($v['companytitle'] != '')
  1478. {
  1479. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1480. }
  1481. }
  1482. }
  1483. **/
  1484. }
  1485. $final_all_list = [];
  1486. foreach ($info_list as $k => $v) {
  1487. $final_all_list[] = [
  1488. 'id' => $v['id'],
  1489. "warehouse" => $v["warehouse"],
  1490. "purchase" => $v["purchase"],
  1491. "sku" => $v["sku"],
  1492. "title" => $v["title"] . "<br/>" . $v["pm"],
  1493. "details" => $v["details"],
  1494. "shop" => $v["shop"],
  1495. "cpbz" => $v["cpbz"],
  1496. 'label' => $v['label'],
  1497. "type" => $v["type"],
  1498. "features" => $v["features"],
  1499. "number" => $v["number"],
  1500. "sm" => $v["sm"],
  1501. "x" => $v["x"],
  1502. "t" => $v["t"],
  1503. "z" => $v["z"]
  1504. ];
  1505. }
  1506. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1507. $pagenum = ceil($total / $perpage);
  1508. $over = $total - ($start + $perpage);
  1509. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1510. echo json_encode($rows);
  1511. exit;
  1512. }
  1513. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1514. $this->data['shop'] = $wlshop;
  1515. $this->data['vip'] = $vip;
  1516. $this->_Template('whlabel_type', $this->data);
  1517. }
  1518. /**
  1519. * _type 优化版 v1
  1520. * 优化点:
  1521. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1522. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1523. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1524. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1525. */
  1526. public function _typev1()
  1527. {
  1528. $vip = 0;
  1529. if (isset($_SESSION['api'])) {
  1530. $user = $this->user->get_api($_SESSION['api']);
  1531. $fgshop = "";
  1532. $sid = "";
  1533. $usersp = explode('|', trim($user['shop'], '|'));
  1534. foreach ($usersp as $value) {
  1535. $fgshop .= " shop = " . $value . " or";
  1536. $sid .= " id = " . $value . " or";
  1537. }
  1538. if ($user['vip'] == 1) {
  1539. $vip = 1;
  1540. }
  1541. } else {
  1542. header('Location: /');
  1543. exit;
  1544. }
  1545. $prc = array();
  1546. $purchase = $this->purchase->find_all();
  1547. foreach ($purchase as $k => $v) {
  1548. $prc[$v['id']] = $v['title'];
  1549. }
  1550. $company = array();
  1551. $ct = $this->company->find_all();
  1552. foreach ($ct as $k => $v) {
  1553. $company[$v['id']] = $v['title'];
  1554. }
  1555. $sp = array();
  1556. $s = $this->shop->find_all('1=1', 'id,shopname');
  1557. foreach ($s as $v) {
  1558. $sp[$v['id']] = $v['shopname'];
  1559. }
  1560. $wh = array();
  1561. $w = $this->warehouse->find_all('1=1', 'id,title');
  1562. foreach ($w as $v) {
  1563. $wh[$v['id']] = $v['title'];
  1564. }
  1565. $post = $this->input->post(NULL, TRUE);
  1566. if (isset($post['page'])) {
  1567. $page = $this->input->post('page', true);
  1568. $perpage = $this->input->post('perpage', true);
  1569. $category = $this->input->post('category', true);
  1570. $size = $this->input->post('size', true);
  1571. $grade = $this->input->post('grade', true);
  1572. $color = $this->input->post('color', true);
  1573. $lowe = $this->input->post('lowe', true);
  1574. $sku = $this->input->post('sku');
  1575. $title = $this->input->post('title');
  1576. $warehouse = $this->input->post('warehouse', true);
  1577. $usa = $this->input->post('usa', true);
  1578. $purchase = $this->input->post('purchase', true);
  1579. $lacetype = $this->input->post('lacetype', true);
  1580. $haircap = $this->input->post('haircap', true);
  1581. $density = $this->input->post('density', true);
  1582. $details = $this->input->post('details', true);
  1583. $state = $this->input->post('state', true);
  1584. $shop = $this->input->post('shop', true);
  1585. $lacecolor = $this->input->post('lacecolor', true);
  1586. $hairnumber = $this->input->post('hairnumber', true);
  1587. $type = $this->input->post('type', true);
  1588. $ktime = $this->input->post('ktime', true);
  1589. $jtime = $this->input->post('jtime', true);
  1590. $ktime = strtotime($ktime);
  1591. $jtime = strtotime($jtime);
  1592. $cpbz = $this->input->post('cpbz', true);
  1593. $sm = $this->input->post('sm', true);
  1594. $where = "1=1";
  1595. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1596. $where_no_features = "1=1";
  1597. if ($usa) {
  1598. if (!$warehouse) {
  1599. $where .= " and (warehouse = '5' or warehouse = '8')";
  1600. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1601. }
  1602. }
  1603. if ($warehouse) {
  1604. $where .= " and warehouse = '$warehouse'";
  1605. $where_no_features .= " and warehouse = '$warehouse'";
  1606. }
  1607. if ($details) {
  1608. $where .= " and details = '$details'";
  1609. $where_no_features .= " and details = '$details'";
  1610. }
  1611. if ($purchase) {
  1612. $where .= " and purchase = '$purchase'";
  1613. $where_no_features .= " and purchase = '$purchase'";
  1614. }
  1615. if ($state) {
  1616. $where .= " and state = '$state'";
  1617. $where_no_features .= " and state = '$state'";
  1618. }
  1619. if ($shop) {
  1620. $where .= " and shop like '%$shop%'";
  1621. $where_no_features .= " and shop like '%$shop%'";
  1622. }
  1623. if ($type) {
  1624. $where .= " and type = '$type'";
  1625. $where_no_features .= " and type = '$type'";
  1626. }
  1627. if ($cpbz) {
  1628. $where .= " and cpbz like '%$cpbz%' ";
  1629. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1630. }
  1631. if ($sm) {
  1632. $where .= " and sm like '%$sm%' ";
  1633. $where_no_features .= " and sm like '%$sm%' ";
  1634. }
  1635. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1636. if ($lacecolor) {
  1637. $where .= " and features like '%-$lacecolor-%'";
  1638. }
  1639. if ($lacetype) {
  1640. $where .= " and features like '%-$lacetype-%'";
  1641. }
  1642. if ($category) {
  1643. $where .= " and features like '%-$category-%'";
  1644. }
  1645. if ($size) {
  1646. $where .= " and features like '%-$size-%'";
  1647. }
  1648. if ($grade) {
  1649. $where .= " and features like '%-$grade-%'";
  1650. }
  1651. if ($color) {
  1652. $where .= " and features like '%-$color-%'";
  1653. }
  1654. if ($lowe) {
  1655. $where .= " and features like '%-$lowe-%'";
  1656. }
  1657. if ($haircap) {
  1658. $where .= " and features like '%-$haircap-%'";
  1659. }
  1660. if ($density) {
  1661. $where .= " and features like '%-$density-%'";
  1662. }
  1663. if (!empty($hairnumber)) {
  1664. $where .= " and features like '%-128-%' ";
  1665. if ($hairnumber < 0) {
  1666. $class_list = $this->typeclass->find_all('classid = 43');
  1667. foreach ($class_list as $v) {
  1668. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1669. }
  1670. } else {
  1671. $where .= " and features like '%-$hairnumber-%'";
  1672. }
  1673. }
  1674. //数据排序
  1675. $order_str = "id desc";
  1676. if (empty($page)) {
  1677. $start = 0;
  1678. $perpage = 1;
  1679. } else {
  1680. $start = ($page - 1) * $perpage;
  1681. }
  1682. $fjnr = '';
  1683. if ($sku) {
  1684. $sku = trim($sku, ' ');
  1685. $sku = trim($sku, ' ');
  1686. $fjnr .= " and sku like '%$sku%'";
  1687. }
  1688. if ($title) {
  1689. $title = trim($title, ' ');
  1690. $title = trim($title, ' ');
  1691. $fjnr .= " and title like '%$title%'";
  1692. }
  1693. $wt = array();
  1694. $whlabel_type = $this->whlabel_type->find_all();
  1695. foreach ($whlabel_type as $v) {
  1696. $wt[$v['id']] = $v['title'];
  1697. }
  1698. // 列表分组(与原来完全一致)
  1699. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage);
  1700. //取得信息列表
  1701. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1702. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1703. $keys = array();
  1704. foreach ($info_list as $v) {
  1705. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1706. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1707. }
  1708. // 组合键函数,用于 PHP 端按分组索引
  1709. $comboKey = function ($r) {
  1710. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1711. };
  1712. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1713. $all_qb = array();
  1714. if (!empty($keys)) {
  1715. $keyInSql = implode(',', $keys);
  1716. $qbAll = $this->whlabel->find_all(
  1717. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1718. );
  1719. foreach ($qbAll as $r) {
  1720. $all_qb[$comboKey($r)][] = $r;
  1721. }
  1722. }
  1723. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1724. $all_zt = array();
  1725. if (!empty($info_list)) {
  1726. $ztKeys = array();
  1727. foreach ($info_list as $v) {
  1728. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1729. . addslashes($v['warehouse']) . "','"
  1730. . addslashes($v['features']) . "')";
  1731. }
  1732. $ztInSql = implode(',', $ztKeys);
  1733. $ztAll = $this->whlabeltransport->find_all(
  1734. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1735. '*',
  1736. 'stime'
  1737. );
  1738. foreach ($ztAll as $r) {
  1739. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1740. $all_zt[$ck][] = $r;
  1741. }
  1742. }
  1743. $rows = array();
  1744. $list = array();
  1745. foreach ($info_list as $key => $value) {
  1746. if (isset($wt[$value['type']])) {
  1747. $info_list[$key]['type'] = $wt[$value['type']];
  1748. } else {
  1749. $info_list[$key]['type'] = '未设置';
  1750. }
  1751. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1752. // transport 在途数据:从预取数组中取
  1753. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1754. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1755. $ztdata = '';
  1756. if (count($zt) > 0) {
  1757. foreach ($zt as $vv) {
  1758. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1759. }
  1760. }
  1761. // whlabel 组数据:从预取数组中取
  1762. $qbCk = $comboKey($value);
  1763. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1764. $cdata = array_filter($qbdata, function ($item) {
  1765. return $item['state'] < 1;
  1766. });
  1767. $c = array_sum(array_column($cdata, 'jnum'));
  1768. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1769. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1770. });
  1771. $g = array_sum(array_column($gdata, 'jnum'));
  1772. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1773. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1774. });
  1775. $x = array_sum(array_column($xdata, 'jnum'));
  1776. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1777. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1778. });
  1779. $t = array_sum(array_column($tdata, 'jnum'));
  1780. $zdata = array_filter($qbdata, function ($item) {
  1781. return $item['zd'] != "" && $item['state'] < 1;
  1782. });
  1783. $z = array_sum(array_column($zdata, 'jnum'));
  1784. $detailsArr = array();
  1785. $cpid = array();
  1786. $od = array();
  1787. $odid = '';
  1788. $companytitle = '';
  1789. $shop_list = [];
  1790. foreach ($qbdata as $v) {
  1791. if ($v['zd'] != "" && $v['state'] < 1) {
  1792. if (!isset($od[$v['zd']])) {
  1793. $od[$v['zd']] = 1;
  1794. } else {
  1795. $od[$v['zd']] = $od[$v['zd']] + 1;
  1796. }
  1797. }
  1798. if ($v['state'] == 0) {
  1799. $detailsArr[$v['details']] = $v['details'];
  1800. }
  1801. if ($v['state'] < 1) {
  1802. if ($v['cpid'] != 0) {
  1803. $cpid[$v['cpid']] = $v['cpid'];
  1804. }
  1805. }
  1806. if ($v['state'] == 0) {
  1807. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1808. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1809. }
  1810. if ($v['shop'] != '') {
  1811. $shopArr = explode(',', trim($v['shop'], ','));
  1812. foreach ($shopArr as $vv) {
  1813. if (!in_array($vv, $shop_list)) {
  1814. $shop_list[] = $vv;
  1815. }
  1816. }
  1817. }
  1818. }
  1819. }
  1820. foreach ($od as $k => $vv) {
  1821. $odid .= $k . '数量' . $vv;
  1822. }
  1823. $info_list[$key]['cpbz'] = $value['cpbz'];
  1824. $info_list[$key]['label'] = $value['sm'];
  1825. $number = $value['number'];
  1826. $z = $z . '(' . $odid . ')';
  1827. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1828. $info_list[$key]['features'] = $c;
  1829. $info_list[$key]['number'] = $ztdata;
  1830. $info_list[$key]['sm'] = $g;
  1831. $info_list[$key]['x'] = $x;
  1832. $info_list[$key]['t'] = $t;
  1833. $info_list[$key]['z'] = $z;
  1834. $info_list[$key]['shop'] = '';
  1835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1836. $shop_list = array_unique($shop_list);
  1837. $shop_str = '';
  1838. foreach ($shop_list as $v) {
  1839. if (isset($sp[$v])) {
  1840. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1841. }
  1842. }
  1843. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1844. }
  1845. $final_all_list = [];
  1846. foreach ($info_list as $k => $v) {
  1847. $final_all_list[] = [
  1848. 'id' => $v['id'],
  1849. "warehouse" => $v["warehouse"],
  1850. "purchase" => $v["purchase"],
  1851. "sku" => $v["sku"],
  1852. "title" => $v["title"] . "<br/>" . $v["pm"],
  1853. "details" => $v["details"],
  1854. "shop" => $v["shop"],
  1855. "cpbz" => $v["cpbz"],
  1856. 'label' => $v['label'],
  1857. "type" => $v["type"],
  1858. "features" => $v["features"],
  1859. "number" => $v["number"],
  1860. "sm" => $v["sm"],
  1861. "x" => $v["x"],
  1862. "t" => $v["t"],
  1863. "z" => $v["z"]
  1864. ];
  1865. }
  1866. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1867. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1868. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1869. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1870. $countResult = $this->whlabel->query($countSql)->result_array();
  1871. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1872. $pagenum = ceil($total / $perpage);
  1873. $over = $total - ($start + $perpage);
  1874. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1875. echo json_encode($rows);
  1876. exit;
  1877. }
  1878. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1879. $this->data['shop'] = $wlshop;
  1880. $this->data['vip'] = $vip;
  1881. $this->_Template('whlabel_typev1', $this->data);
  1882. }
  1883. //美仓进销存浏览
  1884. public function _usatype()
  1885. {
  1886. if (isset($_SESSION['api'])) {
  1887. $user = $this->user->get_api($_SESSION['api']);
  1888. $usp = $user;
  1889. $fgshop = "";
  1890. $sid = "";
  1891. $wid = "";
  1892. $wtype = "";
  1893. $userwh = explode('|', trim($user['warehouse'], '|'));
  1894. foreach ($userwh as $value) {
  1895. $wid .= " id = " . $value . " or";
  1896. $wtype .= " type = " . $value . " or";
  1897. }
  1898. }
  1899. $prc = array();
  1900. $purchase = $this->purchase->find_all();
  1901. foreach ($purchase as $k => $v) {
  1902. $prc[$v['id']] = $v['title'];
  1903. }
  1904. $post = $this->input->post(NULL, TRUE);
  1905. if (isset($post['page'])) {
  1906. $page = $this->input->post('page', true);
  1907. $perpage = $this->input->post('perpage', true);
  1908. $category = $this->input->post('category', true);
  1909. $size = $this->input->post('size', true);
  1910. $grade = $this->input->post('grade', true);
  1911. $color = $this->input->post('color', true);
  1912. $lowe = $this->input->post('lowe', true);
  1913. $sku = $this->input->post('sku');
  1914. $title = $this->input->post('title');
  1915. $warehouse = $this->input->post('warehouse', true);
  1916. $usa = $this->input->post('usa', true);
  1917. $purchase = $this->input->post('purchase', true);
  1918. $lacetype = $this->input->post('lacetype', true);
  1919. $haircap = $this->input->post('haircap', true);
  1920. $density = $this->input->post('density', true);
  1921. $details = $this->input->post('details', true);
  1922. $state = $this->input->post('state', true);
  1923. $lacecolor = $this->input->post('lacecolor', true);
  1924. $cklx = $this->input->post('cklx', true);
  1925. $ktime = $this->input->post('ktime', true);
  1926. $jtime = $this->input->post('jtime', true);
  1927. $ktime = strtotime($ktime);
  1928. $jtime = strtotime($jtime);
  1929. $where = "1=1";
  1930. $gj = "";
  1931. $ck = "";
  1932. if ($lacetype) {
  1933. $where .= " and features like '%-$lacetype-%'";
  1934. }
  1935. if ($category) {
  1936. $where .= " and features like '%-$category-%'";
  1937. }
  1938. if ($size) {
  1939. $where .= " and features like '%-$size-%'";
  1940. }
  1941. if ($grade) {
  1942. $where .= " and features like '%-$grade-%'";
  1943. }
  1944. if ($color) {
  1945. $where .= " and features like '%-$color-%'";
  1946. }
  1947. if ($lowe) {
  1948. $where .= " and features like '%-$lowe-%'";
  1949. }
  1950. if ($haircap) {
  1951. $where .= " and features like '%-$haircap-%'";
  1952. }
  1953. if ($density) {
  1954. $where .= " and features like '%-$density-%'";
  1955. }
  1956. if ($lacecolor) {
  1957. $where .= " and features like '%-$lacecolor-%'";
  1958. }
  1959. if ($usa) {
  1960. if (!$warehouse) {
  1961. $where .= " and (warehouse = '5' or warehouse = '8')";
  1962. }
  1963. }
  1964. if ($warehouse) {
  1965. $where .= " and warehouse = '$warehouse'";
  1966. }
  1967. if ($details) {
  1968. $where .= " and details = '$details'";
  1969. }
  1970. if ($purchase) {
  1971. $where .= " and purchase = '$purchase'";
  1972. }
  1973. if ($state) {
  1974. $where .= " and state = '$state'";
  1975. }
  1976. $where_add = '';
  1977. if ($cklx) {
  1978. $shop = $this->shop->read($cklx);
  1979. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1980. }
  1981. if ($ktime && $jtime) {
  1982. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1983. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1984. }
  1985. //数据排序
  1986. $order_str = "id desc";
  1987. if (empty($page)) {
  1988. $start = 0;
  1989. $perpage = 1;
  1990. } else {
  1991. $start = ($page - 1) * $perpage;
  1992. }
  1993. if ($sku) {
  1994. $sku = trim($sku, ' ');
  1995. $sku = trim($sku, ' ');
  1996. $where .= " and sku like '%$sku%'";
  1997. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1998. } else if ($title) {
  1999. $title = trim($title, ' ');
  2000. $title = trim($title, ' ');
  2001. $where .= " and title like '%$title%'";
  2002. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2003. } else {
  2004. //$where .= " and time > '$ktime' and time < '$jtime'";
  2005. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2006. }
  2007. //取得信息列表
  2008. $rows = array();
  2009. $list = array();
  2010. foreach ($info_list as $key => $value) {
  2011. $warehouse = $this->warehouse->read($value['warehouse']);
  2012. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2013. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2016. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2017. $od = array();
  2018. $odid = '';
  2019. foreach ($z as $v) {
  2020. if (!isset($od[$v['zd']])) {
  2021. $od[$v['zd']] = 1; //所有数据sku
  2022. } else {
  2023. $od[$v['zd']] = $od[$v['zd']] + 1;
  2024. }
  2025. }
  2026. foreach ($od as $k => $vv) {
  2027. $odid .= $k . '数量' . $vv . ' ';
  2028. }
  2029. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2030. $info_list[$key]['features'] = $c;
  2031. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2032. $ztdata = '';
  2033. if (count($zt) > 0) {
  2034. foreach ($zt as $vv) {
  2035. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2036. }
  2037. }
  2038. $info_list[$key]['warehouse'] = $ztdata;
  2039. $info_list[$key]['g'] = $g;
  2040. $info_list[$key]['x'] = $x;
  2041. $info_list[$key]['t'] = $t;
  2042. $info_list[$key]['z'] = $z;
  2043. }
  2044. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2045. $pagenum = ceil($total / $perpage);
  2046. $over = $total - ($start + $perpage);
  2047. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2048. echo json_encode($rows);
  2049. exit;
  2050. }
  2051. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2052. $this->data['warehouse'] = $warehouse;
  2053. $this->_Template('whlabel_typeusa', $this->data);
  2054. }
  2055. //美仓进销存浏览
  2056. public function _usatypeapp()
  2057. {
  2058. $post = $this->input->post(NULL, TRUE);
  2059. if (isset($post['page'])) {
  2060. $page = $this->input->post('page', true);
  2061. $perpage = $this->input->post('perpage', true);
  2062. $sku = $this->input->post('sku', true);
  2063. $warehouse = 5;
  2064. $title = $this->input->post('title', true);
  2065. $state = $this->input->post('state', true);
  2066. $ktime = $this->input->post('ktime', true);
  2067. $jtime = $this->input->post('jtime', true);
  2068. $ktime = strtotime($ktime);
  2069. $jtime = strtotime($jtime);
  2070. $where = "1=1";
  2071. $gj = "";
  2072. $ck = "";
  2073. if ($title) {
  2074. $st = explode(' ', trim($title, ' '));
  2075. foreach ($st as $v) {
  2076. $where .= " and title like '%$v%'";
  2077. }
  2078. }
  2079. if ($warehouse) {
  2080. $where .= " and warehouse = '$warehouse'";
  2081. }
  2082. if ($state) {
  2083. $where .= " and state = '$state'";
  2084. }
  2085. if ($sku) {
  2086. $where .= " and sku like '%$sku%'";
  2087. }
  2088. if ($ktime && $jtime) {
  2089. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2090. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2091. }
  2092. //数据排序
  2093. $order_str = "id desc";
  2094. if (empty($page)) {
  2095. $start = 0;
  2096. $perpage = 1;
  2097. } else {
  2098. $start = ($page - 1) * $perpage;
  2099. }
  2100. //取得信息列表
  2101. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2102. $rows = array();
  2103. $list = array();
  2104. foreach ($info_list as $key => $value) {
  2105. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2106. }
  2107. $rowsdq = array_slice($rows, $start, $perpage);
  2108. foreach ($rowsdq as $value) {
  2109. $warehouse = $this->warehouse->read($value['warehouse']);
  2110. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2111. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2112. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2113. $od = array();
  2114. $odid = '';
  2115. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2116. }
  2117. $total = count($rows);
  2118. $pagenum = ceil($total / $perpage);
  2119. $over = $total - ($start + $perpage);
  2120. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2121. echo json_encode($rows);
  2122. exit;
  2123. }
  2124. $this->_Template('phone/p_usatypeapp', $this->data);
  2125. }
  2126. //入库操作
  2127. public function _enteradd()
  2128. {
  2129. $dt = 0;
  2130. if (isset($_SESSION['api'])) {
  2131. $user = $this->user->get_api($_SESSION['api']);
  2132. $usp = $user;
  2133. $fgshop = "";
  2134. $sid = "";
  2135. $user = explode('|', trim($user['shop'], '|'));
  2136. foreach ($user as $value) {
  2137. $fgshop .= " shop = " . $value . " or";
  2138. $sid .= " id = " . $value . " or";
  2139. }
  2140. }
  2141. $tc = $this->typeclass->find_all();
  2142. $typeclass = array();
  2143. foreach ($tc as $v) {
  2144. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2145. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2146. }
  2147. $post = $this->input->post(NULL, TRUE);
  2148. if (isset($post['sku'])) {
  2149. $list = array();
  2150. $num = "";
  2151. $title = "";
  2152. $features = "";
  2153. $order = $this->input->post('order', true);
  2154. $shop = $this->input->post('shop', true);
  2155. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2156. $sku = $this->input->post('sku', true);
  2157. $post['sm'] = $this->input->post('sm', true);
  2158. $post['warehouse'] = $this->input->post('warehouse', true);
  2159. $post['purchase'] = $this->input->post('purchase', true);
  2160. $post['retreatwarehouse'] = $post['warehouse'];
  2161. $post['state'] = $this->input->post('state', true);
  2162. $post['rktype'] = $this->input->post('rktype', true);
  2163. $post['text'] = $this->input->post('text', true);
  2164. $category = $this->input->post('category', true);
  2165. $list['category'] = $category;
  2166. $list['hairtype'] = $this->input->post('hairtype', true);
  2167. $list['grade'] = $this->input->post('grade', true);
  2168. $size = $this->input->post('size', true);
  2169. $xzsku = $this->input->post('xzsku', true);
  2170. $list['size'] = rtrim($size, ',');
  2171. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2172. $list['extension'] = $this->input->post('extension', true);
  2173. if ($category == 1297) {
  2174. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2175. }
  2176. if ($category == 1702) {
  2177. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2178. $list['syother'] = $this->input->post('syother', true);
  2179. }
  2180. if ($category == 133) {
  2181. $list['fittype'] = $this->input->post('fittype', true);
  2182. $list['acother'] = $this->input->post('acother', true);
  2183. }
  2184. $list['color'] = $this->input->post('color', true);
  2185. $list['lowe'] = $this->input->post('lowe', true);
  2186. if (!$post['purchase']) {
  2187. $post['purchase'] = 1;
  2188. }
  2189. if ($category == 127) {
  2190. $list['type'] = $this->input->post('type', true);
  2191. $list['headroad'] = $this->input->post('headroad', true);
  2192. $list['density'] = $this->input->post('density', true);
  2193. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. }
  2196. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2197. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2198. }
  2199. if ($category == 128) {
  2200. $list['lacetype'] = $this->input->post('lacetype', true);
  2201. $list['haircap'] = $this->input->post('haircap', true);
  2202. $list['density'] = $this->input->post('density', true);
  2203. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2204. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2205. $list['wigother'] = $this->input->post('wigother', true);
  2206. $list['wigother1'] = $this->input->post('wigother1', true);
  2207. $list['wigother2'] = $this->input->post('wigother2', true);
  2208. $list['product_related'] = $this->input->post('product_related', true);
  2209. }
  2210. if ($category == 129) {
  2211. $list['wide'] = $this->input->post('wide', true);
  2212. }
  2213. if ($category == 131) {
  2214. $list['gifttype'] = $this->input->post('gifttype', true);
  2215. $list['giftother'] = $this->input->post('giftother', true);
  2216. }
  2217. if ($category == 134) {
  2218. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2219. }
  2220. if ($category == 1297) {
  2221. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2222. $list['sywigother'] = $this->input->post('sywigother', true);
  2223. }
  2224. if ($category == 130 || $category == 133 || $category == 1702) {
  2225. $list['items'] = $this->input->post('items', true);
  2226. $list['weight'] = $this->input->post('weight', true);
  2227. }
  2228. if($category == 130){
  2229. $list['jfother'] = $this->input->post('jfother', true);
  2230. }
  2231. if ($category == 1702) {
  2232. $list['syhairther'] = $this->input->post('syhairther', true);
  2233. }
  2234. $classid = $this->classid->sku();
  2235. $scsku = $classid;
  2236. $pm = $classid;
  2237. foreach ($list as $k => $v) {
  2238. if ($v != 0) {
  2239. $num .= $v;
  2240. $features .= $v . '-';
  2241. $post[$k] = $v;
  2242. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2243. if ($k != 'size') {
  2244. $title .= $typeclass[$v]['title'] . " ";
  2245. }
  2246. if (isset($pm[$typeclass[$v]['classid']])) {
  2247. if ($typeclass[$v]['title'] == '9A') {
  2248. $pm[$typeclass[$v]['classid']] = '9A';
  2249. } else if ($typeclass[$v]['title'] == '10A') {
  2250. $pm[$typeclass[$v]['classid']] = '10A';
  2251. } else {
  2252. $clzh = $typeclass[$v]['zh'];
  2253. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2254. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2255. $clzh = $clzh[0];
  2256. }
  2257. $pm[$typeclass[$v]['classid']] = $clzh;
  2258. }
  2259. }
  2260. }
  2261. }
  2262. $zh = implode(" ", $pm);
  2263. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2264. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2265. if ($list['size']) {
  2266. $typeclass = $this->typeclass->read($list['size']);
  2267. $title .= $typeclass['title'];
  2268. }
  2269. $time = time();
  2270. if ($xzsku) {
  2271. $scsku = implode("-", $scsku);
  2272. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2273. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2274. $post['sku'] = trim($scsku, ' ');
  2275. } else {
  2276. $post['sku'] = $sku;
  2277. }
  2278. //$post['sku'] = trim($sku,' ');
  2279. $post['title'] = rtrim($title, ' ');
  2280. $post['number'] = $num;
  2281. $post['features'] = '-' . $features;
  2282. $post['enter'] = $time;
  2283. $post['time'] = $time; //操作时间
  2284. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2285. if ($yza) {
  2286. if ($post['features'] != $yza[0]['features']) {
  2287. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2288. exit;
  2289. }
  2290. }
  2291. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2292. if ($yzb) {
  2293. if ($post['sku'] != $yzb[0]['sku']) {
  2294. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2295. exit;
  2296. }
  2297. }
  2298. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2299. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2300. exit;
  2301. }
  2302. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2303. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2304. exit;
  2305. }
  2306. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2307. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2308. exit;
  2309. }
  2310. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2311. if (isset($yz[0]['type'])) {
  2312. $post['type'] = $yz[0]['type'];
  2313. }
  2314. if ($post['state'] == 9) //如果选择预设库存
  2315. {
  2316. $this->whlabel->insert($post);
  2317. } else {
  2318. /**
  2319. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2320. if($ljg == 1)
  2321. {
  2322. for($i=0;$i<$order;$i++)
  2323. {
  2324. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2325. $this->whlabel->insert($post);
  2326. }
  2327. }
  2328. **/
  2329. //if($post['warehouse'] == '5')
  2330. //{
  2331. //}
  2332. $yydata = $post;
  2333. $yydata['zh'] = $zh;
  2334. /**
  2335. $wl = $this->apiyy->get_cjlp($yydata);
  2336. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2337. {
  2338. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2339. }
  2340. if($wl['Data'][0]['m_isSucess'] != 1)
  2341. {
  2342. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2343. }
  2344. **/
  2345. for ($i = 0; $i < $order; $i++) {
  2346. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2347. $this->whlabel->insert($post);
  2348. }
  2349. }
  2350. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2351. exit;
  2352. }
  2353. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2354. $this->data['wlshop'] = $wlshop;
  2355. $this->_Template('whlabel_enteradd', $this->data);
  2356. }
  2357. //修改产品
  2358. public function _enteredit($arg_array)
  2359. {
  2360. $dt = 0;
  2361. if (isset($_SESSION['api'])) {
  2362. $user = $this->user->get_api($_SESSION['api']);
  2363. $usp = $user;
  2364. $fgshop = "";
  2365. $sid = "";
  2366. $user = explode('|', trim($user['shop'], '|'));
  2367. foreach ($user as $value) {
  2368. $fgshop .= " shop = " . $value . " or";
  2369. $sid .= " id = " . $value . " or";
  2370. }
  2371. }
  2372. $post = $this->input->post(NULL, TRUE);
  2373. if (isset($post['sku'])) {
  2374. $list = array();
  2375. $num = "";
  2376. $title = "";
  2377. $features = "";
  2378. $id = $this->input->post('id', true);
  2379. $order = $this->input->post('order', true);
  2380. $shop = $this->input->post('shop', true);
  2381. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2382. $post['sku'] = $this->input->post('sku', true);
  2383. $post['sm'] = $this->input->post('sm', true);
  2384. $post['warehouse'] = $this->input->post('warehouse', true);
  2385. $post['purchase'] = $this->input->post('purchase', true);
  2386. $post['retreatwarehouse'] = $post['warehouse'];
  2387. $category = $this->input->post('category', true);
  2388. $list['category'] = $category;
  2389. $list['hairtype'] = $this->input->post('hairtype', true);
  2390. $list['grade'] = $this->input->post('grade', true);
  2391. $size = $this->input->post('size', true);
  2392. $list['size'] = rtrim($size, ',');
  2393. $post['rktype'] = $this->input->post('rktype', true);
  2394. $post['text'] = $this->input->post('text', true);
  2395. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2396. $list['extension'] = $this->input->post('extension', true);
  2397. if ($category == 1297) {
  2398. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2399. }
  2400. if ($category == 1702) {
  2401. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2402. $list['syother'] = $this->input->post('syother', true);
  2403. }
  2404. if ($category == 133) {
  2405. $list['fittype'] = $this->input->post('fittype', true);
  2406. $list['acother'] = $this->input->post('acother', true);
  2407. }
  2408. $list['color'] = $this->input->post('color', true);
  2409. $list['lowe'] = $this->input->post('lowe', true);
  2410. if (!$post['purchase']) {
  2411. $post['purchase'] = 1;
  2412. }
  2413. if ($category == 127) {
  2414. $list['type'] = $this->input->post('type', true);
  2415. $list['headroad'] = $this->input->post('headroad', true);
  2416. $list['density'] = $this->input->post('density', true);
  2417. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2418. $list['lacesize'] = $this->input->post('lacesize', true);
  2419. }
  2420. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2421. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2422. }
  2423. if ($category == 128) {
  2424. $list['lacetype'] = $this->input->post('lacetype', true);
  2425. $list['haircap'] = $this->input->post('haircap', true);
  2426. $list['density'] = $this->input->post('density', true);
  2427. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2428. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2429. $list['wigother'] = $this->input->post('wigother', true);
  2430. $list['wigother1'] = $this->input->post('wigother1', true);
  2431. $list['wigother2'] = $this->input->post('wigother2', true);
  2432. $list['product_related'] = $this->input->post('product_related', true);
  2433. }
  2434. if ($category == 129) {
  2435. $list['wide'] = $this->input->post('wide', true);
  2436. }
  2437. if ($category == 131) {
  2438. $list['gifttype'] = $this->input->post('gifttype', true);
  2439. $list['giftother'] = $this->input->post('giftother', true);
  2440. }
  2441. if ($category == 134) {
  2442. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2443. }
  2444. if ($category == 1297) {
  2445. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2446. $list['sywigother'] = $this->input->post('sywigother', true);
  2447. }
  2448. if ($category == 130 || $category == 133 || $category == 1702) {
  2449. $list['items'] = $this->input->post('items', true);
  2450. $list['weight'] = $this->input->post('weight', true);
  2451. }
  2452. if($category == 130){
  2453. $list['jfother'] = $this->input->post('jfother', true);
  2454. }
  2455. if ($category == 1702) {
  2456. $list['syhairther'] = $this->input->post('syhairther', true);
  2457. }
  2458. foreach ($list as $k => $v) {
  2459. if ($v != 0) {
  2460. $num .= $v;
  2461. $features .= $v . '-';
  2462. $typeclass = $this->typeclass->read($v);
  2463. if ($k != 'size') {
  2464. $title .= $typeclass['title'] . " ";
  2465. }
  2466. }
  2467. }
  2468. $typeclass = $this->typeclass->read($list['size']);
  2469. $title .= $typeclass['title'];
  2470. $time = time();
  2471. $post['title'] = rtrim($title, ' ');
  2472. $post['number'] = $num;
  2473. $post['features'] = '-' . $features;
  2474. $post['time'] = $time; //操作时间
  2475. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2476. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2477. exit;
  2478. }
  2479. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2480. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2481. exit;
  2482. }
  2483. $uid = $this->whlabel->read($id);
  2484. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2485. if ($datanum > 0) {
  2486. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2487. exit;
  2488. }
  2489. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2490. {
  2491. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2492. if ($yza) {
  2493. if ($post['features'] != $yza[0]['features']) {
  2494. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2495. exit;
  2496. }
  2497. }
  2498. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2499. if ($yzb) {
  2500. if ($post['sku'] != $yzb[0]['sku']) {
  2501. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2502. exit;
  2503. }
  2504. }
  2505. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2506. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2507. exit;
  2508. }
  2509. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2510. foreach ($data as $v) {
  2511. $post['id'] = $v['id'];
  2512. $this->whlabel->save($post, $v['id']);
  2513. }
  2514. } else {
  2515. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2516. if ($data > 0) {
  2517. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2518. exit;
  2519. } else {
  2520. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2521. foreach ($data as $v) {
  2522. $post['id'] = $v['id'];
  2523. $this->whlabel->save($post, $v['id']);
  2524. }
  2525. }
  2526. }
  2527. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2528. exit;
  2529. }
  2530. $uid = $this->whlabel->read($arg_array[0]);
  2531. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2532. $this->data['enter'] = $uid;
  2533. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2534. $this->data['wlshop'] = $wlshop;
  2535. $this->_Template('whlabel_enteredit', $this->data);
  2536. }
  2537. //入库浏览
  2538. public function _enter()
  2539. {
  2540. $post = $this->input->post(NULL, TRUE);
  2541. if (isset($post['s'])) {
  2542. $id_arr = $this->input->post('s');
  2543. $id_arr = explode(',', $id_arr);
  2544. if (!$id_arr) {
  2545. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2546. exit;
  2547. }
  2548. //循环删除记录
  2549. foreach ($id_arr as $v) {
  2550. $sid = $this->whlabel->read($v);
  2551. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2552. if ($count > 0) {
  2553. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2554. exit;
  2555. }
  2556. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2557. foreach ($info_list as $va) {
  2558. $this->whlabel->remove($va['id']);
  2559. }
  2560. }
  2561. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2562. exit;
  2563. }
  2564. $sp = array();
  2565. $s = $this->shop->find_all('1=1', 'id,shopname');
  2566. foreach ($s as $v) {
  2567. $sp[$v['id']] = $v['shopname'];
  2568. }
  2569. $wh = array();
  2570. $w = $this->warehouse->find_all('1=1', 'id,title');
  2571. foreach ($w as $v) {
  2572. $wh[$v['id']] = $v['title'];
  2573. }
  2574. if (isset($post['page'])) {
  2575. $page = $this->input->post('page', true);
  2576. $perpage = $this->input->post('perpage', true);
  2577. $category = $this->input->post('category', true);
  2578. $size = $this->input->post('size', true);
  2579. $grade = $this->input->post('grade', true);
  2580. $color = $this->input->post('color', true);
  2581. $lowe = $this->input->post('lowe', true);
  2582. $sku = $this->input->post('sku', true);
  2583. $warehouse = $this->input->post('warehouse', true);
  2584. $purchase = $this->input->post('purchase', true);
  2585. $ktime = $this->input->post('ktime', true);
  2586. $jtime = $this->input->post('jtime', true);
  2587. $ktime = strtotime($ktime);
  2588. $jtime = strtotime($jtime);
  2589. $where = "1=1";
  2590. $gj = "";
  2591. $ck = "";
  2592. if ($category) {
  2593. $where .= " and features like '%-$category-%'";
  2594. }
  2595. if ($size) {
  2596. $where .= " and features like '%-$size-%'";
  2597. }
  2598. if ($grade) {
  2599. $where .= " and features like '%-$grade-%'";
  2600. }
  2601. if ($color) {
  2602. $where .= " and features like '%-$color-%'";
  2603. }
  2604. if ($lowe) {
  2605. $where .= " and features like '%-$lowe-%'";
  2606. }
  2607. if ($warehouse) {
  2608. $where .= " and warehouse = '$warehouse'";
  2609. }
  2610. if ($purchase) {
  2611. $where .= " and purchase = '$purchase'";
  2612. }
  2613. if ($sku) {
  2614. $where .= " and sku like '%$sku%'";
  2615. }
  2616. if ($ktime && $jtime) {
  2617. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2618. }
  2619. //数据排序
  2620. $order_str = "enter desc";
  2621. if (empty($page)) {
  2622. $start = 0;
  2623. $perpage = 1;
  2624. } else {
  2625. $start = ($page - 1) * $perpage;
  2626. }
  2627. //取得信息列表
  2628. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2629. foreach ($info_list as $k => $v) {
  2630. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2631. if ($v['shop'] == '') {
  2632. $s = '通用';
  2633. } else {
  2634. $info_list[$k]['shop'] = '';
  2635. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2636. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2637. }
  2638. }
  2639. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2640. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2641. $info_list[$k]['g'] = $g;
  2642. }
  2643. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2644. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->_Template('whlabel_enter', $this->data);
  2652. }
  2653. //出库浏览
  2654. public function _out()
  2655. {
  2656. $post = $this->input->post(NULL, TRUE);
  2657. if (isset($post['page'])) {
  2658. $page = $this->input->post('page', true);
  2659. $perpage = $this->input->post('perpage', true);
  2660. $category = $this->input->post('category', true);
  2661. $size = $this->input->post('size', true);
  2662. $grade = $this->input->post('grade', true);
  2663. $color = $this->input->post('color', true);
  2664. $lowe = $this->input->post('lowe', true);
  2665. $sku = $this->input->post('sku', true);
  2666. $warehouse = $this->input->post('warehouse', true);
  2667. $purchase = $this->input->post('purchase', true);
  2668. $state = $this->input->post('state', true);
  2669. $ktime = $this->input->post('ktime', true);
  2670. $jtime = $this->input->post('jtime', true);
  2671. $ktime = strtotime($ktime);
  2672. $jtime = strtotime($jtime);
  2673. $where = "state=3";
  2674. $gj = "";
  2675. $ck = "";
  2676. if ($category) {
  2677. $where .= " and features like '%-$category-%'";
  2678. }
  2679. if ($size) {
  2680. $where .= " and features like '%-$size-%'";
  2681. }
  2682. if ($grade) {
  2683. $where .= " and features like '%-$grade-%'";
  2684. }
  2685. if ($color) {
  2686. $where .= " and features like '%-$color-%'";
  2687. }
  2688. if ($lowe) {
  2689. $where .= " and features like '%-$lowe-%'";
  2690. }
  2691. if ($state) {
  2692. $where .= " and state = '$state'";
  2693. }
  2694. if ($warehouse) {
  2695. $where .= " and warehouse = '$warehouse'";
  2696. }
  2697. if ($purchase) {
  2698. $where .= " and purchase = '$purchase'";
  2699. }
  2700. if ($sku) {
  2701. $where .= " and sku = '$sku'";
  2702. }
  2703. if ($ktime && $jtime) {
  2704. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2705. }
  2706. //数据排序
  2707. $order_str = "id desc";
  2708. if (empty($page)) {
  2709. $start = 0;
  2710. $perpage = 1;
  2711. } else {
  2712. $start = ($page - 1) * $perpage;
  2713. }
  2714. //取得信息列表
  2715. $info_list = $this->whlabel->find_all($where, 'sku');
  2716. $rows = array();
  2717. $list = array();
  2718. foreach ($info_list as $key => $value) {
  2719. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2720. }
  2721. $rows = array_unique($rows); //删除重复记录
  2722. foreach ($rows as $key => $value) {
  2723. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2724. $ck = $this->warehouse->read($data['warehouse']);
  2725. $warehouse = $ck['title'];
  2726. $gy = $this->purchase->read($data['purchase']);
  2727. $purchase = $gy['purchase'];
  2728. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2729. $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);
  2730. }
  2731. $total = count($list);
  2732. $pagenum = ceil($total / $perpage);
  2733. $over = $total - ($start + $perpage);
  2734. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2735. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2736. echo json_encode($rows);
  2737. exit;
  2738. }
  2739. $this->_Template('whlabel_out', $this->data);
  2740. }
  2741. //出库标签浏览
  2742. public function _label()
  2743. {
  2744. $post = $this->input->post(NULL, TRUE);
  2745. if (isset($post['page'])) {
  2746. $page = $this->input->post('page', true);
  2747. $perpage = $this->input->post('perpage', true);
  2748. $sku = $this->input->post('sku', true);
  2749. $warehouse = $this->input->post('warehouse', true);
  2750. $purchase = $this->input->post('purchase', true);
  2751. $orderinfo = $this->input->post('orderinfo', true);
  2752. $waybill = $this->input->post('waybill', true);
  2753. $category = $this->input->post('category', true);
  2754. $size = $this->input->post('size', true);
  2755. $grade = $this->input->post('grade', true);
  2756. $color = $this->input->post('color', true);
  2757. $lowe = $this->input->post('lowe', true);
  2758. $where = "state=1";
  2759. if ($sku) {
  2760. $where .= " and sku = '$sku'";
  2761. }
  2762. if ($warehouse) {
  2763. $where .= " and warehouse = '$warehouse'";
  2764. }
  2765. if ($purchase) {
  2766. $where .= " and purchase = '$purchase'";
  2767. }
  2768. if ($orderinfo) {
  2769. $where .= " and orderinfo = '$orderinfo'";
  2770. }
  2771. if ($waybill) {
  2772. $where .= " and waybill = '$waybill'";
  2773. }
  2774. if ($category) {
  2775. $where .= " and features like '%-$category-%'";
  2776. }
  2777. if ($size) {
  2778. $where .= " and features like '%-$size-%'";
  2779. }
  2780. if ($grade) {
  2781. $where .= " and features like '%-$grade-%'";
  2782. }
  2783. if ($color) {
  2784. $where .= " and features like '%-$color-%'";
  2785. }
  2786. if ($lowe) {
  2787. $where .= " and features like '%-$lowe-%'";
  2788. }
  2789. //数据排序
  2790. $order_str = "outk desc";
  2791. if (empty($page)) {
  2792. $start = 0;
  2793. $perpage = 1;
  2794. } else {
  2795. $start = ($page - 1) * $perpage;
  2796. }
  2797. //取得信息列表
  2798. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2799. foreach ($info_list as $key => $value) {
  2800. $warehouse = $this->warehouse->read($value['warehouse']);
  2801. $info_list[$key]['warehouse'] = $warehouse['title'];
  2802. $purchase = $this->purchase->read($value['purchase']);
  2803. $info_list[$key]['purchase'] = $purchase['title'];
  2804. if ($value['outk'] != 0) {
  2805. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2806. } else {
  2807. $info_list[$key]['outk'] = "";
  2808. }
  2809. if ($value['orderinfo'] == 0) {
  2810. $info_list[$key]['orderinfo'] = "";
  2811. }
  2812. if ($value['waybill'] == 0) {
  2813. $info_list[$key]['waybill'] = "";
  2814. }
  2815. }
  2816. $total = $this->whlabel->find_count($where);
  2817. $pagenum = ceil($total / $perpage);
  2818. $over = $total - ($start + $perpage);
  2819. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2820. echo json_encode($rows);
  2821. exit;
  2822. }
  2823. $this->_Template('whlabel_label', $this->data);
  2824. }
  2825. //独立站出库订单
  2826. public function _outorder()
  2827. {
  2828. if (isset($_SESSION['api'])) {
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $usp = $user;
  2831. $fgshop = "";
  2832. $sid = "";
  2833. $user = explode('|', trim($user['shop'], '|'));
  2834. foreach ($user as $value) {
  2835. $fgshop .= " shop = " . $value . " or";
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. } else {
  2839. echo "请重新登录";
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $sfxh = $this->input->post('sfxh', true);
  2854. $express = $this->input->post('express', true);
  2855. $waybill = $this->input->post('waybill', true);
  2856. $library = $this->input->post('library', true);
  2857. $country = $this->input->post('country', true);
  2858. $so = $this->input->post('so', true);
  2859. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2860. $print = $this->input->post('print', true);
  2861. $state = $this->input->post('state', true);
  2862. $orderurl = $this->input->post('orderurl', true);
  2863. $productid = $this->input->post('productid', true);
  2864. $timetk = strtotime($timetk);
  2865. $timetj = strtotime($timetj);
  2866. /**
  2867. $sj = $this->input->post('sj',true);
  2868. if($sj)
  2869. {
  2870. $sj = $this->input->post('sj',true);
  2871. }
  2872. else
  2873. {
  2874. $sj = "fullorder";
  2875. }
  2876. **/
  2877. $sj = "fullorder";
  2878. $where = "1=1";
  2879. if ($warehouse) {
  2880. $where .= " and type = '$warehouse'";
  2881. }
  2882. if ($timetk && $timetj) {
  2883. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2884. }
  2885. if ($orderinfo) {
  2886. $where .= " and orderinfo = '$orderinfo'";
  2887. }
  2888. if ($number) {
  2889. $where .= " and number = '$number'";
  2890. }
  2891. if ($express) {
  2892. $where .= " and express = '$express'";
  2893. }
  2894. if ($waybill) {
  2895. $where .= " and waybill = '$waybill'";
  2896. }
  2897. if ($library) {
  2898. $where .= " and library = '$library'";
  2899. }
  2900. if ($print) {
  2901. $where .= " and print = '$print'";
  2902. }
  2903. if ($libraryconfirm) {
  2904. $where .= " and libraryconfirm = '$libraryconfirm'";
  2905. }
  2906. if ($state) {
  2907. $where .= " and state = '$state'";
  2908. }
  2909. if ($shop) {
  2910. $where .= " and shop = '$shop'";
  2911. }
  2912. if ($country) {
  2913. $where .= " and country = '$country'";
  2914. }
  2915. if ($sfxh != '') {
  2916. $where .= " and sfxh = '$sfxh'";
  2917. }
  2918. if ($so) {
  2919. $where .= " and shipremarks like '%$so%'";
  2920. }
  2921. if ($source) {
  2922. if ($source == '2d') {
  2923. $where .= " and source >= '2'";
  2924. } else {
  2925. $where .= " and source = '$source'";
  2926. }
  2927. }
  2928. if (isset($_SESSION['api'])) {
  2929. foreach ($user as $value) {
  2930. $fgshop .= " shop = " . $value . " or";
  2931. }
  2932. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2933. }
  2934. if ($orderurl) {
  2935. $url = $this->orderurl->read($orderurl);
  2936. $where .= " and link like '%" . $url['url'] . "%'";
  2937. }
  2938. if($productid){
  2939. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2940. }
  2941. //数据排序
  2942. $order_str = "librarytime desc";
  2943. if (empty($page)) {
  2944. $start = 0;
  2945. $perpage = 1;
  2946. } else {
  2947. $start = ($page - 1) * $perpage;
  2948. }
  2949. //取得信息列表
  2950. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2951. //格式化数据
  2952. foreach ($info_list as $key => $value) {
  2953. $shop = $this->shop->read($value['shop']);
  2954. $info_list[$key]['shop'] = $shop['shopname'];
  2955. $express = $this->express->read($value['express']);
  2956. $info_list[$key]['express'] = $express['servicename'];
  2957. $warehouse = $this->warehouse->read($value['type']);
  2958. $info_list[$key]['type'] = $warehouse['title'];
  2959. if ($value['librarytime'] == '0') {
  2960. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2961. } else {
  2962. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2963. }
  2964. }
  2965. $total = $this->$sj->find_count($where);
  2966. $pagenum = ceil($total / $perpage);
  2967. $over = $total - ($start + $perpage);
  2968. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2969. echo json_encode($rows);
  2970. exit;
  2971. }
  2972. $this->data['express'] = $this->express->find_all();
  2973. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2974. $this->data['wlshop'] = $wlshop;
  2975. $user = $this->user->get_api($_SESSION['api']);
  2976. $powerid = $this->power->read($user['power']);
  2977. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2978. $pid = '';
  2979. foreach ($powertext as $v) {
  2980. $pid .= " id = " . $v . " or";
  2981. }
  2982. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2983. $this->data['fullorderexcel'] = $fullorderexcel;
  2984. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2985. $this->data['orderurl'] = $orderurl;
  2986. $this->_Template('whlabel_outorder', $this->data);
  2987. }
  2988. //tt出库
  2989. public function _toutorder()
  2990. {
  2991. $fgshop = "";
  2992. $sid = "";
  2993. if (isset($_SESSION['api'])) {
  2994. $user = $this->user->get_api($_SESSION['api']);
  2995. $usp = $user;
  2996. $user = explode('|', trim($user['shop'], '|'));
  2997. foreach ($user as $value) {
  2998. $fgshop .= " shop = " . $value . " or";
  2999. $sid .= " id = " . $value . " or";
  3000. }
  3001. } else {
  3002. echo "请重新登录";
  3003. die;
  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. $warehouse = $this->input->post('warehouse', true);
  3010. $xztime = $this->input->post('xztime', true);
  3011. $timetk = $this->input->post('timetkk', true);
  3012. $timetj = $this->input->post('timetjj', true);
  3013. $shop = $this->input->post('shop', true);
  3014. $source = $this->input->post('source', true);
  3015. $orderinfo = $this->input->post('orderinfo', true);
  3016. $number = $this->input->post('number', true);
  3017. $sfxh = $this->input->post('sfxh', true);
  3018. $express = $this->input->post('express', true);
  3019. $waybill = $this->input->post('waybill', true);
  3020. $library = $this->input->post('library', true);
  3021. $country = $this->input->post('country', true);
  3022. $so = $this->input->post('so', true);
  3023. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3024. $print = $this->input->post('print', true);
  3025. $state = $this->input->post('state', true);
  3026. $orderurl = $this->input->post('orderurl', true);
  3027. $timetk = strtotime($timetk);
  3028. $timetj = strtotime($timetj);
  3029. /**
  3030. $sj = $this->input->post('sj',true);
  3031. if($sj)
  3032. {
  3033. $sj = $this->input->post('sj',true);
  3034. }
  3035. else
  3036. {
  3037. $sj = "fullorder";
  3038. }
  3039. **/
  3040. $sj = "fullordertt";
  3041. $where = "1=1";
  3042. if ($warehouse) {
  3043. $where .= " and type = '$warehouse'";
  3044. }
  3045. if ($timetk && $timetj) {
  3046. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3047. }
  3048. if ($orderinfo) {
  3049. $where .= " and orderinfo = '$orderinfo'";
  3050. }
  3051. if ($number) {
  3052. $where .= " and number = '$number'";
  3053. }
  3054. if ($express) {
  3055. $where .= " and express = '$express'";
  3056. }
  3057. if ($waybill) {
  3058. $where .= " and waybill = '$waybill'";
  3059. }
  3060. if ($library) {
  3061. $where .= " and library = '$library'";
  3062. }
  3063. if ($print) {
  3064. $where .= " and print = '$print'";
  3065. }
  3066. if ($libraryconfirm) {
  3067. $where .= " and libraryconfirm = '$libraryconfirm'";
  3068. }
  3069. if ($state) {
  3070. $where .= " and state = '$state'";
  3071. }
  3072. if ($shop) {
  3073. $where .= " and shop = '$shop'";
  3074. }
  3075. if ($country) {
  3076. $where .= " and country = '$country'";
  3077. }
  3078. if ($sfxh != '') {
  3079. $where .= " and sfxh = '$sfxh'";
  3080. }
  3081. if ($so) {
  3082. $where .= " and shipremarks like '%$so%'";
  3083. }
  3084. if ($source) {
  3085. if ($source == '2d') {
  3086. $where .= " and source >= '2'";
  3087. } else {
  3088. $where .= " and source = '$source'";
  3089. }
  3090. }
  3091. if (isset($_SESSION['api'])) {
  3092. foreach ($user as $value) {
  3093. $fgshop .= " shop = " . $value . " or";
  3094. }
  3095. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3096. }
  3097. if ($orderurl) {
  3098. $url = $this->orderurl->read($orderurl);
  3099. $where .= " and link like '%" . $url['url'] . "%'";
  3100. }
  3101. //数据排序
  3102. $order_str = "librarytime desc";
  3103. if (empty($page)) {
  3104. $start = 0;
  3105. $perpage = 1;
  3106. } else {
  3107. $start = ($page - 1) * $perpage;
  3108. }
  3109. //取得信息列表
  3110. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3111. //格式化数据
  3112. foreach ($info_list as $key => $value) {
  3113. $shop = $this->shop->read($value['shop']);
  3114. $info_list[$key]['shop'] = $shop['shopname'];
  3115. $express = $this->express->read($value['express']);
  3116. $info_list[$key]['express'] = $express['servicename'];
  3117. $warehouse = $this->warehouse->read($value['type']);
  3118. $info_list[$key]['type'] = $warehouse['title'];
  3119. if ($value['librarytime'] == '0') {
  3120. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3121. } else {
  3122. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3123. }
  3124. }
  3125. $total = $this->$sj->find_count($where);
  3126. $pagenum = ceil($total / $perpage);
  3127. $over = $total - ($start + $perpage);
  3128. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3129. echo json_encode($rows);
  3130. exit;
  3131. }
  3132. $this->data['express'] = $this->express->find_all();
  3133. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3134. $this->data['wlshop'] = $wlshop;
  3135. $user = $this->user->get_api($_SESSION['api']);
  3136. $powerid = $this->power->read($user['power']);
  3137. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3138. $pid = '';
  3139. foreach ($powertext as $v) {
  3140. $pid .= " id = " . $v . " or";
  3141. }
  3142. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3143. $this->data['fullorderexcel'] = $fullorderexcel;
  3144. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3145. $this->data['orderurl'] = $orderurl;
  3146. $this->_Template('whlabel_toutorder', $this->data);
  3147. }
  3148. //tt出库
  3149. public function _aoutorder()
  3150. {
  3151. if (isset($_SESSION['api'])) {
  3152. $user = $this->user->get_api($_SESSION['api']);
  3153. $usp = $user;
  3154. $fgshop = "";
  3155. $sid = "";
  3156. $user = explode('|', trim($user['shop'], '|'));
  3157. foreach ($user as $value) {
  3158. $fgshop .= " shop = " . $value . " or";
  3159. $sid .= " id = " . $value . " or";
  3160. }
  3161. } else {
  3162. echo "请重新登录";
  3163. }
  3164. $post = $this->input->post(NULL, TRUE);
  3165. if (isset($post['page'])) {
  3166. $page = $this->input->post('page', true);
  3167. $perpage = $this->input->post('perpage', true);
  3168. $warehouse = $this->input->post('warehouse', true);
  3169. $xztime = $this->input->post('xztime', true);
  3170. $timetk = $this->input->post('timetkk', true);
  3171. $timetj = $this->input->post('timetjj', true);
  3172. $shop = $this->input->post('shop', true);
  3173. $source = $this->input->post('source', true);
  3174. $orderinfo = $this->input->post('orderinfo', true);
  3175. $number = $this->input->post('number', true);
  3176. $sfxh = $this->input->post('sfxh', true);
  3177. $express = $this->input->post('express', true);
  3178. $waybill = $this->input->post('waybill', true);
  3179. $library = $this->input->post('library', true);
  3180. $country = $this->input->post('country', true);
  3181. $so = $this->input->post('so', true);
  3182. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3183. $print = $this->input->post('print', true);
  3184. $state = $this->input->post('state', true);
  3185. $orderurl = $this->input->post('orderurl', true);
  3186. $timetk = strtotime($timetk);
  3187. $timetj = strtotime($timetj);
  3188. /**
  3189. $sj = $this->input->post('sj',true);
  3190. if($sj)
  3191. {
  3192. $sj = $this->input->post('sj',true);
  3193. }
  3194. else
  3195. {
  3196. $sj = "fullorder";
  3197. }
  3198. **/
  3199. $sj = "fullorderamz";
  3200. $where = "1=1";
  3201. if ($warehouse) {
  3202. $where .= " and type = '$warehouse'";
  3203. }
  3204. if ($timetk && $timetj) {
  3205. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3206. }
  3207. if ($orderinfo) {
  3208. $where .= " and orderinfo = '$orderinfo'";
  3209. }
  3210. if ($number) {
  3211. $where .= " and number = '$number'";
  3212. }
  3213. if ($express) {
  3214. $where .= " and express = '$express'";
  3215. }
  3216. if ($waybill) {
  3217. $where .= " and waybill = '$waybill'";
  3218. }
  3219. if ($library) {
  3220. $where .= " and library = '$library'";
  3221. }
  3222. if ($print) {
  3223. $where .= " and print = '$print'";
  3224. }
  3225. if ($libraryconfirm) {
  3226. $where .= " and libraryconfirm = '$libraryconfirm'";
  3227. }
  3228. if ($state) {
  3229. $where .= " and state = '$state'";
  3230. }
  3231. if ($shop) {
  3232. $where .= " and shop = '$shop'";
  3233. }
  3234. if ($country) {
  3235. $where .= " and country = '$country'";
  3236. }
  3237. if ($sfxh != '') {
  3238. $where .= " and sfxh = '$sfxh'";
  3239. }
  3240. if ($so) {
  3241. $where .= " and shipremarks like '%$so%'";
  3242. }
  3243. if ($source) {
  3244. if ($source == '2d') {
  3245. $where .= " and source >= '2'";
  3246. } else {
  3247. $where .= " and source = '$source'";
  3248. }
  3249. }
  3250. if (isset($_SESSION['api'])) {
  3251. foreach ($user as $value) {
  3252. $fgshop .= " shop = " . $value . " or";
  3253. }
  3254. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3255. }
  3256. if ($orderurl) {
  3257. $url = $this->orderurl->read($orderurl);
  3258. $where .= " and link like '%" . $url['url'] . "%'";
  3259. }
  3260. //数据排序
  3261. $order_str = "librarytime desc";
  3262. if (empty($page)) {
  3263. $start = 0;
  3264. $perpage = 1;
  3265. } else {
  3266. $start = ($page - 1) * $perpage;
  3267. }
  3268. //取得信息列表
  3269. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3270. //格式化数据
  3271. foreach ($info_list as $key => $value) {
  3272. $shop = $this->shop->read($value['shop']);
  3273. $info_list[$key]['shop'] = $shop['shopname'];
  3274. $express = $this->express->read($value['express']);
  3275. $info_list[$key]['express'] = $express['servicename'];
  3276. $warehouse = $this->warehouse->read($value['type']);
  3277. $info_list[$key]['type'] = $warehouse['title'];
  3278. if ($value['librarytime'] == '0') {
  3279. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3280. } else {
  3281. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3282. }
  3283. }
  3284. $total = $this->$sj->find_count($where);
  3285. $pagenum = ceil($total / $perpage);
  3286. $over = $total - ($start + $perpage);
  3287. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3288. echo json_encode($rows);
  3289. exit;
  3290. }
  3291. $this->data['express'] = $this->express->find_all();
  3292. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3293. $this->data['wlshop'] = $wlshop;
  3294. $user = $this->user->get_api($_SESSION['api']);
  3295. $powerid = $this->power->read($user['power']);
  3296. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3297. $pid = '';
  3298. foreach ($powertext as $v) {
  3299. $pid .= " id = " . $v . " or";
  3300. }
  3301. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3302. $this->data['fullorderexcel'] = $fullorderexcel;
  3303. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3304. $this->data['orderurl'] = $orderurl;
  3305. $this->_Template('whlabel_aoutorder', $this->data);
  3306. }
  3307. //速卖通出库订单
  3308. public function _soutorder()
  3309. {
  3310. if (isset($_SESSION['api'])) {
  3311. $user = $this->user->get_api($_SESSION['api']);
  3312. $usp = $user;
  3313. $fgshop = "";
  3314. $sid = "";
  3315. $user = explode('|', trim($user['shop'], '|'));
  3316. foreach ($user as $value) {
  3317. $sid .= " id = " . $value . " or";
  3318. }
  3319. }
  3320. $post = $this->input->post(NULL, TRUE);
  3321. if (isset($post['page'])) {
  3322. $page = $this->input->post('page', true);
  3323. $perpage = $this->input->post('perpage', true);
  3324. $warehouse = $this->input->post('warehouse', true);
  3325. $xztime = $this->input->post('xztime', true);
  3326. $timetk = $this->input->post('timetkk', true);
  3327. $timetj = $this->input->post('timetjj', true);
  3328. $shop = $this->input->post('shop', true);
  3329. $source = $this->input->post('source', true);
  3330. $orderinfo = $this->input->post('orderinfo', true);
  3331. $number = $this->input->post('number', true);
  3332. $express = $this->input->post('express', true);
  3333. $waybill = $this->input->post('waybill', true);
  3334. $library = $this->input->post('library', true);
  3335. $country = $this->input->post('country', true);
  3336. $sfxh = $this->input->post('sfxh', true);
  3337. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3338. $print = $this->input->post('print', true);
  3339. $state = $this->input->post('state', true);
  3340. $so = $this->input->post('so', true);
  3341. $timetk = strtotime($timetk);
  3342. $timetj = strtotime($timetj);
  3343. /**
  3344. $sj = $this->input->post('sj',true);
  3345. if($sj)
  3346. {
  3347. $sj = $this->input->post('sj',true);
  3348. }
  3349. else
  3350. {
  3351. $sj = "fullorder";
  3352. }
  3353. **/
  3354. $sj = "fullordersmt";
  3355. $where = "1=1";
  3356. if ($warehouse) {
  3357. $where .= " and type = '$warehouse'";
  3358. }
  3359. if ($timetk && $timetj) {
  3360. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3361. }
  3362. if ($orderinfo) {
  3363. $where .= " and orderinfo = '$orderinfo'";
  3364. }
  3365. if ($number) {
  3366. $where .= " and number = '$number'";
  3367. }
  3368. if ($express) {
  3369. $where .= " and express = '$express'";
  3370. }
  3371. if ($waybill) {
  3372. $where .= " and waybill = '$waybill'";
  3373. }
  3374. if ($library) {
  3375. $where .= " and library = '$library'";
  3376. }
  3377. if ($print) {
  3378. $where .= " and print = '$print'";
  3379. }
  3380. if ($libraryconfirm) {
  3381. $where .= " and libraryconfirm = '$libraryconfirm'";
  3382. }
  3383. if ($state) {
  3384. $where .= " and state = '$state'";
  3385. }
  3386. if ($shop) {
  3387. $where .= " and shop = '$shop'";
  3388. }
  3389. if ($sfxh != '') {
  3390. $where .= " and sfxh = '$sfxh'";
  3391. }
  3392. if ($so) {
  3393. $where .= " and shipremarks like '%$so%'";
  3394. }
  3395. if ($source) {
  3396. $where .= " and source = '$source'";
  3397. }
  3398. if ($country) {
  3399. $where .= " and country = '$country'";
  3400. } else {
  3401. if (isset($_SESSION['api'])) {
  3402. foreach ($user as $value) {
  3403. $fgshop .= " shop = " . $value . " or";
  3404. }
  3405. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3406. }
  3407. }
  3408. //数据排序
  3409. $order_str = "librarytime desc";
  3410. if (empty($page)) {
  3411. $start = 0;
  3412. $perpage = 1;
  3413. } else {
  3414. $start = ($page - 1) * $perpage;
  3415. }
  3416. //取得信息列表
  3417. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3418. //格式化数据
  3419. foreach ($info_list as $key => $value) {
  3420. $shop = $this->shop->read($value['shop']);
  3421. $info_list[$key]['shop'] = $shop['shopname'];
  3422. $express = $this->express->read($value['express']);
  3423. $info_list[$key]['express'] = $express['servicename'];
  3424. $warehouse = $this->warehouse->read($value['type']);
  3425. $info_list[$key]['type'] = $warehouse['title'];
  3426. if ($value['librarytime'] == '0') {
  3427. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3428. } else {
  3429. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3430. }
  3431. }
  3432. $total = $this->$sj->find_count($where);
  3433. $pagenum = ceil($total / $perpage);
  3434. $over = $total - ($start + $perpage);
  3435. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3436. echo json_encode($rows);
  3437. exit;
  3438. }
  3439. $this->data['express'] = $this->express->find_all();
  3440. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3441. $this->data['wlshop'] = $wlshop;
  3442. $user = $this->user->get_api($_SESSION['api']);
  3443. $powerid = $this->power->read($user['power']);
  3444. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3445. $pid = '';
  3446. foreach ($powertext as $v) {
  3447. $pid .= " id = " . $v . " or";
  3448. }
  3449. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3450. $this->data['fullorderexcel'] = $fullorderexcel;
  3451. $this->_Template('whlabel_soutorder', $this->data);
  3452. }
  3453. //订单退库
  3454. public function _retreat()
  3455. {
  3456. $post = $this->input->post(NULL, TRUE);
  3457. if (isset($post['page'])) {
  3458. $page = $this->input->post('page', true);
  3459. $perpage = $this->input->post('perpage', true);
  3460. $warehouse = $this->input->post('warehouse', true);
  3461. $timetk = $this->input->post('timetk', true);
  3462. $timetj = $this->input->post('timetj', true);
  3463. $shop = $this->input->post('shop', true);
  3464. $source = $this->input->post('source', true);
  3465. $state = $this->input->post('state', true);
  3466. $review = $this->input->post('review', true);
  3467. $state = $this->input->post('state', true);
  3468. $express = $this->input->post('express', true);
  3469. $orderinfo = $this->input->post('orderinfo', true);
  3470. $user = $this->input->post('user', true);
  3471. $name = $this->input->post('name', true);
  3472. $waybill = $this->input->post('waybill', true);
  3473. $timetk = strtotime($timetk);
  3474. $timetj = strtotime($timetj);
  3475. $where = "(state=206 or state=210) and mergeid = 0";
  3476. if ($warehouse) {
  3477. $where .= " and state = '$warehouse'";
  3478. }
  3479. if ($timetk && $timetj) {
  3480. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3481. }
  3482. if ($shop) {
  3483. $where .= " and shop = '$shop'";
  3484. }
  3485. if ($source) {
  3486. $where .= " and source = '$source'";
  3487. }
  3488. if ($state) {
  3489. $where .= " and state = '$state'";
  3490. }
  3491. if ($review) {
  3492. $where .= " and review = '$review'";
  3493. }
  3494. if ($state) {
  3495. $where .= " and state = '$state'";
  3496. }
  3497. if ($express) {
  3498. $where .= " and express = '$express'";
  3499. }
  3500. if ($orderinfo) {
  3501. $where .= " and orderinfo = '$orderinfo'";
  3502. }
  3503. if ($user) {
  3504. $where .= " and user = '$user'";
  3505. }
  3506. if ($name) {
  3507. $where .= " and name = '$name'";
  3508. }
  3509. if ($waybill) {
  3510. $where .= " and waybill = '$waybill'";
  3511. }
  3512. //数据排序
  3513. $order_str = "id desc";
  3514. if (empty($page)) {
  3515. $start = 0;
  3516. $perpage = 1;
  3517. } else {
  3518. $start = ($page - 1) * $perpage;
  3519. }
  3520. //取得信息列表
  3521. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3522. //格式化数据
  3523. foreach ($info_list as $key => $value) {
  3524. $shop = $this->shop->read($value['shop']);
  3525. $info_list[$key]['shop'] = $shop['shopname'];
  3526. $warehouse = $this->warehouse->read($value['warehouse']);
  3527. $info_list[$key]['warehouse'] = $warehouse['title'];
  3528. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3529. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3530. if ($value['waybill'] == 0) {
  3531. $info_list[$key]['waybill'] = "";
  3532. }
  3533. $express = $this->express->read($value['express']);
  3534. $info_list[$key]['express'] = $express['title'];
  3535. $typeclass = $this->typeclass->read($value['state']);
  3536. $info_list[$key]['state'] = $typeclass['title'];
  3537. }
  3538. $total = $this->fullorder->find_count($where);
  3539. $pagenum = ceil($total / $perpage);
  3540. $over = $total - ($start + $perpage);
  3541. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3542. echo json_encode($rows);
  3543. exit;
  3544. }
  3545. $this->data['express'] = $this->express->find_all();
  3546. $this->_Template('whlabel_retreat', $this->data);
  3547. }
  3548. //退库标签浏览
  3549. public function _retreatlk()
  3550. {
  3551. $post = $this->input->post(NULL, TRUE);
  3552. if (isset($post['page'])) {
  3553. $page = $this->input->post('page', true);
  3554. $perpage = $this->input->post('perpage', true);
  3555. $timetk = $this->input->post('timetk', true);
  3556. $timetj = $this->input->post('timetj', true);
  3557. $sku = $this->input->post('sku', true);
  3558. $warehouse = $this->input->post('warehouse', true);
  3559. $purchase = $this->input->post('purchase', true);
  3560. $orderinfo = $this->input->post('orderinfo', true);
  3561. $waybill = $this->input->post('waybill', true);
  3562. $category = $this->input->post('category', true);
  3563. $size = $this->input->post('size', true);
  3564. $grade = $this->input->post('grade', true);
  3565. $color = $this->input->post('color', true);
  3566. $lowe = $this->input->post('lowe', true);
  3567. $state = $this->input->post('state', true);
  3568. $timetk = strtotime($timetk);
  3569. $timetj = strtotime($timetj);
  3570. $where = "state=2";
  3571. if ($timetk && $timetj) {
  3572. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3573. }
  3574. if ($sku) {
  3575. $where .= " and sku = '$sku'";
  3576. }
  3577. if ($warehouse) {
  3578. $where .= " and warehouse = '$warehouse'";
  3579. }
  3580. if ($purchase) {
  3581. $where .= " and purchase = '$purchase'";
  3582. }
  3583. if ($orderinfo) {
  3584. $where .= " and orderinfo = '$orderinfo'";
  3585. }
  3586. if ($waybill) {
  3587. $where .= " and waybill = '$waybill'";
  3588. }
  3589. if ($category) {
  3590. $where .= " and features like '%-$category-%'";
  3591. }
  3592. if ($size) {
  3593. $where .= " and features like '%-$size-%'";
  3594. }
  3595. if ($grade) {
  3596. $where .= " and features like '%-$grade-%'";
  3597. }
  3598. if ($color) {
  3599. $where .= " and features like '%-$color-%'";
  3600. }
  3601. if ($lowe) {
  3602. $where .= " and features like '%-$lowe-%'";
  3603. }
  3604. //数据排序
  3605. $order_str = "time desc";
  3606. if (empty($page)) {
  3607. $start = 0;
  3608. $perpage = 1;
  3609. } else {
  3610. $start = ($page - 1) * $perpage;
  3611. }
  3612. //取得信息列表
  3613. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3614. foreach ($info_list as $key => $value) {
  3615. $warehouse = $this->warehouse->read($value['warehouse']);
  3616. $info_list[$key]['warehouse'] = $warehouse['title'];
  3617. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3618. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3619. $purchase = $this->purchase->read($value['purchase']);
  3620. $info_list[$key]['purchase'] = $purchase['title'];
  3621. if ($value['outk'] != 0) {
  3622. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3623. } else {
  3624. $info_list[$key]['outk'] = "";
  3625. }
  3626. if ($value['retreat'] != 0) {
  3627. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3628. } else {
  3629. $info_list[$key]['retreat'] = "";
  3630. }
  3631. if ($value['orderinfo'] == 0) {
  3632. $info_list[$key]['orderinfo'] = "";
  3633. }
  3634. if ($value['waybill'] == 0) {
  3635. $info_list[$key]['waybill'] = "";
  3636. }
  3637. }
  3638. $total = $this->whlabel->find_count($where);
  3639. $pagenum = ceil($total / $perpage);
  3640. $over = $total - ($start + $perpage);
  3641. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3642. echo json_encode($rows);
  3643. exit;
  3644. }
  3645. $this->_Template('whlabel_retreatlk', $this->data);
  3646. }
  3647. //更换标签及浏览
  3648. public function _change()
  3649. {
  3650. $post = $this->input->post(NULL, TRUE);
  3651. if (isset($post['page'])) {
  3652. $page = $this->input->post('page', true);
  3653. $perpage = $this->input->post('perpage', true);
  3654. $timetk = $this->input->post('timetk', true);
  3655. $timetj = $this->input->post('timetj', true);
  3656. $label = $this->input->post('label', true);
  3657. $oldlabel = $this->input->post('oldlabel', true);
  3658. $timetk = strtotime($timetk);
  3659. $timetj = strtotime($timetj);
  3660. $where = "state=10 ";
  3661. if ($timetk && $timetj) {
  3662. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3663. }
  3664. if ($label) {
  3665. $where .= " and label = '$label'";
  3666. }
  3667. if ($oldlabel) {
  3668. $where .= " and oldlabel = '$oldlabel'";
  3669. }
  3670. //数据排序
  3671. $order_str = "time asc";
  3672. if (empty($page)) {
  3673. $start = 0;
  3674. $perpage = 1;
  3675. } else {
  3676. $start = ($page - 1) * $perpage;
  3677. }
  3678. //取得信息列表
  3679. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3680. foreach ($info_list as $key => $value) {
  3681. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3682. }
  3683. $total = $this->whlabel->find_count($where);
  3684. $pagenum = ceil($total / $perpage);
  3685. $over = $total - ($start + $perpage);
  3686. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3687. echo json_encode($rows);
  3688. exit;
  3689. }
  3690. $this->_Template('whlabel_change', $this->data);
  3691. }
  3692. //产品标签
  3693. public function _cpbqdc()
  3694. {
  3695. if (isset($_GET['excel'])) {
  3696. $where = "1=1";
  3697. //数据排序
  3698. $order_str = "id desc";
  3699. if (empty($page)) {
  3700. $start = 0;
  3701. $perpage = 1;
  3702. } else {
  3703. $start = ($page - 1) * $perpage;
  3704. }
  3705. $warehouse = $this->input->get('warehouse', true);
  3706. $state = $this->input->get('state', true);
  3707. $timetk = $this->input->get('timetkk', true);
  3708. $timetj = $this->input->get('timetjj', true);
  3709. $timetk = strtotime($timetk);
  3710. $timetj = strtotime($timetj);
  3711. if ($warehouse) {
  3712. $where .= " and warehouse = '$warehouse'";
  3713. }
  3714. if ($state || $state == 0) {
  3715. $where .= " and state = '$state'";
  3716. }
  3717. if ($timetk && $timetj) {
  3718. $where .= " and time > '$timetk' and time < '$timetj'";
  3719. }
  3720. //取得信息列表
  3721. $info_list = $this->whlabel->find_all($where, '*');
  3722. $rows = array();
  3723. $list = array();
  3724. foreach ($info_list as $key => $value) {
  3725. $rows[$value['time']] = $value; //所有数据sku
  3726. }
  3727. foreach ($rows as $value) {
  3728. $warehouse = $this->warehouse->read($value['warehouse']);
  3729. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3730. $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);
  3731. }
  3732. $title = "产品标签统计表";
  3733. $titlename = "<table border=1>
  3734. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3735. <tr align='center'>
  3736. <td>仓库</td>
  3737. <td>SKU</td>
  3738. <td>产品</td>
  3739. <td>入库时间</td>
  3740. <td>操作时间</td>
  3741. <td>备注</td>
  3742. <td>数量</td>
  3743. </tr>
  3744. </table>";
  3745. $filename = $title . ".xls";
  3746. $tail = "";
  3747. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3748. }
  3749. }
  3750. //进销存导出
  3751. public function _exceljxc()
  3752. {
  3753. $classid = $this->classid->sku();
  3754. $pm = $classid;
  3755. $typeclass = array();
  3756. $tc = $this->typeclass->find_all();
  3757. foreach ($tc as $v) {
  3758. $typeclass[$v['id']] = $v;
  3759. }
  3760. $prc = array();
  3761. $purchase = $this->purchase->find_all();
  3762. foreach ($purchase as $k => $v) {
  3763. $prc[$v['id']] = $v['title'];
  3764. }
  3765. if (isset($_GET['excel'])) {
  3766. $where = "sku != 'Preset'";
  3767. //数据排序
  3768. $order_str = "id desc";
  3769. if (empty($page)) {
  3770. $start = 0;
  3771. $perpage = 1;
  3772. } else {
  3773. $start = ($page - 1) * $perpage;
  3774. }
  3775. $category = $this->input->get('category', true);
  3776. $warehouse = $this->input->get('warehouse', true);
  3777. $excelid = $this->input->get('sid', true);
  3778. if ($category) {
  3779. $where .= " and features like '%-$category-%'";
  3780. }
  3781. if ($warehouse) {
  3782. $where .= " and warehouse = '$warehouse'";
  3783. }
  3784. $xzid = '';
  3785. if ($excelid) {
  3786. $excelid = explode(',', trim($excelid, ','));
  3787. foreach ($excelid as $key => $value) {
  3788. $xzid .= " id = " . $value . " or";
  3789. }
  3790. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3791. }
  3792. //取得信息列表
  3793. /**
  3794. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3795. $rows = array();$list = array();
  3796. foreach ($info_list as $key=>$value)
  3797. {
  3798. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3799. }
  3800. **/
  3801. $wt = array();
  3802. $whlabel_type = $this->whlabel_type->find_all();
  3803. foreach ($whlabel_type as $v) {
  3804. $wt[$v['id']] = $v['title'];
  3805. }
  3806. $wh = array();
  3807. $w = $this->warehouse->find_all('1=1', 'id,title');
  3808. foreach ($w as $v) {
  3809. $wh[$v['id']] = $v['title'];
  3810. }
  3811. $list = array();
  3812. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3813. foreach ($rows as $key => $value) {
  3814. if (isset($wt[$value['type']])) {
  3815. $rows[$key]['type'] = $wt[$value['type']];
  3816. } else {
  3817. $rows[$key]['type'] = '未设置';
  3818. }
  3819. $bm = '03';
  3820. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3821. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3822. $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');
  3823. $details = array();
  3824. $cpid = array();
  3825. $cpbz = array();
  3826. $c = 0;
  3827. $g = 0;
  3828. $x = 0;
  3829. $t = 0;
  3830. $s = 0;
  3831. $q = 0;
  3832. foreach ($sd as $k => $v) {
  3833. if ($v['state'] == 0) {
  3834. $c++;
  3835. if ($v['cpid'] != 0) {
  3836. $cpid[$v['cpid']] = $v['cpid'];
  3837. }
  3838. if ($v['cpbz'] != '') {
  3839. $cpbz[$v['cpbz']] = $v['cpbz'];
  3840. }
  3841. }
  3842. if ($v['state'] != 9) {
  3843. $g++;
  3844. }
  3845. if ($v['state'] == 1) {
  3846. $x++;
  3847. }
  3848. if ($v['state'] == 2) {
  3849. $t++;
  3850. }
  3851. if ($v['state'] == 8) {
  3852. $s++;
  3853. }
  3854. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3855. $q++;
  3856. }
  3857. $details[$v['details']] = $v['details'];
  3858. }
  3859. $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'] . '"');
  3860. $rows[$key]['details'] = implode("、", $details);
  3861. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3862. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3863. $number = $value['number'];
  3864. $ftime = time() - 15 * 24 * 3600;
  3865. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3866. $rows[$key]['number'] = $g;
  3867. $rows[$key]['c'] = $c;
  3868. $rows[$key]['x'] = $x;
  3869. $rows[$key]['t'] = $t;
  3870. $rows[$key]['s'] = $s;
  3871. $rows[$key]['q'] = $q;
  3872. $rows[$key]['z'] = $z;
  3873. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3874. $features = explode('-', trim($features, '-'));
  3875. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3876. // $pm = $classid;
  3877. // $jm = $classid;
  3878. // foreach($features as $k=>$v)
  3879. // {
  3880. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3881. // {
  3882. // if($typeclass[$v]['bm'] != '')
  3883. // {
  3884. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3885. // }
  3886. // }
  3887. // if($v != 0)
  3888. // {
  3889. // if(!isset($typeclass[$v]))
  3890. // {
  3891. // continue;
  3892. // }
  3893. // if(isset($pm[$typeclass[$v]['classid']]))
  3894. // {
  3895. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3896. // {
  3897. // $tz = explode('|',$typeclass[$v]['zh']);
  3898. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3899. // }
  3900. // else
  3901. // {
  3902. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3903. // }
  3904. // }
  3905. // if(isset($jm[$typeclass[$v]['classid']]))
  3906. // {
  3907. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3908. // }
  3909. // }
  3910. // }
  3911. // $jm = array_filter($jm);
  3912. // $rows[$key]['bs'] = implode("-",$jm);
  3913. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3914. // $zh = implode(" ",$pm);
  3915. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3916. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3917. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3918. // $rows[$key]['features'] = $zh;
  3919. }
  3920. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3921. $final_list = [];
  3922. foreach ($list as $k => $v) {
  3923. if (empty($v['sku'])) {
  3924. continue;
  3925. }
  3926. $final_list[] = [
  3927. "warehouse" => $v["warehouse"],
  3928. "purchase" => $v["purchase"],
  3929. "details" => $v["details"],
  3930. "cpid" => $v["cpid"],
  3931. "dbcontent" => $v["dbcontent"],
  3932. "sku" => $v["sku"],
  3933. "cs" => $v["bm"],
  3934. "bs" => $v["jm"],
  3935. "title" => $v["title"],
  3936. "features" => $v["pm"],
  3937. "cpbz" => $v["cpbz"],
  3938. "sm" => $v["sm"],
  3939. "type" => $v["type"],
  3940. "number" => $v["number"],
  3941. "c" => $v["c"],
  3942. "x" => $v["x"],
  3943. "t" => $v["t"],
  3944. "s" => $v["s"],
  3945. "q" => $v["q"],
  3946. "z" => $v["z"],
  3947. "weight" => $v['weight'],
  3948. ];
  3949. }
  3950. $title = "总进销存统计表";
  3951. $titlename = "<table border=1>
  3952. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3953. <tr align='center'>
  3954. <td>仓库</td>
  3955. <td>供应商</td>
  3956. <td>位置</td>
  3957. <td>库存编码</td>
  3958. <td>类目</td>
  3959. <td>SKU</td>
  3960. <td>用友编码</td>
  3961. <td>用友料号</td>
  3962. <td>商品名称</td>
  3963. <td>商品中文</td>
  3964. <td>产品备注</td>
  3965. <td>库位负责人</td>
  3966. <td>类型</td>
  3967. <td>入库总量</td>
  3968. <td>库存数量</td>
  3969. <td>销售数量</td>
  3970. <td>退货数量</td>
  3971. <td>删除数量</td>
  3972. <td>其它操作</td>
  3973. <td>占单数量</td>
  3974. <td>重量(g)</td>
  3975. </tr>
  3976. </table>";
  3977. $filename = $title . ".xls";
  3978. $tail = "";
  3979. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3980. }
  3981. }
  3982. //入库导出
  3983. public function _excelr()
  3984. {
  3985. if (isset($_GET['excel'])) {
  3986. $category = $this->input->get('category', true);
  3987. $size = $this->input->get('size', true);
  3988. $grade = $this->input->get('grade', true);
  3989. $color = $this->input->get('color', true);
  3990. $lowe = $this->input->get('lowe', true);
  3991. $sku = $this->input->get('sku', true);
  3992. $warehouse = $this->input->get('warehouse', true);
  3993. $purchase = $this->input->get('purchase', true);
  3994. $ktime = $this->input->get('ktime', true);
  3995. $jtime = $this->input->get('jtime', true);
  3996. $rktype = $this->input->get('rktype',true);
  3997. $ktime = strtotime($ktime);
  3998. $jtime = strtotime($jtime);
  3999. $where = "1=1";
  4000. $gj = "";
  4001. $ck = "";
  4002. if ($category) {
  4003. $where .= " and features like '%-$category-%'";
  4004. }
  4005. if ($size) {
  4006. $where .= " and features like '%-$size-%'";
  4007. }
  4008. if ($grade) {
  4009. $where .= " and features like '%-$grade-%'";
  4010. }
  4011. if ($color) {
  4012. $where .= " and features like '%-$color-%'";
  4013. }
  4014. if ($lowe) {
  4015. $where .= " and features like '%-$lowe-%'";
  4016. }
  4017. if ($warehouse) {
  4018. $where .= " and warehouse = '$warehouse'";
  4019. }
  4020. if ($purchase) {
  4021. $where .= " and purchase = '$purchase'";
  4022. }
  4023. if ($sku) {
  4024. $where .= " and sku = '$sku'";
  4025. }
  4026. if($rktype){
  4027. $where .= " and rktype = '$rktype' ";
  4028. }
  4029. if ($ktime && $jtime) {
  4030. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4031. }
  4032. //数据排序
  4033. $order_str = "id desc";
  4034. if (empty($page)) {
  4035. $start = 0;
  4036. $perpage = 1;
  4037. } else {
  4038. $start = ($page - 1) * $perpage;
  4039. }
  4040. $list = array();
  4041. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4042. foreach ($rows as $value) {
  4043. $ck = $this->warehouse->read($value['warehouse']);
  4044. $warehouse = $ck['title'];
  4045. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4046. $retreatwarehouse = $tkck['title'];
  4047. $gy = $this->purchase->read($value['purchase']);
  4048. $purchase = $gy['title'];
  4049. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4050. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4051. }
  4052. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4053. $titlename = "<table border=1>
  4054. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4055. <tr align='center'>
  4056. <td>仓库</td>
  4057. <td>SKU</td>
  4058. <td>产品</td>
  4059. <td>时间</td>
  4060. <td>数量</td>
  4061. </tr>
  4062. </table>";
  4063. $filename = $title . ".xls";
  4064. $tail = "";
  4065. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4066. }
  4067. }
  4068. //出库、退库导出
  4069. public function _excelct()
  4070. {
  4071. $classid = $this->classid->sku();
  4072. $pm = $classid;
  4073. $typeclass = array();
  4074. $tc = $this->typeclass->find_all();
  4075. foreach ($tc as $v) {
  4076. $typeclass[$v['id']] = $v;
  4077. }
  4078. $prc = array();
  4079. $purchase = $this->purchase->find_all();
  4080. foreach ($purchase as $k => $v) {
  4081. $prc[$v['id']] = $v['title'];
  4082. }
  4083. if (isset($_GET['excel'])) {
  4084. $wh = array();
  4085. $w = $this->warehouse->find_all('1=1', 'id,title');
  4086. foreach ($w as $v) {
  4087. $wh[$v['id']] = $v['title'];
  4088. }
  4089. $type = $this->input->get('excel', true);
  4090. $category = $this->input->get('category', true);
  4091. $size = $this->input->get('size', true);
  4092. $grade = $this->input->get('grade', true);
  4093. $color = $this->input->get('color', true);
  4094. $lowe = $this->input->get('lowe', true);
  4095. $sku = $this->input->get('sku', true);
  4096. $title = $this->input->get('title', true);
  4097. $warehouse = $this->input->get('warehouse', true);
  4098. $purchase = $this->input->get('purchase', true);
  4099. $lacetype = $this->input->get('lacetype', true);
  4100. $haircap = $this->input->get('haircap', true);
  4101. $lacecolor = $this->input->get('lacecolor', true);
  4102. $density = $this->input->get('density', true);
  4103. $details = $this->input->get('details', true);
  4104. $state = $this->input->get('state', true);
  4105. $shop = $this->input->get('shop', true);
  4106. $hairnumber = $this->input->get('hairnumber', true);
  4107. $type_leixi = $this->input->get('type', true);
  4108. $cpbz = $this->input->get('cpbz', true);
  4109. $sm = $this->input->get('sm', true);
  4110. $sid = $this->input->get('sid', true);
  4111. $ktime = $this->input->get('ktime', true);
  4112. $jtime = $this->input->get('jtime', true);
  4113. $ktime = strtotime($ktime);
  4114. $jtime = strtotime($jtime);
  4115. //$where = " 1=1 ";
  4116. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4117. $where = " sku != '' ";
  4118. $gj = "";
  4119. $ck = "";
  4120. if ($category) {
  4121. $where .= " and features like '%-$category-%'";
  4122. }
  4123. if ($size) {
  4124. $where .= " and features like '%-$size-%'";
  4125. }
  4126. if ($grade) {
  4127. $where .= " and features like '%-$grade-%'";
  4128. }
  4129. if ($color) {
  4130. $where .= " and features like '%-$color-%'";
  4131. }
  4132. if ($lowe) {
  4133. $where .= " and features like '%-$lowe-%'";
  4134. }
  4135. if ($warehouse) {
  4136. $where .= " and warehouse = '$warehouse'";
  4137. }
  4138. if ($purchase) {
  4139. $where .= " and purchase = '$purchase'";
  4140. }
  4141. if ($state) {
  4142. $where .= " and state = '$state'";
  4143. }
  4144. if ($lacetype) {
  4145. $where .= " and features like '%-$lacetype-%'";
  4146. }
  4147. if ($lacecolor) {
  4148. $where .= " and features like '%-$lacecolor-%'";
  4149. }
  4150. if ($density) {
  4151. $where .= " and features like '%-$density-%'";
  4152. }
  4153. if ($haircap) {
  4154. $where .= " and features like '%-$haircap-%'";
  4155. }
  4156. if ($details) {
  4157. $where .= " and details = '$details'";
  4158. }
  4159. if ($shop) {
  4160. $where .= " and shop like '%$shop%'";
  4161. }
  4162. if ($title) {
  4163. $title = trim($title, ' ');
  4164. $title = trim($title, ' ');
  4165. $where .= " and title like '%$title%'";
  4166. }
  4167. if (!empty($hairnumber)) {
  4168. $where .= " and features like '%-128-%' ";
  4169. if ($hairnumber < 0) {
  4170. $class_list = $this->typeclass->find_all('classid = 43');
  4171. foreach ($class_list as $v) {
  4172. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4173. }
  4174. } else {
  4175. $where .= " and features like '%-$hairnumber-%'";
  4176. }
  4177. }
  4178. if ($type_leixi) {
  4179. $where .= " and type = '$type_leixi'";
  4180. }
  4181. if ($cpbz) {
  4182. $where .= " and cpbz like '%$cpbz%' ";
  4183. }
  4184. if ($sm) {
  4185. $where .= " and sm like '%$sm%' ";
  4186. }
  4187. if ($sku) {
  4188. $sku = trim($sku, ' ');
  4189. $sku = trim($sku, ' ');
  4190. $where .= " and sku like '%$sku%'";
  4191. }
  4192. if ($ktime && $jtime) {
  4193. if ($type == 1) {
  4194. $tl = '出库';
  4195. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4196. } else if ($type == 2) {
  4197. $tl = '退库';
  4198. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4199. } else if ($type == 3) {
  4200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4202. } else if ($type == 4) {
  4203. $tl = '出库+零售';
  4204. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4205. } else if ($type == 5) {
  4206. $tl = '零售';
  4207. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4208. }
  4209. }
  4210. $sidwhere = '';
  4211. if ($sid) {
  4212. $sd = "";
  4213. $s = explode(',', trim($sid, ','));
  4214. foreach ($s as $value) {
  4215. $sd .= " id = " . $value . " or";
  4216. }
  4217. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4218. }
  4219. //数据排序
  4220. $order_str = "time desc";
  4221. if (empty($page)) {
  4222. $start = 0;
  4223. $perpage = 1;
  4224. } else {
  4225. $start = ($page - 1) * $perpage;
  4226. }
  4227. //取得信息列表
  4228. if ($type != 3 && $type != 5) {
  4229. if ($type == 1 || $type == 4) {
  4230. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4231. foreach ($info_list as $key => $value) {
  4232. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4233. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4234. $warehouse = $this->warehouse->read($value['warehouse']);
  4235. $info_list[$key]['warehouse'] = $warehouse['title'];
  4236. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4237. $features = explode('-', trim($features, '-'));
  4238. $pm = $classid;
  4239. foreach ($features as $k => $v) {
  4240. if ($v != 0) {
  4241. if (!isset($typeclass[$v])) {
  4242. continue;
  4243. }
  4244. if (isset($pm[$typeclass[$v]['classid']])) {
  4245. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4246. $tz = explode('|', $typeclass[$v]['zh']);
  4247. $pm[$typeclass[$v]['classid']] = $tz[0];
  4248. } else {
  4249. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4250. }
  4251. }
  4252. }
  4253. }
  4254. $zh = implode(" ", $pm);
  4255. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4256. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4257. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4258. $info_list[$key]['features'] = $zh;
  4259. }
  4260. $final_list = [];
  4261. foreach($info_list as $k=>$v){
  4262. $number = "";
  4263. if(!empty($v['orderinfo'])){
  4264. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4265. if(!empty($tmp_info['number'])){
  4266. $number = $tmp_info['number'];
  4267. }
  4268. }
  4269. $final_list[] = [
  4270. 'warehouse'=>$v['warehouse'],
  4271. 'purchase'=>$v['purchase'],
  4272. 'sku'=>$v['sku'],
  4273. 'title'=>$v['title'],
  4274. 'features'=>$v['features'],
  4275. 'label'=>$v['label'],
  4276. 'orderinfo'=>$v['orderinfo'],
  4277. 'number'=>$number,
  4278. 'waybill'=>$v['waybill'],
  4279. 'outk'=>$v['outk'],
  4280. ];
  4281. }
  4282. } else {
  4283. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4284. foreach ($info_list as $key => $value) {
  4285. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4286. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4287. $warehouse = $this->warehouse->read($value['warehouse']);
  4288. $info_list[$key]['warehouse'] = $warehouse['title'];
  4289. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4290. $features = explode('-', trim($features, '-'));
  4291. $pm = $classid;
  4292. foreach ($features as $k => $v) {
  4293. if ($v != 0) {
  4294. if (!isset($typeclass[$v])) {
  4295. continue;
  4296. }
  4297. if (isset($pm[$typeclass[$v]['classid']])) {
  4298. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4299. $tz = explode('|', $typeclass[$v]['zh']);
  4300. $pm[$typeclass[$v]['classid']] = $tz[0];
  4301. } else {
  4302. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4303. }
  4304. }
  4305. }
  4306. }
  4307. $zh = implode(" ", $pm);
  4308. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4309. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4310. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4311. $info_list[$key]['features'] = $zh;
  4312. }
  4313. $final_list = [];
  4314. foreach($info_list as $k=>$v){
  4315. $number = "";
  4316. if(!empty($v['orderinfo'])){
  4317. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4318. if(!empty($tmp_info['number'])){
  4319. $number = $tmp_info['number'];
  4320. }
  4321. }
  4322. $final_list[] = [
  4323. 'warehouse'=>$v['warehouse'],
  4324. 'purchase'=>$v['purchase'],
  4325. 'sku'=>$v['sku'],
  4326. 'title'=>$v['title'],
  4327. 'features'=>$v['features'],
  4328. 'label'=>$v['label'],
  4329. 'orderinfo'=>$v['orderinfo'],
  4330. 'number'=>$number,
  4331. 'waybill'=>$v['waybill'],
  4332. 'retreat'=>$v['retreat'],
  4333. ];
  4334. }
  4335. }
  4336. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4337. $titlename = "<table border=1>
  4338. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4339. <tr align='center'>
  4340. <td>仓库</td>
  4341. <td>供应商</td>
  4342. <td>SKU</td>
  4343. <td>商品名称</td>
  4344. <td>商品中文</td>
  4345. <td>标签</td>
  4346. <td>订单号</td>
  4347. <td>订单编码</td>
  4348. <td>运单号</td>
  4349. <td>" . $tl . "时间(中国时间)</td>
  4350. </tr>
  4351. </table>";
  4352. $filename = $title . ".xls";
  4353. $tail = "";
  4354. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4355. } else if ($type == 5) {
  4356. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4357. foreach ($info_list as $key => $value) {
  4358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4359. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4360. $warehouse = $this->warehouse->read($value['warehouse']);
  4361. $info_list[$key]['warehouse'] = $warehouse['title'];
  4362. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4363. $features = explode('-', trim($features, '-'));
  4364. $pm = $classid;
  4365. foreach ($features as $k => $v) {
  4366. if ($v != 0) {
  4367. if (!isset($typeclass[$v])) {
  4368. continue;
  4369. }
  4370. if (isset($pm[$typeclass[$v]['classid']])) {
  4371. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4372. $tz = explode('|', $typeclass[$v]['zh']);
  4373. $pm[$typeclass[$v]['classid']] = $tz[0];
  4374. } else {
  4375. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4376. }
  4377. }
  4378. }
  4379. }
  4380. $zh = implode(" ", $pm);
  4381. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4382. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4383. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4384. $info_list[$key]['features'] = $zh;
  4385. }
  4386. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4387. $titlename = "<table border=1>
  4388. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4389. <tr align='center'>
  4390. <td>仓库</td>
  4391. <td>供应商</td>
  4392. <td>SKU</td>
  4393. <td>商品名称</td>
  4394. <td>商品中文</td>
  4395. <td>标签</td>
  4396. <td>" . $tl . "时间(中国时间)</td>
  4397. </tr>
  4398. </table>";
  4399. $filename = $title . ".xls";
  4400. $tail = "";
  4401. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4402. } else {
  4403. /**
  4404. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4405. $rows = array();$list = array();
  4406. foreach ($info_list as $key=>$value)
  4407. {
  4408. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4409. }
  4410. **/
  4411. $wh = array();
  4412. $w = $this->warehouse->find_all('1=1', 'id,title');
  4413. foreach ($w as $v) {
  4414. $wh[$v['id']] = $v['title'];
  4415. }
  4416. $wt = array();
  4417. $whlabel_type = $this->whlabel_type->find_all();
  4418. foreach ($whlabel_type as $v) {
  4419. $wt[$v['id']] = $v['title'];
  4420. }
  4421. $classid = $this->classid->sku();
  4422. $list = array();
  4423. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4424. foreach ($rows as $key => $value) {
  4425. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4426. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4427. $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');
  4428. $details = array();
  4429. $cpid = array();
  4430. $cpbz = array();
  4431. $c = 0;
  4432. $g = 0;
  4433. $x = 0;
  4434. $t = 0;
  4435. $s = 0;
  4436. $q = 0;
  4437. foreach ($sd as $k => $v) {
  4438. if ($v['state'] == 0) {
  4439. $c++;
  4440. }
  4441. if ($v['state'] != 9) {
  4442. $g++;
  4443. }
  4444. if ($v['outk'] > 1) {
  4445. $x++;
  4446. }
  4447. if ($v['retreat'] > 0) {
  4448. $t++;
  4449. }
  4450. if ($v['state'] == 8) {
  4451. $s++;
  4452. }
  4453. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4454. $q++;
  4455. }
  4456. $details[$v['details']] = $v['details'];
  4457. if ($v['cpid'] != 0) {
  4458. $cpid[$v['cpid']] = $v['cpid'];
  4459. }
  4460. if ($v['cpbz'] != '') {
  4461. $cpbz[$v['cpbz']] = $v['cpbz'];
  4462. }
  4463. }
  4464. if (isset($wt[$value['type']])) {
  4465. $rows[$key]['type'] = $wt[$value['type']];
  4466. } else {
  4467. $rows[$key]['type'] = '未设置';
  4468. }
  4469. $rows[$key]['details'] = implode("、", $details);
  4470. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4471. $ftime = time() - 15 * 24 * 3600;
  4472. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4473. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4474. $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);
  4475. $rows[$key]['c'] = $c;
  4476. $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);
  4477. $rows[$key]['t'] = $t;
  4478. $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'] . '"');
  4479. $rows[$key]['z'] = $z;
  4480. // $jm = $classid;
  4481. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4482. $features = explode('-', trim($features, '-'));
  4483. // $pm = $classid;
  4484. // foreach ($features as $k => $v) {
  4485. // if ($v != 0) {
  4486. // if (!isset($typeclass[$v])) {
  4487. // continue;
  4488. // }
  4489. // if (isset($pm[$typeclass[$v]['classid']])) {
  4490. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4491. // $tz = explode('|', $typeclass[$v]['zh']);
  4492. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4493. // } else {
  4494. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4495. // }
  4496. // if (isset($jm[$typeclass[$v]['classid']])) {
  4497. // if ($typeclass[$v]['jm']) {
  4498. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4499. // }
  4500. // }
  4501. // }
  4502. // }
  4503. // }
  4504. // $zh = implode(" ", $pm);
  4505. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4506. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4507. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4508. // $rows[$key]['features'] = $zh;
  4509. // $jm = array_filter($jm); //去除空值
  4510. // $jm = implode("-", $jm);
  4511. // $rows[$key]['jm'] = $jm;
  4512. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4513. }
  4514. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4515. // echo "<pre>";
  4516. // print_r($tmp_list);
  4517. // die;
  4518. $final_list =[];
  4519. foreach($tmp_list as $k=>$v){
  4520. $final_list[] = [
  4521. "warehouse"=>$v['warehouse'],
  4522. "purchase"=>$v['purchase'],
  4523. "details"=>trim($v['details'],'、'),
  4524. "cpid"=>$v['cpid'],
  4525. "sku"=>$v['sku'],
  4526. "title"=>$v['title'],
  4527. "features"=>$v['pm'],
  4528. "cpbz"=>$v['cpbz'],
  4529. "sm"=>$v['sm'],
  4530. "type"=>$v['type'],
  4531. "g"=>$v["g"],
  4532. "c"=>$v["c"],
  4533. "x"=>$v["x"],
  4534. "t"=>$v["t"],
  4535. "z"=>$v["z"],
  4536. "jm"=>$v["jm"],
  4537. "weight"=>$v["weight"],
  4538. "asd"=>$v["asd"],
  4539. ];
  4540. }
  4541. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4542. $titlename = "<table border=1>
  4543. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4544. <tr align='center'>
  4545. <td>仓库</td>
  4546. <td>供应商</td>
  4547. <td>位置</td>
  4548. <td>库存编码</td>
  4549. <td>SKU</td>
  4550. <td>商品名称</td>
  4551. <td>商品中文</td>
  4552. <td>产品备注</td>
  4553. <td>说明</td>
  4554. <td>类型</td>
  4555. <td>入库总量</td>
  4556. <td>库存数量</td>
  4557. <td>销售数量</td>
  4558. <td>退货数量</td>
  4559. <td>占单数量</td>
  4560. <td>料号</td>
  4561. <td>重量</td>
  4562. <td>类目</td>
  4563. </tr>
  4564. </table>";
  4565. $filename = $title . ".xls";
  4566. $tail = "";
  4567. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4568. }
  4569. }
  4570. }
  4571. //出库+入库数据整合
  4572. public function _excelcr()
  4573. {
  4574. if (isset($_GET['excel'])) {
  4575. $type = $this->input->get('excel', true);
  4576. $category = $this->input->get('category', true);
  4577. $size = $this->input->get('size', true);
  4578. $grade = $this->input->get('grade', true);
  4579. $color = $this->input->get('color', true);
  4580. $lowe = $this->input->get('lowe', true);
  4581. $sku = $this->input->get('sku', true);
  4582. $warehouse = $this->input->get('warehouse', true);
  4583. $purchase = $this->input->get('purchase', true);
  4584. $state = $this->input->get('state', true);
  4585. $sid = $this->input->get('sid', true);
  4586. $ktime = $this->input->get('ktime', true);
  4587. $jtime = $this->input->get('jtime', true);
  4588. $ktime = strtotime($ktime);
  4589. $jtime = strtotime($jtime);
  4590. $where = "1=1";
  4591. $gj = "";
  4592. $ck = "";
  4593. if ($category) {
  4594. $where .= " and features like '%-$category-%'";
  4595. }
  4596. if ($size) {
  4597. $where .= " and features like '%-$size-%'";
  4598. }
  4599. if ($grade) {
  4600. $where .= " and features like '%-$grade-%'";
  4601. }
  4602. if ($color) {
  4603. $where .= " and features like '%-$color-%'";
  4604. }
  4605. if ($lowe) {
  4606. $where .= " and features like '%-$lowe-%'";
  4607. }
  4608. if ($warehouse) {
  4609. $where .= " and warehouse = '$warehouse'";
  4610. }
  4611. if ($purchase) {
  4612. $where .= " and purchase = '$purchase'";
  4613. }
  4614. if ($state) {
  4615. $where .= " and state = '$state'";
  4616. }
  4617. if ($sku) {
  4618. $where .= " and sku like '%$sku%'";
  4619. }
  4620. if ($ktime && $jtime) {
  4621. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4622. }
  4623. $sidwhere = '';
  4624. if ($sid) {
  4625. $sd = "";
  4626. $s = explode(',', trim($sid, ','));
  4627. foreach ($s as $value) {
  4628. $sd .= " id = " . $value . " or";
  4629. }
  4630. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4631. }
  4632. //取得信息列表
  4633. $timeread = $ktime;
  4634. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4635. $timelist = array();
  4636. for ($i = 0; $i < $timenum; $i++) {
  4637. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4638. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4639. }
  4640. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4641. //echo "<pre>";
  4642. //print_r($info_list);
  4643. //exit();
  4644. $rows = array();
  4645. $list = array();
  4646. foreach ($info_list as $key => $value) {
  4647. $thistime = $timelist;
  4648. if (isset($rows[strtolower($value['sku'])])) {
  4649. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4650. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4651. }
  4652. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4653. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4654. }
  4655. } else {
  4656. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4657. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4658. }
  4659. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4660. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4661. }
  4662. $rows[strtolower($value['sku'])] = $thistime;
  4663. }
  4664. }
  4665. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4666. <head>
  4667. <!--[if gte mso 9]><xml>
  4668. <x:ExcelWorkbook>
  4669. <x:ExcelWorksheets>
  4670. <x:ExcelWorksheet>
  4671. <x:Name>EXCEL</x:Name>
  4672. <x:WorksheetOptions>
  4673. <x:Print>
  4674. <x:ValidPrinterInfo />
  4675. </x:Print>
  4676. </x:WorksheetOptions>
  4677. </x:ExcelWorksheet>
  4678. </x:ExcelWorksheets>
  4679. </x:ExcelWorkbook>
  4680. </xml>
  4681. <![endif]-->
  4682. </head><body>";
  4683. $str .= "<table border=1><tr><td>SKU</td>";
  4684. foreach ($timelist as $k => $v) {
  4685. $str .= "<td>" . $k . "出库</td>";
  4686. $str .= "<td>" . $k . "入库</td>";
  4687. }
  4688. $str .= "</tr></table>";
  4689. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4690. foreach ($rows as $key => $val) {
  4691. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4692. foreach ($val as $k => $v) {
  4693. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4694. if ($val[$k]['r'] > 0) {
  4695. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4696. } else {
  4697. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4698. }
  4699. }
  4700. $str .= "</tr>";
  4701. }
  4702. $str .= "</table>";
  4703. $str .= "</body></html>";
  4704. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4705. header("Content-type: application/octet-stream");
  4706. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4707. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4708. header("Pragma: no-cache");
  4709. header("Expires: 0");
  4710. exit($str);
  4711. }
  4712. }
  4713. //数量调整模板导出
  4714. public function _presetout()
  4715. {
  4716. if (isset($_GET['excel'])) {
  4717. $where = "sku != 'Preset' and purchase != 0";
  4718. //数据排序
  4719. $order_str = "id desc";
  4720. if (empty($page)) {
  4721. $start = 0;
  4722. $perpage = 1;
  4723. } else {
  4724. $start = ($page - 1) * $perpage;
  4725. }
  4726. //取得信息列表
  4727. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4728. $rows = array();
  4729. $list = array();
  4730. foreach ($info_list as $value) {
  4731. $warehouse = $this->warehouse->read($value['warehouse']);
  4732. $number = $value['number'];
  4733. $ftime = time() - 15 * 24 * 3600;
  4734. $purchase = $this->purchase->read($value['purchase']);
  4735. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4736. }
  4737. $title = "库存模板";
  4738. $titlename = "<table border=1>
  4739. <tr align='center'>
  4740. <td>仓库</td>
  4741. <td>供应商编码</td>
  4742. <td>SKU</td>
  4743. <td>增减数量(正数或负数)</td>
  4744. <td>增减备注</td>
  4745. <td>库位</td>
  4746. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4747. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4748. </tr>
  4749. </table>";
  4750. $filename = $title . ".xls";
  4751. $tail = "";
  4752. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4753. }
  4754. }
  4755. //数量调整模板导入
  4756. public function _presetedit()
  4757. {
  4758. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4759. $config['upload_path'] = '.' . $dir;
  4760. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4761. $config['allowed_types'] = 'xls|xlsx|csv';
  4762. $config['max_size'] = 10240;
  4763. $this->load->library('upload', $config);
  4764. $this->upload->initialize($config);
  4765. if ($this->upload->do_upload('userfile')) {
  4766. $full_path = $dir . $this->upload->data('file_name');
  4767. $fileName = '.' . $full_path;
  4768. if (!file_exists($fileName)) {
  4769. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4770. exit;
  4771. } else {
  4772. require_once "./data/excel/PHPExcel/IOFactory.php";
  4773. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4774. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4775. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4776. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4777. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4778. ++$column; //如果列数大于26行
  4779. $list = array();
  4780. for ($i = 2; $i <= $row; $i++) // 行数循环
  4781. {
  4782. $data = array();
  4783. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4784. {
  4785. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4786. }
  4787. $list[] = $data;
  4788. }
  4789. }
  4790. $i = 0;
  4791. $j = 0;
  4792. $ed = array();
  4793. foreach ($list as $key => $value) {
  4794. $time = time();
  4795. if ($value['0'] == "") {
  4796. continue;
  4797. }
  4798. $warehouse = $this->warehouse->get_title($value['0']);
  4799. $purchase = $this->purchase->get_bm($value['1']);
  4800. $sku = $value['2'];
  4801. $num = $value['3']; //调整数量
  4802. $text = $value['4']; //扣减说明
  4803. $type = $value['5']; //调整方式0扣减1删除
  4804. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4805. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4806. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4807. if (!$purchase) //如果没有这个SKU
  4808. {
  4809. $ed[] = array($purchase . '-不存在此供应商编码');
  4810. $j++;
  4811. continue;
  4812. }
  4813. if (!$d) //如果没有这个SKU
  4814. {
  4815. $ed[] = array($sku . '-库存中不存在此SKU');
  4816. $j++;
  4817. continue;
  4818. }
  4819. if (!isset($warehouse['id'])) {
  4820. $ed[] = array($sku . '-仓库名错误!');
  4821. $j++;
  4822. continue;
  4823. }
  4824. if ($type != '0' && $type != '1') {
  4825. $ed[] = array($sku . '-扣减方式填写错误!');
  4826. $j++;
  4827. continue;
  4828. }
  4829. if ($num < 0) //扣减库存
  4830. {
  4831. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4832. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4833. $j++;
  4834. continue;
  4835. }
  4836. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4837. if (count($data) < abs($num)) {
  4838. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4839. $j++;
  4840. continue;
  4841. }
  4842. if ($type == 0) //如果扣减方式为 扣减库存
  4843. {
  4844. for ($i = 0; $i < abs($num); $i++) {
  4845. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4846. }
  4847. } else if ($type == 1) {
  4848. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4849. if (count($zt) > 0) {
  4850. $ed[] = array($sku . '-有在途库存无法删除!');
  4851. $j++;
  4852. continue;
  4853. }
  4854. for ($i = 0; $i < abs($num); $i++) {
  4855. $this->whlabel->remove($data[$i]['id']);
  4856. }
  4857. }
  4858. } else if ($num > 0) //增加库存
  4859. {
  4860. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4861. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4862. $j++;
  4863. continue;
  4864. }
  4865. $post['sku'] = $d['sku'];
  4866. $post['shop'] = $d['shop'];
  4867. $post['warehouse'] = $warehouse['id'];
  4868. $post['purchase'] = $purchase['id'];
  4869. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4870. $post['state'] = 0;
  4871. $post['title'] = $d['title'];
  4872. $post['number'] = $d['number'];
  4873. $post['features'] = $d['features'];
  4874. $post['enter'] = $time;
  4875. $post['time'] = $time; //操作时间
  4876. $post['rktype'] = $rktype;
  4877. for ($i = 0; $i < $num; $i++) {
  4878. $post['label'] = time() . rand(100, 999) . $i;
  4879. $this->whlabel->insert($post);
  4880. }
  4881. }
  4882. sleep(1); //防止入库时间一样,需要延迟1秒
  4883. }
  4884. if ($j > 0) {
  4885. $tt = date('Ymd', time());
  4886. $title = '库存导入错误信息-' . $tt;
  4887. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4888. $tail = "\n";
  4889. $filename = $title . ".xls";
  4890. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4891. $dir = '/data/excel/' . $time . '/';
  4892. $file_name = 'error_' . $time . rand(1000, 9999);
  4893. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4894. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4895. fwrite($myfile, $ecl);
  4896. fclose($myfile);
  4897. $error = $dir . $file_name . '.xls';
  4898. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4899. exit;
  4900. } else {
  4901. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4902. exit;
  4903. }
  4904. }
  4905. }
  4906. public function _presetedittwo(){
  4907. $data = $this->input->post(NULL, TRUE);
  4908. if(empty($list)){
  4909. $raw_data = $this->input->raw_input_stream;
  4910. // 解码 JSON
  4911. $data = json_decode($raw_data, true);
  4912. }
  4913. if(empty($data)){
  4914. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4915. exit;
  4916. }
  4917. $list = [];
  4918. if(isset($data['list'])){
  4919. $list = $data['list'];
  4920. }
  4921. $i = 0;
  4922. $j = 0;
  4923. $ed = array();
  4924. foreach ($list as $key => $value) {
  4925. $time = time();
  4926. if ($value['0'] == "") {
  4927. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4928. $j++;
  4929. continue;
  4930. }
  4931. $warehouse = $this->warehouse->get_title($value['0']);
  4932. if(empty($warehouse)){
  4933. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4934. $j++;
  4935. continue;
  4936. }
  4937. $purchase = $this->purchase->get_bm($value['1']);
  4938. $sku = $value['2'];
  4939. $num = $value['3']; //调整数量
  4940. $text = $value['4']; //扣减说明
  4941. $type = 0; //调整方式0扣减1删除
  4942. $details = empty($value['5'])?'':$value['5']; //库位
  4943. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4944. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4945. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4946. if (!$purchase) //如果没有这个SKU
  4947. {
  4948. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4949. $j++;
  4950. continue;
  4951. }
  4952. if (!$d) //如果没有这个SKU
  4953. {
  4954. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4955. $j++;
  4956. continue;
  4957. }
  4958. if (!isset($warehouse['id'])) {
  4959. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4960. $j++;
  4961. continue;
  4962. }
  4963. if ($type != '0' && $type != '1') {
  4964. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4965. $j++;
  4966. continue;
  4967. }
  4968. if ($num < 0) //扣减库存
  4969. {
  4970. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4971. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4972. $j++;
  4973. continue;
  4974. }
  4975. if(!empty($details)){
  4976. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4977. }else{
  4978. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4979. }
  4980. if (count($data) < abs($num)) {
  4981. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4982. $j++;
  4983. continue;
  4984. }
  4985. if ($type == 0) //如果扣减方式为 扣减库存
  4986. {
  4987. for ($i = 0; $i < abs($num); $i++) {
  4988. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4989. }
  4990. } else if ($type == 1) {
  4991. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4992. if (count($zt) > 0) {
  4993. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4994. $j++;
  4995. continue;
  4996. }
  4997. for ($i = 0; $i < abs($num); $i++) {
  4998. $this->whlabel->remove($data[$i]['id']);
  4999. }
  5000. }
  5001. } else if ($num > 0) //增加库存
  5002. {
  5003. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5004. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5005. $j++;
  5006. continue;
  5007. }
  5008. if(empty($details)){
  5009. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5010. if(empty($tmp_info)){
  5011. $details = '';
  5012. }else{
  5013. $details = $tmp_info['details'];
  5014. }
  5015. }else{
  5016. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5017. if(empty($tmp_info)){
  5018. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5019. $j++;
  5020. continue;
  5021. }
  5022. }
  5023. $post['sku'] = $d['sku'];
  5024. $post['shop'] = $d['shop'];
  5025. $post['warehouse'] = $warehouse['id'];
  5026. $post['purchase'] = $purchase['id'];
  5027. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5028. $post['state'] = 0;
  5029. $post['title'] = $d['title'];
  5030. $post['number'] = $d['number'];
  5031. $post['features'] = $d['features'];
  5032. $post['details'] = $details;
  5033. $post['enter'] = $time;
  5034. $post['time'] = $time; //操作时间
  5035. $post['rktype'] = $rktype;
  5036. $post['sku_master_id'] = $d['sku_master_id'];
  5037. $post['sku_shop_id'] = $d['sku_shop_id'];
  5038. for ($i = 0; $i < $num; $i++) {
  5039. $post['label'] = time() . rand(100, 999) . $i;
  5040. $this->whlabel->insert($post);
  5041. }
  5042. }
  5043. sleep(1); //防止入库时间一样,需要延迟1秒
  5044. }
  5045. if ($j > 0) {
  5046. $tt = date('Ymd', time());
  5047. $title = '库存导入错误信息-' . $tt;
  5048. $error = $title . '.xls';
  5049. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5050. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5051. exit;
  5052. } else {
  5053. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5054. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5055. exit;
  5056. }
  5057. }
  5058. //笛卡儿积
  5059. function cp($ps, $sets, $list)
  5060. {
  5061. $result = array();
  5062. $j = 0;
  5063. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5064. if ($i == 0) {
  5065. $result = $sets[$i];
  5066. }
  5067. $tmp = array();
  5068. foreach ($result as $res) {
  5069. foreach ($sets[$i + 1] as $set) {
  5070. $tmp[] = $res . ',' . $set;
  5071. }
  5072. }
  5073. $result = $tmp;
  5074. }
  5075. $this->db->trans_begin();
  5076. foreach ($result as $v) {
  5077. $post = array();
  5078. $title = "";
  5079. $num = "";
  5080. $data = explode(',', $v);
  5081. for ($i = 0; $i < count($list); $i++) {
  5082. $post[$list[$i]] = $data[$i];
  5083. $typeclass = $this->typeclass->read($data[$i]);
  5084. $title = $title . $typeclass['title'] . " ";
  5085. if ($data[$i] != 0) {
  5086. $num .= $data[$i]; //所有数据ID拼接
  5087. }
  5088. }
  5089. foreach ($ps as $kp => $vp) {
  5090. $post[$kp] = $vp;
  5091. }
  5092. $post['number'] = $num;
  5093. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5094. if ($info_list) {
  5095. $j++;
  5096. } else {
  5097. $skunum = $this->whlabel->find_count();
  5098. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5099. $post['title'] = rtrim($title, ' ');
  5100. $this->whlabel->insert($post);
  5101. }
  5102. }
  5103. if ($this->db->trans_status() === FALSE) {
  5104. $this->db->trans_commit();
  5105. return NULL;
  5106. } else {
  5107. $this->db->trans_commit();
  5108. return $j;
  5109. }
  5110. }
  5111. public function _kj($arg_array)
  5112. {
  5113. if (isset($_POST['sku'])) {
  5114. $time = time();
  5115. $sku = $this->input->post('sku', true);
  5116. $warehouse = $this->input->post('warehouse', true);
  5117. $num = $this->input->post('num', true);
  5118. $text = $this->input->post('text', true);
  5119. $purchase = $this->input->post('purchase', true);
  5120. $cktype = $this->input->post('cktype', true);
  5121. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5122. if ($cktype != 1 && $text == '') {
  5123. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5124. exit;
  5125. }
  5126. if ($num > count($order)) {
  5127. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5128. exit;
  5129. } else {
  5130. for ($i = 0; $i < $num; $i++) {
  5131. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5132. }
  5133. }
  5134. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5135. exit;
  5136. }
  5137. $uid = $this->whlabel->read($arg_array[0]);
  5138. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5139. $this->data['data'] = $uid;
  5140. $this->_Template('whlabel_kj', $this->data);
  5141. }
  5142. public function _summary($arg_array)
  5143. {
  5144. $prc = array();
  5145. $purchase = $this->purchase->find_all();
  5146. foreach ($purchase as $k => $v) {
  5147. $prc[$v['id']] = $v['title'];
  5148. }
  5149. if (isset($_GET['excel'])) {
  5150. $ktime = $this->input->get('ktime', true);
  5151. $jtime = $this->input->get('jtime', true);
  5152. $ktime = strtotime($ktime);
  5153. $jtime = strtotime($jtime);
  5154. $where = "1=1";
  5155. if ($ktime && $jtime) {
  5156. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5157. }
  5158. //数据排序
  5159. $order_str = "time desc";
  5160. if (empty($page)) {
  5161. $start = 0;
  5162. $perpage = 1;
  5163. } else {
  5164. $start = ($page - 1) * $perpage;
  5165. }
  5166. //取得信息列表
  5167. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5168. foreach ($info_list as $key => $value) {
  5169. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5170. $warehouse = $this->warehouse->read($value['warehouse']);
  5171. $info_list[$key]['warehouse'] = $warehouse['title'];
  5172. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  5173. $details = array();
  5174. $cpid = array();
  5175. foreach ($x as $k => $v) {
  5176. if ($v['details'] != '') {
  5177. $details[$v['details']] = $v['details'];
  5178. }
  5179. if ($v['cpid'] != 0) {
  5180. $cpid[$v['cpid']] = $v['cpid'];
  5181. }
  5182. }
  5183. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5184. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5185. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5186. $info_list[$key]['s'] = $s;
  5187. $info_list[$key]['x'] = count($x);
  5188. }
  5189. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5190. $titlename = "<table border=1>
  5191. <tr align='center'>
  5192. <td>仓库</td>
  5193. <td>供应商</td>
  5194. <td>出库位置</td>
  5195. <td>出库编码</td>
  5196. <td>SKU</td>
  5197. <td>产品名</td>
  5198. <td>总剩余库存</td>
  5199. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5200. </tr>
  5201. </table>";
  5202. $filename = $title . ".xls";
  5203. $tail = "";
  5204. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5205. }
  5206. }
  5207. //usps发货清单
  5208. public function _manifest()
  5209. {
  5210. if (isset($_POST['manifest'])) {
  5211. $wltext = $this->input->post('wltext', true);
  5212. $time = time() - 16 * 3600;
  5213. $ptime = strtotime(date('Y-m-d', $time));
  5214. $waybill = array();
  5215. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5216. foreach ($fullorder as $v) {
  5217. $waybill[$v['waybill']] = $v['waybill'];
  5218. }
  5219. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5220. foreach ($fullordersmt as $v) {
  5221. $waybill[$v['waybill']] = $v['waybill'];
  5222. }
  5223. $wltext = explode(';', $wltext);
  5224. foreach ($wltext as $v) {
  5225. if (isset($waybill[$v])) {
  5226. unset($waybill[$v]);
  5227. }
  5228. }
  5229. $data = $this->usps->get_manifest($waybill);
  5230. if (isset($data['Description'])) {
  5231. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5232. exit;
  5233. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5234. $bctime = date('Ymd', time());
  5235. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5236. echo json_encode(array('msg' => $pdf, 'success' => true));
  5237. exit;
  5238. } else {
  5239. echo json_encode(array('msg' => $data, 'success' => false));
  5240. exit;
  5241. }
  5242. }
  5243. }
  5244. public function _pdf($pdf, $title, $bctime)
  5245. {
  5246. $pdf_path = './data/pdf/' . $bctime . '/';
  5247. $file_base64 = $pdf;
  5248. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5249. $file_base64 = base64_decode($file_base64);
  5250. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5251. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5252. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5253. }
  5254. /**
  5255. *
  5256. *
  5257. *
  5258. 进销存占单异常索引
  5259. *
  5260. *
  5261. *
  5262. **/
  5263. public function _abnormal()
  5264. {
  5265. $post = $this->input->post(NULL, TRUE);
  5266. if (isset($post['page'])) {
  5267. $page = $this->input->post('page', true);
  5268. $perpage = $this->input->post('perpage', true);
  5269. $sku = $this->input->post('sku', true);
  5270. $where = "1=1";
  5271. //数据排序
  5272. $order_str = "id desc";
  5273. if (empty($page)) {
  5274. $start = 0;
  5275. $perpage = 1;
  5276. } else {
  5277. $start = ($page - 1) * $perpage;
  5278. }
  5279. //取得信息列表
  5280. $info_list = $this->whlabel->find_all($where, '*');
  5281. $rows = array();
  5282. $list = array();
  5283. foreach ($info_list as $key => $value) {
  5284. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5285. }
  5286. foreach ($rows as $value) {
  5287. $warehouse = $this->warehouse->read($value['warehouse']);
  5288. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5289. $number = $value['number'];
  5290. $ftime = time() - 15 * 24 * 3600;
  5291. if ($value['shop'] != '') {
  5292. $shop = $value['shop'];
  5293. $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');
  5294. $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');
  5295. $order = array_merge($orderdlz, $ordersmt);
  5296. $od = 0;
  5297. $a = '';
  5298. $orid = '';
  5299. foreach ($order as $v) {
  5300. $or = explode('|', ltrim($v['whlabel'], '|'));
  5301. for ($i = 0; $i < count($or); $i++) {
  5302. $orod = explode('-', $or[$i]);
  5303. if ($orod[0] == $number) {
  5304. $od += $orod[1];
  5305. }
  5306. }
  5307. $orid .= $v['number'] . '-';
  5308. }
  5309. } else {
  5310. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5311. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5312. $order = array_merge($orderdlz, $ordersmt);
  5313. $od = 0;
  5314. $a = '';
  5315. $orid = '';
  5316. $qt = array();
  5317. foreach ($order as $v) {
  5318. $or = explode('|', ltrim($v['whlabel'], '|'));
  5319. for ($i = 0; $i < count($or); $i++) {
  5320. $orod = explode('-', $or[$i]);
  5321. if ($orod[0] == $number) {
  5322. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5323. if ($czzs > 0) {
  5324. if (isset($qt[$v['shop']])) {
  5325. if ($qt[$v['shop']] < $orod[1]) {
  5326. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5327. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5328. } else {
  5329. $qt[$v['shop']] -= $orod[1];
  5330. }
  5331. } else {
  5332. $qt[$v['shop']] = $czzs;
  5333. }
  5334. } else {
  5335. $od += $orod[1];
  5336. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5337. }
  5338. }
  5339. }
  5340. }
  5341. }
  5342. $z = $od . '(' . $orid . ')'; //查看订单号
  5343. //$z = $od;
  5344. if ($od > $c) {
  5345. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5346. }
  5347. }
  5348. $listdata = array_slice($list, $start, $perpage);
  5349. $total = count($list);
  5350. $pagenum = ceil($total / $perpage);
  5351. $over = $total - ($start + $perpage);
  5352. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5353. echo json_encode($rows);
  5354. exit;
  5355. }
  5356. $this->_Template('whlabel_abnormal', $this->data);
  5357. }
  5358. /**
  5359. *
  5360. *
  5361. *
  5362. 进销存占单异常索引
  5363. *
  5364. *
  5365. *
  5366. **/
  5367. public function _error()
  5368. {
  5369. $post = $this->input->post(NULL, TRUE);
  5370. if (isset($post['page'])) {
  5371. $page = $this->input->post('page', true);
  5372. $perpage = $this->input->post('perpage', true);
  5373. $sku = $this->input->post('sku', true);
  5374. $warehouse = $this->input->post('warehouse', true);
  5375. $ktime = $this->input->post('ktime', true);
  5376. $jtime = $this->input->post('jtime', true);
  5377. $ktime = strtotime($ktime);
  5378. $jtime = strtotime($jtime);
  5379. $where = "sku != 'Preset'";
  5380. $gj = '';
  5381. if ($sku) {
  5382. $where .= " and sku like '%$sku%'";
  5383. } else {
  5384. if ($ktime && $jtime) {
  5385. $gj = " and time > '$ktime' and time < '$jtime'";
  5386. }
  5387. }
  5388. if ($warehouse) {
  5389. $where .= " and warehouse = '$warehouse'";
  5390. }
  5391. //数据排序
  5392. $order_str = "id desc";
  5393. if (empty($page)) {
  5394. $start = 0;
  5395. $perpage = 1;
  5396. } else {
  5397. $start = ($page - 1) * $perpage;
  5398. }
  5399. //取得信息列表
  5400. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5401. $rows = array();
  5402. $list = array();
  5403. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5404. // foreach ($info_list as $value)
  5405. // {
  5406. // $warehouse = $this->warehouse->read($value['warehouse']);
  5407. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5408. // $number = $value['number'];$ftime = time()-15*24*3600;
  5409. // if($c < 1)
  5410. // {
  5411. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5412. // }
  5413. // }
  5414. $warehouse_list = $this->warehouse->find_all();
  5415. $warehouse_list = array_column($warehouse_list, null, 'id');
  5416. foreach ($info_list as $value) {
  5417. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5418. 'title' => "",
  5419. ];
  5420. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5421. $number = $value['number'];
  5422. $ftime = time() - 15 * 24 * 3600;
  5423. if ($c < 1) {
  5424. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5425. }
  5426. }
  5427. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5428. // $query = $this->db->query($sql);
  5429. // $info_list = $query->result_array();
  5430. // $sql_two = "select title,id from crowd_warehouse";
  5431. // $query_two = $this->db->query($sql_two);
  5432. // $warehouse_list = $query_two->result_array();
  5433. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5434. // foreach ($info_list as $value)
  5435. // {
  5436. // if(isset($warehouse_arr[$value['warehouse']])){
  5437. // $warehouse = $warehouse_arr[$value['warehouse']];
  5438. // }else{
  5439. // $warehouse = [
  5440. // 'id'=>0,
  5441. // 'title'=>"异常",
  5442. // ];
  5443. // }
  5444. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5445. // $number = $value['number'];$ftime = time()-15*24*3600;
  5446. // if($c < 1)
  5447. // {
  5448. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5449. // }
  5450. // }
  5451. $listdata = array_slice($list, $start, $perpage);
  5452. $total = count($list);
  5453. $pagenum = ceil($total / $perpage);
  5454. $over = $total - ($start + $perpage);
  5455. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5456. echo json_encode($rows);
  5457. exit;
  5458. }
  5459. if (isset($post['s'])) {
  5460. $id_arr = $this->input->post('s');
  5461. $id_arr = explode(',', trim($id_arr, ','));
  5462. if (!$id_arr) {
  5463. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5464. exit;
  5465. }
  5466. //循环删除记录
  5467. foreach ($id_arr as $v) {
  5468. $dd = $this->whlabel->read($v);
  5469. if (!isset($dd['id'])) {
  5470. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5471. exit;
  5472. }
  5473. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5474. if (isset($zt[0])) {
  5475. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5476. exit;
  5477. }
  5478. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5479. foreach ($deldd as $vv) {
  5480. $this->whlabel->remove($vv['id']);
  5481. }
  5482. }
  5483. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5484. exit;
  5485. }
  5486. $this->_Template('whlabel_error', $this->data);
  5487. }
  5488. public function _errorexcel()
  5489. {
  5490. $post = $this->input->post(NULL, TRUE);
  5491. if (isset($_GET['page'])) {
  5492. $page = $this->input->get('page', true);
  5493. $perpage = $this->input->get('perpage', true);
  5494. $sku = $this->input->get('sku', true);
  5495. $warehouse = $this->input->get('warehouse', true);
  5496. $ktime = $this->input->get('ktime', true);
  5497. $jtime = $this->input->get('jtime', true);
  5498. $ktime = strtotime($ktime);
  5499. $jtime = strtotime($jtime);
  5500. $where = "sku != 'Preset'";
  5501. $gj = '';
  5502. if ($sku) {
  5503. $where .= " and sku like '%$sku%'";
  5504. } else {
  5505. if ($ktime && $jtime) {
  5506. $gj = " and time > '$ktime' and time < '$jtime'";
  5507. }
  5508. }
  5509. if ($warehouse) {
  5510. $where .= " and warehouse = '$warehouse'";
  5511. }
  5512. //数据排序
  5513. $order_str = "id desc";
  5514. if (empty($page)) {
  5515. $start = 0;
  5516. $perpage = 1;
  5517. } else {
  5518. $start = ($page - 1) * $perpage;
  5519. }
  5520. //取得信息列表
  5521. $rows = array();
  5522. $list = array();
  5523. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5524. foreach ($info_list as $value) {
  5525. $warehouse = $this->warehouse->read($value['warehouse']);
  5526. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5527. $number = $value['number'];
  5528. $ftime = time() - 15 * 24 * 3600;
  5529. if ($c < 1) {
  5530. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5531. }
  5532. }
  5533. $title = "0库存汇总";
  5534. $titlename = "<table border=1>
  5535. <tr align='center'>
  5536. <td>仓库</td>
  5537. <td>SKU</td>
  5538. <td>产品</td>
  5539. <td>当前库存</td>
  5540. </tr>
  5541. </table>";
  5542. $filename = $title . ".xls";
  5543. $tail = "";
  5544. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5545. }
  5546. }
  5547. /**
  5548. *
  5549. *
  5550. * 占单
  5551. *
  5552. *
  5553. **/
  5554. public function _kcyz()
  5555. {
  5556. $post = $this->input->post(NULL, TRUE);
  5557. if (isset($post['warehouse'])) {
  5558. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5559. exit; //不再使用
  5560. $warehouse = $this->input->post('warehouse', true);
  5561. $whlabel = $this->input->post('whlabel', true);
  5562. $id = $this->input->post('id', true);
  5563. $shop = $this->input->post('shop', true);
  5564. $number = $this->input->post('number', true);
  5565. if (!$whlabel || $whlabel == '|') {
  5566. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5567. exit;
  5568. }
  5569. $pp = explode('|', trim($whlabel, '|'));
  5570. $x = 0;
  5571. $save = array();
  5572. foreach ($pp as $va) {
  5573. $num = explode('-', $va);
  5574. if ($number) {
  5575. $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 = '')"); //通用
  5576. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5577. } else {
  5578. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5579. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5580. }
  5581. $x++;
  5582. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5583. $save[] = $x - 1;
  5584. continue; //提前先加X不然出错,所以要减1
  5585. }
  5586. }
  5587. if (isset($save[0])) {
  5588. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5589. exit;
  5590. } else {
  5591. echo json_encode(array('success' => true));
  5592. exit;
  5593. }
  5594. }
  5595. }
  5596. public function _db()
  5597. {
  5598. $post = $this->input->post(NULL, TRUE);
  5599. if (isset($post['page'])) {
  5600. $page = $this->input->post('page', true);
  5601. $perpage = $this->input->post('perpage', true);
  5602. $sku = $this->input->post('sku', true);
  5603. $number = $this->input->post('number', true);
  5604. $warehouse = $this->input->post('warehouse', true);
  5605. $purchase = $this->input->post('purchase', true);
  5606. $orderinfo = $this->input->post('orderinfo', true);
  5607. $waybill = $this->input->post('waybill', true);
  5608. $category = $this->input->post('category', true);
  5609. $size = $this->input->post('size', true);
  5610. $grade = $this->input->post('grade', true);
  5611. $color = $this->input->post('color', true);
  5612. $lowe = $this->input->post('lowe', true);
  5613. $state = $this->input->post('state', true);
  5614. $label = $this->input->post('label', true);
  5615. $timetk = $this->input->post('timetkk', true);
  5616. $timetj = $this->input->post('timetjj', true);
  5617. $timetk = strtotime($timetk);
  5618. $timetj = strtotime($timetj);
  5619. $where = "dbtime > 0";
  5620. if ($timetk && $timetj) {
  5621. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5622. }
  5623. if ($sku) {
  5624. $where .= " and sku = '$sku'";
  5625. }
  5626. if ($warehouse) {
  5627. $where .= " and warehouse = '$warehouse'";
  5628. if ($warehouse == 12) {
  5629. $w = 'specialstock';
  5630. } else {
  5631. $w = 'whlabel';
  5632. }
  5633. }
  5634. if ($purchase) {
  5635. $where .= " and purchase = '$purchase'";
  5636. }
  5637. if ($category) {
  5638. $where .= " and features like '%-$category-%'";
  5639. }
  5640. if ($size) {
  5641. $where .= " and features like '%-$size-%'";
  5642. }
  5643. if ($grade) {
  5644. $where .= " and features like '%-$grade-%'";
  5645. }
  5646. if ($color) {
  5647. $where .= " and features like '%-$color-%'";
  5648. }
  5649. if ($lowe) {
  5650. $where .= " and features like '%-$lowe-%'";
  5651. }
  5652. if ($state != '') {
  5653. $where .= " and state = '$state'";
  5654. }
  5655. //数据排序
  5656. $order_str = "dbtime desc";
  5657. if (empty($page)) {
  5658. $start = 0;
  5659. $perpage = 1;
  5660. } else {
  5661. $start = ($page - 1) * $perpage;
  5662. }
  5663. //取得信息列表
  5664. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5665. foreach ($info_list as $key => $value) {
  5666. $warehouse = $this->$w->read($value['warehouse']);
  5667. $info_list[$key]['warehouse'] = $warehouse['title'];
  5668. $purchase = $this->purchase->read($value['purchase']);
  5669. $info_list[$key]['purchase'] = $purchase['title'];
  5670. if ($value['enter'] != 0) {
  5671. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5672. } else {
  5673. $info_list[$key]['enter'] = "";
  5674. }
  5675. if ($value['dbtime'] != 0) {
  5676. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5677. } else {
  5678. $info_list[$key]['dbtime'] = "";
  5679. }
  5680. if ($value['state'] == 0) {
  5681. $info_list[$key]['state'] = "在库";
  5682. } else if ($value['state'] == 1) {
  5683. $info_list[$key]['state'] = "出库";
  5684. } else if ($value['state'] == 2) {
  5685. $info_list[$key]['state'] = "退库";
  5686. } else if ($value['state'] == 3) {
  5687. $info_list[$key]['state'] = "调拨中";
  5688. } else if ($value['state'] == 4) {
  5689. $info_list[$key]['state'] = "再加工";
  5690. } else if ($value['state'] == 5) {
  5691. $info_list[$key]['state'] = "维修中";
  5692. } else if ($value['state'] == 6) {
  5693. $info_list[$key]['state'] = "盘亏";
  5694. } else if ($value['state'] == 7) {
  5695. $info_list[$key]['state'] = "更换标签";
  5696. } else if ($value['state'] == 8) {
  5697. $info_list[$key]['state'] = "其它";
  5698. } else if ($value['state'] == 9) {
  5699. $info_list[$key]['state'] = "预设";
  5700. }
  5701. }
  5702. $total = $this->whlabel->find_count($where);
  5703. $pagenum = ceil($total / $perpage);
  5704. $over = $total - ($start + $perpage);
  5705. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5706. echo json_encode($rows);
  5707. exit;
  5708. }
  5709. if (isset($post['outsku'])) {
  5710. $time = time();
  5711. $cz = $this->input->post('cz', true);
  5712. $label = $this->input->post('outsku', true);
  5713. $sl = $this->input->post('sl', true);
  5714. $num = $this->input->post('num', true);
  5715. //$warehouse = $this->input->post('warehouse',true);
  5716. if (!$sl) {
  5717. $sl = 1;
  5718. }
  5719. if (!$warehouse) {
  5720. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5721. exit;
  5722. }
  5723. $dblabel = $this->whlabellabel->get_label($label);
  5724. if ($dblabel) {
  5725. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5726. if (count($data) < 1) {
  5727. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5728. exit;
  5729. }
  5730. if (count($data) < $num) {
  5731. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5732. exit;
  5733. }
  5734. for ($i = 0; $i < $sl; $i++) {
  5735. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5736. }
  5737. echo json_encode(array('success' => true));
  5738. exit;
  5739. } else {
  5740. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5741. exit;
  5742. }
  5743. }
  5744. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5745. $this->_Template('whlabel_db', $this->data);
  5746. }
  5747. public function _dbrk()
  5748. {
  5749. $post = $this->input->post(NULL, TRUE);
  5750. if (isset($post['page'])) {
  5751. $page = $this->input->post('page', true);
  5752. $perpage = $this->input->post('perpage', true);
  5753. $sku = $this->input->post('sku', true);
  5754. $number = $this->input->post('number', true);
  5755. $warehouse = $this->input->post('warehouse', true);
  5756. $purchase = $this->input->post('purchase', true);
  5757. $orderinfo = $this->input->post('orderinfo', true);
  5758. $waybill = $this->input->post('waybill', true);
  5759. $category = $this->input->post('category', true);
  5760. $size = $this->input->post('size', true);
  5761. $grade = $this->input->post('grade', true);
  5762. $color = $this->input->post('color', true);
  5763. $lowe = $this->input->post('lowe', true);
  5764. $state = $this->input->post('state', true);
  5765. $label = $this->input->post('label', true);
  5766. $ctime = $this->input->post('ctime', true);
  5767. $timetk = $this->input->post('timetkk', true);
  5768. $timetj = $this->input->post('timetjj', true);
  5769. $timetk = strtotime($timetk);
  5770. $timetj = strtotime($timetj);
  5771. $where = "dbtime > 0";
  5772. if ($timetk && $timetj) {
  5773. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5774. }
  5775. if ($sku) {
  5776. $where .= " and sku = '$sku'";
  5777. }
  5778. if ($warehouse) {
  5779. $where .= " and warehouse = '$warehouse'";
  5780. }
  5781. if ($purchase) {
  5782. $where .= " and purchase = '$purchase'";
  5783. }
  5784. if ($category) {
  5785. $where .= " and features like '%-$category-%'";
  5786. }
  5787. if ($size) {
  5788. $where .= " and features like '%-$size-%'";
  5789. }
  5790. if ($grade) {
  5791. $where .= " and features like '%-$grade-%'";
  5792. }
  5793. if ($color) {
  5794. $where .= " and features like '%-$color-%'";
  5795. }
  5796. if ($lowe) {
  5797. $where .= " and features like '%-$lowe-%'";
  5798. }
  5799. if ($state != '') {
  5800. $where .= " and state = '$state'";
  5801. }
  5802. //数据排序
  5803. $order_str = "dbtime desc";
  5804. if (empty($page)) {
  5805. $start = 0;
  5806. $perpage = 1;
  5807. } else {
  5808. $start = ($page - 1) * $perpage;
  5809. }
  5810. //取得信息列表
  5811. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5812. foreach ($info_list as $key => $value) {
  5813. $warehouse = $this->warehouse->read($value['warehouse']);
  5814. $info_list[$key]['warehouse'] = $warehouse['title'];
  5815. $purchase = $this->purchase->read($value['purchase']);
  5816. $info_list[$key]['purchase'] = $purchase['title'];
  5817. if ($value['enter'] != 0) {
  5818. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5819. } else {
  5820. $info_list[$key]['enter'] = "";
  5821. }
  5822. if ($value['dbtime'] != 0) {
  5823. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5824. } else {
  5825. $info_list[$key]['dbtime'] = "";
  5826. }
  5827. if ($value['state'] == 0) {
  5828. $info_list[$key]['state'] = "在库";
  5829. } else if ($value['state'] == 1) {
  5830. $info_list[$key]['state'] = "出库";
  5831. } else if ($value['state'] == 2) {
  5832. $info_list[$key]['state'] = "退库";
  5833. } else if ($value['state'] == 3) {
  5834. $info_list[$key]['state'] = "调拨中";
  5835. } else if ($value['state'] == 4) {
  5836. $info_list[$key]['state'] = "再加工";
  5837. } else if ($value['state'] == 5) {
  5838. $info_list[$key]['state'] = "维修中";
  5839. } else if ($value['state'] == 6) {
  5840. $info_list[$key]['state'] = "盘亏";
  5841. } else if ($value['state'] == 7) {
  5842. $info_list[$key]['state'] = "更换标签";
  5843. } else if ($value['state'] == 8) {
  5844. $info_list[$key]['state'] = "其它";
  5845. } else if ($value['state'] == 9) {
  5846. $info_list[$key]['state'] = "预设";
  5847. }
  5848. }
  5849. $total = $this->whlabel->find_count($where);
  5850. $pagenum = ceil($total / $perpage);
  5851. $over = $total - ($start + $perpage);
  5852. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5853. echo json_encode($rows);
  5854. exit;
  5855. }
  5856. if (isset($post['rsku'])) {
  5857. $cz = $this->input->post('cz', true);
  5858. $label = $this->input->post('rsku', true);
  5859. $sl = $this->input->post('sl', true);
  5860. $warehouse = $this->input->post('warehouse', true);
  5861. if (!$sl) {
  5862. $sl = 1;
  5863. }
  5864. if (!$warehouse) {
  5865. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5866. exit;
  5867. }
  5868. $dblabel = $this->whlabellabel->get_label($label);
  5869. if ($dblabel) {
  5870. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5871. if (count($data) < 1) {
  5872. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5873. exit;
  5874. }
  5875. if ($sl > count($data)) {
  5876. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5877. exit;
  5878. }
  5879. $time = time();
  5880. for ($i = 0; $i < $sl; $i++) {
  5881. $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']);
  5882. }
  5883. echo json_encode(array('success' => true));
  5884. exit;
  5885. } else {
  5886. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5887. exit;
  5888. }
  5889. }
  5890. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5891. $this->_Template('whlabel_dbrk', $this->data);
  5892. }
  5893. public function _whlabelczdc()
  5894. {
  5895. if (isset($_GET['excel'])) {
  5896. //数据排序
  5897. $order_str = "id desc";
  5898. if (empty($page)) {
  5899. $start = 0;
  5900. $perpage = 1;
  5901. } else {
  5902. $start = ($page - 1) * $perpage;
  5903. }
  5904. $state = $this->input->get('state', true);
  5905. $sku = $this->input->get('sku', true);
  5906. $ctime = $this->input->get('ctime', true);
  5907. $category = $this->input->get('category', true);
  5908. $size = $this->input->get('size', true);
  5909. $grade = $this->input->get('grade', true);
  5910. $color = $this->input->get('color', true);
  5911. $lowe = $this->input->get('lowe', true);
  5912. $timetk = $this->input->get('timetkk', true);
  5913. $timetj = $this->input->get('timetjj', true);
  5914. $timetk = strtotime($timetk);
  5915. $timetj = strtotime($timetj);
  5916. $where = "dbtime > 0";
  5917. if ($timetk && $timetj) {
  5918. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5919. }
  5920. if ($category) {
  5921. $where .= " and features like '%-$category-%'";
  5922. }
  5923. if ($size) {
  5924. $where .= " and features like '%-$size-%'";
  5925. }
  5926. if ($grade) {
  5927. $where .= " and features like '%-$grade-%'";
  5928. }
  5929. if ($color) {
  5930. $where .= " and features like '%-$color-%'";
  5931. }
  5932. if ($lowe) {
  5933. $where .= " and features like '%-$lowe-%'";
  5934. }
  5935. //取得信息列表
  5936. $info_list = $this->whlabel->find_all($where, '*');
  5937. $rows = array();
  5938. $list = array();
  5939. foreach ($info_list as $key => $value) {
  5940. $rows[$value['sku']] = $value; //所有数据sku
  5941. }
  5942. foreach ($rows as $value) {
  5943. $warehouse = $this->warehouse->read($value['warehouse']);
  5944. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5945. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5946. if ($value['orderinfo'] == 0) {
  5947. $info_list[$key]['orderinfo'] = "";
  5948. }
  5949. if ($value['waybill'] == 0) {
  5950. $info_list[$key]['waybill'] = "";
  5951. }
  5952. if ($value['state'] == 0) {
  5953. $value['state'] = "在库";
  5954. } else if ($value['state'] == 3) {
  5955. $value['state'] = "调拨中";
  5956. }
  5957. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5958. }
  5959. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5960. $titlename = "<table border=1>
  5961. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5962. <tr align='center'>
  5963. <td>SKU</td>
  5964. <td>产品</td>
  5965. <td>调拨数量</td>
  5966. <td>入库数量</td>
  5967. </tr>
  5968. </table>";
  5969. $filename = $title . ".xls";
  5970. $tail = "";
  5971. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5972. }
  5973. }
  5974. public function _print($arg_array)
  5975. {
  5976. if (isset($_SESSION['api'])) {
  5977. $user = $this->user->get_api($_SESSION['api']);
  5978. $usp = $user;
  5979. $fgshop = "";
  5980. $sid = "";
  5981. $wid = "";
  5982. $wtype = "";
  5983. $usersp = explode('|', trim($user['shop'], '|'));
  5984. $userwh = explode('|', trim($user['warehouse'], '|'));
  5985. foreach ($usersp as $value) {
  5986. $fgshop .= " shop = " . $value . " or";
  5987. $sid .= " id = " . $value . " or";
  5988. }
  5989. foreach ($userwh as $value) {
  5990. $wid .= " id = " . $value . " or";
  5991. $wtype .= " type = " . $value . " or";
  5992. }
  5993. }
  5994. $post = $this->input->post(NULL, TRUE);
  5995. if (isset($post['tmsku'])) {
  5996. $tmsku = $this->input->post('tmsku', true);
  5997. if (is_numeric($tmsku)) {
  5998. $yyh = $this->whlabellabel->get_label($tmsku);
  5999. } else {
  6000. $yyh = $this->whlabellabel->get_sku($tmsku);
  6001. if(empty($yyh)){
  6002. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6003. if($r['code'] == -1 ){
  6004. echo json_encode(array('success' => false));
  6005. exit;
  6006. }else{
  6007. echo json_encode(array('features' => $r['data'], 'success' => true));
  6008. exit;
  6009. }
  6010. }
  6011. }
  6012. if ($yyh) {
  6013. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6014. exit;
  6015. } else {
  6016. echo json_encode(array('success' => false));
  6017. exit;
  6018. }
  6019. }
  6020. $classid = $this->classid->sku();
  6021. $pm = $classid;
  6022. $scsku = $classid;
  6023. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6024. if (isset($post['warehouse'])) {
  6025. if ($post['warehouse']) {
  6026. $list = array();
  6027. $num = "";
  6028. $title = "";
  6029. $features = "";
  6030. $order = 0;
  6031. $post['shop'] = '';
  6032. $brand = $this->input->post('brand', true);
  6033. if ($brand != '0,') {
  6034. $b = $this->brand->read(rtrim($brand, ','));
  6035. if ($b) {
  6036. $post['shop'] = str_replace('|', ',', $b['shop']);
  6037. }
  6038. }
  6039. $post['details'] = $this->input->post('details', true); //打印数量
  6040. $xbqnum = $this->input->post('xbqnum', true);
  6041. $post['purchase'] = $this->input->post('purchase', true);
  6042. $post['warehouse'] = $this->input->post('warehouse', true);
  6043. $post['purchase'] = $this->input->post('purchase', true);
  6044. $post['retreatwarehouse'] = $post['warehouse'];
  6045. $post['cpbz'] = $this->input->post('cpbz', true);
  6046. $post['state'] = 9;
  6047. $category = $this->input->post('category', true);
  6048. $list['category'] = $category;
  6049. $list['hairtype'] = $this->input->post('hairtype', true);
  6050. $list['grade'] = $this->input->post('grade', true);
  6051. $size = $this->input->post('size', true);
  6052. $list['size'] = rtrim($size, ',');
  6053. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6054. $list['extension'] = $this->input->post('extension', true);
  6055. if ($category == 1297) {
  6056. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6057. }
  6058. if ($category == 1702) {
  6059. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6060. $list['syother'] = $this->input->post('syother', true);
  6061. }
  6062. if ($category == 133) {
  6063. $list['fittype'] = $this->input->post('fittype', true);
  6064. $list['acother'] = $this->input->post('acother', true);
  6065. }
  6066. $list['color'] = $this->input->post('color', true);
  6067. $list['lowe'] = $this->input->post('lowe', true);
  6068. if ($category == 127) {
  6069. $list['type'] = $this->input->post('type', true);
  6070. $list['headroad'] = $this->input->post('headroad', true);
  6071. $list['density'] = $this->input->post('density', true);
  6072. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6073. $list['lacesize'] = $this->input->post('lacesize', true);
  6074. }
  6075. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6076. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6077. }
  6078. if ($category == 128) {
  6079. $list['lacetype'] = $this->input->post('lacetype', true);
  6080. $list['haircap'] = $this->input->post('haircap', true);
  6081. $list['density'] = $this->input->post('density', true);
  6082. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6083. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6084. $list['wigother'] = $this->input->post('wigother', true);
  6085. $list['wigother1'] = $this->input->post('wigother1', true);
  6086. $list['wigother2'] = $this->input->post('wigother2', true);
  6087. $list['product_related'] = $this->input->post('product_related', true);
  6088. }
  6089. if ($category == 129) {
  6090. $list['wide'] = $this->input->post('wide', true);
  6091. }
  6092. if ($category == 131) {
  6093. $list['gifttype'] = $this->input->post('gifttype', true);
  6094. $list['giftother'] = $this->input->post('giftother', true);
  6095. }
  6096. if ($category == 134) {
  6097. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6098. }
  6099. if ($category == 1297) {
  6100. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6101. $list['sywigother'] = $this->input->post('sywigother', true);
  6102. }
  6103. if ($category == 130 || $category == 133 || $category == 1702) {
  6104. $list['items'] = $this->input->post('items', true);
  6105. $list['weight'] = $this->input->post('weight', true);
  6106. }
  6107. if ($category == 1702) {
  6108. $list['syhairther'] = $this->input->post('syhairther', true);
  6109. }
  6110. if($category == 130){
  6111. $list['jfother'] = $this->input->post('jfother', true);
  6112. }
  6113. foreach ($list as $k => $v) {
  6114. if ($v != 0) {
  6115. $num .= $v;
  6116. $features .= $v . '-';
  6117. $post[$k] = $v;
  6118. $typeclass = $this->typeclass->read($v);
  6119. if (isset($pm[$typeclass['classid']])) {
  6120. if (stripos($typeclass['zh'], '|') !== false) {
  6121. $exzh = explode('|', $typeclass['zh']);
  6122. $pm[$typeclass['classid']] = $exzh[0];
  6123. } else {
  6124. $pm[$typeclass['classid']] = $typeclass['zh'];
  6125. }
  6126. }
  6127. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6128. if ($k != 'size') {
  6129. $title .= $typeclass['title'] . " ";
  6130. }
  6131. }
  6132. }
  6133. $typeclass = $this->typeclass->read($list['size']);
  6134. $title .= $typeclass['title'];
  6135. $time = time();
  6136. $post['title'] = rtrim($title, ' ');
  6137. $post['number'] = $num;
  6138. $post['features'] = '-' . $features;
  6139. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6140. $featurespp = explode('-', trim($featurespp, '-'));
  6141. if (isset($featurespp[5])) {
  6142. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6143. } else {
  6144. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6145. }
  6146. $post['enter'] = $time;
  6147. $post['time'] = $time; //操作时间
  6148. $scsku = implode("-", $scsku);
  6149. $zh = implode(" ", $pm);
  6150. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6151. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6152. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6153. $post['sku'] = $bqsku;
  6154. $label = time() . rand(0, 9);
  6155. $post['label'] = $label;
  6156. $cpid = $this->whlabellabel->find_count();
  6157. $post['cpid'] = $cpid + 1;
  6158. $cpid = $post['cpid'];
  6159. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6160. //if($whlabelbarcode)
  6161. //{
  6162. //$post['label'] = $whlabelbarcode['label'];
  6163. //if(!$this->whlabellabel->insert($post))
  6164. //{
  6165. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6166. //}
  6167. //}
  6168. //else
  6169. //{
  6170. $this->db->trans_begin();
  6171. $this->whlabellabel->insert($post);
  6172. //$this->whlabelbarcode->insert($post);
  6173. if ($this->db->trans_status() === TRUE) {
  6174. $this->db->trans_commit();
  6175. } else {
  6176. $this->db->trans_rollback();
  6177. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6178. exit;
  6179. }
  6180. //}
  6181. $warehouse_name = "";
  6182. $warehouse = $post['warehouse'];
  6183. if($warehouse == 12){
  6184. $warehouse_name = "特殊库存库";
  6185. }
  6186. // if($warehouse == 13){
  6187. // $warehouse_name = "许昌仓";
  6188. // }
  6189. // if($warehouse == 5){
  6190. // $warehouse_name = "美国店";
  6191. // }
  6192. // if($warehouse == 16){
  6193. // $warehouse_name = "定制头套仓";
  6194. // }
  6195. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6196. if(!empty($warehouse_name)){
  6197. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6198. }
  6199. $purchase = $this->purchase->read($post['purchase']);
  6200. 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));
  6201. exit; //特殊仓目前不需要仓库选项
  6202. }
  6203. }
  6204. if (isset($_SESSION['api'])) {
  6205. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6206. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6207. $this->data['wlshop'] = $wlshop;
  6208. $this->data['warehouse'] = $warehouse;
  6209. }
  6210. $whlabelwz = $this->whlabelwz->find_all();
  6211. $this->data['whlabelwz'] = $whlabelwz;
  6212. $this->_Template('whlabel_print', $this->data);
  6213. }
  6214. public function _usaprint($arg_array)
  6215. {
  6216. if (isset($_SESSION['api'])) {
  6217. $user = $this->user->get_api($_SESSION['api']);
  6218. $usp = $user;
  6219. $fgshop = "";
  6220. $sid = "";
  6221. $wid = "";
  6222. $wtype = "";
  6223. $usersp = explode('|', trim($user['shop'], '|'));
  6224. $userwh = explode('|', trim($user['warehouse'], '|'));
  6225. foreach ($usersp as $value) {
  6226. $fgshop .= " shop = " . $value . " or";
  6227. $sid .= " id = " . $value . " or";
  6228. }
  6229. foreach ($userwh as $value) {
  6230. $wid .= " id = " . $value . " or";
  6231. $wtype .= " type = " . $value . " or";
  6232. }
  6233. }
  6234. $post = $this->input->post(NULL, TRUE);
  6235. if (isset($post['tmsku'])) {
  6236. $tmsku = $this->input->post('tmsku', true);
  6237. if (is_numeric($tmsku)) {
  6238. $yyh = $this->whlabellabel->get_label($tmsku);
  6239. } else {
  6240. $yyh = $this->whlabellabel->get_sku($tmsku);
  6241. }
  6242. if ($yyh) {
  6243. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6244. exit;
  6245. } else {
  6246. echo json_encode(array('success' => false));
  6247. exit;
  6248. }
  6249. }
  6250. $classid = $this->classid->sku();
  6251. $pm = $classid;
  6252. $scsku = $classid;
  6253. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6254. if (isset($post['warehouse'])) {
  6255. if ($post['warehouse']) {
  6256. $list = array();
  6257. $num = "";
  6258. $title = "";
  6259. $features = "";
  6260. $order = 0;
  6261. $post['shop'] = '';
  6262. $brand = $this->input->post('brand', true);
  6263. if ($brand != '0,') {
  6264. $b = $this->brand->read(rtrim($brand, ','));
  6265. if ($b) {
  6266. $post['shop'] = str_replace('|', ',', $b['shop']);
  6267. }
  6268. }
  6269. $post['details'] = $this->input->post('details', true); //打印数量
  6270. $xbqnum = $this->input->post('xbqnum', true);
  6271. $post['purchase'] = $this->input->post('purchase', true);
  6272. $post['warehouse'] = $this->input->post('warehouse', true);
  6273. $post['purchase'] = $this->input->post('purchase', true);
  6274. $post['retreatwarehouse'] = $post['warehouse'];
  6275. $post['cpbz'] = $this->input->post('cpbz', true);
  6276. $post['state'] = 9;
  6277. $category = $this->input->post('category', true);
  6278. $list['category'] = $category;
  6279. $list['hairtype'] = $this->input->post('hairtype', true);
  6280. $list['grade'] = $this->input->post('grade', true);
  6281. $size = $this->input->post('size', true);
  6282. $list['size'] = rtrim($size, ',');
  6283. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6284. $list['extension'] = $this->input->post('extension', true);
  6285. if ($category == 1297) {
  6286. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6287. }
  6288. if ($category == 1702) {
  6289. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6290. $list['syother'] = $this->input->post('syother', true);
  6291. }
  6292. if ($category == 133) {
  6293. $list['fittype'] = $this->input->post('fittype', true);
  6294. $list['acother'] = $this->input->post('acother', true);
  6295. }
  6296. $list['color'] = $this->input->post('color', true);
  6297. $list['lowe'] = $this->input->post('lowe', true);
  6298. if ($category == 127) {
  6299. $list['type'] = $this->input->post('type', true);
  6300. $list['headroad'] = $this->input->post('headroad', true);
  6301. $list['density'] = $this->input->post('density', true);
  6302. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6303. $list['lacesize'] = $this->input->post('lacesize', true);
  6304. }
  6305. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6306. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6307. }
  6308. if ($category == 128) {
  6309. $list['lacetype'] = $this->input->post('lacetype', true);
  6310. $list['haircap'] = $this->input->post('haircap', true);
  6311. $list['density'] = $this->input->post('density', true);
  6312. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6313. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6314. $list['wigother'] = $this->input->post('wigother', true);
  6315. $list['wigother1'] = $this->input->post('wigother1', true);
  6316. $list['wigother2'] = $this->input->post('wigother2', true);
  6317. $list['product_related'] = $this->input->post('product_related', true);
  6318. }
  6319. if ($category == 129) {
  6320. $list['wide'] = $this->input->post('wide', true);
  6321. }
  6322. if ($category == 131) {
  6323. $list['gifttype'] = $this->input->post('gifttype', true);
  6324. $list['giftother'] = $this->input->post('giftother', true);
  6325. }
  6326. if ($category == 134) {
  6327. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6328. }
  6329. if ($category == 1297) {
  6330. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6331. $list['sywigother'] = $this->input->post('sywigother', true);
  6332. }
  6333. if ($category == 130 || $category == 133 || $category == 1702) {
  6334. $list['items'] = $this->input->post('items', true);
  6335. $list['weight'] = $this->input->post('weight', true);
  6336. }
  6337. if ($category == 1702) {
  6338. $list['syhairther'] = $this->input->post('syhairther', true);
  6339. }
  6340. foreach ($list as $k => $v) {
  6341. if ($v != 0) {
  6342. $num .= $v;
  6343. $features .= $v . '-';
  6344. $post[$k] = $v;
  6345. $typeclass = $this->typeclass->read($v);
  6346. if (isset($pm[$typeclass['classid']])) {
  6347. if (stripos($typeclass['zh'], '|') !== false) {
  6348. $exzh = explode('|', $typeclass['zh']);
  6349. $pm[$typeclass['classid']] = $exzh[0];
  6350. } else {
  6351. $pm[$typeclass['classid']] = $typeclass['zh'];
  6352. }
  6353. }
  6354. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6355. if ($k != 'size') {
  6356. $title .= $typeclass['title'] . " ";
  6357. }
  6358. }
  6359. }
  6360. $typeclass = $this->typeclass->read($list['size']);
  6361. $title .= $typeclass['title'];
  6362. $time = time();
  6363. $post['title'] = rtrim($title, ' ');
  6364. $post['number'] = $num;
  6365. $post['features'] = '-' . $features;
  6366. $fp = $this->whlabel->get_features($post['features']);
  6367. if (!$fp) {
  6368. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6369. exit;
  6370. }
  6371. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6372. $featurespp = explode('-', trim($featurespp, '-'));
  6373. if (isset($featurespp[5])) {
  6374. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6375. } else {
  6376. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6377. }
  6378. $post['enter'] = $time;
  6379. $post['time'] = $time; //操作时间
  6380. $scsku = implode("-", $scsku);
  6381. $zh = implode(" ", $pm);
  6382. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6383. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6384. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6385. $post['sku'] = $fp['sku'];
  6386. $post['label'] = $fp['sku'];
  6387. $cpid = $this->whlabellabel->find_count();
  6388. $post['cpid'] = $cpid + 1;
  6389. $cpid = $post['cpid'];
  6390. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6391. //if($whlabelbarcode)
  6392. //{
  6393. //$post['label'] = $whlabelbarcode['label'];
  6394. //if(!$this->whlabellabel->insert($post))
  6395. //{
  6396. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6397. //}
  6398. //}
  6399. //else
  6400. //{
  6401. $this->db->trans_begin();
  6402. $this->whlabellabel->insert($post);
  6403. //$this->whlabelbarcode->insert($post);
  6404. if ($this->db->trans_status() === TRUE) {
  6405. $this->db->trans_commit();
  6406. } else {
  6407. $this->db->trans_rollback();
  6408. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6409. exit;
  6410. }
  6411. //}
  6412. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6413. $purchase = $this->purchase->read($post['purchase']);
  6414. 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));
  6415. exit; //特殊仓目前不需要仓库选项
  6416. }
  6417. }
  6418. if (isset($_SESSION['api'])) {
  6419. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6420. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6421. $this->data['wlshop'] = $wlshop;
  6422. $this->data['warehouse'] = $warehouse;
  6423. }
  6424. $whlabelwz = $this->whlabelwz->find_all();
  6425. $this->data['whlabelwz'] = $whlabelwz;
  6426. $this->_Template('whlabel_usaprint', $this->data);
  6427. }
  6428. public function _printrk($arg_array)
  6429. {
  6430. $prc = array();
  6431. $purchase = $this->purchase->find_all();
  6432. foreach ($purchase as $k => $v) {
  6433. $prc[$v['id']] = $v['title'];
  6434. }
  6435. $post = $this->input->post(NULL, TRUE);
  6436. if (isset($post['page'])) {
  6437. $page = $this->input->post('page', true);
  6438. $perpage = $this->input->post('perpage', true);
  6439. $sku = $this->input->post('sku', true);
  6440. $bs = $this->input->post('bs', true);
  6441. $number = $this->input->post('number', true);
  6442. $warehouse = $this->input->post('warehouse', true);
  6443. $purchase = $this->input->post('purchase', true);
  6444. $orderinfo = $this->input->post('orderinfo', true);
  6445. $waybill = $this->input->post('waybill', true);
  6446. $category = $this->input->post('category', true);
  6447. $size = $this->input->post('size', true);
  6448. $grade = $this->input->post('grade', true);
  6449. $color = $this->input->post('color', true);
  6450. $lowe = $this->input->post('lowe', true);
  6451. $state = $this->input->post('state', true);
  6452. $label = $this->input->post('label', true);
  6453. $timetk = $this->input->post('ktime', true);
  6454. $timetj = $this->input->post('jtime', true);
  6455. $timetk = strtotime($timetk);
  6456. $timetj = strtotime($timetj);
  6457. $where = "1=1 ";
  6458. if ($timetk && $timetj) {
  6459. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6460. }
  6461. if ($sku) {
  6462. $where .= " and sku = '$sku'";
  6463. }
  6464. if ($bs != '') {
  6465. $where .= " and bs = '$bs'";
  6466. }
  6467. if ($number) {
  6468. $where .= " and number = '$number'";
  6469. }
  6470. if ($warehouse) {
  6471. $where .= " and warehouse = '$warehouse'";
  6472. }
  6473. if ($purchase) {
  6474. $where .= " and purchase = '$purchase'";
  6475. }
  6476. if ($orderinfo) {
  6477. $where .= " and orderinfo = '$orderinfo'";
  6478. }
  6479. if ($waybill) {
  6480. $where .= " and waybill = '$waybill'";
  6481. }
  6482. if ($category) {
  6483. $where .= " and features like '%-$category-%'";
  6484. }
  6485. if ($size) {
  6486. $where .= " and features like '%-$size-%'";
  6487. }
  6488. if ($grade) {
  6489. $where .= " and features like '%-$grade-%'";
  6490. }
  6491. if ($color) {
  6492. $where .= " and features like '%-$color-%'";
  6493. }
  6494. if ($lowe) {
  6495. $where .= " and features like '%-$lowe-%'";
  6496. }
  6497. if ($label) {
  6498. $where .= " and label = '$label'";
  6499. }
  6500. if ($state || $state == 0) {
  6501. $where .= " and state = '$state'";
  6502. }
  6503. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6504. //数据排序
  6505. $order_str = "enter desc";
  6506. if (empty($page)) {
  6507. $start = 0;
  6508. $perpage = 1;
  6509. } else {
  6510. $start = ($page - 1) * $perpage;
  6511. }
  6512. //取得信息列表
  6513. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6514. foreach ($info_list as $key => $value) {
  6515. $warehouse = $this->warehouse->read($value['warehouse']);
  6516. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6517. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6518. if ($value['state'] == 0) {
  6519. $info_list[$key]['state'] = "在库";
  6520. } else if ($value['state'] == 1) {
  6521. $info_list[$key]['state'] = "出库";
  6522. } else if ($value['state'] == 2) {
  6523. $info_list[$key]['state'] = "退库";
  6524. } else if ($value['state'] == 3) {
  6525. $info_list[$key]['state'] = "调拨中";
  6526. } else if ($value['state'] == 4) {
  6527. $info_list[$key]['state'] = "再加工";
  6528. } else if ($value['state'] == 5) {
  6529. $info_list[$key]['state'] = "维修中";
  6530. } else if ($value['state'] == 6) {
  6531. $info_list[$key]['state'] = "盘亏";
  6532. } else if ($value['state'] == 7) {
  6533. $info_list[$key]['state'] = "更换标签";
  6534. } else if ($value['state'] == 8) {
  6535. $info_list[$key]['state'] = "其它";
  6536. } else if ($value['state'] == 9) {
  6537. $info_list[$key]['state'] = "预设";
  6538. } else if ($value['state'] == 10) {
  6539. $info_list[$key]['state'] = "美店零售";
  6540. }
  6541. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6542. }
  6543. $total = $this->$ck->find_count($where);
  6544. $pagenum = ceil($total / $perpage);
  6545. $over = $total - ($start + $perpage);
  6546. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6547. echo json_encode($rows);
  6548. exit;
  6549. }
  6550. if (isset($post['tmsku'])) {
  6551. $time = time();
  6552. $tmsku = $this->input->post('tmsku', true);
  6553. //$post['shop'] = $this->input->post('shop',true);
  6554. $num = $this->input->post('num', true);
  6555. $rktype = $this->input->post('rktype', true);
  6556. if ($num > 200) {
  6557. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6558. exit;
  6559. }
  6560. if (!$rktype) {
  6561. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6562. }
  6563. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6564. /**
  6565. $wz = array();
  6566. foreach ($rk as $key=>$value)
  6567. {
  6568. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6569. }
  6570. if(count($wz) > 1)
  6571. {
  6572. $wz = array_values($wz);
  6573. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6574. }
  6575. **/
  6576. if (isset($rk[0]['purchase'])) {
  6577. $rk = $rk[0];
  6578. $j = 0;
  6579. $post['purchase'] = $rk['purchase'];
  6580. $post['warehouse'] = $rk['warehouse'];
  6581. $post['retreatwarehouse'] = $rk['warehouse'];
  6582. $post['sku'] = $rk['sku'];
  6583. $post['number'] = $rk['number'];
  6584. $post['features'] = $rk['features'];
  6585. $post['title'] = $rk['title'];
  6586. $post['enter'] = $time;
  6587. $post['time'] = $time;
  6588. $post['bs'] = 1;
  6589. $post['shop'] = $rk['shop'];
  6590. $post['details'] = $rk['details'];
  6591. $post['cpid'] = $rk['cpid'];
  6592. $post['cpbz'] = $rk['cpbz'];
  6593. $post['rktype'] = $rktype;
  6594. $warehouse = $this->warehouse->read($rk['warehouse']);
  6595. if ($warehouse['bdck'] == '') {
  6596. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6597. exit;
  6598. } else {
  6599. $bdck = $warehouse['bdck'];
  6600. }
  6601. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6602. if (isset($pdwz['details'])) {
  6603. if ($pdwz['details'] != $post['details']) {
  6604. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6605. }else{
  6606. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6607. exit;
  6608. }
  6609. }
  6610. }
  6611. $post['featurespp'] = $rk['featurespp'];
  6612. if ($post['warehouse'] == '5') {
  6613. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6614. if ($yza) {
  6615. if ($post['features'] != $yza[0]['features']) {
  6616. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6617. exit;
  6618. }
  6619. }
  6620. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6621. if ($yzb) {
  6622. if ($post['sku'] != $yzb[0]['sku']) {
  6623. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6624. exit;
  6625. }
  6626. }
  6627. }
  6628. for ($i = 0; $i < $num; $i++) {
  6629. $post['label'] = time() . rand(100, 999) . $i;
  6630. if ($this->$bdck->insert($post)) {
  6631. $j++;
  6632. }
  6633. }
  6634. /**
  6635. if($post['warehouse'] != 12)
  6636. {
  6637. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6638. }
  6639. **/
  6640. $this->whlabelscanlog->insert([
  6641. 'shop'=>$rk['shop'],
  6642. 'type'=>1,
  6643. 'purchase'=>$rk['purchase'],
  6644. 'sku'=>$rk['sku'],
  6645. 'features'=>$rk['features'],
  6646. 'title'=>$rk['title'],
  6647. 'label'=>$rk['label'],
  6648. 'warehouse'=>$rk['warehouse'],
  6649. 'wlid'=>$rk['id'],
  6650. 'num'=>$num,
  6651. 'addtime'=>time()
  6652. ]);
  6653. if ($j == $num) {
  6654. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6655. exit;
  6656. } else {
  6657. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6658. exit;
  6659. }
  6660. } else {
  6661. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6662. exit;
  6663. }
  6664. }
  6665. $this->_Template('whlabel_printrk', $this->data);
  6666. }
  6667. public function _printxzrk($arg_array)
  6668. {
  6669. $post = $this->input->post(NULL, TRUE);
  6670. if (isset($post['wzid'])) {
  6671. $time = time();
  6672. $id = $this->input->post('wzid', true);
  6673. //$post['shop'] = $this->input->post('shop',true);
  6674. $num = 1;
  6675. $rk = $this->whlabellabel->read($id);
  6676. if (isset($rk['purchase'])) {
  6677. $x = 0;
  6678. $post['purchase'] = $rk['purchase'];
  6679. $post['warehouse'] = $rk['warehouse'];
  6680. $post['retreatwarehouse'] = $rk['warehouse'];
  6681. $post['sku'] = $rk['sku'];
  6682. $post['number'] = $rk['number'];
  6683. $post['features'] = $rk['features'];
  6684. $post['title'] = $rk['title'];
  6685. $post['enter'] = $time;
  6686. $post['time'] = $time;
  6687. $post['bs'] = 1;
  6688. $post['shop'] = $rk['shop'];
  6689. $post['details'] = $rk['details'];
  6690. $post['cpid'] = $rk['cpid'];
  6691. $post['cpbz'] = $rk['cpbz'];
  6692. $warehouse = $this->warehouse->read($rk['warehouse']);
  6693. if ($warehouse['bdck'] == '') {
  6694. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6695. exit;
  6696. } else {
  6697. $bdck = $warehouse['bdck'];
  6698. }
  6699. $post['featurespp'] = $rk['featurespp'];
  6700. $this->db->trans_begin();
  6701. for ($i = 0; $i < $num; $i++) {
  6702. $post['label'] = time() . rand(100, 999) . $i;
  6703. $this->$bdck->insert($post);
  6704. }
  6705. /**
  6706. if($post['warehouse'] != 12)
  6707. {
  6708. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6709. }
  6710. **/
  6711. if ($this->db->trans_status() === TRUE) {
  6712. $this->db->trans_commit();
  6713. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6714. exit;
  6715. } else {
  6716. $this->db->trans_rollback();
  6717. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6718. exit;
  6719. }
  6720. } else {
  6721. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6722. exit;
  6723. }
  6724. }
  6725. }
  6726. public function _printck($arg_array)
  6727. {
  6728. $prc = array();
  6729. $purchase = $this->purchase->find_all();
  6730. foreach ($purchase as $k => $v) {
  6731. $prc[$v['id']] = $v['title'];
  6732. }
  6733. $post = $this->input->post(NULL, TRUE);
  6734. if (isset($post['page'])) {
  6735. $page = $this->input->post('page', true);
  6736. $perpage = $this->input->post('perpage', true);
  6737. $sku = $this->input->post('sku', true);
  6738. $bs = $this->input->post('bs', true);
  6739. $number = $this->input->post('number', true);
  6740. $warehouse = $this->input->post('warehouse', true);
  6741. $purchase = $this->input->post('purchase', true);
  6742. $orderinfo = $this->input->post('orderinfo', true);
  6743. $waybill = $this->input->post('waybill', true);
  6744. $category = $this->input->post('category', true);
  6745. $size = $this->input->post('size', true);
  6746. $grade = $this->input->post('grade', true);
  6747. $color = $this->input->post('color', true);
  6748. $lowe = $this->input->post('lowe', true);
  6749. $state = $this->input->post('state', true);
  6750. $label = $this->input->post('label', true);
  6751. $timetk = $this->input->post('ktime', true);
  6752. $timetj = $this->input->post('jtime', true);
  6753. $timetk = strtotime($timetk);
  6754. $timetj = strtotime($timetj);
  6755. $where = "state=1 ";
  6756. if ($timetk && $timetj) {
  6757. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6758. }
  6759. if ($sku) {
  6760. $where .= " and sku = '$sku'";
  6761. }
  6762. if ($bs != '') {
  6763. $where .= " and bs = '$bs'";
  6764. }
  6765. if ($number) {
  6766. $where .= " and number = '$number'";
  6767. }
  6768. if ($warehouse) {
  6769. $where .= " and warehouse = '$warehouse'";
  6770. }
  6771. if ($purchase) {
  6772. $where .= " and purchase = '$purchase'";
  6773. }
  6774. if ($orderinfo) {
  6775. $where .= " and orderinfo = '$orderinfo'";
  6776. }
  6777. if ($waybill) {
  6778. $where .= " and waybill = '$waybill'";
  6779. }
  6780. if ($category) {
  6781. $where .= " and features like '%-$category-%'";
  6782. }
  6783. if ($size) {
  6784. $where .= " and features like '%-$size-%'";
  6785. }
  6786. if ($grade) {
  6787. $where .= " and features like '%-$grade-%'";
  6788. }
  6789. if ($color) {
  6790. $where .= " and features like '%-$color-%'";
  6791. }
  6792. if ($lowe) {
  6793. $where .= " and features like '%-$lowe-%'";
  6794. }
  6795. if ($label) {
  6796. $where .= " and label = '$label'";
  6797. }
  6798. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6799. //数据排序
  6800. $order_str = "outk desc";
  6801. if (empty($page)) {
  6802. $start = 0;
  6803. $perpage = 1;
  6804. } else {
  6805. $start = ($page - 1) * $perpage;
  6806. }
  6807. //取得信息列表
  6808. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6809. foreach ($info_list as $key => $value) {
  6810. $warehouse = $this->warehouse->read($value['warehouse']);
  6811. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6812. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6813. if ($value['state'] == 0) {
  6814. $info_list[$key]['state'] = "在库";
  6815. } else if ($value['state'] == 1) {
  6816. $info_list[$key]['state'] = "出库";
  6817. } else if ($value['state'] == 2) {
  6818. $info_list[$key]['state'] = "退库";
  6819. } else if ($value['state'] == 3) {
  6820. $info_list[$key]['state'] = "调拨中";
  6821. } else if ($value['state'] == 4) {
  6822. $info_list[$key]['state'] = "再加工";
  6823. } else if ($value['state'] == 5) {
  6824. $info_list[$key]['state'] = "维修中";
  6825. } else if ($value['state'] == 6) {
  6826. $info_list[$key]['state'] = "盘亏";
  6827. } else if ($value['state'] == 7) {
  6828. $info_list[$key]['state'] = "更换标签";
  6829. } else if ($value['state'] == 8) {
  6830. $info_list[$key]['state'] = "其它";
  6831. } else if ($value['state'] == 9) {
  6832. $info_list[$key]['state'] = "预设";
  6833. } else if ($value['state'] == 10) {
  6834. $info_list[$key]['state'] = "美店零售";
  6835. }
  6836. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6837. }
  6838. $total = $this->$ck->find_count($where);
  6839. $pagenum = ceil($total / $perpage);
  6840. $over = $total - ($start + $perpage);
  6841. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6842. echo json_encode($rows);
  6843. exit;
  6844. }
  6845. if (isset($post['tmsku'])) {
  6846. $time = time();
  6847. $tmsku = $this->input->post('tmsku', true);
  6848. //$post['shop'] = $this->input->post('shop',true);
  6849. $num = $this->input->post('num', true);
  6850. $cktype = $this->input->post('cktype', true);
  6851. $label = $this->whlabellabel->get_label($tmsku);
  6852. if (!$cktype) {
  6853. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6854. }
  6855. if (!isset($label['warehouse'])) {
  6856. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6857. exit;
  6858. }
  6859. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6860. $extra_where = "";
  6861. if(!empty($label['details'])){
  6862. $extra_where .= " and details = '" . $label['details'] . "'";
  6863. }
  6864. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6865. if (stripos($label['features'], '-126-') !== false) {
  6866. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6867. } else {
  6868. $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 = '' or zd is null ) ".$extra_where);
  6869. }
  6870. $j = 0;
  6871. if (count($ck) >= $num) {
  6872. for ($i = 0; $i < $num; $i++) {
  6873. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6874. {
  6875. $j++;
  6876. }
  6877. }
  6878. $this->whlabelscanlog->insert([
  6879. 'shop'=>$label['shop'],
  6880. 'type'=>2,
  6881. 'purchase'=>$label['purchase'],
  6882. 'sku'=>$label['sku'],
  6883. 'features'=>$label['features'],
  6884. 'title'=>$label['title'],
  6885. 'label'=>$label['label'],
  6886. 'warehouse'=>$label['warehouse'],
  6887. 'wlid'=>$label['id'],
  6888. 'num'=>$num,
  6889. 'addtime'=>time()
  6890. ]);
  6891. if ($j == $num) {
  6892. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6893. exit;
  6894. } else {
  6895. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6896. exit;
  6897. }
  6898. } else {
  6899. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6900. exit;
  6901. }
  6902. }
  6903. if(isset($_SESSION['api']))
  6904. {
  6905. $user = $this->user->get_api($_SESSION['api']);
  6906. if(in_array($user['power'],[1,27])){
  6907. $vip = 1;
  6908. }
  6909. }
  6910. else
  6911. {
  6912. $vip = 0;
  6913. header('Location: /');exit;
  6914. }
  6915. $this->data['vip'] = $vip;
  6916. $this->_Template('whlabel_printck', $this->data);
  6917. }
  6918. public function _printexcel()
  6919. {
  6920. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6921. $config['upload_path'] = '.' . $dir;
  6922. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6923. $config['allowed_types'] = 'xls|xlsx|csv';
  6924. $config['max_size'] = 10240;
  6925. $this->load->library('upload', $config);
  6926. $this->upload->initialize($config);
  6927. if ($this->upload->do_upload('userfile')) {
  6928. $full_path = $dir . $this->upload->data('file_name');
  6929. $fileName = '.' . $full_path;
  6930. if (!file_exists($fileName)) {
  6931. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6932. exit;
  6933. } else {
  6934. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6935. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6936. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6937. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6938. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6939. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6940. ++$column; //如果列数大于26行
  6941. $list = array();
  6942. for ($i = 2; $i <= $row; $i++) // 行数循环
  6943. {
  6944. $data = array();
  6945. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6946. {
  6947. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6948. }
  6949. $list[] = $data;
  6950. }
  6951. }
  6952. $ed = array();
  6953. $i = 0;
  6954. $j = 0;
  6955. $dcdata = array();
  6956. $yc = '';
  6957. $cmf_arr = array_column($list, '1');
  6958. array_multisort($cmf_arr, SORT_ASC, $list);
  6959. foreach ($list as $key => $value) {
  6960. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6961. if ($typeclass) {
  6962. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6963. } else {
  6964. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6965. $i++;
  6966. continue;
  6967. }
  6968. }
  6969. if ($i > 0) {
  6970. $yc = $i . '条异常';
  6971. }
  6972. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6973. exit;
  6974. }
  6975. }
  6976. public function _uck()
  6977. {
  6978. if (isset($_GET['excel'])) {
  6979. $tc = array();
  6980. $typeclass = $this->typeclass->find_all();
  6981. foreach ($typeclass as $v) {
  6982. $tc[$v['id']] = $v['zh'];
  6983. }
  6984. $data = array();
  6985. $t = array();
  6986. $rq = '';
  6987. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6988. $ts = $ts / (24 * 3600);
  6989. for ($i = 0; $i < $ts; $i++) {
  6990. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6991. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6992. }
  6993. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6994. foreach ($info_list as $k => $v) {
  6995. $features = explode('-', trim($v['features'], '-'));
  6996. if (!isset($features[3]) || !isset($features[4])) {
  6997. continue;
  6998. }
  6999. $data[$k][0] = $tc[$features[0]]; //类型
  7000. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7001. $data[$k][2] = $tc[$features[4]]; //曲度
  7002. $data[$k][3] = '';
  7003. if (isset($data[$k][1])) {
  7004. $data[$k][3] .= $data[$k][1];
  7005. }
  7006. if (isset($data[$k][2])) {
  7007. $data[$k][3] .= $data[$k][2];
  7008. }
  7009. if (isset($features[5])) {
  7010. $data[$k][3] .= $tc[$features[5]];
  7011. }
  7012. if (isset($features[2])) {
  7013. $data[$k][3] .= $tc[$features[2]];
  7014. }
  7015. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7016. $data[$k][4] = $v['sku'];
  7017. $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())) . '))'); //月初库存
  7018. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7019. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7020. $ztrq = '';
  7021. $ztsl = '';
  7022. if (count($zt) > 0) {
  7023. foreach ($zt as $vv) {
  7024. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7025. $ztsl .= $vv['num'] . '<br>';
  7026. }
  7027. }
  7028. $data[$k][] = trim($ztsl, '<br>');
  7029. $data[$k][] = trim($ztrq, '<br>');
  7030. $byck = 0;
  7031. foreach ($t as $vv) {
  7032. $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));
  7033. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7034. $byck += $sl;
  7035. }
  7036. $data[$k][] = ($byck > 0) ? $byck : '';
  7037. }
  7038. $title = "详情 " . date("Y-m-d", time());
  7039. $titlename = "<table border=1>
  7040. <tr align='center'>
  7041. <td>类别</td>
  7042. <td>颜色</td>
  7043. <td>曲度</td>
  7044. <td>名称</td>
  7045. <td>SKU</td>
  7046. <td>月初库存</td>
  7047. <td>剩余库存</td>
  7048. <td>在途数量</td>
  7049. <td>预达日期</td>" .
  7050. $rq
  7051. . "<td>本月出库</td></tr>
  7052. </table>";
  7053. $filename = $title . ".xls";
  7054. $tail = "";
  7055. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7056. }
  7057. }
  7058. public function _whlabelexcelzh()
  7059. {
  7060. if (isset($_GET['excel'])) {
  7061. $where = "sku != 'Preset'";
  7062. //数据排序
  7063. $order_str = "id desc";
  7064. if (empty($page)) {
  7065. $start = 0;
  7066. $perpage = 1;
  7067. } else {
  7068. $start = ($page - 1) * $perpage;
  7069. }
  7070. $category = $this->input->get('category', true);
  7071. $warehouse = $this->input->get('warehouse', true);
  7072. $excelid = $this->input->get('sid', true);
  7073. if ($category) {
  7074. $where .= " and features like '%-$category-%'";
  7075. }
  7076. if ($warehouse) {
  7077. $where .= " and warehouse = '$warehouse'";
  7078. }
  7079. $xzid = '';
  7080. if ($excelid) {
  7081. $excelid = explode(',', trim($excelid, ','));
  7082. foreach ($excelid as $key => $value) {
  7083. $xzid .= " id = " . $value . " or";
  7084. }
  7085. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7086. }
  7087. //取得信息列表
  7088. /**
  7089. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7090. $rows = array();$list = array();
  7091. foreach ($info_list as $key=>$value)
  7092. {
  7093. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7094. }
  7095. **/
  7096. $list = array();
  7097. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7098. foreach ($rows as $key => $value) {
  7099. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7100. $zh = '';
  7101. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7102. foreach ($zt as $v) {
  7103. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7104. }
  7105. $zt = array_sum(array_column($zt, 'num'));
  7106. $number = $value['number'];
  7107. $ftime = time() - 15 * 24 * 3600;
  7108. $warehouse = $this->warehouse->read($value['warehouse']);
  7109. $rows[$key]['warehouse'] = $warehouse['title'];
  7110. $rows[$key]['number'] = $c;
  7111. $rows[$key]['features'] = $zh;
  7112. $rows[$key]['hb'] = $c + $zt;
  7113. }
  7114. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7115. $titlename = "<table border=1>
  7116. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7117. <tr align='center'>
  7118. <td>仓库</td>
  7119. <td>SKU</td>
  7120. <td>产品</td>
  7121. <td>库存数量</td>
  7122. <td>在途数量及预达日期</td>
  7123. <td>在途+库存数量</td>
  7124. </tr>
  7125. </table>";
  7126. $filename = $title . ".xls";
  7127. $tail = "";
  7128. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7129. }
  7130. if (isset($_GET['excel'])) {
  7131. $warehouse = $this->input->get('warehouse', true);
  7132. $sku = $this->input->get('sku', true);
  7133. $cz = $this->input->get('cz', true);
  7134. $text = $this->input->post('text', true);
  7135. $xztime = $this->input->get('xztime', true);
  7136. $timetk = $this->input->get('timetk', true);
  7137. $timetj = $this->input->get('timetj', true);
  7138. $timetk = strtotime($timetk);
  7139. $timetj = strtotime($timetj);
  7140. $where = "time = '0' ";
  7141. if ($warehouse) {
  7142. $where .= " and warehouse = '$warehouse'";
  7143. }
  7144. if ($sku) {
  7145. $where .= " and sku = '$sku'";
  7146. }
  7147. if ($text) {
  7148. $where .= " and text like '%$text%'";
  7149. }
  7150. if ($cz != '') {
  7151. $where .= " and cz = '$cz'";
  7152. }
  7153. if ($timetk && $timetj) {
  7154. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7155. }
  7156. //数据排序
  7157. $order_str = $xztime . " desc";
  7158. //取得信息列表
  7159. $zh = array();
  7160. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7161. foreach ($info_list as $v) {
  7162. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7163. $warehouse = $this->warehouse->read($v['warehouse']);
  7164. $v['warehouse'] = $warehouse['title'];
  7165. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7166. $v['stime'] = date('Y-m-d', $v['stime']);
  7167. if (isset($zh[$v['features']])) {
  7168. $zh[$v['features']]['num'] += $v['num'];
  7169. } else {
  7170. $zh[$v['features']] = $v;
  7171. }
  7172. $zh[$v['features']]['features'] = $c;
  7173. }
  7174. $title = "在途数据" . date('Y-m-d', time());
  7175. $titlename = "<table border=1>
  7176. <tr align='center'>
  7177. <td>仓库</td>
  7178. <td>SKU</td>
  7179. <td>名称</td>
  7180. <td>在途数量</td>
  7181. <td>库存数量</td>
  7182. <td>添加在途日期</td>
  7183. <td>预达日期</td>
  7184. <td>备注</td>
  7185. </tr>
  7186. </table>";
  7187. $filename = $title . ".xls";
  7188. $tail = "";
  7189. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7190. }
  7191. }
  7192. public function _fc()
  7193. {
  7194. $vip = 0;
  7195. if (isset($_SESSION['api'])) {
  7196. $user = $this->user->get_api($_SESSION['api']);
  7197. if ($user['vip'] == 1) {
  7198. $vip = 1;
  7199. }
  7200. } else {
  7201. header('Location: /');
  7202. exit;
  7203. }
  7204. $post = $this->input->post(NULL, TRUE);
  7205. if (isset($post['page'])) {
  7206. $page = $this->input->post('page', true);
  7207. $perpage = $this->input->post('perpage', true);
  7208. $category = $this->input->post('category', true);
  7209. $size = $this->input->post('size', true);
  7210. $grade = $this->input->post('grade', true);
  7211. $color = $this->input->post('color', true);
  7212. $lowe = $this->input->post('lowe', true);
  7213. $sku = $this->input->post('sku');
  7214. $title = $this->input->post('title');
  7215. $warehouse = $this->input->post('warehouse', true);
  7216. $usa = $this->input->post('usa', true);
  7217. $purchase = $this->input->post('purchase', true);
  7218. $lacetype = $this->input->post('lacetype', true);
  7219. $haircap = $this->input->post('haircap', true);
  7220. $density = $this->input->post('density', true);
  7221. $details = $this->input->post('details', true);
  7222. $state = $this->input->post('state', true);
  7223. $ktime = $this->input->post('ktime', true);
  7224. $jtime = $this->input->post('jtime', true);
  7225. $ktime = strtotime($ktime);
  7226. $jtime = strtotime($jtime);
  7227. $where = "state = '11'";
  7228. $gj = "";
  7229. $ck = "";
  7230. if ($lacetype) {
  7231. $where .= " and features like '%-$lacetype-%'";
  7232. }
  7233. if ($category) {
  7234. $where .= " and features like '%-$category-%'";
  7235. }
  7236. if ($size) {
  7237. $where .= " and features like '%-$size-%'";
  7238. }
  7239. if ($grade) {
  7240. $where .= " and features like '%-$grade-%'";
  7241. }
  7242. if ($color) {
  7243. $where .= " and features like '%-$color-%'";
  7244. }
  7245. if ($lowe) {
  7246. $where .= " and features like '%-$lowe-%'";
  7247. }
  7248. if ($haircap) {
  7249. $where .= " and features like '%-$haircap-%'";
  7250. }
  7251. if ($density) {
  7252. $where .= " and features like '%-$density-%'";
  7253. }
  7254. if ($usa) {
  7255. if (!$warehouse) {
  7256. $where .= " and (warehouse = '5' or warehouse = '8')";
  7257. }
  7258. }
  7259. if ($warehouse) {
  7260. $where .= " and warehouse = '$warehouse'";
  7261. }
  7262. if ($details) {
  7263. $where .= " and details = '$details'";
  7264. }
  7265. if ($purchase) {
  7266. $where .= " and purchase = '$purchase'";
  7267. }
  7268. if ($state) {
  7269. $where .= " and state = '$state'";
  7270. }
  7271. if ($ktime && $jtime) {
  7272. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7273. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7274. }
  7275. //数据排序
  7276. $order_str = "id desc";
  7277. if (empty($page)) {
  7278. $start = 0;
  7279. $perpage = 1;
  7280. } else {
  7281. $start = ($page - 1) * $perpage;
  7282. }
  7283. if ($sku) {
  7284. $sku = trim($sku, ' ');
  7285. $sku = trim($sku, ' ');
  7286. $where .= " and sku like '%$sku%'";
  7287. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7288. } else if ($title) {
  7289. $title = trim($title, ' ');
  7290. $title = trim($title, ' ');
  7291. $where .= " and title like '%$title%'";
  7292. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7293. } else {
  7294. //$where .= " and time > '$ktime' and time < '$jtime'";
  7295. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7296. }
  7297. //取得信息列表
  7298. $rows = array();
  7299. $list = array();
  7300. foreach ($info_list as $key => $value) {
  7301. $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'] . '"');
  7302. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7303. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7304. $warehouse = $this->warehouse->read($value['warehouse']);
  7305. $info_list[$key]['warehouse'] = $warehouse['title'];
  7306. $info_list[$key]['number'] = $g;
  7307. $info_list[$key]['features'] = $x;
  7308. $info_list[$key]['x'] = $s;
  7309. }
  7310. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7311. $pagenum = ceil($total / $perpage);
  7312. $over = $total - ($start + $perpage);
  7313. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7314. echo json_encode($rows);
  7315. exit;
  7316. }
  7317. $this->data['vip'] = $vip;
  7318. $this->_Template('whlabel_fc', $this->data);
  7319. }
  7320. public function _fcmb()
  7321. {
  7322. $where = "sku != 'Preset'";
  7323. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7324. foreach ($rows as $k => $v) {
  7325. $warehouse = $this->warehouse->read($v['warehouse']);
  7326. $rows[$k]['warehouse'] = $warehouse['title'];
  7327. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7328. $rows[$k]['t'] = '';
  7329. $rows[$k]['n'] = '';
  7330. }
  7331. $title = "封货产品数据导入模板";
  7332. $titlename = "<table border=1>
  7333. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7334. <tr align='center'>
  7335. <td>仓库</td>
  7336. <td>SKU</td>
  7337. <td>产品</td>
  7338. <td>封存产品总数量</td>
  7339. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7340. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7341. </tr>
  7342. </table>";
  7343. $filename = $title . ".xls";
  7344. $tail = "";
  7345. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7346. }
  7347. public function _fcexcel()
  7348. {
  7349. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7350. $config['upload_path'] = '.' . $dir;
  7351. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7352. $config['allowed_types'] = 'xls|xlsx|csv';
  7353. $config['max_size'] = 10240;
  7354. $this->load->library('upload', $config);
  7355. $this->upload->initialize($config);
  7356. if ($this->upload->do_upload('userfile')) {
  7357. $full_path = $dir . $this->upload->data('file_name');
  7358. $fileName = '.' . $full_path;
  7359. if (!file_exists($fileName)) {
  7360. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7361. exit;
  7362. } else {
  7363. libxml_use_internal_errors(true);
  7364. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7365. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7366. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7367. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7368. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7369. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7370. ++$column; //如果列数大于26行
  7371. $list = array();
  7372. for ($i = 2; $i <= $row; $i++) // 行数循环
  7373. {
  7374. $data = array();
  7375. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7376. {
  7377. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7378. }
  7379. $list[] = $data;
  7380. }
  7381. }
  7382. $i = 0;
  7383. $j = 0;
  7384. $ed = array();
  7385. foreach ($list as $key => $value) {
  7386. $time = time();
  7387. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7388. continue;
  7389. }
  7390. $warehouse = $this->warehouse->get_title($value['0']);
  7391. $sku = $value['1'];
  7392. $type = $value['4']; //调整方式0扣减1删除
  7393. $num = $value['5']; //调整数量
  7394. //$text = $value['4'];//扣减说明
  7395. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7396. if (!$d) //如果没有这个SKU
  7397. {
  7398. $ed[] = array($sku . '-库存中不存在此SKU');
  7399. $j++;
  7400. continue;
  7401. }
  7402. if (!isset($warehouse['id'])) {
  7403. $ed[] = array($sku . '-仓库名错误!');
  7404. $j++;
  7405. continue;
  7406. }
  7407. if ($type == 1 || $type == 2) //扣减库存
  7408. {
  7409. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7410. if (count($data) < abs($num)) {
  7411. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7412. $j++;
  7413. continue;
  7414. }
  7415. if ($type == 1) //转入库存
  7416. {
  7417. for ($i = 0; $i < abs($num); $i++) {
  7418. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7419. }
  7420. } else if ($type == 2) //删除
  7421. {
  7422. for ($i = 0; $i < abs($num); $i++) {
  7423. $this->whlabel->remove($data[$i]['id']);
  7424. }
  7425. }
  7426. } else if ($type == 0) //增加库存
  7427. {
  7428. $post['sku'] = $d['sku'];
  7429. $post['shop'] = '';
  7430. $post['warehouse'] = $warehouse['id'];
  7431. $post['purchase'] = $d['purchase'];
  7432. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7433. $post['state'] = 11;
  7434. $post['title'] = $d['title'];
  7435. $post['number'] = $d['number'];
  7436. $post['features'] = $d['features'];
  7437. $post['enter'] = $time;
  7438. $post['time'] = $time; //操作时间
  7439. for ($i = 0; $i < $num; $i++) {
  7440. $post['label'] = time() . rand(100, 999) . $i;
  7441. $this->whlabel->insert($post);
  7442. }
  7443. }
  7444. sleep(1); //防止入库时间一样,需要延迟1秒
  7445. }
  7446. if ($j > 0) {
  7447. $tt = date('Ymd', time());
  7448. $title = '库存导入错误信息-' . $tt;
  7449. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7450. $tail = "\n";
  7451. $filename = $title . ".xls";
  7452. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7453. $dir = '/data/excel/' . $time . '/';
  7454. $file_name = 'error_' . $time . rand(1000, 9999);
  7455. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7456. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7457. fwrite($myfile, $ecl);
  7458. fclose($myfile);
  7459. $error = $dir . $file_name . '.xls';
  7460. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7461. exit;
  7462. } else {
  7463. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7464. exit;
  7465. }
  7466. }
  7467. }
  7468. public function _fcjxc($arg_array)
  7469. {
  7470. if (isset($_GET['excel'])) {
  7471. $category = $this->input->get('category', true);
  7472. $size = $this->input->get('size', true);
  7473. $grade = $this->input->get('grade', true);
  7474. $color = $this->input->get('color', true);
  7475. $lowe = $this->input->get('lowe', true);
  7476. $sku = $this->input->get('sku');
  7477. $title = $this->input->get('title');
  7478. $warehouse = $arg_array[0];
  7479. $usa = $this->input->get('usa', true);
  7480. $purchase = $this->input->get('purchase', true);
  7481. $lacetype = $this->input->get('lacetype', true);
  7482. $haircap = $this->input->get('haircap', true);
  7483. $density = $this->input->get('density', true);
  7484. $title = $this->input->get('title', true);
  7485. $state = $this->input->get('state', true);
  7486. $ktime = $this->input->get('ktime', true);
  7487. $jtime = $this->input->get('jtime', true);
  7488. $where = "state=11";
  7489. $gj = "";
  7490. $ck = "";
  7491. if ($lacetype) {
  7492. $where .= " and features like '%-$lacetype-%'";
  7493. }
  7494. if ($category) {
  7495. $where .= " and features like '%-$category-%'";
  7496. }
  7497. if ($size) {
  7498. $where .= " and features like '%-$size-%'";
  7499. }
  7500. if ($grade) {
  7501. $where .= " and features like '%-$grade-%'";
  7502. }
  7503. if ($color) {
  7504. $where .= " and features like '%-$color-%'";
  7505. }
  7506. if ($lowe) {
  7507. $where .= " and features like '%-$lowe-%'";
  7508. }
  7509. if ($haircap) {
  7510. $where .= " and features like '%-$haircap-%'";
  7511. }
  7512. if ($density) {
  7513. $where .= " and features like '%-$density-%'";
  7514. }
  7515. if ($usa) {
  7516. if (!$warehouse) {
  7517. $where .= " and (warehouse = '5' or warehouse = '8')";
  7518. }
  7519. }
  7520. if ($warehouse) {
  7521. $where .= " and warehouse = '$warehouse'";
  7522. }
  7523. if ($purchase) {
  7524. $where .= " and purchase = '$purchase'";
  7525. }
  7526. if ($state) {
  7527. $where .= " and state = '$state'";
  7528. }
  7529. $order_str = "id desc";
  7530. if ($sku) {
  7531. $sku = trim($sku, ' ');
  7532. $sku = trim($sku, ' ');
  7533. $where .= " and sku like '%$sku%'";
  7534. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7535. } else if ($title) {
  7536. $title = trim($title, ' ');
  7537. $title = trim($title, ' ');
  7538. $where .= " and title like '%$title%'";
  7539. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7540. } else {
  7541. //$where .= " and time > '$ktime' and time < '$jtime'";
  7542. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7543. }
  7544. //取得信息列表
  7545. $rows = array();
  7546. $list = array();
  7547. foreach ($info_list as $key => $value) {
  7548. $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'] . '"');
  7549. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7550. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7551. $rows[$key] = $value;
  7552. $warehouse = $this->warehouse->read($value['warehouse']);
  7553. $rows[$key]['warehouse'] = $warehouse['title'];
  7554. $rows[$key]['features'] = $g;
  7555. $rows[$key]['a'] = $x;
  7556. $rows[$key]['b'] = $s;
  7557. }
  7558. $title = "总统计表";
  7559. $titlename = "<table border=1>
  7560. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7561. <tr align='center'>
  7562. <td>仓库</td>
  7563. <td>SKU</td>
  7564. <td>产品名称</td>
  7565. <td>录入总量</td>
  7566. <td>取出总量</td>
  7567. <td>剩余总量</td>
  7568. </tr>
  7569. </table>";
  7570. $filename = $title . ".xls";
  7571. $tail = "";
  7572. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7573. }
  7574. $vip = 0;
  7575. if (isset($_SESSION['api'])) {
  7576. $user = $this->user->get_api($_SESSION['api']);
  7577. if ($user['vip'] == 1) {
  7578. $vip = 1;
  7579. }
  7580. } else {
  7581. header('Location: /');
  7582. exit;
  7583. }
  7584. $post = $this->input->post(NULL, TRUE);
  7585. if (isset($post['page'])) {
  7586. $page = $this->input->post('page', true);
  7587. $perpage = $this->input->post('perpage', true);
  7588. $category = $this->input->post('category', true);
  7589. $size = $this->input->post('size', true);
  7590. $grade = $this->input->post('grade', true);
  7591. $color = $this->input->post('color', true);
  7592. $lowe = $this->input->post('lowe', true);
  7593. $sku = $this->input->post('sku');
  7594. $title = $this->input->post('title');
  7595. $warehouse = $arg_array[0];
  7596. $usa = $this->input->post('usa', true);
  7597. $purchase = $this->input->post('purchase', true);
  7598. $lacetype = $this->input->post('lacetype', true);
  7599. $haircap = $this->input->post('haircap', true);
  7600. $density = $this->input->post('density', true);
  7601. $title = $this->input->post('title', true);
  7602. $state = $this->input->post('state', true);
  7603. $ktime = $this->input->post('ktime', true);
  7604. $jtime = $this->input->post('jtime', true);
  7605. $ktime = strtotime($ktime);
  7606. $jtime = strtotime($jtime);
  7607. $where = "state=11";
  7608. $gj = "";
  7609. $ck = "";
  7610. if ($lacetype) {
  7611. $where .= " and features like '%-$lacetype-%'";
  7612. }
  7613. if ($category) {
  7614. $where .= " and features like '%-$category-%'";
  7615. }
  7616. if ($size) {
  7617. $where .= " and features like '%-$size-%'";
  7618. }
  7619. if ($grade) {
  7620. $where .= " and features like '%-$grade-%'";
  7621. }
  7622. if ($color) {
  7623. $where .= " and features like '%-$color-%'";
  7624. }
  7625. if ($lowe) {
  7626. $where .= " and features like '%-$lowe-%'";
  7627. }
  7628. if ($haircap) {
  7629. $where .= " and features like '%-$haircap-%'";
  7630. }
  7631. if ($density) {
  7632. $where .= " and features like '%-$density-%'";
  7633. }
  7634. if ($usa) {
  7635. if (!$warehouse) {
  7636. $where .= " and (warehouse = '5' or warehouse = '8')";
  7637. }
  7638. }
  7639. if ($warehouse) {
  7640. $where .= " and warehouse = '$warehouse'";
  7641. }
  7642. if ($purchase) {
  7643. $where .= " and purchase = '$purchase'";
  7644. }
  7645. if ($state) {
  7646. $where .= " and state = '$state'";
  7647. }
  7648. if ($ktime && $jtime) {
  7649. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7650. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7651. }
  7652. //数据排序
  7653. $order_str = "id desc";
  7654. $xs = 0;
  7655. $rows = array();
  7656. $list = array();
  7657. if (empty($page)) {
  7658. $start = 0;
  7659. $perpage = 1;
  7660. } else {
  7661. $start = ($page - 1) * $perpage;
  7662. }
  7663. if ($sku || $title) {
  7664. if ($title) {
  7665. $title = trim($title, ' ');
  7666. $title = trim($title, ' ');
  7667. $where .= " and title like '%$title%'";
  7668. } else {
  7669. $sku = trim($sku, ' ');
  7670. $sku = trim($sku, ' ');
  7671. $where .= " and sku like '%$sku%'";
  7672. }
  7673. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7674. foreach ($info_list as $key => $value) {
  7675. $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'] . '"');
  7676. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7677. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7678. $rows[$key] = $value;
  7679. $warehouse = $this->warehouse->read($value['warehouse']);
  7680. $rows[$key]['warehouse'] = $warehouse['title'];
  7681. $rows[$key]['features'] = $g;
  7682. $rows[$key]['a'] = $x;
  7683. $rows[$key]['b'] = $s;
  7684. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7685. $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天销量
  7686. $yj = $c / ($xl / 30);
  7687. if ($yj < 7) {
  7688. $rows[$key]['y'] = round($yj) . '天销量';
  7689. } else {
  7690. $rows[$key]['y'] = '正常';
  7691. }
  7692. }
  7693. } else {
  7694. //$where .= " and time > '$ktime' and time < '$jtime'";
  7695. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7696. foreach ($info_list as $key => $value) {
  7697. $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'] . '"');
  7698. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7699. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7700. $zs[$key] = $value;
  7701. $warehouse = $this->warehouse->read($value['warehouse']);
  7702. $zs[$key]['warehouse'] = $warehouse['title'];
  7703. $zs[$key]['features'] = $g;
  7704. $zs[$key]['a'] = $x;
  7705. $zs[$key]['b'] = $s;
  7706. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7707. $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天销量
  7708. $yj = $c / ($xl / 30);
  7709. if ($yj < 7) {
  7710. $zs[$key]['y'] = round($yj) . '天销量';
  7711. $rows[$key] = $zs[$key];
  7712. }
  7713. }
  7714. }
  7715. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7716. $pagenum = ceil($total / $perpage);
  7717. $over = $total - ($start + $perpage);
  7718. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7719. echo json_encode($rows);
  7720. exit;
  7721. }
  7722. $this->data['arg_array'] = $arg_array[0];
  7723. $this->_Template('whlabel_fcjxc', $this->data);
  7724. }
  7725. public function _0kcdel()
  7726. {
  7727. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7728. $config['upload_path'] = '.' . $dir;
  7729. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7730. $config['allowed_types'] = 'xls|xlsx|csv';
  7731. $config['max_size'] = 10240;
  7732. $this->load->library('upload', $config);
  7733. $this->upload->initialize($config);
  7734. if ($this->upload->do_upload('userfile')) {
  7735. $full_path = $dir . $this->upload->data('file_name');
  7736. $fileName = '.' . $full_path;
  7737. if (!file_exists($fileName)) {
  7738. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7739. exit;
  7740. } else {
  7741. require_once "./data/excel/PHPExcel/IOFactory.php";
  7742. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7743. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7744. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7745. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7746. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7747. ++$column; //如果列数大于26行
  7748. $list = array();
  7749. for ($i = 2; $i <= $row; $i++) // 行数循环
  7750. {
  7751. $data = array();
  7752. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7753. {
  7754. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7755. }
  7756. $list[] = $data;
  7757. }
  7758. }
  7759. $i = 0;
  7760. $j = 0;
  7761. $ed = array();
  7762. foreach ($list as $key => $value) {
  7763. $time = time();
  7764. if ($value['0'] == "" || $value['1'] == "") {
  7765. continue;
  7766. }
  7767. $warehouse = $this->warehouse->get_title($value['0']);
  7768. $sku = $value['1'];
  7769. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7770. if (!$d) //如果没有这个SKU
  7771. {
  7772. $ed[] = array($sku . '-库存中不存在此SKU');
  7773. $j++;
  7774. continue;
  7775. }
  7776. if (!isset($warehouse['id'])) {
  7777. $ed[] = array($sku . '-仓库名错误!');
  7778. $j++;
  7779. continue;
  7780. }
  7781. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7782. if ($z < 1) {
  7783. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7784. foreach ($z as $v) {
  7785. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7786. if (count($zt) > 0) {
  7787. $ed[] = array($sku . '-有在途库存无法删除!');
  7788. $j++;
  7789. continue;
  7790. }
  7791. $this->whlabel->remove($v['id']);
  7792. }
  7793. } else {
  7794. $ed[] = array($sku . '-非0库存!');
  7795. $j++;
  7796. continue;
  7797. }
  7798. }
  7799. if ($j > 0) {
  7800. $tt = date('Ymd', time());
  7801. $title = '删除0库存错误信息-' . $tt;
  7802. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7803. $tail = "\n";
  7804. $filename = $title . ".xls";
  7805. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7806. $dir = '/data/excel/' . $time . '/';
  7807. $file_name = 'error_' . $time . rand(1000, 9999);
  7808. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7809. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7810. fwrite($myfile, $ecl);
  7811. fclose($myfile);
  7812. $error = $dir . $file_name . '.xls';
  7813. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7814. exit;
  7815. } else {
  7816. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7817. exit;
  7818. }
  7819. }
  7820. }
  7821. public function _gbhtype()
  7822. {
  7823. $post = $this->input->post(NULL, TRUE);
  7824. if (isset($post['s'])) {
  7825. $n = $this->input->post('n');
  7826. $d = $this->input->post('s');
  7827. if (!$d) {
  7828. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7829. exit;
  7830. }
  7831. $d = explode(',', trim($d, ','));
  7832. $t = $this->whlabel_type->read($n);
  7833. //循环删除记录
  7834. foreach ($d as $v) {
  7835. $u = $this->whlabel->read($v);
  7836. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7837. foreach ($data as $val) {
  7838. $this->whlabel->save(array('type' => $n), $val['id']);
  7839. }
  7840. }
  7841. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7842. }
  7843. }
  7844. //出库、退库导出
  7845. public function _dccrtype()
  7846. {
  7847. $classid = $this->classid->sku();
  7848. $pm = $classid;
  7849. $typeclass = array();
  7850. $tc = $this->typeclass->find_all();
  7851. foreach ($tc as $v) {
  7852. $typeclass[$v['id']] = $v;
  7853. }
  7854. $prc = array();
  7855. $purchase = $this->purchase->find_all();
  7856. foreach ($purchase as $k => $v) {
  7857. $prc[$v['id']] = $v['title'];
  7858. }
  7859. if (isset($_GET['sid'])) {
  7860. $wh = array();
  7861. $w = $this->warehouse->find_all('1=1', 'id,title');
  7862. foreach ($w as $v) {
  7863. $wh[$v['id']] = $v['title'];
  7864. }
  7865. $type = $this->input->get('excel', true);
  7866. $category = $this->input->get('category', true);
  7867. $size = $this->input->get('size', true);
  7868. $grade = $this->input->get('grade', true);
  7869. $color = $this->input->get('color', true);
  7870. $lowe = $this->input->get('lowe', true);
  7871. $sku = $this->input->get('sku', true);
  7872. $warehouse = $this->input->get('warehouse', true);
  7873. $lacetype = $this->input->get('lacetype', true);
  7874. $lacecolor = $this->input->get('lacecolor', true);
  7875. $density = $this->input->get('density', true);
  7876. $haircap = $this->input->get('haircap', true);
  7877. $purchase = $this->input->get('purchase', true);
  7878. $title = $this->input->get('title', true);
  7879. $state = $this->input->get('state', true);
  7880. $sid = $this->input->get('sid', true);
  7881. $ktime = $this->input->get('ktime', true);
  7882. $jtime = $this->input->get('jtime', true);
  7883. $ktime = strtotime($ktime);
  7884. $jtime = strtotime($jtime);
  7885. $where = "1=1";
  7886. $gj = "";
  7887. $ck = "";
  7888. if ($category) {
  7889. $where .= " and features like '%-$category-%'";
  7890. }
  7891. if ($size) {
  7892. $where .= " and features like '%-$size-%'";
  7893. }
  7894. if ($grade) {
  7895. $where .= " and features like '%-$grade-%'";
  7896. }
  7897. if ($color) {
  7898. $where .= " and features like '%-$color-%'";
  7899. }
  7900. if ($lowe) {
  7901. $where .= " and features like '%-$lowe-%'";
  7902. }
  7903. if ($warehouse) {
  7904. $where .= " and warehouse = '$warehouse'";
  7905. }
  7906. if ($purchase) {
  7907. $where .= " and purchase = '$purchase'";
  7908. }
  7909. if ($state) {
  7910. $where .= " and state = '$state'";
  7911. }
  7912. if ($lacetype) {
  7913. $where .= " and features like '%-$lacetype-%'";
  7914. }
  7915. if ($lacecolor) {
  7916. $where .= " and features like '%-$lacecolor-%'";
  7917. }
  7918. if ($density) {
  7919. $where .= " and features like '%-$density-%'";
  7920. }
  7921. if ($haircap) {
  7922. $where .= " and features like '%-$haircap-%'";
  7923. }
  7924. if ($title) {
  7925. $title = trim($title, ' ');
  7926. $title = trim($title, ' ');
  7927. $where .= " and title like '%$title%'";
  7928. }
  7929. if ($sku) {
  7930. $sku = trim($sku, ' ');
  7931. $sku = trim($sku, ' ');
  7932. $where .= " and sku like '%$sku%'";
  7933. }
  7934. if ($ktime && $jtime) {
  7935. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7936. }
  7937. $sidwhere = '';
  7938. if ($sid) {
  7939. $sd = "";
  7940. $s = explode(',', trim($sid, ','));
  7941. foreach ($s as $value) {
  7942. $sd .= " id = " . $value . " or";
  7943. }
  7944. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7945. }
  7946. //数据排序
  7947. $order_str = "time desc";
  7948. if (empty($page)) {
  7949. $start = 0;
  7950. $perpage = 1;
  7951. } else {
  7952. $start = ($page - 1) * $perpage;
  7953. }
  7954. $wh = array();
  7955. $w = $this->warehouse->find_all('1=1', 'id,title');
  7956. foreach ($w as $v) {
  7957. $wh[$v['id']] = $v['title'];
  7958. }
  7959. $wt = array();
  7960. $whlabel_type = $this->whlabel_type->find_all();
  7961. foreach ($whlabel_type as $v) {
  7962. $wt[$v['id']] = $v['title'];
  7963. }
  7964. $classid = $this->classid->sku();
  7965. $list = array();
  7966. $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');
  7967. foreach ($rows_r as $key => $value) {
  7968. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7969. $pm = $classid;
  7970. $jm = $classid;
  7971. $rows_r[$key]['enter'] = '入库';
  7972. $rows_r[$key]['time'] = $value['enter'];
  7973. if ($value['rktype'] == 1) {
  7974. $rows_r[$key]['rktype'] = '采购入库';
  7975. } else if ($value['rktype'] == 2) {
  7976. $rows_r[$key]['rktype'] = '盘盈调整';
  7977. } else if ($value['rktype'] == 3) {
  7978. $rows_r[$key]['rktype'] = '其他调整入库';
  7979. } else if ($value['rktype'] == 4) {
  7980. $rows_r[$key]['rktype'] = '其他调整入库';
  7981. } else if ($value['rktype'] == 5) {
  7982. $rows_r[$key]['rktype'] = '退库入库';
  7983. } else if ($value['rktype'] == 6) {
  7984. $rows_r[$key]['rktype'] = '退货可用入库';
  7985. } else if ($value['rktype'] == 7) {
  7986. $rows_r[$key]['rktype'] = '形态转换入库';
  7987. } else {
  7988. $rows_r[$key]['rktype'] = '';
  7989. }
  7990. $features = explode('-', trim($value['features'], '-'));
  7991. foreach ($features as $v) {
  7992. if (isset($typeclass[$v])) {
  7993. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7994. $pm[$typeclass[$v]['classid']] = $zh[0];
  7995. }
  7996. if (isset($typeclass[$v])) {
  7997. if (isset($jm[$typeclass[$v]['classid']])) {
  7998. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7999. }
  8000. }
  8001. }
  8002. $zh = implode(" ", $pm);
  8003. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8004. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8005. $rows_r[$key]['zh'] = $zh;
  8006. $jm = array_filter($jm);
  8007. $rows_r[$key]['features'] = implode("-", $jm);
  8008. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8009. }
  8010. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  8011. foreach ($rows_c as $key => $value) {
  8012. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8013. $pm = $classid;
  8014. $jm = $classid;
  8015. $rows_c[$key]['time'] = $value['outk'];
  8016. $rows_c[$key]['outk'] = '出库';
  8017. if ($value['cktype'] == 1) {
  8018. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8019. } else if ($value['cktype'] == 2) {
  8020. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8021. } else if ($value['cktype'] == 3) {
  8022. $rows_c[$key]['cktype'] = '盘亏调整';
  8023. } else if ($value['cktype'] == 4) {
  8024. $rows_c[$key]['cktype'] = '其他调整出库';
  8025. } else if ($value['cktype'] == 5) {
  8026. $rows_c[$key]['cktype'] = '形态转换出库';
  8027. } else {
  8028. $rows_c[$key]['cktype'] = '';
  8029. }
  8030. unset($rows_c[$key]['state']);
  8031. $features = explode('-', trim($value['features'], '-'));
  8032. foreach ($features as $v) {
  8033. if (isset($typeclass[$v])) {
  8034. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8035. $pm[$typeclass[$v]['classid']] = $zh[0];
  8036. }
  8037. if (isset($typeclass[$v])) {
  8038. if (isset($jm[$typeclass[$v]['classid']])) {
  8039. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8040. }
  8041. }
  8042. }
  8043. $zh = implode(" ", $pm);
  8044. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8045. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8046. $rows_c[$key]['zh'] = $zh;
  8047. $jm = array_filter($jm);
  8048. $rows_c[$key]['features'] = implode("-", $jm);
  8049. $rows_c[$key]['number'] = 1;
  8050. }
  8051. $merged = $rows_r;
  8052. foreach ($rows_c as $key => $value) {
  8053. if (isset($merged[$key])) {
  8054. $merged[] = $value;
  8055. } else {
  8056. $merged[$key] = $value;
  8057. }
  8058. }
  8059. usort($merged, function ($a, $b) {
  8060. return $a['time'] - $b['time'];
  8061. });
  8062. foreach ($merged as $key => $value) {
  8063. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8064. }
  8065. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8066. $titlename = "<table border=1>
  8067. <tr align='center'>
  8068. <td>仓库</td>
  8069. <td>SKU</td>
  8070. <td>商品名称</td>
  8071. <td>仓库品名</td>
  8072. <td>料号</td>
  8073. <td>时间</td>
  8074. <td>操作</td>
  8075. <td>类型</td>
  8076. <td>数量</td>
  8077. <td>备注</td>
  8078. </tr>
  8079. </table>";
  8080. $filename = $title . ".xlsx";
  8081. $tail = "";
  8082. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8083. }
  8084. }
  8085. /*************************************处理exceljs导出****************************************************/
  8086. public function _excelrjs(){
  8087. if (isset($_GET['excel'])) {
  8088. $category = $this->input->get('category', true);
  8089. $size = $this->input->get('size', true);
  8090. $grade = $this->input->get('grade', true);
  8091. $color = $this->input->get('color', true);
  8092. $lowe = $this->input->get('lowe', true);
  8093. $sku = $this->input->get('sku', true);
  8094. $warehouse = $this->input->get('warehouse', true);
  8095. $purchase = $this->input->get('purchase', true);
  8096. $ktime = $this->input->get('ktime', true);
  8097. $jtime = $this->input->get('jtime', true);
  8098. $ktime = strtotime($ktime);
  8099. $jtime = strtotime($jtime);
  8100. $where = "1=1";
  8101. $gj = "";
  8102. $ck = "";
  8103. if ($category) {
  8104. $where .= " and features like '%-$category-%'";
  8105. }
  8106. if ($size) {
  8107. $where .= " and features like '%-$size-%'";
  8108. }
  8109. if ($grade) {
  8110. $where .= " and features like '%-$grade-%'";
  8111. }
  8112. if ($color) {
  8113. $where .= " and features like '%-$color-%'";
  8114. }
  8115. if ($lowe) {
  8116. $where .= " and features like '%-$lowe-%'";
  8117. }
  8118. if ($warehouse) {
  8119. $where .= " and warehouse = '$warehouse'";
  8120. }
  8121. if ($purchase) {
  8122. $where .= " and purchase = '$purchase'";
  8123. }
  8124. if ($sku) {
  8125. $where .= " and sku = '$sku'";
  8126. }
  8127. if ($ktime && $jtime) {
  8128. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8129. }
  8130. //数据排序
  8131. $order_str = "id desc";
  8132. if (empty($page)) {
  8133. $start = 0;
  8134. $perpage = 1;
  8135. } else {
  8136. $start = ($page - 1) * $perpage;
  8137. }
  8138. $list = array();
  8139. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8140. foreach ($rows as $value) {
  8141. $ck = $this->warehouse->read($value['warehouse']);
  8142. $warehouse = $ck['title'];
  8143. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8144. $retreatwarehouse = $tkck['title'];
  8145. $gy = $this->purchase->read($value['purchase']);
  8146. $purchase = $gy['title'];
  8147. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8148. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8149. }
  8150. if(empty($list)){
  8151. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8152. }else{
  8153. $final_list = [];
  8154. foreach($list as $v){
  8155. $final_list[] = array_values($v);
  8156. }
  8157. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8158. array_unshift($final_list,[
  8159. "仓库","SKU","商品名称","时间","数量"
  8160. ]);
  8161. array_unshift($final_list,[
  8162. $title,"","","",""
  8163. ]);
  8164. $merges = [
  8165. [
  8166. "s"=>["r"=>0,"c"=>0],
  8167. "e"=>["r"=>0,"c"=>4]
  8168. ]
  8169. ];
  8170. $cols = [
  8171. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8172. ];
  8173. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8174. }
  8175. }
  8176. }
  8177. //出库、退库导出
  8178. public function _excelctjs()
  8179. {
  8180. $classid = $this->classid->sku();
  8181. $pm = $classid;
  8182. $typeclass = array();
  8183. $tc = $this->typeclass->find_all();
  8184. foreach ($tc as $v) {
  8185. $typeclass[$v['id']] = $v;
  8186. }
  8187. $prc = array();
  8188. $purchase = $this->purchase->find_all();
  8189. foreach ($purchase as $k => $v) {
  8190. $prc[$v['id']] = $v['title'];
  8191. }
  8192. if (isset($_GET['excel'])) {
  8193. $wh = array();
  8194. $w = $this->warehouse->find_all('1=1', 'id,title');
  8195. foreach ($w as $v) {
  8196. $wh[$v['id']] = $v['title'];
  8197. }
  8198. $type = $this->input->get('excel', true);
  8199. $category = $this->input->get('category', true);
  8200. $size = $this->input->get('size', true);
  8201. $grade = $this->input->get('grade', true);
  8202. $color = $this->input->get('color', true);
  8203. $lowe = $this->input->get('lowe', true);
  8204. $sku = $this->input->get('sku', true);
  8205. $title = $this->input->get('title', true);
  8206. $warehouse = $this->input->get('warehouse', true);
  8207. $purchase = $this->input->get('purchase', true);
  8208. $lacetype = $this->input->get('lacetype', true);
  8209. $haircap = $this->input->get('haircap', true);
  8210. $lacecolor = $this->input->get('lacecolor', true);
  8211. $density = $this->input->get('density', true);
  8212. $details = $this->input->get('details', true);
  8213. $state = $this->input->get('state', true);
  8214. $shop = $this->input->get('shop', true);
  8215. $hairnumber = $this->input->get('hairnumber', true);
  8216. $type_leixi = $this->input->get('type', true);
  8217. $cpbz = $this->input->get('cpbz', true);
  8218. $sm = $this->input->get('sm', true);
  8219. $sid = $this->input->get('sid', true);
  8220. $ktime = $this->input->get('ktime', true);
  8221. $jtime = $this->input->get('jtime', true);
  8222. $ktime = strtotime($ktime);
  8223. $jtime = strtotime($jtime);
  8224. //$where = " 1=1 ";
  8225. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8226. $where = " sku != '' ";
  8227. $gj = "";
  8228. $ck = "";
  8229. if ($category) {
  8230. $where .= " and features like '%-$category-%'";
  8231. }
  8232. if ($size) {
  8233. $where .= " and features like '%-$size-%'";
  8234. }
  8235. if ($grade) {
  8236. $where .= " and features like '%-$grade-%'";
  8237. }
  8238. if ($color) {
  8239. $where .= " and features like '%-$color-%'";
  8240. }
  8241. if ($lowe) {
  8242. $where .= " and features like '%-$lowe-%'";
  8243. }
  8244. if ($warehouse) {
  8245. $where .= " and warehouse = '$warehouse'";
  8246. }
  8247. if ($purchase) {
  8248. $where .= " and purchase = '$purchase'";
  8249. }
  8250. if ($state) {
  8251. $where .= " and state = '$state'";
  8252. }
  8253. if ($lacetype) {
  8254. $where .= " and features like '%-$lacetype-%'";
  8255. }
  8256. if ($lacecolor) {
  8257. $where .= " and features like '%-$lacecolor-%'";
  8258. }
  8259. if ($density) {
  8260. $where .= " and features like '%-$density-%'";
  8261. }
  8262. if ($haircap) {
  8263. $where .= " and features like '%-$haircap-%'";
  8264. }
  8265. if ($details) {
  8266. $where .= " and details = '$details'";
  8267. }
  8268. if ($shop) {
  8269. $where .= " and shop like '%$shop%'";
  8270. }
  8271. if ($title) {
  8272. $title = trim($title, ' ');
  8273. $title = trim($title, ' ');
  8274. $where .= " and title like '%$title%'";
  8275. }
  8276. if (!empty($hairnumber)) {
  8277. $where .= " and features like '%-128-%' ";
  8278. if ($hairnumber < 0) {
  8279. $class_list = $this->typeclass->find_all('classid = 43');
  8280. foreach ($class_list as $v) {
  8281. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8282. }
  8283. } else {
  8284. $where .= " and features like '%-$hairnumber-%'";
  8285. }
  8286. }
  8287. if ($type_leixi) {
  8288. $where .= " and type = '$type_leixi'";
  8289. }
  8290. if ($cpbz) {
  8291. $where .= " and cpbz like '%$cpbz%' ";
  8292. }
  8293. if ($sm) {
  8294. $where .= " and sm like '%$sm%' ";
  8295. }
  8296. if ($sku) {
  8297. $sku = trim($sku, ' ');
  8298. $sku = trim($sku, ' ');
  8299. $where .= " and sku like '%$sku%'";
  8300. }
  8301. if ($ktime && $jtime) {
  8302. if ($type == 1) {
  8303. $tl = '出库';
  8304. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8305. } else if ($type == 2) {
  8306. $tl = '退库';
  8307. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8308. } else if ($type == 3) {
  8309. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8310. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8311. } else if ($type == 4) {
  8312. $tl = '出库+零售';
  8313. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8314. } else if ($type == 5) {
  8315. $tl = '零售';
  8316. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8317. }
  8318. }
  8319. $sidwhere = '';
  8320. if ($sid) {
  8321. $sd = "";
  8322. $s = explode(',', trim($sid, ','));
  8323. foreach ($s as $value) {
  8324. $sd .= " id = " . $value . " or";
  8325. }
  8326. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8327. }
  8328. //数据排序
  8329. $order_str = "time desc";
  8330. if (empty($page)) {
  8331. $start = 0;
  8332. $perpage = 1;
  8333. } else {
  8334. $start = ($page - 1) * $perpage;
  8335. }
  8336. //取得信息列表
  8337. if ($type != 3 && $type != 5) {
  8338. if ($type == 1 || $type == 4) {
  8339. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8340. foreach ($info_list as $key => $value) {
  8341. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8342. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8343. $warehouse = $this->warehouse->read($value['warehouse']);
  8344. $info_list[$key]['warehouse'] = $warehouse['title'];
  8345. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8346. $features = explode('-', trim($features, '-'));
  8347. $pm = $classid;
  8348. foreach ($features as $k => $v) {
  8349. if ($v != 0) {
  8350. if (!isset($typeclass[$v])) {
  8351. continue;
  8352. }
  8353. if (isset($pm[$typeclass[$v]['classid']])) {
  8354. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8355. $tz = explode('|', $typeclass[$v]['zh']);
  8356. $pm[$typeclass[$v]['classid']] = $tz[0];
  8357. } else {
  8358. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8359. }
  8360. }
  8361. }
  8362. }
  8363. $zh = implode(" ", $pm);
  8364. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8365. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8366. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8367. $info_list[$key]['features'] = $zh;
  8368. }
  8369. $final_list = [];
  8370. foreach($info_list as $k=>$v){
  8371. $number = "";
  8372. if(!empty($v['orderinfo'])){
  8373. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8374. if(!empty($tmp_info['number'])){
  8375. $number = $tmp_info['number'];
  8376. }
  8377. }
  8378. $final_list[] = [
  8379. 'warehouse'=>$v['warehouse'],
  8380. 'purchase'=>$v['purchase'],
  8381. 'sku'=>$v['sku'],
  8382. 'title'=>$v['title'],
  8383. 'features'=>$v['features'],
  8384. 'label'=>$v['label'],
  8385. 'orderinfo'=>$v['orderinfo'],
  8386. 'number'=>$number,
  8387. 'waybill'=>$v['waybill'],
  8388. 'outk'=>$v['outk'],
  8389. ];
  8390. }
  8391. } else {
  8392. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8393. foreach ($info_list as $key => $value) {
  8394. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8395. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8396. $warehouse = $this->warehouse->read($value['warehouse']);
  8397. $info_list[$key]['warehouse'] = $warehouse['title'];
  8398. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8399. $features = explode('-', trim($features, '-'));
  8400. $pm = $classid;
  8401. foreach ($features as $k => $v) {
  8402. if ($v != 0) {
  8403. if (!isset($typeclass[$v])) {
  8404. continue;
  8405. }
  8406. if (isset($pm[$typeclass[$v]['classid']])) {
  8407. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8408. $tz = explode('|', $typeclass[$v]['zh']);
  8409. $pm[$typeclass[$v]['classid']] = $tz[0];
  8410. } else {
  8411. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8412. }
  8413. }
  8414. }
  8415. }
  8416. $zh = implode(" ", $pm);
  8417. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8418. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8419. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8420. $info_list[$key]['features'] = $zh;
  8421. }
  8422. $final_list = [];
  8423. foreach($info_list as $k=>$v){
  8424. $number = "";
  8425. if(!empty($v['orderinfo'])){
  8426. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8427. if(!empty($tmp_info['number'])){
  8428. $number = $tmp_info['number'];
  8429. }
  8430. }
  8431. $final_list[] = [
  8432. 'warehouse'=>$v['warehouse'],
  8433. 'purchase'=>$v['purchase'],
  8434. 'sku'=>$v['sku'],
  8435. 'title'=>$v['title'],
  8436. 'features'=>$v['features'],
  8437. 'label'=>$v['label'],
  8438. 'orderinfo'=>$v['orderinfo'],
  8439. 'number'=>$number,
  8440. 'waybill'=>$v['waybill'],
  8441. 'retreat'=>$v['retreat'],
  8442. ];
  8443. }
  8444. }
  8445. if(empty($final_list)){
  8446. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8447. }else{
  8448. $end_list = [];
  8449. foreach($final_list as $v){
  8450. $end_list[] = array_values($v);
  8451. }
  8452. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8453. array_unshift($end_list,[
  8454. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8455. ]);
  8456. array_unshift($end_list,[
  8457. $title,"","","","","","","","",""
  8458. ]);
  8459. $merges = [
  8460. [
  8461. "s"=>["r"=>0,"c"=>0],
  8462. "e"=>["r"=>0,"c"=>9]
  8463. ]
  8464. ];
  8465. $cols = [
  8466. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8467. ];
  8468. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8469. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8470. ] )));
  8471. }
  8472. } else if ($type == 5) {
  8473. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8474. foreach ($info_list as $key => $value) {
  8475. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8476. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8477. $warehouse = $this->warehouse->read($value['warehouse']);
  8478. $info_list[$key]['warehouse'] = $warehouse['title'];
  8479. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8480. $features = explode('-', trim($features, '-'));
  8481. $pm = $classid;
  8482. foreach ($features as $k => $v) {
  8483. if ($v != 0) {
  8484. if (!isset($typeclass[$v])) {
  8485. continue;
  8486. }
  8487. if (isset($pm[$typeclass[$v]['classid']])) {
  8488. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8489. $tz = explode('|', $typeclass[$v]['zh']);
  8490. $pm[$typeclass[$v]['classid']] = $tz[0];
  8491. } else {
  8492. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8493. }
  8494. }
  8495. }
  8496. }
  8497. $zh = implode(" ", $pm);
  8498. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8499. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8500. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8501. $info_list[$key]['features'] = $zh;
  8502. }
  8503. if(empty($info_list)){
  8504. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8505. }else{
  8506. $final_list = [];
  8507. foreach($info_list as $v){
  8508. $final_list[] = array_values($v);
  8509. }
  8510. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8511. array_unshift($final_list,[
  8512. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8513. ]);
  8514. array_unshift($final_list,[
  8515. $title,"","","","","","",
  8516. ]);
  8517. $merges = [
  8518. [
  8519. "s"=>["r"=>0,"c"=>0],
  8520. "e"=>["r"=>0,"c"=>6]
  8521. ]
  8522. ];
  8523. $cols = [
  8524. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8525. ];
  8526. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8527. }
  8528. } else {
  8529. $wh = array();
  8530. $w = $this->warehouse->find_all('1=1', 'id,title');
  8531. foreach ($w as $v) {
  8532. $wh[$v['id']] = $v['title'];
  8533. }
  8534. $wt = array();
  8535. $whlabel_type = $this->whlabel_type->find_all();
  8536. foreach ($whlabel_type as $v) {
  8537. $wt[$v['id']] = $v['title'];
  8538. }
  8539. $classid = $this->classid->sku();
  8540. $list = array();
  8541. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8542. foreach ($rows as $key => $value) {
  8543. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8544. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8545. $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');
  8546. $details = array();
  8547. $cpid = array();
  8548. $cpbz = array();
  8549. $c = 0;
  8550. $g = 0;
  8551. $x = 0;
  8552. $t = 0;
  8553. $s = 0;
  8554. $q = 0;
  8555. foreach ($sd as $k => $v) {
  8556. if ($v['state'] == 0) {
  8557. $c++;
  8558. }
  8559. if ($v['state'] != 9) {
  8560. $g++;
  8561. }
  8562. if ($v['outk'] > 1) {
  8563. $x++;
  8564. }
  8565. if ($v['retreat'] > 0) {
  8566. $t++;
  8567. }
  8568. if ($v['state'] == 8) {
  8569. $s++;
  8570. }
  8571. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8572. $q++;
  8573. }
  8574. $details[$v['details']] = $v['details'];
  8575. if ($v['cpid'] != 0) {
  8576. $cpid[$v['cpid']] = $v['cpid'];
  8577. }
  8578. if ($v['cpbz'] != '') {
  8579. $cpbz[$v['cpbz']] = $v['cpbz'];
  8580. }
  8581. }
  8582. if (isset($wt[$value['type']])) {
  8583. $rows[$key]['type'] = $wt[$value['type']];
  8584. } else {
  8585. $rows[$key]['type'] = '未设置';
  8586. }
  8587. $rows[$key]['details'] = implode("、", $details);
  8588. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8589. $ftime = time() - 15 * 24 * 3600;
  8590. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8591. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8592. $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);
  8593. $rows[$key]['c'] = $c;
  8594. $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);
  8595. $rows[$key]['t'] = $t;
  8596. $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'] . '"');
  8597. $rows[$key]['z'] = $z;
  8598. // $jm = $classid;
  8599. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8600. $features = explode('-', trim($features, '-'));
  8601. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8602. }
  8603. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8604. $final_list =[];
  8605. foreach($tmp_list as $k=>$v){
  8606. $final_list[] = [
  8607. "warehouse"=>$v['warehouse'],
  8608. "purchase"=>$v['purchase'],
  8609. "details"=>$v['details'],
  8610. "cpid"=>$v['cpid'],
  8611. "sku"=>$v['sku'],
  8612. "title"=>$v['title'],
  8613. "features"=>$v['pm'],
  8614. "cpbz"=>$v['cpbz'],
  8615. "sm"=>$v['sm'],
  8616. "type"=>$v['type'],
  8617. "g"=>$v["g"],
  8618. "c"=>$v["c"],
  8619. "x"=>$v["x"],
  8620. "t"=>$v["t"],
  8621. "z"=>$v["z"],
  8622. "jm"=>$v["jm"],
  8623. "weight"=>$v["weight"],
  8624. "asd"=>$v["asd"],
  8625. ];
  8626. }
  8627. if(empty($final_list)){
  8628. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8629. }else{
  8630. $end_list = [];
  8631. foreach($final_list as $v){
  8632. $end_list[] = array_values($v);
  8633. }
  8634. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8635. array_unshift($end_list,[
  8636. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8637. ]);
  8638. array_unshift($end_list,[
  8639. $title,"","","","","","","","","","","","","","","","","",""
  8640. ]);
  8641. $merges = [
  8642. [
  8643. "s"=>["r"=>0,"c"=>0],
  8644. "e"=>["r"=>0,"c"=>6]
  8645. ]
  8646. ];
  8647. $cols = [
  8648. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8649. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8650. ];
  8651. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8652. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8653. ])));
  8654. }
  8655. }
  8656. }
  8657. }
  8658. public function _exceljxcjs(){
  8659. $classid = $this->classid->sku();
  8660. $pm = $classid;
  8661. $typeclass = array();
  8662. $tc = $this->typeclass->find_all();
  8663. foreach ($tc as $v) {
  8664. $typeclass[$v['id']] = $v;
  8665. }
  8666. $prc = array();
  8667. $purchase = $this->purchase->find_all();
  8668. foreach ($purchase as $k => $v) {
  8669. $prc[$v['id']] = $v['title'];
  8670. }
  8671. if(!isset($_GET['excel'])){
  8672. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8673. }
  8674. $where = "sku != 'Preset'";
  8675. //数据排序
  8676. $order_str = "id desc";
  8677. if (empty($page)) {
  8678. $start = 0;
  8679. $perpage = 1;
  8680. } else {
  8681. $start = ($page - 1) * $perpage;
  8682. }
  8683. $category = $this->input->get('category', true);
  8684. $warehouse = $this->input->get('warehouse', true);
  8685. $excelid = $this->input->get('sid', true);
  8686. if ($category) {
  8687. $where .= " and features like '%-$category-%'";
  8688. }
  8689. if ($warehouse) {
  8690. $where .= " and warehouse = '$warehouse'";
  8691. }
  8692. $xzid = '';
  8693. if ($excelid) {
  8694. $excelid = explode(',', trim($excelid, ','));
  8695. foreach ($excelid as $key => $value) {
  8696. $xzid .= " id = " . $value . " or";
  8697. }
  8698. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8699. }
  8700. $wt = array();
  8701. $whlabel_type = $this->whlabel_type->find_all();
  8702. foreach ($whlabel_type as $v) {
  8703. $wt[$v['id']] = $v['title'];
  8704. }
  8705. $wh = array();
  8706. $w = $this->warehouse->find_all('1=1', 'id,title');
  8707. foreach ($w as $v) {
  8708. $wh[$v['id']] = $v['title'];
  8709. }
  8710. $list = array();
  8711. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8712. foreach ($rows as $key => $value) {
  8713. if (isset($wt[$value['type']])) {
  8714. $rows[$key]['type'] = $wt[$value['type']];
  8715. } else {
  8716. $rows[$key]['type'] = '未设置';
  8717. }
  8718. $bm = '03';
  8719. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8720. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8721. $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');
  8722. $details = array();
  8723. $cpid = array();
  8724. $cpbz = array();
  8725. $c = 0;
  8726. $g = 0;
  8727. $x = 0;
  8728. $t = 0;
  8729. $s = 0;
  8730. $q = 0;
  8731. foreach ($sd as $k => $v) {
  8732. if ($v['state'] == 0) {
  8733. $c++;
  8734. if ($v['cpid'] != 0) {
  8735. $cpid[$v['cpid']] = $v['cpid'];
  8736. }
  8737. if ($v['cpbz'] != '') {
  8738. $cpbz[$v['cpbz']] = $v['cpbz'];
  8739. }
  8740. }
  8741. if ($v['state'] != 9) {
  8742. $g++;
  8743. }
  8744. if ($v['state'] == 1) {
  8745. $x++;
  8746. }
  8747. if ($v['state'] == 2) {
  8748. $t++;
  8749. }
  8750. if ($v['state'] == 8) {
  8751. $s++;
  8752. }
  8753. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8754. $q++;
  8755. }
  8756. $details[$v['details']] = $v['details'];
  8757. }
  8758. $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'] . '"');
  8759. $rows[$key]['details'] = implode("、", $details);
  8760. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8761. $number = $value['number'];
  8762. $ftime = time() - 15 * 24 * 3600;
  8763. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8764. $rows[$key]['number'] = $g;
  8765. $rows[$key]['c'] = $c;
  8766. $rows[$key]['x'] = $x;
  8767. $rows[$key]['t'] = $t;
  8768. $rows[$key]['s'] = $s;
  8769. $rows[$key]['q'] = $q;
  8770. $rows[$key]['z'] = $z;
  8771. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8772. $features = explode('-', trim($features, '-'));
  8773. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8774. }
  8775. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8776. $final_list = [];
  8777. foreach ($list as $k => $v) {
  8778. if (empty($v['sku'])) {
  8779. continue;
  8780. }
  8781. $final_list[] = [
  8782. $v["warehouse"],
  8783. $v["purchase"],
  8784. $v["details"],
  8785. $v["cpid"],
  8786. $v["dbcontent"],
  8787. $v["sku"],
  8788. $v["bm"],
  8789. $v["jm"],
  8790. $v["title"],
  8791. $v["pm"],
  8792. $v["cpbz"],
  8793. $v["sm"],
  8794. $v["type"],
  8795. $v["number"],
  8796. $v["c"],
  8797. $v["x"],
  8798. $v["t"],
  8799. $v["s"],
  8800. $v["q"],
  8801. $v["z"],
  8802. $v['weight'],
  8803. ];
  8804. }
  8805. if(empty($final_list)){
  8806. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8807. }
  8808. $title = "总进销存统计表";
  8809. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8810. $merges = [
  8811. [
  8812. "s"=>["r"=>0,"c"=>0],
  8813. "e"=>["r"=>0,"c"=>21]
  8814. ]
  8815. ];
  8816. $cols = [
  8817. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8818. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8819. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8820. ];
  8821. array_unshift($final_list, $first_row);
  8822. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8823. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8824. }
  8825. public function _summaryjs($arg_array)
  8826. {
  8827. $prc = array();
  8828. $purchase = $this->purchase->find_all();
  8829. foreach ($purchase as $k => $v) {
  8830. $prc[$v['id']] = $v['title'];
  8831. }
  8832. if (isset($_GET['excel'])) {
  8833. $ktime = $this->input->get('ktime', true);
  8834. $jtime = $this->input->get('jtime', true);
  8835. $ktime = strtotime($ktime);
  8836. $jtime = strtotime($jtime);
  8837. $where = "1=1";
  8838. if ($ktime && $jtime) {
  8839. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8840. }
  8841. //数据排序
  8842. $order_str = "time desc";
  8843. if (empty($page)) {
  8844. $start = 0;
  8845. $perpage = 1;
  8846. } else {
  8847. $start = ($page - 1) * $perpage;
  8848. }
  8849. //取得信息列表
  8850. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8851. foreach ($info_list as $key => $value) {
  8852. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8853. $warehouse = $this->warehouse->read($value['warehouse']);
  8854. $info_list[$key]['warehouse'] = $warehouse['title'];
  8855. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8856. $details = array();
  8857. $cpid = array();
  8858. foreach ($x as $k => $v) {
  8859. if ($v['details'] != '') {
  8860. $details[$v['details']] = $v['details'];
  8861. }
  8862. if ($v['cpid'] != 0) {
  8863. $cpid[$v['cpid']] = $v['cpid'];
  8864. }
  8865. }
  8866. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8867. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8868. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8869. $info_list[$key]['s'] = $s;
  8870. $info_list[$key]['x'] = count($x);
  8871. }
  8872. if(empty($info_list)){
  8873. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8874. }
  8875. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8876. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8877. $merges = [
  8878. [
  8879. "s"=>["r"=>0,"c"=>0],
  8880. "e"=>["r"=>0,"c"=>7]
  8881. ]
  8882. ];
  8883. $cols = [
  8884. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8885. ];
  8886. $final_list = [];
  8887. foreach($info_list as $k => $v){
  8888. $final_list[] = array_values($v);
  8889. }
  8890. array_unshift($final_list, $first_row);
  8891. array_unshift($final_list,[
  8892. $title,"","","","","","","","",
  8893. ]);
  8894. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8895. $titlename = "<table border=1>
  8896. <tr align='center'>
  8897. <td>仓库</td>
  8898. <td>供应商</td>
  8899. <td>出库位置</td>
  8900. <td>出库编码</td>
  8901. <td>SKU</td>
  8902. <td>产品名</td>
  8903. <td>总剩余库存</td>
  8904. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8905. </tr>
  8906. </table>";
  8907. $filename = $title . ".xls";
  8908. $tail = "";
  8909. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8910. }
  8911. }
  8912. public function _uckjs()
  8913. {
  8914. if (isset($_GET['excel'])) {
  8915. $tc = array();
  8916. $typeclass = $this->typeclass->find_all();
  8917. foreach ($typeclass as $v) {
  8918. $tc[$v['id']] = $v['zh'];
  8919. }
  8920. $first_row = [
  8921. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8922. ];
  8923. $t = array();
  8924. $rq = '';
  8925. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8926. $ts = $ts / (24 * 3600);
  8927. for ($i = 0; $i < $ts; $i++) {
  8928. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8929. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8930. }
  8931. $day_len = count($t);
  8932. $first_row[] = "本月出库";
  8933. $merges = [
  8934. ];
  8935. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8936. $excel_key = 1;
  8937. $final_list = [];
  8938. foreach ($info_list as $k => $v) {
  8939. $features = explode('-', trim($v['features'], '-'));
  8940. if (!isset($features[3]) || !isset($features[4])) {
  8941. continue;
  8942. }
  8943. $tmp = [];
  8944. $tmp[0] = $tc[$features[0]]; //类型
  8945. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8946. $tmp[2] = $tc[$features[4]]; //曲度
  8947. $tmp[3] = '';
  8948. if (isset($data[$k][1])) {
  8949. $tmp[3] .=$tmp[1];
  8950. }
  8951. if (isset($data[$k][2])) {
  8952. $tmp[3] .= $tmp[2];
  8953. }
  8954. if (isset($features[5])) {
  8955. $tmp[3] .= $tc[$features[5]];
  8956. }
  8957. if (isset($features[2])) {
  8958. $tmp[3] .= $tc[$features[2]];
  8959. }
  8960. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8961. $tmp[4] = $v['sku'];
  8962. $tmp[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())) . '))'); //月初库存
  8963. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8964. $tmp[7] ="";
  8965. $tmp[8] ="";
  8966. $byck = 0;
  8967. foreach ($t as $vv) {
  8968. $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));
  8969. $tmp[] = ($sl > 0) ? $sl : '';
  8970. $byck += $sl;
  8971. }
  8972. $tmp[] = ($byck > 0) ? $byck : '';
  8973. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8974. // $ztrq = '';
  8975. // $ztsl = '';
  8976. // if (count($zt) > 0) {
  8977. // foreach ($zt as $vv) {
  8978. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8979. // $ztsl .= $vv['num'] . '<br>';
  8980. // }
  8981. // }
  8982. if(empty($zt)){
  8983. $final_list[] = $tmp;
  8984. $excel_key = $excel_key + 1;
  8985. }else{
  8986. $len = count($zt);
  8987. if($len == 1){
  8988. $tmp[7] = $zt[0]['num'] ;
  8989. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8990. $final_list[] = $tmp;
  8991. $excel_key = $excel_key + 1;
  8992. }else{
  8993. foreach($zt as $vv){
  8994. $tmp[7] = "";
  8995. $tmp[8] = "";
  8996. $tmp[7] = $vv['num'];
  8997. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8998. $final_list[] = $tmp;
  8999. }
  9000. $merges[] = [
  9001. "s"=>["r"=>$excel_key,"c"=>0],
  9002. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9003. ];
  9004. $merges[] = [
  9005. "s"=>["r"=>$excel_key,"c"=>1],
  9006. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9007. ];
  9008. $merges[] = [
  9009. "s"=>["r"=>$excel_key,"c"=>2],
  9010. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9011. ];
  9012. $merges[] = [
  9013. "s"=>["r"=>$excel_key,"c"=>3],
  9014. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9015. ];
  9016. $merges[] = [
  9017. "s"=>["r"=>$excel_key,"c"=>4],
  9018. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9019. ];
  9020. $merges[] = [
  9021. "s"=>["r"=>$excel_key,"c"=>5],
  9022. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9023. ];
  9024. $merges[] = [
  9025. "s"=>["r"=>$excel_key,"c"=>6],
  9026. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9027. ];
  9028. for($i=1;$i<=$day_len;$i++){
  9029. $merges[] = [
  9030. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9031. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9032. ];
  9033. }
  9034. $merges[] = [
  9035. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9036. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9037. ];
  9038. $excel_key = $excel_key + $len;
  9039. }
  9040. }
  9041. }
  9042. $title = "详情 " . date("Y-m-d", time());
  9043. if(empty($final_list)){
  9044. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9045. }
  9046. $cols = [
  9047. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9048. ];
  9049. array_unshift($final_list, $first_row);
  9050. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9051. }
  9052. }
  9053. public function _whlabelexcelzhjs(){
  9054. if(empty($_GET['excel'])){
  9055. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9056. }
  9057. $where = "sku != 'Preset' and sku != '' ";
  9058. //数据排序
  9059. $order_str = "id desc";
  9060. if (empty($page)) {
  9061. $start = 0;
  9062. $perpage = 1;
  9063. } else {
  9064. $start = ($page - 1) * $perpage;
  9065. }
  9066. $category = $this->input->get('category', true);
  9067. $warehouse = $this->input->get('warehouse', true);
  9068. $excelid = $this->input->get('sid', true);
  9069. if ($category) {
  9070. $where .= " and features like '%-$category-%'";
  9071. }
  9072. if ($warehouse) {
  9073. $where .= " and warehouse = '$warehouse'";
  9074. }
  9075. $xzid = '';
  9076. if ($excelid) {
  9077. $excelid = explode(',', trim($excelid, ','));
  9078. foreach ($excelid as $key => $value) {
  9079. $xzid .= " id = " . $value . " or";
  9080. }
  9081. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9082. }
  9083. $merges = [
  9084. [
  9085. "s"=>["r"=>0,"c"=>0],
  9086. "e"=>["r"=>0,"c"=>6]
  9087. ]
  9088. ];
  9089. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9090. $excel_index = 2;
  9091. $final_list = [];
  9092. foreach ($rows as $key => $value) {
  9093. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9094. $zh = '';
  9095. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9096. // foreach ($zt_list as $v) {
  9097. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9098. // }
  9099. $zt = array_sum(array_column($zt_list, 'num'));
  9100. $number = $value['number'];
  9101. $ftime = time() - 15 * 24 * 3600;
  9102. $warehouse = $this->warehouse->read($value['warehouse']);
  9103. // $rows[$key]['warehouse'] = $warehouse['title'];
  9104. // $rows[$key]['number'] = $c;
  9105. // $rows[$key]['features'] = $zh;
  9106. //$rows[$key]['hb'] = $c + $zt;
  9107. $tmp = [];
  9108. $tmp[0] = $warehouse['title'];
  9109. $tmp[1] = $value['sku'];
  9110. $tmp[2] = $value['title'];
  9111. $tmp[3] = $c;
  9112. $tmp[4] = "";
  9113. $tmp[5] = $c + $zt;
  9114. if(empty($zt_list)){
  9115. $tmp[4] = "";
  9116. $final_list[] = $tmp;
  9117. $excel_index = $excel_index + 1;
  9118. }else{
  9119. if(count($zt_list) == 1){
  9120. $tmp[4] = "";
  9121. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9122. $final_list[] = $tmp;
  9123. $excel_index = $excel_index + 1;
  9124. }else{
  9125. $len = count($zt_list);
  9126. foreach ($zt_list as $v){
  9127. $tmp[4] = "";
  9128. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9129. $final_list[] = $tmp;
  9130. }
  9131. $merges[] = [
  9132. "s"=>["r"=>$excel_index,"c"=>0],
  9133. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9134. ];
  9135. $merges[] = [
  9136. "s"=>["r"=>$excel_index,"c"=>1],
  9137. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9138. ];
  9139. $merges[] = [
  9140. "s"=>["r"=>$excel_index,"c"=>2],
  9141. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9142. ];
  9143. $merges[] = [
  9144. "s"=>["r"=>$excel_index,"c"=>3],
  9145. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9146. ];
  9147. $merges[] = [
  9148. "s"=>["r"=>$excel_index,"c"=>5],
  9149. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9150. ];
  9151. $excel_index = $excel_index + $len;
  9152. }
  9153. }
  9154. }
  9155. $first_row = [
  9156. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9157. ];
  9158. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9159. if(empty($final_list)){
  9160. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9161. }
  9162. $cols = [
  9163. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9164. ];
  9165. array_unshift($final_list, $first_row);
  9166. array_unshift($final_list, [
  9167. $title,"","","","",""
  9168. ]);
  9169. $end_list = [];
  9170. foreach ($final_list as $key => $value) {
  9171. $end_list[] = array_values($value);
  9172. }
  9173. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9174. }
  9175. //出库、退库导出
  9176. public function _dccrtypejs()
  9177. {
  9178. $classid = $this->classid->sku();
  9179. $pm = $classid;
  9180. $typeclass = array();
  9181. $tc = $this->typeclass->find_all();
  9182. foreach ($tc as $v) {
  9183. $typeclass[$v['id']] = $v;
  9184. }
  9185. $prc = array();
  9186. $purchase = $this->purchase->find_all();
  9187. foreach ($purchase as $k => $v) {
  9188. $prc[$v['id']] = $v['title'];
  9189. }
  9190. if (isset($_GET['sid'])) {
  9191. $wh = array();
  9192. $w = $this->warehouse->find_all('1=1', 'id,title');
  9193. foreach ($w as $v) {
  9194. $wh[$v['id']] = $v['title'];
  9195. }
  9196. $type = $this->input->get('excel', true);
  9197. $category = $this->input->get('category', true);
  9198. $size = $this->input->get('size', true);
  9199. $grade = $this->input->get('grade', true);
  9200. $color = $this->input->get('color', true);
  9201. $lowe = $this->input->get('lowe', true);
  9202. $sku = $this->input->get('sku', true);
  9203. $warehouse = $this->input->get('warehouse', true);
  9204. $lacetype = $this->input->get('lacetype', true);
  9205. $lacecolor = $this->input->get('lacecolor', true);
  9206. $density = $this->input->get('density', true);
  9207. $haircap = $this->input->get('haircap', true);
  9208. $purchase = $this->input->get('purchase', true);
  9209. $title = $this->input->get('title', true);
  9210. $state = $this->input->get('state', true);
  9211. $sid = $this->input->get('sid', true);
  9212. $ktime = $this->input->get('ktime', true);
  9213. $jtime = $this->input->get('jtime', true);
  9214. $ktime = strtotime($ktime);
  9215. $jtime = strtotime($jtime);
  9216. $where = "1=1";
  9217. $gj = "";
  9218. $ck = "";
  9219. if ($category) {
  9220. $where .= " and features like '%-$category-%'";
  9221. }
  9222. if ($size) {
  9223. $where .= " and features like '%-$size-%'";
  9224. }
  9225. if ($grade) {
  9226. $where .= " and features like '%-$grade-%'";
  9227. }
  9228. if ($color) {
  9229. $where .= " and features like '%-$color-%'";
  9230. }
  9231. if ($lowe) {
  9232. $where .= " and features like '%-$lowe-%'";
  9233. }
  9234. if ($warehouse) {
  9235. $where .= " and warehouse = '$warehouse'";
  9236. }
  9237. if ($purchase) {
  9238. $where .= " and purchase = '$purchase'";
  9239. }
  9240. if ($state) {
  9241. $where .= " and state = '$state'";
  9242. }
  9243. if ($lacetype) {
  9244. $where .= " and features like '%-$lacetype-%'";
  9245. }
  9246. if ($lacecolor) {
  9247. $where .= " and features like '%-$lacecolor-%'";
  9248. }
  9249. if ($density) {
  9250. $where .= " and features like '%-$density-%'";
  9251. }
  9252. if ($haircap) {
  9253. $where .= " and features like '%-$haircap-%'";
  9254. }
  9255. if ($title) {
  9256. $title = trim($title, ' ');
  9257. $title = trim($title, ' ');
  9258. $where .= " and title like '%$title%'";
  9259. }
  9260. if ($sku) {
  9261. $sku = trim($sku, ' ');
  9262. $sku = trim($sku, ' ');
  9263. $where .= " and sku like '%$sku%'";
  9264. }
  9265. if ($ktime && $jtime) {
  9266. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9267. }
  9268. $sidwhere = '';
  9269. if ($sid) {
  9270. $sd = "";
  9271. $s = explode(',', trim($sid, ','));
  9272. foreach ($s as $value) {
  9273. $sd .= " id = " . $value . " or";
  9274. }
  9275. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9276. }
  9277. //数据排序
  9278. $order_str = "time desc";
  9279. if (empty($page)) {
  9280. $start = 0;
  9281. $perpage = 1;
  9282. } else {
  9283. $start = ($page - 1) * $perpage;
  9284. }
  9285. $wh = array();
  9286. $w = $this->warehouse->find_all('1=1', 'id,title');
  9287. foreach ($w as $v) {
  9288. $wh[$v['id']] = $v['title'];
  9289. }
  9290. $wt = array();
  9291. $whlabel_type = $this->whlabel_type->find_all();
  9292. foreach ($whlabel_type as $v) {
  9293. $wt[$v['id']] = $v['title'];
  9294. }
  9295. $classid = $this->classid->sku();
  9296. $list = array();
  9297. $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');
  9298. foreach ($rows_r as $key => $value) {
  9299. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9300. $pm = $classid;
  9301. $jm = $classid;
  9302. $rows_r[$key]['enter'] = '入库';
  9303. $rows_r[$key]['time'] = $value['enter'];
  9304. if ($value['rktype'] == 1) {
  9305. $rows_r[$key]['rktype'] = '采购入库';
  9306. } else if ($value['rktype'] == 2) {
  9307. $rows_r[$key]['rktype'] = '盘盈调整';
  9308. } else if ($value['rktype'] == 3) {
  9309. $rows_r[$key]['rktype'] = '其他调整入库';
  9310. } else if ($value['rktype'] == 4) {
  9311. $rows_r[$key]['rktype'] = '其他调整入库';
  9312. } else if ($value['rktype'] == 5) {
  9313. $rows_r[$key]['rktype'] = '退库入库';
  9314. } else if ($value['rktype'] == 6) {
  9315. $rows_r[$key]['rktype'] = '退货可用入库';
  9316. } else if ($value['rktype'] == 7) {
  9317. $rows_r[$key]['rktype'] = '形态转换入库';
  9318. } else {
  9319. $rows_r[$key]['rktype'] = '';
  9320. }
  9321. $features = explode('-', trim($value['features'], '-'));
  9322. foreach ($features as $v) {
  9323. if (isset($typeclass[$v])) {
  9324. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9325. $pm[$typeclass[$v]['classid']] = $zh[0];
  9326. }
  9327. if (isset($typeclass[$v])) {
  9328. if (isset($jm[$typeclass[$v]['classid']])) {
  9329. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9330. }
  9331. }
  9332. }
  9333. $zh = implode(" ", $pm);
  9334. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9335. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9336. $rows_r[$key]['zh'] = $zh;
  9337. $jm = array_filter($jm);
  9338. $rows_r[$key]['features'] = implode("-", $jm);
  9339. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9340. }
  9341. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  9342. foreach ($rows_c as $key => $value) {
  9343. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9344. $pm = $classid;
  9345. $jm = $classid;
  9346. $rows_c[$key]['time'] = $value['outk'];
  9347. $rows_c[$key]['outk'] = '出库';
  9348. if ($value['cktype'] == 1) {
  9349. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9350. } else if ($value['cktype'] == 2) {
  9351. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9352. } else if ($value['cktype'] == 3) {
  9353. $rows_c[$key]['cktype'] = '盘亏调整';
  9354. } else if ($value['cktype'] == 4) {
  9355. $rows_c[$key]['cktype'] = '其他调整出库';
  9356. } else if ($value['cktype'] == 5) {
  9357. $rows_c[$key]['cktype'] = '形态转换出库';
  9358. } else {
  9359. $rows_c[$key]['cktype'] = '';
  9360. }
  9361. unset($rows_c[$key]['state']);
  9362. $features = explode('-', trim($value['features'], '-'));
  9363. foreach ($features as $v) {
  9364. if (isset($typeclass[$v])) {
  9365. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9366. $pm[$typeclass[$v]['classid']] = $zh[0];
  9367. }
  9368. if (isset($typeclass[$v])) {
  9369. if (isset($jm[$typeclass[$v]['classid']])) {
  9370. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9371. }
  9372. }
  9373. }
  9374. $zh = implode(" ", $pm);
  9375. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9376. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9377. $rows_c[$key]['zh'] = $zh;
  9378. $jm = array_filter($jm);
  9379. $rows_c[$key]['features'] = implode("-", $jm);
  9380. $rows_c[$key]['number'] = 1;
  9381. }
  9382. $merged = $rows_r;
  9383. foreach ($rows_c as $key => $value) {
  9384. if (isset($merged[$key])) {
  9385. $merged[] = $value;
  9386. } else {
  9387. $merged[$key] = $value;
  9388. }
  9389. }
  9390. usort($merged, function ($a, $b) {
  9391. return $a['time'] - $b['time'];
  9392. });
  9393. foreach ($merged as $key => $value) {
  9394. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9395. }
  9396. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9397. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9398. $cols = [
  9399. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9400. ];
  9401. $final_list= [];
  9402. foreach($merged as $key => $value){
  9403. $final_list[] = array_values($value) ;
  9404. }
  9405. if(empty($merged)){
  9406. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9407. }
  9408. array_unshift($final_list, $first_row);
  9409. $end_list = [];
  9410. foreach ($final_list as $key => $value) {
  9411. $end_list[] = array_values($value);
  9412. }
  9413. $merges = [];
  9414. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9415. }
  9416. }
  9417. public function _errorexceljs()
  9418. {
  9419. $post = $this->input->post(NULL, TRUE);
  9420. if (isset($_GET['page'])) {
  9421. $page = $this->input->get('page', true);
  9422. $perpage = $this->input->get('perpage', true);
  9423. $sku = $this->input->get('sku', true);
  9424. $warehouse = $this->input->get('warehouse', true);
  9425. $ktime = $this->input->get('ktime', true);
  9426. $jtime = $this->input->get('jtime', true);
  9427. $ktime = strtotime($ktime);
  9428. $jtime = strtotime($jtime);
  9429. $where = "sku != 'Preset'";
  9430. $gj = '';
  9431. if ($sku) {
  9432. $where .= " and sku like '%$sku%'";
  9433. } else {
  9434. if ($ktime && $jtime) {
  9435. $gj = " and time > '$ktime' and time < '$jtime'";
  9436. }
  9437. }
  9438. if ($warehouse) {
  9439. $where .= " and warehouse = '$warehouse'";
  9440. }
  9441. //数据排序
  9442. $order_str = "id desc";
  9443. if (empty($page)) {
  9444. $start = 0;
  9445. $perpage = 1;
  9446. } else {
  9447. $start = ($page - 1) * $perpage;
  9448. }
  9449. //取得信息列表
  9450. $rows = array();
  9451. $list = array();
  9452. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9453. foreach ($info_list as $value) {
  9454. $warehouse = $this->warehouse->read($value['warehouse']);
  9455. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9456. $number = $value['number'];
  9457. $ftime = time() - 15 * 24 * 3600;
  9458. if ($c < 1) {
  9459. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9460. }
  9461. }
  9462. $title = "0库存汇总";
  9463. $first_row = ["仓库","SKU","产品","当前库存"];
  9464. $cols = [
  9465. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9466. ];
  9467. $final_list= [];
  9468. foreach($list as $key => $value){
  9469. $final_list[] = array_values($value) ;
  9470. }
  9471. if(empty($final_list)){
  9472. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9473. }
  9474. array_unshift($final_list, $first_row);
  9475. $merges = [];
  9476. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9477. }
  9478. }
  9479. }