Whlabel.php 319 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403
  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 == 'typedy') //进销存浏览店员页面
  62. {
  63. $this->_typedy($arg_array);
  64. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  65. {
  66. $this->_typedy_ck($arg_array);
  67. } else if ($arg == 'typeck') {
  68. $this->_typeck($arg_array);
  69. } else if ($arg == 'whlabeckdc') {
  70. $this->_whlabeckdc($arg_array);
  71. } else if ($arg == 'usatype') //美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  75. {
  76. $this->_usatypeapp();
  77. } else if ($arg == 'enteradd') //入库操作
  78. {
  79. $this->_enteradd();
  80. } else if ($arg == 'enteredit') //修改
  81. {
  82. $this->_enteredit($arg_array);
  83. } else if ($arg == 'enter') //入库浏览
  84. {
  85. $this->_enter();
  86. } else if ($arg == 'out') //出库浏览
  87. {
  88. $this->_out();
  89. } else if ($arg == 'label') //出库标签浏览
  90. {
  91. $this->_label();
  92. } else if ($arg == 'outorder') //独立站出库订单
  93. {
  94. $this->_outorder();
  95. } else if ($arg == 'soutorder') //速卖通出库订单
  96. {
  97. $this->_soutorder();
  98. } else if ($arg == 'toutorder') //TT出库订单
  99. {
  100. $this->_toutorder();
  101. }else if ($arg == 'aoutorder') //amz出库订单
  102. {
  103. $this->_aoutorder();
  104. } else if ($arg == 'retreat') //退库订单
  105. {
  106. $this->_retreat();
  107. } else if ($arg == 'retreatlk') //退库订单
  108. {
  109. $this->_retreatlk();
  110. } else if ($arg == 'change') //更换标签
  111. {
  112. $this->_change();
  113. } else if ($arg == 'del') //删除
  114. {
  115. $this->_del();
  116. } else if ($arg == 'exceljxc') //进销存信息导出
  117. {
  118. $this->_exceljxc();
  119. } else if ($arg == 'excelr') //入库信息导出
  120. {
  121. $this->_excelr();
  122. } else if ($arg == 'excelct') //出库、退库信息导出
  123. {
  124. $this->_excelct();
  125. } else if ($arg == 'dccrtype') //根据出入库类型导出
  126. {
  127. $this->_dccrtype();
  128. } else if ($arg == 'excelcr') //出库、退库信息导出
  129. {
  130. $this->_excelcr();
  131. } else if ($arg == 'kcyz') //库存验证
  132. {
  133. $this->_kcyz();
  134. } else if ($arg == 'kj') //库存扣减
  135. {
  136. $this->_kj($arg_array);
  137. } else if ($arg == 'presetout') //预设库存导入
  138. {
  139. $this->_presetout($arg_array);
  140. } else if ($arg == 'presetedit') //预设库存导入
  141. {
  142. $this->_presetedit($arg_array);
  143. }else if ($arg == 'presetedittwo') //预设库存导入
  144. {
  145. $this->_presetedittwo($arg_array);
  146. } else if ($arg == 'summary') //汇总导出
  147. {
  148. $this->_summary($arg_array);
  149. } else if ($arg == 'manifest') //usps发货清单
  150. {
  151. $this->_manifest();
  152. } else if ($arg == 'abnormal') //占单异常
  153. {
  154. $this->_abnormal();
  155. } else if ($arg == 'error') //0库存SKU
  156. {
  157. $this->_error();
  158. } else if ($arg == 'errorexcel') //0库存SKU导出
  159. {
  160. $this->_errorexcel();
  161. } else if ($arg == 'db') {
  162. $this->_db();
  163. } else if ($arg == 'dbrk') {
  164. $this->_dbrk();
  165. } else if ($arg == 'whlabelczdc') {
  166. $this->_whlabelczdc();
  167. } else if ($arg == 'print') {
  168. $this->_print($arg_array);
  169. } else if ($arg == 'usaprint') {
  170. $this->_usaprint($arg_array);
  171. } else if ($arg == 'printck') {
  172. $this->_printck($arg_array);
  173. } else if ($arg == 'printrk') {
  174. $this->_printrk($arg_array);
  175. } else if ($arg == 'printxzrk') {
  176. $this->_printxzrk($arg_array);
  177. } else if ($arg == 'printexcel') {
  178. $this->_printexcel($arg_array);
  179. } else if ($arg == 'uck') {
  180. $this->_uck();
  181. } else if ($arg == 'whlabelexcelzh') {
  182. $this->_whlabelexcelzh();
  183. } else if ($arg == 'fc') {
  184. $this->_fc();
  185. } else if ($arg == 'fcmb') {
  186. $this->_fcmb();
  187. } else if ($arg == 'fcexcel') {
  188. $this->_fcexcel();
  189. } else if ($arg == 'fcjxc') {
  190. $this->_fcjxc($arg_array);
  191. } else if ($arg == '0kcdel') {
  192. $this->_0kcdel(); //导表删除0库存
  193. } else if ($arg == 'gbhtype') {
  194. $this->_gbhtype(); //更改备货状态
  195. } else if($arg == 'excelrjs'){
  196. $this->_excelrjs();
  197. } else if($arg == 'excelctjs'){
  198. $this->_excelctjs();
  199. }else if ($arg == 'exceljxcjs') //进销存信息导出
  200. {
  201. $this->_exceljxcjs();
  202. } else if ($arg == 'summaryjs') //汇总导出
  203. {
  204. $this->_summaryjs($arg_array);
  205. }else if($arg == 'uckjs'){
  206. $this->_uckjs();
  207. }else if ($arg == 'whlabelexcelzhjs') {
  208. $this->_whlabelexcelzhjs();
  209. }else if($arg == 'dccrtypejs'){
  210. $this->_dccrtypejs();
  211. }else if($arg == 'errorexceljs'){
  212. $this->_errorexceljs();
  213. }else if($arg == "w_t_cs"){
  214. $this->_w_t_cs(); //首页
  215. }else {
  216. $this->_index();
  217. }
  218. }
  219. public function _w_t_cs(){
  220. $vip = 0;
  221. if (isset($_SESSION['api'])) {
  222. $user = $this->user->get_api($_SESSION['api']);
  223. $fgshop = "";
  224. $sid = "";
  225. $usersp = explode('|', trim($user['shop'], '|'));
  226. foreach ($usersp as $value) {
  227. $fgshop .= " shop = " . $value . " or";
  228. $sid .= " id = " . $value . " or";
  229. }
  230. if ($user['vip'] == 1) {
  231. $vip = 1;
  232. }
  233. } else {
  234. header('Location: /');
  235. exit;
  236. }
  237. $prc = array();
  238. $purchase = $this->purchase->find_all();
  239. foreach ($purchase as $k => $v) {
  240. $prc[$v['id']] = $v['title'];
  241. }
  242. $company = array();
  243. $ct = $this->company->find_all();
  244. foreach ($ct as $k => $v) {
  245. $company[$v['id']] = $v['title'];
  246. }
  247. $sp = array();
  248. $s = $this->shop->find_all('1=1', 'id,shopname');
  249. foreach ($s as $v) {
  250. $sp[$v['id']] = $v['shopname'];
  251. }
  252. $wh = array();
  253. $w = $this->warehouse->find_all('1=1', 'id,title');
  254. foreach ($w as $v) {
  255. $wh[$v['id']] = $v['title'];
  256. }
  257. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  258. $this->data['shop'] = $wlshop;
  259. $this->data['vip'] = $vip;
  260. $this->_Template('whlabel_typejs', $this->data);
  261. }
  262. //管理
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if (isset($post['page'])) {
  267. $page = $this->input->post('page', true);
  268. $perpage = $this->input->post('perpage', true);
  269. $sku = $this->input->post('sku', true);
  270. $number = $this->input->post('number', true);
  271. $warehouse = $this->input->post('warehouse', true);
  272. $purchase = $this->input->post('purchase', true);
  273. $orderinfo = $this->input->post('orderinfo', true);
  274. $waybill = $this->input->post('waybill', true);
  275. $category = $this->input->post('category', true);
  276. $size = $this->input->post('size', true);
  277. $grade = $this->input->post('grade', true);
  278. $color = $this->input->post('color', true);
  279. $lowe = $this->input->post('lowe', true);
  280. $state = $this->input->post('state', true);
  281. $label = $this->input->post('label', true);
  282. $timetk = $this->input->post('timetkk', true);
  283. $timetj = $this->input->post('timetjj', true);
  284. $timetk = strtotime($timetk);
  285. $timetj = strtotime($timetj);
  286. $where = "1=1 ";
  287. if ($timetk && $timetj) {
  288. $where .= " and time > '$timetk' and time < '$timetj'";
  289. }
  290. if ($sku) {
  291. $where .= " and sku = '$sku'";
  292. }
  293. if ($number) {
  294. $where .= " and number = '$number'";
  295. }
  296. if ($warehouse) {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if ($purchase) {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if ($orderinfo) {
  303. $where .= " and orderinfo = '$orderinfo'";
  304. }
  305. if ($waybill) {
  306. $where .= " and waybill = '$waybill'";
  307. }
  308. if ($category) {
  309. $where .= " and features like '%-$category-%'";
  310. }
  311. if ($size) {
  312. $where .= " and features like '%-$size-%'";
  313. }
  314. if ($grade) {
  315. $where .= " and features like '%-$grade-%'";
  316. }
  317. if ($color) {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if ($lowe) {
  321. $where .= " and features like '%-$lowe-%'";
  322. }
  323. if ($label) {
  324. $where .= " and label = '$label'";
  325. }
  326. if ($state != '') {
  327. $where .= " and state = '$state'";
  328. }
  329. //数据排序
  330. $order_str = "time desc";
  331. if (empty($page)) {
  332. $start = 0;
  333. $perpage = 1;
  334. } else {
  335. $start = ($page - 1) * $perpage;
  336. }
  337. //取得信息列表
  338. $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);
  339. foreach ($info_list as $key => $value) {
  340. $warehouse = $this->warehouse->read($value['warehouse']);
  341. $info_list[$key]['warehouse'] = $warehouse['title'];
  342. $purchase = $this->purchase->read($value['purchase']);
  343. $info_list[$key]['purchase'] = $purchase['title'];
  344. if ($value['enter'] != 0) {
  345. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  346. } else {
  347. $info_list[$key]['enter'] = "";
  348. }
  349. if ($value['outk'] != 0) {
  350. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  351. } else {
  352. $info_list[$key]['outk'] = "";
  353. }
  354. if ($value['printing'] != 0) {
  355. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  356. } else {
  357. $info_list[$key]['printing'] = "";
  358. }
  359. if ($value['orderinfo'] == 0) {
  360. $info_list[$key]['orderinfo'] = "";
  361. }
  362. if ($value['waybill'] == 0) {
  363. $info_list[$key]['waybill'] = "";
  364. }
  365. if ($value['state'] == 0) {
  366. $info_list[$key]['state'] = "在库";
  367. } else if ($value['state'] == 1) {
  368. $info_list[$key]['state'] = "出库";
  369. } else if ($value['state'] == 2) {
  370. $info_list[$key]['state'] = "退库";
  371. } else if ($value['state'] == 3) {
  372. $info_list[$key]['state'] = "调拨中";
  373. } else if ($value['state'] == 4) {
  374. $info_list[$key]['state'] = "再加工";
  375. } else if ($value['state'] == 5) {
  376. $info_list[$key]['state'] = "维修中";
  377. } else if ($value['state'] == 6) {
  378. $info_list[$key]['state'] = "盘亏";
  379. } else if ($value['state'] == 7) {
  380. $info_list[$key]['state'] = "更换标签";
  381. } else if ($value['state'] == 8) {
  382. $info_list[$key]['state'] = "其它";
  383. } else if ($value['state'] == 9) {
  384. $info_list[$key]['state'] = "预设";
  385. } else if ($value['state'] == 10) {
  386. $info_list[$key]['state'] = "美店零售";
  387. }
  388. if ($value['text'] == "") {
  389. $info_list[$key]['text'] = "";
  390. }
  391. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  392. }
  393. $total = $this->whlabel->find_count($where);
  394. $pagenum = ceil($total / $perpage);
  395. $over = $total - ($start + $perpage);
  396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  397. echo json_encode($rows);
  398. exit;
  399. }
  400. if (isset($post['outsku'])) {
  401. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  402. $cz = $this->input->post('cz', true);
  403. if ($cz == '1') {
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. } else {
  416. $sku = $this->input->post('outsku', true);
  417. if ($sku) {
  418. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  419. if (count($data) < 1) {
  420. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  421. exit;
  422. }
  423. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  424. echo json_encode(array('success' => true));
  425. exit;
  426. }
  427. }
  428. }
  429. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  430. $this->_Template('whlabel', $this->data);
  431. }
  432. //在库标签
  433. public function _existence()
  434. {
  435. $post = $this->input->post(NULL, TRUE);
  436. if (isset($post['s'])) {
  437. $id_arr = $this->input->post('s');
  438. $id_arr = explode(',', $id_arr);
  439. if (!$id_arr) {
  440. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  441. exit;
  442. }
  443. //循环删除记录
  444. foreach ($id_arr as $v) {
  445. $sid = $this->whlabel->read($v);
  446. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  447. if ($count > 0) {
  448. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  449. exit;
  450. }
  451. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  452. if (count($zt) > 0) {
  453. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  454. exit;
  455. }
  456. $this->whlabel->remove($v);
  457. }
  458. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  459. exit;
  460. }
  461. if (isset($post['page'])) {
  462. $page = $this->input->post('page', true);
  463. $perpage = $this->input->post('perpage', true);
  464. $warehouse = $this->input->post('warehouse', true);
  465. $label = $this->input->post('label', true);
  466. $where = "1=1 and state = 0";
  467. if ($warehouse) {
  468. $where .= " and warehouse = '$warehouse'";
  469. }
  470. if ($label) {
  471. $where .= " and label = '$label'";
  472. }
  473. //数据排序
  474. $order_str = "time asc";
  475. if (empty($page)) {
  476. $start = 0;
  477. $perpage = 1;
  478. } else {
  479. $start = ($page - 1) * $perpage;
  480. }
  481. //取得信息列表
  482. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  483. foreach ($info_list as $key => $value) {
  484. if ($value['enter'] != 0) {
  485. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  486. } else {
  487. $info_list[$key]['enter'] = "";
  488. }
  489. if ($value['printing'] != 0) {
  490. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  491. } else {
  492. $info_list[$key]['printing'] = "";
  493. }
  494. }
  495. $total = $this->whlabel->find_count($where);
  496. $pagenum = ceil($total / $perpage);
  497. $over = $total - ($start + $perpage);
  498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  499. echo json_encode($rows);
  500. exit;
  501. }
  502. $this->_Template('whlabel_existence', $this->data);
  503. }
  504. //进销存浏览
  505. public function _typedy($arg_array)
  506. {
  507. $prc = array();
  508. $purchase = $this->purchase->find_all();
  509. foreach ($purchase as $k => $v) {
  510. $prc[$v['id']] = $v['title'];
  511. }
  512. $post = $this->input->post(NULL, TRUE);
  513. if (isset($post['page'])) {
  514. $page = $this->input->post('page', true);
  515. $perpage = $this->input->post('perpage', true);
  516. $category = $this->input->post('category', true);
  517. $size = $this->input->post('size', true);
  518. $grade = $this->input->post('grade', true);
  519. $color = $this->input->post('color', true);
  520. $lowe = $this->input->post('lowe', true);
  521. $sku = $this->input->post('sku');
  522. $title = $this->input->post('title');
  523. $warehouse = $this->input->post('warehouse', true);
  524. $usa = $this->input->post('usa', true);
  525. $purchase = $this->input->post('purchase', true);
  526. $lacetype = $this->input->post('lacetype', true);
  527. $haircap = $this->input->post('haircap', true);
  528. $density = $this->input->post('density', true);
  529. $details = $this->input->post('details', true);
  530. $state = $this->input->post('state', true);
  531. $lacecolor = $this->input->post('lacecolor', true);
  532. $hairnumber = $this->input->post('hairnumber', true);
  533. $cklx = $this->input->post('cklx', true);
  534. $ktime = $this->input->post('ktime', true);
  535. $jtime = $this->input->post('jtime', true);
  536. $sm = $this->input->post('sm', true);
  537. $cpbz = $this->input->post('cpbz', true);
  538. $type = $this->input->post('type', true);
  539. $ktime = strtotime($ktime);
  540. $jtime = strtotime($jtime);
  541. $where = "1=1";
  542. $gj = "";
  543. $ck = "";
  544. if ($usa) {
  545. if (!$warehouse) {
  546. $where .= " and (warehouse = '5' or warehouse = '8')";
  547. }
  548. }
  549. if ($warehouse) {
  550. $where .= " and warehouse = '$warehouse'";
  551. }
  552. if ($details) {
  553. $where .= " and details = '$details'";
  554. }
  555. if ($purchase) {
  556. $where .= " and purchase = '$purchase'";
  557. }
  558. if (isset($state)) {
  559. if($state >-1){
  560. $where .= " and state = '$state'";
  561. }
  562. }
  563. if ($lacetype) {
  564. $where .= " and features like '%-$lacetype-%'";
  565. }
  566. if ($category) {
  567. $where .= " and features like '%-$category-%'";
  568. }
  569. if ($size) {
  570. $where .= " and features like '%-$size-%'";
  571. }
  572. if ($grade) {
  573. $where .= " and features like '%-$grade-%'";
  574. }
  575. if ($color) {
  576. $where .= " and features like '%-$color-%'";
  577. }
  578. if ($lowe) {
  579. $where .= " and features like '%-$lowe-%'";
  580. }
  581. if ($haircap) {
  582. $where .= " and features like '%-$haircap-%'";
  583. }
  584. if ($density) {
  585. $where .= " and features like '%-$density-%'";
  586. }
  587. if ($lacecolor) {
  588. $where .= " and features like '%-$lacecolor-%'";
  589. }
  590. if($sm){
  591. $where .= " and sm like '%".$sm."%'";
  592. }
  593. if($cpbz){
  594. $where .= " and cpbz like '%".$cpbz."%'";
  595. }
  596. if($type){
  597. $where .= " and type = ".$type."";
  598. }
  599. if (!empty($hairnumber)) {
  600. $where .= " and features like '%-128-%' ";
  601. if ($hairnumber < 0) {
  602. $class_list = $this->typeclass->find_all('classid = 43');
  603. foreach ($class_list as $v) {
  604. $where .= " and features not like '%-" . $v['id'] . "-%'";
  605. }
  606. } else {
  607. $where .= " and features like '%-$hairnumber-%'";
  608. }
  609. }
  610. $where_add = '';
  611. if ($cklx) {
  612. $shop = $this->shop->read($cklx);
  613. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  614. }
  615. if ($ktime && $jtime) {
  616. $gj = " and enter > '$ktime' and enter < '$jtime'";
  617. $ck = " and outk > '$ktime' and outk < '$jtime'";
  618. }
  619. //数据排序
  620. $order_str = "id desc";
  621. if (empty($page)) {
  622. $start = 0;
  623. $perpage = 1;
  624. } else {
  625. $start = ($page - 1) * $perpage;
  626. }
  627. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  628. if ($sku) {
  629. $sku = trim($sku, ' ');
  630. $sku = trim($sku, ' ');
  631. $where .= " and sku like '%$sku%'";
  632. $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);
  633. } else if ($title) {
  634. $title = trim($title, ' ');
  635. $title = trim($title, ' ');
  636. $where .= " and title like '%$title%'";
  637. $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);
  638. } else {
  639. //$where .= " and time > '$ktime' and time < '$jtime'";
  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. }
  642. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  643. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  644. foreach ($info_list as $k => $v) {
  645. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  646. unset($info_list[$k]['pm']);
  647. unset($info_list[$k]['jm']);
  648. unset($info_list[$k]['bm']);
  649. }
  650. //取得信息列表
  651. $rows = array();
  652. $list = array();
  653. foreach ($info_list as $key => $value) {
  654. $warehouse = $this->warehouse->read($value['warehouse']);
  655. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  656. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  657. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  658. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  659. $info_list[$key]['label'] = $value['sm'];
  660. $number = $value['number'];
  661. $ftime = time() - 15 * 24 * 3600;
  662. $info_list[$key]['warehouse'] = $warehouse['title'];
  663. $info_list[$key]['features'] = count($c);
  664. $z = count($z); //查看订单号
  665. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  666. $ztdata = '';
  667. if (count($zt) > 0) {
  668. foreach ($zt as $vv) {
  669. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  670. }
  671. }
  672. $info_list[$key]['number'] = $ztdata;
  673. $info_list[$key]['sm'] = $z;
  674. $details = array();
  675. $cpid = array();
  676. foreach ($c as $k => $v) {
  677. $details[$v['details']] = $v['details'];
  678. if ($v['cpid'] != 0) {
  679. $cpid[$v['cpid']] = $v['cpid'];
  680. }
  681. }
  682. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  683. if ($value['shop'] != '') {
  684. $shop = explode(',', trim($value['shop'], ','));
  685. $shop = $this->shop->read($shop[0]);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. }
  688. }
  689. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  690. $pagenum = ceil($total / $perpage);
  691. $over = $total - ($start + $perpage);
  692. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  693. echo json_encode($rows);
  694. exit;
  695. }
  696. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  697. $this->_Template('whlabel_typedy', $this->data);
  698. }
  699. //进销存浏览
  700. public function _typedy_ck($arg_array)
  701. {
  702. $prc = array();
  703. $purchase = $this->purchase->find_all();
  704. foreach ($purchase as $k => $v) {
  705. $prc[$v['id']] = $v['title'];
  706. }
  707. $post = $this->input->post(NULL, TRUE);
  708. if (isset($post['page'])) {
  709. $page = $this->input->post('page', true);
  710. $perpage = $this->input->post('perpage', true);
  711. $category = $this->input->post('category', true);
  712. $size = $this->input->post('size', true);
  713. $grade = $this->input->post('grade', true);
  714. $color = $this->input->post('color', true);
  715. $lowe = $this->input->post('lowe', true);
  716. $sku = $this->input->post('sku');
  717. $title = $this->input->post('title');
  718. $warehouse = $this->input->post('warehouse', true);
  719. $usa = $this->input->post('usa', true);
  720. $purchase = $this->input->post('purchase', true);
  721. $lacetype = $this->input->post('lacetype', true);
  722. $haircap = $this->input->post('haircap', true);
  723. $density = $this->input->post('density', true);
  724. $details = $this->input->post('details', true);
  725. $state = $this->input->post('state', true);
  726. $lacecolor = $this->input->post('lacecolor', true);
  727. $cklx = $this->input->post('cklx', true);
  728. $ktime = $this->input->post('ktime', true);
  729. $jtime = $this->input->post('jtime', true);
  730. $ktime = strtotime($ktime);
  731. $jtime = strtotime($jtime);
  732. $where = "1=1";
  733. $gj = "";
  734. $ck = "";
  735. if ($lacetype) {
  736. $where .= " and features like '%-$lacetype-%'";
  737. }
  738. if ($category) {
  739. $where .= " and features like '%-$category-%'";
  740. }
  741. if ($size) {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if ($grade) {
  745. $where .= " and features like '%-$grade-%'";
  746. }
  747. if ($color) {
  748. $where .= " and features like '%-$color-%'";
  749. }
  750. if ($lowe) {
  751. $where .= " and features like '%-$lowe-%'";
  752. }
  753. if ($haircap) {
  754. $where .= " and features like '%-$haircap-%'";
  755. }
  756. if ($density) {
  757. $where .= " and features like '%-$density-%'";
  758. }
  759. if ($lacecolor) {
  760. $where .= " and features like '%-$lacecolor-%'";
  761. }
  762. if ($usa) {
  763. if (!$warehouse) {
  764. $where .= " and (warehouse = '5' or warehouse = '8')";
  765. }
  766. }
  767. if ($warehouse) {
  768. $where .= " and warehouse = '$warehouse'";
  769. }
  770. if ($details) {
  771. $where .= " and details = '$details'";
  772. }
  773. if ($purchase) {
  774. $where .= " and purchase = '$purchase'";
  775. }
  776. if ($state) {
  777. $where .= " and state = '$state'";
  778. }
  779. $where_add = '';
  780. if ($cklx) {
  781. $shop = $this->shop->read($cklx);
  782. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  783. }
  784. if ($ktime && $jtime) {
  785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  787. }
  788. //数据排序
  789. $order_str = "id desc";
  790. if (empty($page)) {
  791. $start = 0;
  792. $perpage = 1;
  793. } else {
  794. $start = ($page - 1) * $perpage;
  795. }
  796. if ($sku) {
  797. $sku = trim($sku, ' ');
  798. $sku = trim($sku, ' ');
  799. $where .= " and sku like '%$sku%'";
  800. $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);
  801. } else if ($title) {
  802. $title = trim($title, ' ');
  803. $title = trim($title, ' ');
  804. $where .= " and title like '%$title%'";
  805. $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);
  806. } else {
  807. //$where .= " and time > '$ktime' and time < '$jtime'";
  808. $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);
  809. }
  810. //取得信息列表
  811. $rows = array();
  812. $list = array();
  813. foreach ($info_list as $key => $value) {
  814. $warehouse = $this->warehouse->read($value['warehouse']);
  815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  816. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  817. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  818. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  819. $ftime = time() - 15 * 24 * 3600;
  820. $info_list[$key]['warehouse'] = $warehouse['title'];
  821. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  822. //$z = count($z);//查看订单号
  823. //$info_list[$key]['zd'] = $z;
  824. $details = array();
  825. $cpid = array();
  826. foreach ($c as $k => $v) {
  827. $details[$v['details']] = $v['details'];
  828. if ($v['cpid'] != 0) {
  829. $cpid[$v['cpid']] = $v['cpid'];
  830. }
  831. }
  832. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  833. if ($value['shop'] != '') {
  834. $shop = explode(',', trim($value['shop'], ','));
  835. $shop = $this->shop->read($shop[0]);
  836. $info_list[$key]['shop'] = $shop['shopname'];
  837. }
  838. }
  839. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  840. $pagenum = ceil($total / $perpage);
  841. $over = $total - ($start + $perpage);
  842. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  843. echo json_encode($rows);
  844. exit;
  845. }
  846. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  847. $this->_Template('whlabel_typedy_ck', $this->data);
  848. }
  849. public function _typeck($arg_array)
  850. {
  851. $prc = array();
  852. $purchase = $this->purchase->find_all();
  853. foreach ($purchase as $k => $v) {
  854. $prc[$v['id']] = $v['title'];
  855. }
  856. $post = $this->input->post(NULL, TRUE);
  857. if (isset($post['page'])) {
  858. $page = $this->input->post('page', true);
  859. $perpage = $this->input->post('perpage', true);
  860. $category = $this->input->post('category', true);
  861. $size = $this->input->post('size', true);
  862. $grade = $this->input->post('grade', true);
  863. $color = $this->input->post('color', true);
  864. $lacecolor = $this->input->post('lacecolor', true);
  865. $lowe = $this->input->post('lowe', true);
  866. $sku = $this->input->post('sku');
  867. $title = $this->input->post('title');
  868. $warehouse = 13;
  869. $usa = $this->input->post('usa', true);
  870. $purchase = $this->input->post('purchase', true);
  871. $lacetype = $this->input->post('lacetype', true);
  872. $haircap = $this->input->post('haircap', true);
  873. $density = $this->input->post('density', true);
  874. $details = $this->input->post('details', true);
  875. $state = $this->input->post('state', true);
  876. $ktime = $this->input->post('ktime', true);
  877. $jtime = $this->input->post('jtime', true);
  878. $ktime = strtotime($ktime);
  879. $jtime = strtotime($jtime);
  880. $where = "1=1";
  881. $gj = "";
  882. $ck = "";
  883. if ($lacetype) {
  884. $where .= " and features like '%-$lacetype-%'";
  885. }
  886. if ($category) {
  887. $where .= " and features like '%-$category-%'";
  888. }
  889. if ($size) {
  890. $where .= " and features like '%-$size-%'";
  891. }
  892. if ($grade) {
  893. $where .= " and features like '%-$grade-%'";
  894. }
  895. if ($color) {
  896. $where .= " and features like '%-$color-%'";
  897. }
  898. if ($lacecolor) {
  899. $where .= " and features like '%-$lacecolor-%'";
  900. }
  901. if ($lowe) {
  902. $where .= " and features like '%-$lowe-%'";
  903. }
  904. if ($haircap) {
  905. $where .= " and features like '%-$haircap-%'";
  906. }
  907. if ($density) {
  908. $where .= " and features like '%-$density-%'";
  909. }
  910. if ($warehouse) {
  911. $where .= " and warehouse = '$warehouse'";
  912. }
  913. if ($details) {
  914. $where .= " and details = '$details'";
  915. }
  916. if ($purchase) {
  917. $where .= " and purchase = '$purchase'";
  918. }
  919. if ($state) {
  920. $where .= " and state = '$state'";
  921. }
  922. if ($ktime && $jtime) {
  923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  925. }
  926. //数据排序
  927. $order_str = "id desc";
  928. if (empty($page)) {
  929. $start = 0;
  930. $perpage = 1;
  931. } else {
  932. $start = ($page - 1) * $perpage;
  933. }
  934. if ($sku) {
  935. $sku = trim($sku, ' ');
  936. $sku = trim($sku, ' ');
  937. $where .= " and sku like '%$sku%'";
  938. } else if ($title) {
  939. $title = trim($title, ' ');
  940. $title = trim($title, ' ');
  941. $where .= " and title like '%$title%'";
  942. }
  943. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  944. //取得信息列表
  945. $t = array();
  946. $typeclass = $this->typeclass->find_all();
  947. foreach ($typeclass as $v) {
  948. $t[$v['id']] = $v;
  949. }
  950. $rows = array();
  951. $list = array();
  952. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  953. foreach ($info_list as $key => $value) {
  954. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  955. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  956. $warehouse = $this->warehouse->read($value['warehouse']);
  957. $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');
  958. $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'] . '"');
  959. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  960. $number = $value['number'];
  961. $ftime = time() - 15 * 24 * 3600;
  962. $z = count($z); //查看订单号
  963. $info_list[$key]['warehouse'] = $warehouse['title'];
  964. $info_list[$key]['features'] = count($c);
  965. $info_list[$key]['number'] = $z;
  966. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  967. $details = array();
  968. $cpid = array();
  969. foreach ($c as $k => $v) {
  970. $details[$v['details']] = $v['details'];
  971. if ($v['cpid'] != 0) {
  972. $cpid[$v['cpid']] = $v['cpid'];
  973. }
  974. }
  975. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  976. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  977. unset($info_list[$key]['pm']);
  978. unset($info_list[$key]['jm']);
  979. unset($info_list[$key]['bm']);
  980. }
  981. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  982. $pagenum = ceil($total / $perpage);
  983. $over = $total - ($start + $perpage);
  984. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  985. echo json_encode($rows);
  986. exit;
  987. }
  988. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  989. $this->_Template('whlabel_typeck', $this->data);
  990. }
  991. //进销存导出
  992. public function _whlabeckdc()
  993. {
  994. $prc = array();
  995. $purchase = $this->purchase->find_all();
  996. foreach ($purchase as $k => $v) {
  997. $prc[$v['id']] = $v['title'];
  998. }
  999. if (isset($_GET['excel'])) {
  1000. $where = "sku != 'Preset'";
  1001. //数据排序
  1002. $order_str = "id desc";
  1003. if (empty($page)) {
  1004. $start = 0;
  1005. $perpage = 1;
  1006. } else {
  1007. $start = ($page - 1) * $perpage;
  1008. }
  1009. $category = $this->input->get('category', true);
  1010. $color = $this->input->get('color', true);
  1011. $lowe = $this->input->get('lowe', true);
  1012. $lacetype = $this->input->get('lacetype', true);
  1013. $size = $this->input->get('size', true);
  1014. $density = $this->input->get('density', true);
  1015. $haircap = $this->input->get('haircap', true);
  1016. $sku = $this->input->get('sku', true);
  1017. $details = $this->input->get('details', true);
  1018. $warehouse = 13;
  1019. $excelid = $this->input->get('sid', true);
  1020. if ($category) {
  1021. $where .= " and features like '%-$category-%'";
  1022. }
  1023. if ($color) {
  1024. $where .= " and features like '%-$color-%'";
  1025. }
  1026. if ($lowe) {
  1027. $where .= " and features like '%-$lowe-%'";
  1028. }
  1029. if ($lacetype) {
  1030. $where .= " and features like '%-$lacetype-%'";
  1031. }
  1032. if ($size) {
  1033. $where .= " and features like '%-$size-%'";
  1034. }
  1035. if ($density) {
  1036. $where .= " and features like '%-$density-%'";
  1037. }
  1038. if ($haircap) {
  1039. $where .= " and features like '%-$haircap-%'";
  1040. }
  1041. if ($warehouse) {
  1042. $where .= " and warehouse = '$warehouse'";
  1043. }
  1044. if ($sku) {
  1045. $where .= " and sku like '%$sku%'";
  1046. }
  1047. if ($details) {
  1048. $where .= " and details = '$details'";
  1049. }
  1050. $xzid = '';
  1051. if ($excelid) {
  1052. $excelid = explode(',', trim($excelid, ','));
  1053. foreach ($excelid as $key => $value) {
  1054. $xzid .= " id = " . $value . " or";
  1055. }
  1056. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1057. }
  1058. //取得信息列表
  1059. /**
  1060. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1061. $rows = array();$list = array();
  1062. foreach ($info_list as $key=>$value)
  1063. {
  1064. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1065. }
  1066. **/
  1067. $wh = array();
  1068. $w = $this->warehouse->find_all('1=1', 'id,title');
  1069. foreach ($w as $v) {
  1070. $wh[$v['id']] = $v['title'];
  1071. }
  1072. $tc = array();
  1073. $tcdata = array();
  1074. $list = array();
  1075. $classid = $this->classid->sku();
  1076. $tcall = $this->typeclass->find_all();
  1077. $typeclass = array();
  1078. foreach ($tcall as $v)
  1079. {
  1080. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1081. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1082. }
  1083. $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 ");
  1084. foreach ($rows as $key => $value) {
  1085. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1086. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1087. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1088. $rows[$key]['cpbz'] = $u9_info['bm'];
  1089. $rows[$key]['cs'] = $u9_info['jm'];
  1090. if(empty($value['details'])){
  1091. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1092. }else{
  1093. $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');
  1094. }
  1095. $details = array();
  1096. $cpid = array();
  1097. $cpbz = array();
  1098. $c = 0;
  1099. $g = 0;
  1100. $x = 0;
  1101. $t = 0;
  1102. $s = 0;
  1103. $q = 0;
  1104. foreach ($sd as $k => $v) {
  1105. if ($v['state'] == 0) {
  1106. $c++;
  1107. }
  1108. if ($v['state'] != 9) {
  1109. $g++;
  1110. }
  1111. if ($v['state'] == 1) {
  1112. $x++;
  1113. }
  1114. if ($v['state'] == 2) {
  1115. $t++;
  1116. }
  1117. if ($v['state'] == 8) {
  1118. $s++;
  1119. }
  1120. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1121. $q++;
  1122. }
  1123. $details[$v['details']] = $v['details'];
  1124. if ($v['cpid'] != 0) {
  1125. $cpid[$v['cpid']] = $v['cpid'];
  1126. }
  1127. if ($v['cpbz'] != '') {
  1128. $cpbz[$v['cpbz']] = $v['cpbz'];
  1129. }
  1130. }
  1131. $rows[$key]['details'] = implode("、", $details);
  1132. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1133. $number = $value['number'];
  1134. $ftime = time() - 15 * 24 * 3600;
  1135. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1136. $rows[$key]['number'] = $g;
  1137. $rows[$key]['features'] = $c;
  1138. $rows[$key]['x'] = $x;
  1139. $rows[$key]['t'] = $t;
  1140. $rows[$key]['s'] = $s;
  1141. $rows[$key]['q'] = $q;
  1142. $rows[$key]['wzsl'] = count($details);
  1143. //cpbzs
  1144. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1145. $unique_arr = array_unique($tmp_cpbzs);
  1146. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1147. }
  1148. $title = "进销存统计表" . date('Y-m-d', time());
  1149. $titlename = "<table border=1>
  1150. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1151. <tr align='center'>
  1152. <td>仓库</td>
  1153. <td>供应商</td>
  1154. <td>位置</td>
  1155. <td>库存编码</td>
  1156. <td>SKU</td>
  1157. <td>用友编码</td>
  1158. <td>用友料号</td>
  1159. <td>产品英文名</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. </tr>
  1170. </table>";
  1171. $filename = $title . ".xls";
  1172. $tail = "";
  1173. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1174. }
  1175. }
  1176. public function _type()
  1177. {
  1178. $vip = 0;
  1179. if (isset($_SESSION['api'])) {
  1180. $user = $this->user->get_api($_SESSION['api']);
  1181. $fgshop = "";
  1182. $sid = "";
  1183. $usersp = explode('|', trim($user['shop'], '|'));
  1184. foreach ($usersp as $value) {
  1185. $fgshop .= " shop = " . $value . " or";
  1186. $sid .= " id = " . $value . " or";
  1187. }
  1188. if ($user['vip'] == 1) {
  1189. $vip = 1;
  1190. }
  1191. } else {
  1192. header('Location: /');
  1193. exit;
  1194. }
  1195. $prc = array();
  1196. $purchase = $this->purchase->find_all();
  1197. foreach ($purchase as $k => $v) {
  1198. $prc[$v['id']] = $v['title'];
  1199. }
  1200. $company = array();
  1201. $ct = $this->company->find_all();
  1202. foreach ($ct as $k => $v) {
  1203. $company[$v['id']] = $v['title'];
  1204. }
  1205. $sp = array();
  1206. $s = $this->shop->find_all('1=1', 'id,shopname');
  1207. foreach ($s as $v) {
  1208. $sp[$v['id']] = $v['shopname'];
  1209. }
  1210. $wh = array();
  1211. $w = $this->warehouse->find_all('1=1', 'id,title');
  1212. foreach ($w as $v) {
  1213. $wh[$v['id']] = $v['title'];
  1214. }
  1215. $post = $this->input->post(NULL, TRUE);
  1216. if (isset($post['page'])) {
  1217. $page = $this->input->post('page', true);
  1218. $perpage = $this->input->post('perpage', true);
  1219. $category = $this->input->post('category', true);
  1220. $size = $this->input->post('size', true);
  1221. $grade = $this->input->post('grade', true);
  1222. $color = $this->input->post('color', true);
  1223. $lowe = $this->input->post('lowe', true);
  1224. $sku = $this->input->post('sku');
  1225. $title = $this->input->post('title');
  1226. $warehouse = $this->input->post('warehouse', true);
  1227. $usa = $this->input->post('usa', true);
  1228. $purchase = $this->input->post('purchase', true);
  1229. $lacetype = $this->input->post('lacetype', true);
  1230. $haircap = $this->input->post('haircap', true);
  1231. $density = $this->input->post('density', true);
  1232. $details = $this->input->post('details', true);
  1233. $state = $this->input->post('state', true);
  1234. $shop = $this->input->post('shop', true);
  1235. $lacecolor = $this->input->post('lacecolor', true);
  1236. $hairnumber = $this->input->post('hairnumber', true);
  1237. $type = $this->input->post('type', true);
  1238. $ktime = $this->input->post('ktime', true);
  1239. $jtime = $this->input->post('jtime', true);
  1240. $ktime = strtotime($ktime);
  1241. $jtime = strtotime($jtime);
  1242. $cpbz = $this->input->post('cpbz', true);
  1243. $sm = $this->input->post('sm', true);
  1244. $where = "1=1";
  1245. $gj = "";
  1246. $ck = "";
  1247. if ($usa) {
  1248. if (!$warehouse) {
  1249. $where .= " and (warehouse = '5' or warehouse = '8')";
  1250. }
  1251. }
  1252. if ($warehouse) {
  1253. $where .= " and warehouse = '$warehouse'";
  1254. }
  1255. if ($details) {
  1256. $where .= " and details = '$details'";
  1257. }
  1258. if ($purchase) {
  1259. $where .= " and purchase = '$purchase'";
  1260. }
  1261. if ($state) {
  1262. $where .= " and state = '$state'";
  1263. }
  1264. if ($shop) {
  1265. $where .= " and shop like '%$shop%'";
  1266. }
  1267. if ($type) {
  1268. $where .= " and type = '$type'";
  1269. }
  1270. if ($ktime && $jtime) {
  1271. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1272. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1273. }
  1274. if ($cpbz) {
  1275. $where .= " and cpbz like '%$cpbz%' ";
  1276. }
  1277. if ($sm) {
  1278. $where .= " and sm like '%$sm%' ";
  1279. }
  1280. if ($lacecolor) {
  1281. $where .= " and features like '%-$lacecolor-%'";
  1282. }
  1283. if ($lacetype) {
  1284. $where .= " and features like '%-$lacetype-%'";
  1285. }
  1286. if ($category) {
  1287. $where .= " and features like '%-$category-%'";
  1288. }
  1289. if ($size) {
  1290. $where .= " and features like '%-$size-%'";
  1291. }
  1292. if ($grade) {
  1293. $where .= " and features like '%-$grade-%'";
  1294. }
  1295. if ($color) {
  1296. $where .= " and features like '%-$color-%'";
  1297. }
  1298. if ($lowe) {
  1299. $where .= " and features like '%-$lowe-%'";
  1300. }
  1301. if ($haircap) {
  1302. $where .= " and features like '%-$haircap-%'";
  1303. }
  1304. if ($density) {
  1305. $where .= " and features like '%-$density-%'";
  1306. }
  1307. if (!empty($hairnumber)) {
  1308. $where .= " and features like '%-128-%' ";
  1309. if ($hairnumber < 0) {
  1310. $class_list = $this->typeclass->find_all('classid = 43');
  1311. foreach ($class_list as $v) {
  1312. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1313. }
  1314. } else {
  1315. $where .= " and features like '%-$hairnumber-%'";
  1316. }
  1317. }
  1318. //数据排序
  1319. $order_str = "id desc";
  1320. if (empty($page)) {
  1321. $start = 0;
  1322. $perpage = 1;
  1323. } else {
  1324. $start = ($page - 1) * $perpage;
  1325. }
  1326. $fjnr = '';
  1327. if ($sku) {
  1328. $sku = trim($sku, ' ');
  1329. $sku = trim($sku, ' ');
  1330. $fjnr .= " and sku like '%$sku%'";
  1331. }
  1332. if ($title) {
  1333. $title = trim($title, ' ');
  1334. $title = trim($title, ' ');
  1335. $fjnr .= " and title like '%$title%'";
  1336. }
  1337. $wt = array();
  1338. $whlabel_type = $this->whlabel_type->find_all();
  1339. foreach ($whlabel_type as $v) {
  1340. $wt[$v['id']] = $v['title'];
  1341. }
  1342. //$where .= " and time > '$ktime' and time < '$jtime'";
  1343. $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
  1344. //取得信息列表
  1345. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1346. $rows = array();
  1347. $list = array();
  1348. foreach ($info_list as $key => $value) {
  1349. if (isset($wt[$value['type']])) {
  1350. $info_list[$key]['type'] = $wt[$value['type']];
  1351. } else {
  1352. $info_list[$key]['type'] = '未设置';
  1353. }
  1354. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1355. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1356. $ztdata = '';
  1357. if (count($zt) > 0) {
  1358. foreach ($zt as $vv) {
  1359. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1360. }
  1361. }
  1362. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1363. $cdata = array_filter($qbdata, function ($item) {
  1364. return $item['state'] < 1;
  1365. });
  1366. $c = array_sum(array_column($cdata, 'jnum'));
  1367. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1368. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1369. });
  1370. $g = array_sum(array_column($gdata, 'jnum'));
  1371. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1373. });
  1374. $x = array_sum(array_column($xdata, 'jnum'));
  1375. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $t = array_sum(array_column($tdata, 'jnum'));
  1379. // $zdata = array_filter($qbdata, function ($item) {
  1380. // return $item['zd'] != "" && $item['state'] < 1;
  1381. // });
  1382. // $z = array_sum(array_column($zdata, 'jnum'));
  1383. $zdata = array_filter($qbdata, function ($item) {
  1384. return $item['zd'] != "" && $item['state'] < 1;
  1385. });
  1386. $z = array_sum(array_column($zdata, 'jnum'));
  1387. //$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');
  1388. //$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'].'"');
  1389. //$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'].'"');
  1390. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1391. //$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'].'"');
  1392. $details = array();
  1393. $cpid = array();
  1394. $od = array();
  1395. $odid = '';
  1396. $companytitle = '';
  1397. $shop_list = [];
  1398. foreach ($qbdata as $v) {
  1399. if ($v['zd'] != "" && $v['state'] < 1) {
  1400. if (!isset($od[$v['zd']])) {
  1401. $od[$v['zd']] = 1; //所有数据sku
  1402. } else {
  1403. $od[$v['zd']] = $od[$v['zd']] + 1;
  1404. }
  1405. }
  1406. if($v['state'] == 0){
  1407. $details[$v['details']] = $v['details'];
  1408. }
  1409. if ($v['state'] < 1) {
  1410. //$details[$v['details']] = $v['details'];
  1411. if ($v['cpid'] != 0) {
  1412. $cpid[$v['cpid']] = $v['cpid'];
  1413. }
  1414. }
  1415. if($v['state'] == 0){
  1416. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1417. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1418. }
  1419. if ($v['shop'] != '') {
  1420. $shop = explode(',', trim($v['shop'], ','));
  1421. foreach ($shop as $vv) {
  1422. if (!in_array($vv, $shop_list)) {
  1423. $shop_list[] = $vv;
  1424. }
  1425. }
  1426. }
  1427. }
  1428. }
  1429. foreach ($od as $k => $vv) {
  1430. $odid .= $k . '数量' . $vv;
  1431. }
  1432. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1433. $info_list[$key]['label'] = $value['sm'];
  1434. $number = $value['number'];
  1435. $ftime = time() - 15 * 24 * 3600;
  1436. $z = $z . '(' . $odid . ')'; //查看订单号
  1437. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1438. $info_list[$key]['features'] = $c;
  1439. $info_list[$key]['number'] = $ztdata;
  1440. $info_list[$key]['sm'] = $g;
  1441. $info_list[$key]['x'] = $x;
  1442. $info_list[$key]['t'] = $t;
  1443. $info_list[$key]['z'] = $z;
  1444. /**
  1445. foreach ($cdata as $k=>$v)
  1446. {
  1447. $details[$v['details']] = $v['details'];
  1448. if($v['cpid'] != 0)
  1449. {
  1450. $cpid[$v['cpid']] = $v['cpid'];
  1451. }
  1452. }
  1453. **/
  1454. $info_list[$key]['shop'] = '';
  1455. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1456. // if ($value['shop'] != '') {
  1457. // $shop = explode(',', trim($value['shop'], ','));
  1458. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1459. // }
  1460. $shop_list = array_unique($shop_list);
  1461. $shop_str = '';
  1462. foreach ($shop_list as $v) {
  1463. if(isset($sp[$v])){
  1464. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1465. }
  1466. }
  1467. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1468. /**
  1469. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1470. if(isset($companytitle[0]))
  1471. {
  1472. foreach ($companytitle as $k=>$v)
  1473. {
  1474. if($v['companytitle'] != '')
  1475. {
  1476. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1477. }
  1478. }
  1479. }
  1480. **/
  1481. }
  1482. $final_all_list = [];
  1483. foreach ($info_list as $k => $v) {
  1484. $final_all_list[] = [
  1485. 'id' => $v['id'],
  1486. "warehouse" => $v["warehouse"],
  1487. "purchase" => $v["purchase"],
  1488. "sku" => $v["sku"],
  1489. "title" => $v["title"] . "<br/>" . $v["pm"],
  1490. "details" => $v["details"],
  1491. "shop" => $v["shop"],
  1492. "cpbz" => $v["cpbz"],
  1493. 'label' => $v['label'],
  1494. "type" => $v["type"],
  1495. "features" => $v["features"],
  1496. "number" => $v["number"],
  1497. "sm" => $v["sm"],
  1498. "x" => $v["x"],
  1499. "t" => $v["t"],
  1500. "z" => $v["z"]
  1501. ];
  1502. }
  1503. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1504. $pagenum = ceil($total / $perpage);
  1505. $over = $total - ($start + $perpage);
  1506. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1507. echo json_encode($rows);
  1508. exit;
  1509. }
  1510. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1511. $this->data['shop'] = $wlshop;
  1512. $this->data['vip'] = $vip;
  1513. $this->_Template('whlabel_type', $this->data);
  1514. }
  1515. //美仓进销存浏览
  1516. public function _usatype()
  1517. {
  1518. if (isset($_SESSION['api'])) {
  1519. $user = $this->user->get_api($_SESSION['api']);
  1520. $usp = $user;
  1521. $fgshop = "";
  1522. $sid = "";
  1523. $wid = "";
  1524. $wtype = "";
  1525. $userwh = explode('|', trim($user['warehouse'], '|'));
  1526. foreach ($userwh as $value) {
  1527. $wid .= " id = " . $value . " or";
  1528. $wtype .= " type = " . $value . " or";
  1529. }
  1530. }
  1531. $prc = array();
  1532. $purchase = $this->purchase->find_all();
  1533. foreach ($purchase as $k => $v) {
  1534. $prc[$v['id']] = $v['title'];
  1535. }
  1536. $post = $this->input->post(NULL, TRUE);
  1537. if (isset($post['page'])) {
  1538. $page = $this->input->post('page', true);
  1539. $perpage = $this->input->post('perpage', true);
  1540. $category = $this->input->post('category', true);
  1541. $size = $this->input->post('size', true);
  1542. $grade = $this->input->post('grade', true);
  1543. $color = $this->input->post('color', true);
  1544. $lowe = $this->input->post('lowe', true);
  1545. $sku = $this->input->post('sku');
  1546. $title = $this->input->post('title');
  1547. $warehouse = $this->input->post('warehouse', true);
  1548. $usa = $this->input->post('usa', true);
  1549. $purchase = $this->input->post('purchase', true);
  1550. $lacetype = $this->input->post('lacetype', true);
  1551. $haircap = $this->input->post('haircap', true);
  1552. $density = $this->input->post('density', true);
  1553. $details = $this->input->post('details', true);
  1554. $state = $this->input->post('state', true);
  1555. $lacecolor = $this->input->post('lacecolor', true);
  1556. $cklx = $this->input->post('cklx', true);
  1557. $ktime = $this->input->post('ktime', true);
  1558. $jtime = $this->input->post('jtime', true);
  1559. $ktime = strtotime($ktime);
  1560. $jtime = strtotime($jtime);
  1561. $where = "1=1";
  1562. $gj = "";
  1563. $ck = "";
  1564. if ($lacetype) {
  1565. $where .= " and features like '%-$lacetype-%'";
  1566. }
  1567. if ($category) {
  1568. $where .= " and features like '%-$category-%'";
  1569. }
  1570. if ($size) {
  1571. $where .= " and features like '%-$size-%'";
  1572. }
  1573. if ($grade) {
  1574. $where .= " and features like '%-$grade-%'";
  1575. }
  1576. if ($color) {
  1577. $where .= " and features like '%-$color-%'";
  1578. }
  1579. if ($lowe) {
  1580. $where .= " and features like '%-$lowe-%'";
  1581. }
  1582. if ($haircap) {
  1583. $where .= " and features like '%-$haircap-%'";
  1584. }
  1585. if ($density) {
  1586. $where .= " and features like '%-$density-%'";
  1587. }
  1588. if ($lacecolor) {
  1589. $where .= " and features like '%-$lacecolor-%'";
  1590. }
  1591. if ($usa) {
  1592. if (!$warehouse) {
  1593. $where .= " and (warehouse = '5' or warehouse = '8')";
  1594. }
  1595. }
  1596. if ($warehouse) {
  1597. $where .= " and warehouse = '$warehouse'";
  1598. }
  1599. if ($details) {
  1600. $where .= " and details = '$details'";
  1601. }
  1602. if ($purchase) {
  1603. $where .= " and purchase = '$purchase'";
  1604. }
  1605. if ($state) {
  1606. $where .= " and state = '$state'";
  1607. }
  1608. $where_add = '';
  1609. if ($cklx) {
  1610. $shop = $this->shop->read($cklx);
  1611. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1612. }
  1613. if ($ktime && $jtime) {
  1614. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1615. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1616. }
  1617. //数据排序
  1618. $order_str = "id desc";
  1619. if (empty($page)) {
  1620. $start = 0;
  1621. $perpage = 1;
  1622. } else {
  1623. $start = ($page - 1) * $perpage;
  1624. }
  1625. if ($sku) {
  1626. $sku = trim($sku, ' ');
  1627. $sku = trim($sku, ' ');
  1628. $where .= " and sku like '%$sku%'";
  1629. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1630. } else if ($title) {
  1631. $title = trim($title, ' ');
  1632. $title = trim($title, ' ');
  1633. $where .= " and title like '%$title%'";
  1634. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1635. } else {
  1636. //$where .= " and time > '$ktime' and time < '$jtime'";
  1637. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1638. }
  1639. //取得信息列表
  1640. $rows = array();
  1641. $list = array();
  1642. foreach ($info_list as $key => $value) {
  1643. $warehouse = $this->warehouse->read($value['warehouse']);
  1644. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1645. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1646. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1647. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1648. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1649. $od = array();
  1650. $odid = '';
  1651. foreach ($z as $v) {
  1652. if (!isset($od[$v['zd']])) {
  1653. $od[$v['zd']] = 1; //所有数据sku
  1654. } else {
  1655. $od[$v['zd']] = $od[$v['zd']] + 1;
  1656. }
  1657. }
  1658. foreach ($od as $k => $vv) {
  1659. $odid .= $k . '数量' . $vv . ' ';
  1660. }
  1661. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1662. $info_list[$key]['features'] = $c;
  1663. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1664. $ztdata = '';
  1665. if (count($zt) > 0) {
  1666. foreach ($zt as $vv) {
  1667. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1668. }
  1669. }
  1670. $info_list[$key]['warehouse'] = $ztdata;
  1671. $info_list[$key]['g'] = $g;
  1672. $info_list[$key]['x'] = $x;
  1673. $info_list[$key]['t'] = $t;
  1674. $info_list[$key]['z'] = $z;
  1675. }
  1676. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1677. $pagenum = ceil($total / $perpage);
  1678. $over = $total - ($start + $perpage);
  1679. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1680. echo json_encode($rows);
  1681. exit;
  1682. }
  1683. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1684. $this->data['warehouse'] = $warehouse;
  1685. $this->_Template('whlabel_typeusa', $this->data);
  1686. }
  1687. //美仓进销存浏览
  1688. public function _usatypeapp()
  1689. {
  1690. $post = $this->input->post(NULL, TRUE);
  1691. if (isset($post['page'])) {
  1692. $page = $this->input->post('page', true);
  1693. $perpage = $this->input->post('perpage', true);
  1694. $sku = $this->input->post('sku', true);
  1695. $warehouse = 5;
  1696. $title = $this->input->post('title', true);
  1697. $state = $this->input->post('state', true);
  1698. $ktime = $this->input->post('ktime', true);
  1699. $jtime = $this->input->post('jtime', true);
  1700. $ktime = strtotime($ktime);
  1701. $jtime = strtotime($jtime);
  1702. $where = "1=1";
  1703. $gj = "";
  1704. $ck = "";
  1705. if ($title) {
  1706. $st = explode(' ', trim($title, ' '));
  1707. foreach ($st as $v) {
  1708. $where .= " and title like '%$v%'";
  1709. }
  1710. }
  1711. if ($warehouse) {
  1712. $where .= " and warehouse = '$warehouse'";
  1713. }
  1714. if ($state) {
  1715. $where .= " and state = '$state'";
  1716. }
  1717. if ($sku) {
  1718. $where .= " and sku like '%$sku%'";
  1719. }
  1720. if ($ktime && $jtime) {
  1721. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1722. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1723. }
  1724. //数据排序
  1725. $order_str = "id desc";
  1726. if (empty($page)) {
  1727. $start = 0;
  1728. $perpage = 1;
  1729. } else {
  1730. $start = ($page - 1) * $perpage;
  1731. }
  1732. //取得信息列表
  1733. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1734. $rows = array();
  1735. $list = array();
  1736. foreach ($info_list as $key => $value) {
  1737. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1738. }
  1739. $rowsdq = array_slice($rows, $start, $perpage);
  1740. foreach ($rowsdq as $value) {
  1741. $warehouse = $this->warehouse->read($value['warehouse']);
  1742. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1743. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1744. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1745. $od = array();
  1746. $odid = '';
  1747. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1748. }
  1749. $total = count($rows);
  1750. $pagenum = ceil($total / $perpage);
  1751. $over = $total - ($start + $perpage);
  1752. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1753. echo json_encode($rows);
  1754. exit;
  1755. }
  1756. $this->_Template('phone/p_usatypeapp', $this->data);
  1757. }
  1758. //入库操作
  1759. public function _enteradd()
  1760. {
  1761. $dt = 0;
  1762. if (isset($_SESSION['api'])) {
  1763. $user = $this->user->get_api($_SESSION['api']);
  1764. $usp = $user;
  1765. $fgshop = "";
  1766. $sid = "";
  1767. $user = explode('|', trim($user['shop'], '|'));
  1768. foreach ($user as $value) {
  1769. $fgshop .= " shop = " . $value . " or";
  1770. $sid .= " id = " . $value . " or";
  1771. }
  1772. }
  1773. $tc = $this->typeclass->find_all();
  1774. $typeclass = array();
  1775. foreach ($tc as $v) {
  1776. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1777. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1778. }
  1779. $post = $this->input->post(NULL, TRUE);
  1780. if (isset($post['sku'])) {
  1781. $list = array();
  1782. $num = "";
  1783. $title = "";
  1784. $features = "";
  1785. $order = $this->input->post('order', true);
  1786. $shop = $this->input->post('shop', true);
  1787. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1788. $sku = $this->input->post('sku', true);
  1789. $post['sm'] = $this->input->post('sm', true);
  1790. $post['warehouse'] = $this->input->post('warehouse', true);
  1791. $post['purchase'] = $this->input->post('purchase', true);
  1792. $post['retreatwarehouse'] = $post['warehouse'];
  1793. $post['state'] = $this->input->post('state', true);
  1794. $post['rktype'] = $this->input->post('rktype', true);
  1795. $post['text'] = $this->input->post('text', true);
  1796. $category = $this->input->post('category', true);
  1797. $list['category'] = $category;
  1798. $list['hairtype'] = $this->input->post('hairtype', true);
  1799. $list['grade'] = $this->input->post('grade', true);
  1800. $size = $this->input->post('size', true);
  1801. $xzsku = $this->input->post('xzsku', true);
  1802. $list['size'] = rtrim($size, ',');
  1803. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1804. $list['extension'] = $this->input->post('extension', true);
  1805. if ($category == 1297) {
  1806. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1807. }
  1808. if ($category == 1702) {
  1809. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1810. $list['syother'] = $this->input->post('syother', true);
  1811. }
  1812. if ($category == 133) {
  1813. $list['fittype'] = $this->input->post('fittype', true);
  1814. $list['acother'] = $this->input->post('acother', true);
  1815. }
  1816. $list['color'] = $this->input->post('color', true);
  1817. $list['lowe'] = $this->input->post('lowe', true);
  1818. if (!$post['purchase']) {
  1819. $post['purchase'] = 1;
  1820. }
  1821. if ($category == 127) {
  1822. $list['type'] = $this->input->post('type', true);
  1823. $list['headroad'] = $this->input->post('headroad', true);
  1824. $list['density'] = $this->input->post('density', true);
  1825. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1826. $list['lacesize'] = $this->input->post('lacesize', true);
  1827. }
  1828. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1829. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1830. }
  1831. if ($category == 128) {
  1832. $list['lacetype'] = $this->input->post('lacetype', true);
  1833. $list['haircap'] = $this->input->post('haircap', true);
  1834. $list['density'] = $this->input->post('density', true);
  1835. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1836. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1837. $list['wigother'] = $this->input->post('wigother', true);
  1838. $list['wigother1'] = $this->input->post('wigother1', true);
  1839. $list['wigother2'] = $this->input->post('wigother2', true);
  1840. $list['product_related'] = $this->input->post('product_related', true);
  1841. }
  1842. if ($category == 129) {
  1843. $list['wide'] = $this->input->post('wide', true);
  1844. }
  1845. if ($category == 131) {
  1846. $list['gifttype'] = $this->input->post('gifttype', true);
  1847. $list['giftother'] = $this->input->post('giftother', true);
  1848. }
  1849. if ($category == 134) {
  1850. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1851. }
  1852. if ($category == 1297) {
  1853. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1854. $list['sywigother'] = $this->input->post('sywigother', true);
  1855. }
  1856. if ($category == 130 || $category == 133 || $category == 1702) {
  1857. $list['items'] = $this->input->post('items', true);
  1858. $list['weight'] = $this->input->post('weight', true);
  1859. }
  1860. if($category == 130){
  1861. $list['jfother'] = $this->input->post('jfother', true);
  1862. }
  1863. if ($category == 1702) {
  1864. $list['syhairther'] = $this->input->post('syhairther', true);
  1865. }
  1866. $classid = $this->classid->sku();
  1867. $scsku = $classid;
  1868. $pm = $classid;
  1869. foreach ($list as $k => $v) {
  1870. if ($v != 0) {
  1871. $num .= $v;
  1872. $features .= $v . '-';
  1873. $post[$k] = $v;
  1874. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1875. if ($k != 'size') {
  1876. $title .= $typeclass[$v]['title'] . " ";
  1877. }
  1878. if (isset($pm[$typeclass[$v]['classid']])) {
  1879. if ($typeclass[$v]['title'] == '9A') {
  1880. $pm[$typeclass[$v]['classid']] = '9A';
  1881. } else if ($typeclass[$v]['title'] == '10A') {
  1882. $pm[$typeclass[$v]['classid']] = '10A';
  1883. } else {
  1884. $clzh = $typeclass[$v]['zh'];
  1885. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1886. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1887. $clzh = $clzh[0];
  1888. }
  1889. $pm[$typeclass[$v]['classid']] = $clzh;
  1890. }
  1891. }
  1892. }
  1893. }
  1894. $zh = implode(" ", $pm);
  1895. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1896. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1897. if ($list['size']) {
  1898. $typeclass = $this->typeclass->read($list['size']);
  1899. $title .= $typeclass['title'];
  1900. }
  1901. $time = time();
  1902. if ($xzsku) {
  1903. $scsku = implode("-", $scsku);
  1904. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1905. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1906. $post['sku'] = trim($scsku, ' ');
  1907. } else {
  1908. $post['sku'] = $sku;
  1909. }
  1910. //$post['sku'] = trim($sku,' ');
  1911. $post['title'] = rtrim($title, ' ');
  1912. $post['number'] = $num;
  1913. $post['features'] = '-' . $features;
  1914. $post['enter'] = $time;
  1915. $post['time'] = $time; //操作时间
  1916. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1917. if ($yza) {
  1918. if ($post['features'] != $yza[0]['features']) {
  1919. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1920. exit;
  1921. }
  1922. }
  1923. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1924. if ($yzb) {
  1925. if ($post['sku'] != $yzb[0]['sku']) {
  1926. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1927. exit;
  1928. }
  1929. }
  1930. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1931. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1932. exit;
  1933. }
  1934. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1935. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1936. exit;
  1937. }
  1938. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1939. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1940. exit;
  1941. }
  1942. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1943. if (isset($yz[0]['type'])) {
  1944. $post['type'] = $yz[0]['type'];
  1945. }
  1946. if ($post['state'] == 9) //如果选择预设库存
  1947. {
  1948. $this->whlabel->insert($post);
  1949. } else {
  1950. /**
  1951. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1952. if($ljg == 1)
  1953. {
  1954. for($i=0;$i<$order;$i++)
  1955. {
  1956. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1957. $this->whlabel->insert($post);
  1958. }
  1959. }
  1960. **/
  1961. //if($post['warehouse'] == '5')
  1962. //{
  1963. //}
  1964. $yydata = $post;
  1965. $yydata['zh'] = $zh;
  1966. /**
  1967. $wl = $this->apiyy->get_cjlp($yydata);
  1968. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1969. {
  1970. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1971. }
  1972. if($wl['Data'][0]['m_isSucess'] != 1)
  1973. {
  1974. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1975. }
  1976. **/
  1977. for ($i = 0; $i < $order; $i++) {
  1978. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1979. $this->whlabel->insert($post);
  1980. }
  1981. }
  1982. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1983. exit;
  1984. }
  1985. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1986. $this->data['wlshop'] = $wlshop;
  1987. $this->_Template('whlabel_enteradd', $this->data);
  1988. }
  1989. //修改产品
  1990. public function _enteredit($arg_array)
  1991. {
  1992. $dt = 0;
  1993. if (isset($_SESSION['api'])) {
  1994. $user = $this->user->get_api($_SESSION['api']);
  1995. $usp = $user;
  1996. $fgshop = "";
  1997. $sid = "";
  1998. $user = explode('|', trim($user['shop'], '|'));
  1999. foreach ($user as $value) {
  2000. $fgshop .= " shop = " . $value . " or";
  2001. $sid .= " id = " . $value . " or";
  2002. }
  2003. }
  2004. $post = $this->input->post(NULL, TRUE);
  2005. if (isset($post['sku'])) {
  2006. $list = array();
  2007. $num = "";
  2008. $title = "";
  2009. $features = "";
  2010. $id = $this->input->post('id', true);
  2011. $order = $this->input->post('order', true);
  2012. $shop = $this->input->post('shop', true);
  2013. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2014. $post['sku'] = $this->input->post('sku', true);
  2015. $post['sm'] = $this->input->post('sm', true);
  2016. $post['warehouse'] = $this->input->post('warehouse', true);
  2017. $post['purchase'] = $this->input->post('purchase', true);
  2018. $post['retreatwarehouse'] = $post['warehouse'];
  2019. $category = $this->input->post('category', true);
  2020. $list['category'] = $category;
  2021. $list['hairtype'] = $this->input->post('hairtype', true);
  2022. $list['grade'] = $this->input->post('grade', true);
  2023. $size = $this->input->post('size', true);
  2024. $list['size'] = rtrim($size, ',');
  2025. $post['rktype'] = $this->input->post('rktype', true);
  2026. $post['text'] = $this->input->post('text', true);
  2027. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2028. $list['extension'] = $this->input->post('extension', true);
  2029. if ($category == 1297) {
  2030. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2031. }
  2032. if ($category == 1702) {
  2033. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2034. $list['syother'] = $this->input->post('syother', true);
  2035. }
  2036. if ($category == 133) {
  2037. $list['fittype'] = $this->input->post('fittype', true);
  2038. $list['acother'] = $this->input->post('acother', true);
  2039. }
  2040. $list['color'] = $this->input->post('color', true);
  2041. $list['lowe'] = $this->input->post('lowe', true);
  2042. if (!$post['purchase']) {
  2043. $post['purchase'] = 1;
  2044. }
  2045. if ($category == 127) {
  2046. $list['type'] = $this->input->post('type', true);
  2047. $list['headroad'] = $this->input->post('headroad', true);
  2048. $list['density'] = $this->input->post('density', true);
  2049. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2050. $list['lacesize'] = $this->input->post('lacesize', true);
  2051. }
  2052. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2053. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2054. }
  2055. if ($category == 128) {
  2056. $list['lacetype'] = $this->input->post('lacetype', true);
  2057. $list['haircap'] = $this->input->post('haircap', true);
  2058. $list['density'] = $this->input->post('density', true);
  2059. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2060. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2061. $list['wigother'] = $this->input->post('wigother', true);
  2062. $list['wigother1'] = $this->input->post('wigother1', true);
  2063. $list['wigother2'] = $this->input->post('wigother2', true);
  2064. $list['product_related'] = $this->input->post('product_related', true);
  2065. }
  2066. if ($category == 129) {
  2067. $list['wide'] = $this->input->post('wide', true);
  2068. }
  2069. if ($category == 131) {
  2070. $list['gifttype'] = $this->input->post('gifttype', true);
  2071. $list['giftother'] = $this->input->post('giftother', true);
  2072. }
  2073. if ($category == 134) {
  2074. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2075. }
  2076. if ($category == 1297) {
  2077. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2078. $list['sywigother'] = $this->input->post('sywigother', true);
  2079. }
  2080. if ($category == 130 || $category == 133 || $category == 1702) {
  2081. $list['items'] = $this->input->post('items', true);
  2082. $list['weight'] = $this->input->post('weight', true);
  2083. }
  2084. if($category == 130){
  2085. $list['jfother'] = $this->input->post('jfother', true);
  2086. }
  2087. if ($category == 1702) {
  2088. $list['syhairther'] = $this->input->post('syhairther', true);
  2089. }
  2090. foreach ($list as $k => $v) {
  2091. if ($v != 0) {
  2092. $num .= $v;
  2093. $features .= $v . '-';
  2094. $typeclass = $this->typeclass->read($v);
  2095. if ($k != 'size') {
  2096. $title .= $typeclass['title'] . " ";
  2097. }
  2098. }
  2099. }
  2100. $typeclass = $this->typeclass->read($list['size']);
  2101. $title .= $typeclass['title'];
  2102. $time = time();
  2103. $post['title'] = rtrim($title, ' ');
  2104. $post['number'] = $num;
  2105. $post['features'] = '-' . $features;
  2106. $post['time'] = $time; //操作时间
  2107. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2108. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2109. exit;
  2110. }
  2111. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2112. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2113. exit;
  2114. }
  2115. $uid = $this->whlabel->read($id);
  2116. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2117. if ($datanum > 0) {
  2118. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2119. exit;
  2120. }
  2121. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2122. {
  2123. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2124. if ($yza) {
  2125. if ($post['features'] != $yza[0]['features']) {
  2126. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2127. exit;
  2128. }
  2129. }
  2130. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2131. if ($yzb) {
  2132. if ($post['sku'] != $yzb[0]['sku']) {
  2133. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2134. exit;
  2135. }
  2136. }
  2137. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2138. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2139. exit;
  2140. }
  2141. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2142. foreach ($data as $v) {
  2143. $post['id'] = $v['id'];
  2144. $this->whlabel->save($post, $v['id']);
  2145. }
  2146. } else {
  2147. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2148. if ($data > 0) {
  2149. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2150. exit;
  2151. } else {
  2152. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2153. foreach ($data as $v) {
  2154. $post['id'] = $v['id'];
  2155. $this->whlabel->save($post, $v['id']);
  2156. }
  2157. }
  2158. }
  2159. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2160. exit;
  2161. }
  2162. $uid = $this->whlabel->read($arg_array[0]);
  2163. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2164. $this->data['enter'] = $uid;
  2165. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2166. $this->data['wlshop'] = $wlshop;
  2167. $this->_Template('whlabel_enteredit', $this->data);
  2168. }
  2169. //入库浏览
  2170. public function _enter()
  2171. {
  2172. $post = $this->input->post(NULL, TRUE);
  2173. if (isset($post['s'])) {
  2174. $id_arr = $this->input->post('s');
  2175. $id_arr = explode(',', $id_arr);
  2176. if (!$id_arr) {
  2177. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2178. exit;
  2179. }
  2180. //循环删除记录
  2181. foreach ($id_arr as $v) {
  2182. $sid = $this->whlabel->read($v);
  2183. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2184. if ($count > 0) {
  2185. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2186. exit;
  2187. }
  2188. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2189. foreach ($info_list as $va) {
  2190. $this->whlabel->remove($va['id']);
  2191. }
  2192. }
  2193. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2194. exit;
  2195. }
  2196. $sp = array();
  2197. $s = $this->shop->find_all('1=1', 'id,shopname');
  2198. foreach ($s as $v) {
  2199. $sp[$v['id']] = $v['shopname'];
  2200. }
  2201. $wh = array();
  2202. $w = $this->warehouse->find_all('1=1', 'id,title');
  2203. foreach ($w as $v) {
  2204. $wh[$v['id']] = $v['title'];
  2205. }
  2206. if (isset($post['page'])) {
  2207. $page = $this->input->post('page', true);
  2208. $perpage = $this->input->post('perpage', true);
  2209. $category = $this->input->post('category', true);
  2210. $size = $this->input->post('size', true);
  2211. $grade = $this->input->post('grade', true);
  2212. $color = $this->input->post('color', true);
  2213. $lowe = $this->input->post('lowe', true);
  2214. $sku = $this->input->post('sku', true);
  2215. $warehouse = $this->input->post('warehouse', true);
  2216. $purchase = $this->input->post('purchase', true);
  2217. $ktime = $this->input->post('ktime', true);
  2218. $jtime = $this->input->post('jtime', true);
  2219. $ktime = strtotime($ktime);
  2220. $jtime = strtotime($jtime);
  2221. $where = "1=1";
  2222. $gj = "";
  2223. $ck = "";
  2224. if ($category) {
  2225. $where .= " and features like '%-$category-%'";
  2226. }
  2227. if ($size) {
  2228. $where .= " and features like '%-$size-%'";
  2229. }
  2230. if ($grade) {
  2231. $where .= " and features like '%-$grade-%'";
  2232. }
  2233. if ($color) {
  2234. $where .= " and features like '%-$color-%'";
  2235. }
  2236. if ($lowe) {
  2237. $where .= " and features like '%-$lowe-%'";
  2238. }
  2239. if ($warehouse) {
  2240. $where .= " and warehouse = '$warehouse'";
  2241. }
  2242. if ($purchase) {
  2243. $where .= " and purchase = '$purchase'";
  2244. }
  2245. if ($sku) {
  2246. $where .= " and sku like '%$sku%'";
  2247. }
  2248. if ($ktime && $jtime) {
  2249. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2250. }
  2251. //数据排序
  2252. $order_str = "enter desc";
  2253. if (empty($page)) {
  2254. $start = 0;
  2255. $perpage = 1;
  2256. } else {
  2257. $start = ($page - 1) * $perpage;
  2258. }
  2259. //取得信息列表
  2260. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2261. foreach ($info_list as $k => $v) {
  2262. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2263. if ($v['shop'] == '') {
  2264. $s = '通用';
  2265. } else {
  2266. $info_list[$k]['shop'] = '';
  2267. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2268. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2269. }
  2270. }
  2271. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2272. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2273. $info_list[$k]['g'] = $g;
  2274. }
  2275. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2276. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2277. $pagenum = ceil($total / $perpage);
  2278. $over = $total - ($start + $perpage);
  2279. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2280. echo json_encode($rows);
  2281. exit;
  2282. }
  2283. $this->_Template('whlabel_enter', $this->data);
  2284. }
  2285. //出库浏览
  2286. public function _out()
  2287. {
  2288. $post = $this->input->post(NULL, TRUE);
  2289. if (isset($post['page'])) {
  2290. $page = $this->input->post('page', true);
  2291. $perpage = $this->input->post('perpage', true);
  2292. $category = $this->input->post('category', true);
  2293. $size = $this->input->post('size', true);
  2294. $grade = $this->input->post('grade', true);
  2295. $color = $this->input->post('color', true);
  2296. $lowe = $this->input->post('lowe', true);
  2297. $sku = $this->input->post('sku', true);
  2298. $warehouse = $this->input->post('warehouse', true);
  2299. $purchase = $this->input->post('purchase', true);
  2300. $state = $this->input->post('state', true);
  2301. $ktime = $this->input->post('ktime', true);
  2302. $jtime = $this->input->post('jtime', true);
  2303. $ktime = strtotime($ktime);
  2304. $jtime = strtotime($jtime);
  2305. $where = "state=3";
  2306. $gj = "";
  2307. $ck = "";
  2308. if ($category) {
  2309. $where .= " and features like '%-$category-%'";
  2310. }
  2311. if ($size) {
  2312. $where .= " and features like '%-$size-%'";
  2313. }
  2314. if ($grade) {
  2315. $where .= " and features like '%-$grade-%'";
  2316. }
  2317. if ($color) {
  2318. $where .= " and features like '%-$color-%'";
  2319. }
  2320. if ($lowe) {
  2321. $where .= " and features like '%-$lowe-%'";
  2322. }
  2323. if ($state) {
  2324. $where .= " and state = '$state'";
  2325. }
  2326. if ($warehouse) {
  2327. $where .= " and warehouse = '$warehouse'";
  2328. }
  2329. if ($purchase) {
  2330. $where .= " and purchase = '$purchase'";
  2331. }
  2332. if ($sku) {
  2333. $where .= " and sku = '$sku'";
  2334. }
  2335. if ($ktime && $jtime) {
  2336. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2337. }
  2338. //数据排序
  2339. $order_str = "id desc";
  2340. if (empty($page)) {
  2341. $start = 0;
  2342. $perpage = 1;
  2343. } else {
  2344. $start = ($page - 1) * $perpage;
  2345. }
  2346. //取得信息列表
  2347. $info_list = $this->whlabel->find_all($where, 'sku');
  2348. $rows = array();
  2349. $list = array();
  2350. foreach ($info_list as $key => $value) {
  2351. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2352. }
  2353. $rows = array_unique($rows); //删除重复记录
  2354. foreach ($rows as $key => $value) {
  2355. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2356. $ck = $this->warehouse->read($data['warehouse']);
  2357. $warehouse = $ck['title'];
  2358. $gy = $this->purchase->read($data['purchase']);
  2359. $purchase = $gy['purchase'];
  2360. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2361. $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);
  2362. }
  2363. $total = count($list);
  2364. $pagenum = ceil($total / $perpage);
  2365. $over = $total - ($start + $perpage);
  2366. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2367. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2368. echo json_encode($rows);
  2369. exit;
  2370. }
  2371. $this->_Template('whlabel_out', $this->data);
  2372. }
  2373. //出库标签浏览
  2374. public function _label()
  2375. {
  2376. $post = $this->input->post(NULL, TRUE);
  2377. if (isset($post['page'])) {
  2378. $page = $this->input->post('page', true);
  2379. $perpage = $this->input->post('perpage', true);
  2380. $sku = $this->input->post('sku', true);
  2381. $warehouse = $this->input->post('warehouse', true);
  2382. $purchase = $this->input->post('purchase', true);
  2383. $orderinfo = $this->input->post('orderinfo', true);
  2384. $waybill = $this->input->post('waybill', true);
  2385. $category = $this->input->post('category', true);
  2386. $size = $this->input->post('size', true);
  2387. $grade = $this->input->post('grade', true);
  2388. $color = $this->input->post('color', true);
  2389. $lowe = $this->input->post('lowe', true);
  2390. $where = "state=1";
  2391. if ($sku) {
  2392. $where .= " and sku = '$sku'";
  2393. }
  2394. if ($warehouse) {
  2395. $where .= " and warehouse = '$warehouse'";
  2396. }
  2397. if ($purchase) {
  2398. $where .= " and purchase = '$purchase'";
  2399. }
  2400. if ($orderinfo) {
  2401. $where .= " and orderinfo = '$orderinfo'";
  2402. }
  2403. if ($waybill) {
  2404. $where .= " and waybill = '$waybill'";
  2405. }
  2406. if ($category) {
  2407. $where .= " and features like '%-$category-%'";
  2408. }
  2409. if ($size) {
  2410. $where .= " and features like '%-$size-%'";
  2411. }
  2412. if ($grade) {
  2413. $where .= " and features like '%-$grade-%'";
  2414. }
  2415. if ($color) {
  2416. $where .= " and features like '%-$color-%'";
  2417. }
  2418. if ($lowe) {
  2419. $where .= " and features like '%-$lowe-%'";
  2420. }
  2421. //数据排序
  2422. $order_str = "outk desc";
  2423. if (empty($page)) {
  2424. $start = 0;
  2425. $perpage = 1;
  2426. } else {
  2427. $start = ($page - 1) * $perpage;
  2428. }
  2429. //取得信息列表
  2430. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2431. foreach ($info_list as $key => $value) {
  2432. $warehouse = $this->warehouse->read($value['warehouse']);
  2433. $info_list[$key]['warehouse'] = $warehouse['title'];
  2434. $purchase = $this->purchase->read($value['purchase']);
  2435. $info_list[$key]['purchase'] = $purchase['title'];
  2436. if ($value['outk'] != 0) {
  2437. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2438. } else {
  2439. $info_list[$key]['outk'] = "";
  2440. }
  2441. if ($value['orderinfo'] == 0) {
  2442. $info_list[$key]['orderinfo'] = "";
  2443. }
  2444. if ($value['waybill'] == 0) {
  2445. $info_list[$key]['waybill'] = "";
  2446. }
  2447. }
  2448. $total = $this->whlabel->find_count($where);
  2449. $pagenum = ceil($total / $perpage);
  2450. $over = $total - ($start + $perpage);
  2451. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2452. echo json_encode($rows);
  2453. exit;
  2454. }
  2455. $this->_Template('whlabel_label', $this->data);
  2456. }
  2457. //独立站出库订单
  2458. public function _outorder()
  2459. {
  2460. if (isset($_SESSION['api'])) {
  2461. $user = $this->user->get_api($_SESSION['api']);
  2462. $usp = $user;
  2463. $fgshop = "";
  2464. $sid = "";
  2465. $user = explode('|', trim($user['shop'], '|'));
  2466. foreach ($user as $value) {
  2467. $fgshop .= " shop = " . $value . " or";
  2468. $sid .= " id = " . $value . " or";
  2469. }
  2470. } else {
  2471. echo "请重新登录";
  2472. }
  2473. $post = $this->input->post(NULL, TRUE);
  2474. if (isset($post['page'])) {
  2475. $page = $this->input->post('page', true);
  2476. $perpage = $this->input->post('perpage', true);
  2477. $warehouse = $this->input->post('warehouse', true);
  2478. $xztime = $this->input->post('xztime', true);
  2479. $timetk = $this->input->post('timetkk', true);
  2480. $timetj = $this->input->post('timetjj', true);
  2481. $shop = $this->input->post('shop', true);
  2482. $source = $this->input->post('source', true);
  2483. $orderinfo = $this->input->post('orderinfo', true);
  2484. $number = $this->input->post('number', true);
  2485. $sfxh = $this->input->post('sfxh', true);
  2486. $express = $this->input->post('express', true);
  2487. $waybill = $this->input->post('waybill', true);
  2488. $library = $this->input->post('library', true);
  2489. $country = $this->input->post('country', true);
  2490. $so = $this->input->post('so', true);
  2491. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2492. $print = $this->input->post('print', true);
  2493. $state = $this->input->post('state', true);
  2494. $orderurl = $this->input->post('orderurl', true);
  2495. $productid = $this->input->post('productid', true);
  2496. $timetk = strtotime($timetk);
  2497. $timetj = strtotime($timetj);
  2498. /**
  2499. $sj = $this->input->post('sj',true);
  2500. if($sj)
  2501. {
  2502. $sj = $this->input->post('sj',true);
  2503. }
  2504. else
  2505. {
  2506. $sj = "fullorder";
  2507. }
  2508. **/
  2509. $sj = "fullorder";
  2510. $where = "1=1";
  2511. if ($warehouse) {
  2512. $where .= " and type = '$warehouse'";
  2513. }
  2514. if ($timetk && $timetj) {
  2515. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2516. }
  2517. if ($orderinfo) {
  2518. $where .= " and orderinfo = '$orderinfo'";
  2519. }
  2520. if ($number) {
  2521. $where .= " and number = '$number'";
  2522. }
  2523. if ($express) {
  2524. $where .= " and express = '$express'";
  2525. }
  2526. if ($waybill) {
  2527. $where .= " and waybill = '$waybill'";
  2528. }
  2529. if ($library) {
  2530. $where .= " and library = '$library'";
  2531. }
  2532. if ($print) {
  2533. $where .= " and print = '$print'";
  2534. }
  2535. if ($libraryconfirm) {
  2536. $where .= " and libraryconfirm = '$libraryconfirm'";
  2537. }
  2538. if ($state) {
  2539. $where .= " and state = '$state'";
  2540. }
  2541. if ($shop) {
  2542. $where .= " and shop = '$shop'";
  2543. }
  2544. if ($country) {
  2545. $where .= " and country = '$country'";
  2546. }
  2547. if ($sfxh != '') {
  2548. $where .= " and sfxh = '$sfxh'";
  2549. }
  2550. if ($so) {
  2551. $where .= " and shipremarks like '%$so%'";
  2552. }
  2553. if ($source) {
  2554. if ($source == '2d') {
  2555. $where .= " and source >= '2'";
  2556. } else {
  2557. $where .= " and source = '$source'";
  2558. }
  2559. }
  2560. if (isset($_SESSION['api'])) {
  2561. foreach ($user as $value) {
  2562. $fgshop .= " shop = " . $value . " or";
  2563. }
  2564. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2565. }
  2566. if ($orderurl) {
  2567. $url = $this->orderurl->read($orderurl);
  2568. $where .= " and link like '%" . $url['url'] . "%'";
  2569. }
  2570. if($productid){
  2571. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2572. }
  2573. //数据排序
  2574. $order_str = "librarytime desc";
  2575. if (empty($page)) {
  2576. $start = 0;
  2577. $perpage = 1;
  2578. } else {
  2579. $start = ($page - 1) * $perpage;
  2580. }
  2581. //取得信息列表
  2582. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2583. //格式化数据
  2584. foreach ($info_list as $key => $value) {
  2585. $shop = $this->shop->read($value['shop']);
  2586. $info_list[$key]['shop'] = $shop['shopname'];
  2587. $express = $this->express->read($value['express']);
  2588. $info_list[$key]['express'] = $express['servicename'];
  2589. $warehouse = $this->warehouse->read($value['type']);
  2590. $info_list[$key]['type'] = $warehouse['title'];
  2591. if ($value['librarytime'] == '0') {
  2592. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2593. } else {
  2594. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2595. }
  2596. }
  2597. $total = $this->$sj->find_count($where);
  2598. $pagenum = ceil($total / $perpage);
  2599. $over = $total - ($start + $perpage);
  2600. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2601. echo json_encode($rows);
  2602. exit;
  2603. }
  2604. $this->data['express'] = $this->express->find_all();
  2605. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2606. $this->data['wlshop'] = $wlshop;
  2607. $user = $this->user->get_api($_SESSION['api']);
  2608. $powerid = $this->power->read($user['power']);
  2609. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2610. $pid = '';
  2611. foreach ($powertext as $v) {
  2612. $pid .= " id = " . $v . " or";
  2613. }
  2614. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2615. $this->data['fullorderexcel'] = $fullorderexcel;
  2616. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2617. $this->data['orderurl'] = $orderurl;
  2618. $this->_Template('whlabel_outorder', $this->data);
  2619. }
  2620. //tt出库
  2621. public function _toutorder()
  2622. {
  2623. $fgshop = "";
  2624. $sid = "";
  2625. if (isset($_SESSION['api'])) {
  2626. $user = $this->user->get_api($_SESSION['api']);
  2627. $usp = $user;
  2628. $user = explode('|', trim($user['shop'], '|'));
  2629. foreach ($user as $value) {
  2630. $fgshop .= " shop = " . $value . " or";
  2631. $sid .= " id = " . $value . " or";
  2632. }
  2633. } else {
  2634. echo "请重新登录";
  2635. die;
  2636. }
  2637. $post = $this->input->post(NULL, TRUE);
  2638. if (isset($post['page'])) {
  2639. $page = $this->input->post('page', true);
  2640. $perpage = $this->input->post('perpage', true);
  2641. $warehouse = $this->input->post('warehouse', true);
  2642. $xztime = $this->input->post('xztime', true);
  2643. $timetk = $this->input->post('timetkk', true);
  2644. $timetj = $this->input->post('timetjj', true);
  2645. $shop = $this->input->post('shop', true);
  2646. $source = $this->input->post('source', true);
  2647. $orderinfo = $this->input->post('orderinfo', true);
  2648. $number = $this->input->post('number', true);
  2649. $sfxh = $this->input->post('sfxh', true);
  2650. $express = $this->input->post('express', true);
  2651. $waybill = $this->input->post('waybill', true);
  2652. $library = $this->input->post('library', true);
  2653. $country = $this->input->post('country', true);
  2654. $so = $this->input->post('so', true);
  2655. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2656. $print = $this->input->post('print', true);
  2657. $state = $this->input->post('state', true);
  2658. $orderurl = $this->input->post('orderurl', true);
  2659. $timetk = strtotime($timetk);
  2660. $timetj = strtotime($timetj);
  2661. /**
  2662. $sj = $this->input->post('sj',true);
  2663. if($sj)
  2664. {
  2665. $sj = $this->input->post('sj',true);
  2666. }
  2667. else
  2668. {
  2669. $sj = "fullorder";
  2670. }
  2671. **/
  2672. $sj = "fullordertt";
  2673. $where = "1=1";
  2674. if ($warehouse) {
  2675. $where .= " and type = '$warehouse'";
  2676. }
  2677. if ($timetk && $timetj) {
  2678. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2679. }
  2680. if ($orderinfo) {
  2681. $where .= " and orderinfo = '$orderinfo'";
  2682. }
  2683. if ($number) {
  2684. $where .= " and number = '$number'";
  2685. }
  2686. if ($express) {
  2687. $where .= " and express = '$express'";
  2688. }
  2689. if ($waybill) {
  2690. $where .= " and waybill = '$waybill'";
  2691. }
  2692. if ($library) {
  2693. $where .= " and library = '$library'";
  2694. }
  2695. if ($print) {
  2696. $where .= " and print = '$print'";
  2697. }
  2698. if ($libraryconfirm) {
  2699. $where .= " and libraryconfirm = '$libraryconfirm'";
  2700. }
  2701. if ($state) {
  2702. $where .= " and state = '$state'";
  2703. }
  2704. if ($shop) {
  2705. $where .= " and shop = '$shop'";
  2706. }
  2707. if ($country) {
  2708. $where .= " and country = '$country'";
  2709. }
  2710. if ($sfxh != '') {
  2711. $where .= " and sfxh = '$sfxh'";
  2712. }
  2713. if ($so) {
  2714. $where .= " and shipremarks like '%$so%'";
  2715. }
  2716. if ($source) {
  2717. if ($source == '2d') {
  2718. $where .= " and source >= '2'";
  2719. } else {
  2720. $where .= " and source = '$source'";
  2721. }
  2722. }
  2723. if (isset($_SESSION['api'])) {
  2724. foreach ($user as $value) {
  2725. $fgshop .= " shop = " . $value . " or";
  2726. }
  2727. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2728. }
  2729. if ($orderurl) {
  2730. $url = $this->orderurl->read($orderurl);
  2731. $where .= " and link like '%" . $url['url'] . "%'";
  2732. }
  2733. //数据排序
  2734. $order_str = "librarytime desc";
  2735. if (empty($page)) {
  2736. $start = 0;
  2737. $perpage = 1;
  2738. } else {
  2739. $start = ($page - 1) * $perpage;
  2740. }
  2741. //取得信息列表
  2742. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2743. //格式化数据
  2744. foreach ($info_list as $key => $value) {
  2745. $shop = $this->shop->read($value['shop']);
  2746. $info_list[$key]['shop'] = $shop['shopname'];
  2747. $express = $this->express->read($value['express']);
  2748. $info_list[$key]['express'] = $express['servicename'];
  2749. $warehouse = $this->warehouse->read($value['type']);
  2750. $info_list[$key]['type'] = $warehouse['title'];
  2751. if ($value['librarytime'] == '0') {
  2752. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2753. } else {
  2754. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2755. }
  2756. }
  2757. $total = $this->$sj->find_count($where);
  2758. $pagenum = ceil($total / $perpage);
  2759. $over = $total - ($start + $perpage);
  2760. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2761. echo json_encode($rows);
  2762. exit;
  2763. }
  2764. $this->data['express'] = $this->express->find_all();
  2765. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2766. $this->data['wlshop'] = $wlshop;
  2767. $user = $this->user->get_api($_SESSION['api']);
  2768. $powerid = $this->power->read($user['power']);
  2769. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2770. $pid = '';
  2771. foreach ($powertext as $v) {
  2772. $pid .= " id = " . $v . " or";
  2773. }
  2774. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2775. $this->data['fullorderexcel'] = $fullorderexcel;
  2776. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2777. $this->data['orderurl'] = $orderurl;
  2778. $this->_Template('whlabel_toutorder', $this->data);
  2779. }
  2780. //tt出库
  2781. public function _aoutorder()
  2782. {
  2783. if (isset($_SESSION['api'])) {
  2784. $user = $this->user->get_api($_SESSION['api']);
  2785. $usp = $user;
  2786. $fgshop = "";
  2787. $sid = "";
  2788. $user = explode('|', trim($user['shop'], '|'));
  2789. foreach ($user as $value) {
  2790. $fgshop .= " shop = " . $value . " or";
  2791. $sid .= " id = " . $value . " or";
  2792. }
  2793. } else {
  2794. echo "请重新登录";
  2795. }
  2796. $post = $this->input->post(NULL, TRUE);
  2797. if (isset($post['page'])) {
  2798. $page = $this->input->post('page', true);
  2799. $perpage = $this->input->post('perpage', true);
  2800. $warehouse = $this->input->post('warehouse', true);
  2801. $xztime = $this->input->post('xztime', true);
  2802. $timetk = $this->input->post('timetkk', true);
  2803. $timetj = $this->input->post('timetjj', true);
  2804. $shop = $this->input->post('shop', true);
  2805. $source = $this->input->post('source', true);
  2806. $orderinfo = $this->input->post('orderinfo', true);
  2807. $number = $this->input->post('number', true);
  2808. $sfxh = $this->input->post('sfxh', true);
  2809. $express = $this->input->post('express', true);
  2810. $waybill = $this->input->post('waybill', true);
  2811. $library = $this->input->post('library', true);
  2812. $country = $this->input->post('country', true);
  2813. $so = $this->input->post('so', true);
  2814. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2815. $print = $this->input->post('print', true);
  2816. $state = $this->input->post('state', true);
  2817. $orderurl = $this->input->post('orderurl', true);
  2818. $timetk = strtotime($timetk);
  2819. $timetj = strtotime($timetj);
  2820. /**
  2821. $sj = $this->input->post('sj',true);
  2822. if($sj)
  2823. {
  2824. $sj = $this->input->post('sj',true);
  2825. }
  2826. else
  2827. {
  2828. $sj = "fullorder";
  2829. }
  2830. **/
  2831. $sj = "fullorderamz";
  2832. $where = "1=1";
  2833. if ($warehouse) {
  2834. $where .= " and type = '$warehouse'";
  2835. }
  2836. if ($timetk && $timetj) {
  2837. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2838. }
  2839. if ($orderinfo) {
  2840. $where .= " and orderinfo = '$orderinfo'";
  2841. }
  2842. if ($number) {
  2843. $where .= " and number = '$number'";
  2844. }
  2845. if ($express) {
  2846. $where .= " and express = '$express'";
  2847. }
  2848. if ($waybill) {
  2849. $where .= " and waybill = '$waybill'";
  2850. }
  2851. if ($library) {
  2852. $where .= " and library = '$library'";
  2853. }
  2854. if ($print) {
  2855. $where .= " and print = '$print'";
  2856. }
  2857. if ($libraryconfirm) {
  2858. $where .= " and libraryconfirm = '$libraryconfirm'";
  2859. }
  2860. if ($state) {
  2861. $where .= " and state = '$state'";
  2862. }
  2863. if ($shop) {
  2864. $where .= " and shop = '$shop'";
  2865. }
  2866. if ($country) {
  2867. $where .= " and country = '$country'";
  2868. }
  2869. if ($sfxh != '') {
  2870. $where .= " and sfxh = '$sfxh'";
  2871. }
  2872. if ($so) {
  2873. $where .= " and shipremarks like '%$so%'";
  2874. }
  2875. if ($source) {
  2876. if ($source == '2d') {
  2877. $where .= " and source >= '2'";
  2878. } else {
  2879. $where .= " and source = '$source'";
  2880. }
  2881. }
  2882. if (isset($_SESSION['api'])) {
  2883. foreach ($user as $value) {
  2884. $fgshop .= " shop = " . $value . " or";
  2885. }
  2886. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2887. }
  2888. if ($orderurl) {
  2889. $url = $this->orderurl->read($orderurl);
  2890. $where .= " and link like '%" . $url['url'] . "%'";
  2891. }
  2892. //数据排序
  2893. $order_str = "librarytime desc";
  2894. if (empty($page)) {
  2895. $start = 0;
  2896. $perpage = 1;
  2897. } else {
  2898. $start = ($page - 1) * $perpage;
  2899. }
  2900. //取得信息列表
  2901. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2902. //格式化数据
  2903. foreach ($info_list as $key => $value) {
  2904. $shop = $this->shop->read($value['shop']);
  2905. $info_list[$key]['shop'] = $shop['shopname'];
  2906. $express = $this->express->read($value['express']);
  2907. $info_list[$key]['express'] = $express['servicename'];
  2908. $warehouse = $this->warehouse->read($value['type']);
  2909. $info_list[$key]['type'] = $warehouse['title'];
  2910. if ($value['librarytime'] == '0') {
  2911. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2912. } else {
  2913. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2914. }
  2915. }
  2916. $total = $this->$sj->find_count($where);
  2917. $pagenum = ceil($total / $perpage);
  2918. $over = $total - ($start + $perpage);
  2919. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2920. echo json_encode($rows);
  2921. exit;
  2922. }
  2923. $this->data['express'] = $this->express->find_all();
  2924. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2925. $this->data['wlshop'] = $wlshop;
  2926. $user = $this->user->get_api($_SESSION['api']);
  2927. $powerid = $this->power->read($user['power']);
  2928. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2929. $pid = '';
  2930. foreach ($powertext as $v) {
  2931. $pid .= " id = " . $v . " or";
  2932. }
  2933. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2934. $this->data['fullorderexcel'] = $fullorderexcel;
  2935. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2936. $this->data['orderurl'] = $orderurl;
  2937. $this->_Template('whlabel_aoutorder', $this->data);
  2938. }
  2939. //速卖通出库订单
  2940. public function _soutorder()
  2941. {
  2942. if (isset($_SESSION['api'])) {
  2943. $user = $this->user->get_api($_SESSION['api']);
  2944. $usp = $user;
  2945. $fgshop = "";
  2946. $sid = "";
  2947. $user = explode('|', trim($user['shop'], '|'));
  2948. foreach ($user as $value) {
  2949. $sid .= " id = " . $value . " or";
  2950. }
  2951. }
  2952. $post = $this->input->post(NULL, TRUE);
  2953. if (isset($post['page'])) {
  2954. $page = $this->input->post('page', true);
  2955. $perpage = $this->input->post('perpage', true);
  2956. $warehouse = $this->input->post('warehouse', true);
  2957. $xztime = $this->input->post('xztime', true);
  2958. $timetk = $this->input->post('timetkk', true);
  2959. $timetj = $this->input->post('timetjj', true);
  2960. $shop = $this->input->post('shop', true);
  2961. $source = $this->input->post('source', true);
  2962. $orderinfo = $this->input->post('orderinfo', true);
  2963. $number = $this->input->post('number', true);
  2964. $express = $this->input->post('express', true);
  2965. $waybill = $this->input->post('waybill', true);
  2966. $library = $this->input->post('library', true);
  2967. $country = $this->input->post('country', true);
  2968. $sfxh = $this->input->post('sfxh', true);
  2969. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2970. $print = $this->input->post('print', true);
  2971. $state = $this->input->post('state', true);
  2972. $so = $this->input->post('so', true);
  2973. $timetk = strtotime($timetk);
  2974. $timetj = strtotime($timetj);
  2975. /**
  2976. $sj = $this->input->post('sj',true);
  2977. if($sj)
  2978. {
  2979. $sj = $this->input->post('sj',true);
  2980. }
  2981. else
  2982. {
  2983. $sj = "fullorder";
  2984. }
  2985. **/
  2986. $sj = "fullordersmt";
  2987. $where = "1=1";
  2988. if ($warehouse) {
  2989. $where .= " and type = '$warehouse'";
  2990. }
  2991. if ($timetk && $timetj) {
  2992. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2993. }
  2994. if ($orderinfo) {
  2995. $where .= " and orderinfo = '$orderinfo'";
  2996. }
  2997. if ($number) {
  2998. $where .= " and number = '$number'";
  2999. }
  3000. if ($express) {
  3001. $where .= " and express = '$express'";
  3002. }
  3003. if ($waybill) {
  3004. $where .= " and waybill = '$waybill'";
  3005. }
  3006. if ($library) {
  3007. $where .= " and library = '$library'";
  3008. }
  3009. if ($print) {
  3010. $where .= " and print = '$print'";
  3011. }
  3012. if ($libraryconfirm) {
  3013. $where .= " and libraryconfirm = '$libraryconfirm'";
  3014. }
  3015. if ($state) {
  3016. $where .= " and state = '$state'";
  3017. }
  3018. if ($shop) {
  3019. $where .= " and shop = '$shop'";
  3020. }
  3021. if ($sfxh != '') {
  3022. $where .= " and sfxh = '$sfxh'";
  3023. }
  3024. if ($so) {
  3025. $where .= " and shipremarks like '%$so%'";
  3026. }
  3027. if ($source) {
  3028. $where .= " and source = '$source'";
  3029. }
  3030. if ($country) {
  3031. $where .= " and country = '$country'";
  3032. } else {
  3033. if (isset($_SESSION['api'])) {
  3034. foreach ($user as $value) {
  3035. $fgshop .= " shop = " . $value . " or";
  3036. }
  3037. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3038. }
  3039. }
  3040. //数据排序
  3041. $order_str = "librarytime desc";
  3042. if (empty($page)) {
  3043. $start = 0;
  3044. $perpage = 1;
  3045. } else {
  3046. $start = ($page - 1) * $perpage;
  3047. }
  3048. //取得信息列表
  3049. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3050. //格式化数据
  3051. foreach ($info_list as $key => $value) {
  3052. $shop = $this->shop->read($value['shop']);
  3053. $info_list[$key]['shop'] = $shop['shopname'];
  3054. $express = $this->express->read($value['express']);
  3055. $info_list[$key]['express'] = $express['servicename'];
  3056. $warehouse = $this->warehouse->read($value['type']);
  3057. $info_list[$key]['type'] = $warehouse['title'];
  3058. if ($value['librarytime'] == '0') {
  3059. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3060. } else {
  3061. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3062. }
  3063. }
  3064. $total = $this->$sj->find_count($where);
  3065. $pagenum = ceil($total / $perpage);
  3066. $over = $total - ($start + $perpage);
  3067. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3068. echo json_encode($rows);
  3069. exit;
  3070. }
  3071. $this->data['express'] = $this->express->find_all();
  3072. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3073. $this->data['wlshop'] = $wlshop;
  3074. $user = $this->user->get_api($_SESSION['api']);
  3075. $powerid = $this->power->read($user['power']);
  3076. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3077. $pid = '';
  3078. foreach ($powertext as $v) {
  3079. $pid .= " id = " . $v . " or";
  3080. }
  3081. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3082. $this->data['fullorderexcel'] = $fullorderexcel;
  3083. $this->_Template('whlabel_soutorder', $this->data);
  3084. }
  3085. //订单退库
  3086. public function _retreat()
  3087. {
  3088. $post = $this->input->post(NULL, TRUE);
  3089. if (isset($post['page'])) {
  3090. $page = $this->input->post('page', true);
  3091. $perpage = $this->input->post('perpage', true);
  3092. $warehouse = $this->input->post('warehouse', true);
  3093. $timetk = $this->input->post('timetk', true);
  3094. $timetj = $this->input->post('timetj', true);
  3095. $shop = $this->input->post('shop', true);
  3096. $source = $this->input->post('source', true);
  3097. $state = $this->input->post('state', true);
  3098. $review = $this->input->post('review', true);
  3099. $state = $this->input->post('state', true);
  3100. $express = $this->input->post('express', true);
  3101. $orderinfo = $this->input->post('orderinfo', true);
  3102. $user = $this->input->post('user', true);
  3103. $name = $this->input->post('name', true);
  3104. $waybill = $this->input->post('waybill', true);
  3105. $timetk = strtotime($timetk);
  3106. $timetj = strtotime($timetj);
  3107. $where = "(state=206 or state=210) and mergeid = 0";
  3108. if ($warehouse) {
  3109. $where .= " and state = '$warehouse'";
  3110. }
  3111. if ($timetk && $timetj) {
  3112. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3113. }
  3114. if ($shop) {
  3115. $where .= " and shop = '$shop'";
  3116. }
  3117. if ($source) {
  3118. $where .= " and source = '$source'";
  3119. }
  3120. if ($state) {
  3121. $where .= " and state = '$state'";
  3122. }
  3123. if ($review) {
  3124. $where .= " and review = '$review'";
  3125. }
  3126. if ($state) {
  3127. $where .= " and state = '$state'";
  3128. }
  3129. if ($express) {
  3130. $where .= " and express = '$express'";
  3131. }
  3132. if ($orderinfo) {
  3133. $where .= " and orderinfo = '$orderinfo'";
  3134. }
  3135. if ($user) {
  3136. $where .= " and user = '$user'";
  3137. }
  3138. if ($name) {
  3139. $where .= " and name = '$name'";
  3140. }
  3141. if ($waybill) {
  3142. $where .= " and waybill = '$waybill'";
  3143. }
  3144. //数据排序
  3145. $order_str = "id desc";
  3146. if (empty($page)) {
  3147. $start = 0;
  3148. $perpage = 1;
  3149. } else {
  3150. $start = ($page - 1) * $perpage;
  3151. }
  3152. //取得信息列表
  3153. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3154. //格式化数据
  3155. foreach ($info_list as $key => $value) {
  3156. $shop = $this->shop->read($value['shop']);
  3157. $info_list[$key]['shop'] = $shop['shopname'];
  3158. $warehouse = $this->warehouse->read($value['warehouse']);
  3159. $info_list[$key]['warehouse'] = $warehouse['title'];
  3160. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3161. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3162. if ($value['waybill'] == 0) {
  3163. $info_list[$key]['waybill'] = "";
  3164. }
  3165. $express = $this->express->read($value['express']);
  3166. $info_list[$key]['express'] = $express['title'];
  3167. $typeclass = $this->typeclass->read($value['state']);
  3168. $info_list[$key]['state'] = $typeclass['title'];
  3169. }
  3170. $total = $this->fullorder->find_count($where);
  3171. $pagenum = ceil($total / $perpage);
  3172. $over = $total - ($start + $perpage);
  3173. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3174. echo json_encode($rows);
  3175. exit;
  3176. }
  3177. $this->data['express'] = $this->express->find_all();
  3178. $this->_Template('whlabel_retreat', $this->data);
  3179. }
  3180. //退库标签浏览
  3181. public function _retreatlk()
  3182. {
  3183. $post = $this->input->post(NULL, TRUE);
  3184. if (isset($post['page'])) {
  3185. $page = $this->input->post('page', true);
  3186. $perpage = $this->input->post('perpage', true);
  3187. $timetk = $this->input->post('timetk', true);
  3188. $timetj = $this->input->post('timetj', true);
  3189. $sku = $this->input->post('sku', true);
  3190. $warehouse = $this->input->post('warehouse', true);
  3191. $purchase = $this->input->post('purchase', true);
  3192. $orderinfo = $this->input->post('orderinfo', true);
  3193. $waybill = $this->input->post('waybill', true);
  3194. $category = $this->input->post('category', true);
  3195. $size = $this->input->post('size', true);
  3196. $grade = $this->input->post('grade', true);
  3197. $color = $this->input->post('color', true);
  3198. $lowe = $this->input->post('lowe', true);
  3199. $state = $this->input->post('state', true);
  3200. $timetk = strtotime($timetk);
  3201. $timetj = strtotime($timetj);
  3202. $where = "state=2";
  3203. if ($timetk && $timetj) {
  3204. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3205. }
  3206. if ($sku) {
  3207. $where .= " and sku = '$sku'";
  3208. }
  3209. if ($warehouse) {
  3210. $where .= " and warehouse = '$warehouse'";
  3211. }
  3212. if ($purchase) {
  3213. $where .= " and purchase = '$purchase'";
  3214. }
  3215. if ($orderinfo) {
  3216. $where .= " and orderinfo = '$orderinfo'";
  3217. }
  3218. if ($waybill) {
  3219. $where .= " and waybill = '$waybill'";
  3220. }
  3221. if ($category) {
  3222. $where .= " and features like '%-$category-%'";
  3223. }
  3224. if ($size) {
  3225. $where .= " and features like '%-$size-%'";
  3226. }
  3227. if ($grade) {
  3228. $where .= " and features like '%-$grade-%'";
  3229. }
  3230. if ($color) {
  3231. $where .= " and features like '%-$color-%'";
  3232. }
  3233. if ($lowe) {
  3234. $where .= " and features like '%-$lowe-%'";
  3235. }
  3236. //数据排序
  3237. $order_str = "time desc";
  3238. if (empty($page)) {
  3239. $start = 0;
  3240. $perpage = 1;
  3241. } else {
  3242. $start = ($page - 1) * $perpage;
  3243. }
  3244. //取得信息列表
  3245. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3246. foreach ($info_list as $key => $value) {
  3247. $warehouse = $this->warehouse->read($value['warehouse']);
  3248. $info_list[$key]['warehouse'] = $warehouse['title'];
  3249. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3250. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3251. $purchase = $this->purchase->read($value['purchase']);
  3252. $info_list[$key]['purchase'] = $purchase['title'];
  3253. if ($value['outk'] != 0) {
  3254. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3255. } else {
  3256. $info_list[$key]['outk'] = "";
  3257. }
  3258. if ($value['retreat'] != 0) {
  3259. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3260. } else {
  3261. $info_list[$key]['retreat'] = "";
  3262. }
  3263. if ($value['orderinfo'] == 0) {
  3264. $info_list[$key]['orderinfo'] = "";
  3265. }
  3266. if ($value['waybill'] == 0) {
  3267. $info_list[$key]['waybill'] = "";
  3268. }
  3269. }
  3270. $total = $this->whlabel->find_count($where);
  3271. $pagenum = ceil($total / $perpage);
  3272. $over = $total - ($start + $perpage);
  3273. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3274. echo json_encode($rows);
  3275. exit;
  3276. }
  3277. $this->_Template('whlabel_retreatlk', $this->data);
  3278. }
  3279. //更换标签及浏览
  3280. public function _change()
  3281. {
  3282. $post = $this->input->post(NULL, TRUE);
  3283. if (isset($post['page'])) {
  3284. $page = $this->input->post('page', true);
  3285. $perpage = $this->input->post('perpage', true);
  3286. $timetk = $this->input->post('timetk', true);
  3287. $timetj = $this->input->post('timetj', true);
  3288. $label = $this->input->post('label', true);
  3289. $oldlabel = $this->input->post('oldlabel', true);
  3290. $timetk = strtotime($timetk);
  3291. $timetj = strtotime($timetj);
  3292. $where = "state=10 ";
  3293. if ($timetk && $timetj) {
  3294. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3295. }
  3296. if ($label) {
  3297. $where .= " and label = '$label'";
  3298. }
  3299. if ($oldlabel) {
  3300. $where .= " and oldlabel = '$oldlabel'";
  3301. }
  3302. //数据排序
  3303. $order_str = "time asc";
  3304. if (empty($page)) {
  3305. $start = 0;
  3306. $perpage = 1;
  3307. } else {
  3308. $start = ($page - 1) * $perpage;
  3309. }
  3310. //取得信息列表
  3311. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3312. foreach ($info_list as $key => $value) {
  3313. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3314. }
  3315. $total = $this->whlabel->find_count($where);
  3316. $pagenum = ceil($total / $perpage);
  3317. $over = $total - ($start + $perpage);
  3318. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3319. echo json_encode($rows);
  3320. exit;
  3321. }
  3322. $this->_Template('whlabel_change', $this->data);
  3323. }
  3324. //产品标签
  3325. public function _cpbqdc()
  3326. {
  3327. if (isset($_GET['excel'])) {
  3328. $where = "1=1";
  3329. //数据排序
  3330. $order_str = "id desc";
  3331. if (empty($page)) {
  3332. $start = 0;
  3333. $perpage = 1;
  3334. } else {
  3335. $start = ($page - 1) * $perpage;
  3336. }
  3337. $warehouse = $this->input->get('warehouse', true);
  3338. $state = $this->input->get('state', true);
  3339. $timetk = $this->input->get('timetkk', true);
  3340. $timetj = $this->input->get('timetjj', true);
  3341. $timetk = strtotime($timetk);
  3342. $timetj = strtotime($timetj);
  3343. if ($warehouse) {
  3344. $where .= " and warehouse = '$warehouse'";
  3345. }
  3346. if ($state || $state == 0) {
  3347. $where .= " and state = '$state'";
  3348. }
  3349. if ($timetk && $timetj) {
  3350. $where .= " and time > '$timetk' and time < '$timetj'";
  3351. }
  3352. //取得信息列表
  3353. $info_list = $this->whlabel->find_all($where, '*');
  3354. $rows = array();
  3355. $list = array();
  3356. foreach ($info_list as $key => $value) {
  3357. $rows[$value['time']] = $value; //所有数据sku
  3358. }
  3359. foreach ($rows as $value) {
  3360. $warehouse = $this->warehouse->read($value['warehouse']);
  3361. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3362. $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);
  3363. }
  3364. $title = "产品标签统计表";
  3365. $titlename = "<table border=1>
  3366. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3367. <tr align='center'>
  3368. <td>仓库</td>
  3369. <td>SKU</td>
  3370. <td>产品</td>
  3371. <td>入库时间</td>
  3372. <td>操作时间</td>
  3373. <td>备注</td>
  3374. <td>数量</td>
  3375. </tr>
  3376. </table>";
  3377. $filename = $title . ".xls";
  3378. $tail = "";
  3379. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3380. }
  3381. }
  3382. //进销存导出
  3383. public function _exceljxc()
  3384. {
  3385. $classid = $this->classid->sku();
  3386. $pm = $classid;
  3387. $typeclass = array();
  3388. $tc = $this->typeclass->find_all();
  3389. foreach ($tc as $v) {
  3390. $typeclass[$v['id']] = $v;
  3391. }
  3392. $prc = array();
  3393. $purchase = $this->purchase->find_all();
  3394. foreach ($purchase as $k => $v) {
  3395. $prc[$v['id']] = $v['title'];
  3396. }
  3397. if (isset($_GET['excel'])) {
  3398. $where = "sku != 'Preset'";
  3399. //数据排序
  3400. $order_str = "id desc";
  3401. if (empty($page)) {
  3402. $start = 0;
  3403. $perpage = 1;
  3404. } else {
  3405. $start = ($page - 1) * $perpage;
  3406. }
  3407. $category = $this->input->get('category', true);
  3408. $warehouse = $this->input->get('warehouse', true);
  3409. $excelid = $this->input->get('sid', true);
  3410. if ($category) {
  3411. $where .= " and features like '%-$category-%'";
  3412. }
  3413. if ($warehouse) {
  3414. $where .= " and warehouse = '$warehouse'";
  3415. }
  3416. $xzid = '';
  3417. if ($excelid) {
  3418. $excelid = explode(',', trim($excelid, ','));
  3419. foreach ($excelid as $key => $value) {
  3420. $xzid .= " id = " . $value . " or";
  3421. }
  3422. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3423. }
  3424. //取得信息列表
  3425. /**
  3426. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3427. $rows = array();$list = array();
  3428. foreach ($info_list as $key=>$value)
  3429. {
  3430. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3431. }
  3432. **/
  3433. $wt = array();
  3434. $whlabel_type = $this->whlabel_type->find_all();
  3435. foreach ($whlabel_type as $v) {
  3436. $wt[$v['id']] = $v['title'];
  3437. }
  3438. $wh = array();
  3439. $w = $this->warehouse->find_all('1=1', 'id,title');
  3440. foreach ($w as $v) {
  3441. $wh[$v['id']] = $v['title'];
  3442. }
  3443. $list = array();
  3444. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3445. foreach ($rows as $key => $value) {
  3446. if (isset($wt[$value['type']])) {
  3447. $rows[$key]['type'] = $wt[$value['type']];
  3448. } else {
  3449. $rows[$key]['type'] = '未设置';
  3450. }
  3451. $bm = '03';
  3452. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3453. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3454. $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');
  3455. $details = array();
  3456. $cpid = array();
  3457. $cpbz = array();
  3458. $c = 0;
  3459. $g = 0;
  3460. $x = 0;
  3461. $t = 0;
  3462. $s = 0;
  3463. $q = 0;
  3464. foreach ($sd as $k => $v) {
  3465. if ($v['state'] == 0) {
  3466. $c++;
  3467. if ($v['cpid'] != 0) {
  3468. $cpid[$v['cpid']] = $v['cpid'];
  3469. }
  3470. if ($v['cpbz'] != '') {
  3471. $cpbz[$v['cpbz']] = $v['cpbz'];
  3472. }
  3473. }
  3474. if ($v['state'] != 9) {
  3475. $g++;
  3476. }
  3477. if ($v['state'] == 1) {
  3478. $x++;
  3479. }
  3480. if ($v['state'] == 2) {
  3481. $t++;
  3482. }
  3483. if ($v['state'] == 8) {
  3484. $s++;
  3485. }
  3486. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3487. $q++;
  3488. }
  3489. $details[$v['details']] = $v['details'];
  3490. }
  3491. $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'] . '"');
  3492. $rows[$key]['details'] = implode("、", $details);
  3493. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3494. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3495. $number = $value['number'];
  3496. $ftime = time() - 15 * 24 * 3600;
  3497. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3498. $rows[$key]['number'] = $g;
  3499. $rows[$key]['c'] = $c;
  3500. $rows[$key]['x'] = $x;
  3501. $rows[$key]['t'] = $t;
  3502. $rows[$key]['s'] = $s;
  3503. $rows[$key]['q'] = $q;
  3504. $rows[$key]['z'] = $z;
  3505. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3506. $features = explode('-', trim($features, '-'));
  3507. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3508. // $pm = $classid;
  3509. // $jm = $classid;
  3510. // foreach($features as $k=>$v)
  3511. // {
  3512. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3513. // {
  3514. // if($typeclass[$v]['bm'] != '')
  3515. // {
  3516. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3517. // }
  3518. // }
  3519. // if($v != 0)
  3520. // {
  3521. // if(!isset($typeclass[$v]))
  3522. // {
  3523. // continue;
  3524. // }
  3525. // if(isset($pm[$typeclass[$v]['classid']]))
  3526. // {
  3527. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3528. // {
  3529. // $tz = explode('|',$typeclass[$v]['zh']);
  3530. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3531. // }
  3532. // else
  3533. // {
  3534. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3535. // }
  3536. // }
  3537. // if(isset($jm[$typeclass[$v]['classid']]))
  3538. // {
  3539. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3540. // }
  3541. // }
  3542. // }
  3543. // $jm = array_filter($jm);
  3544. // $rows[$key]['bs'] = implode("-",$jm);
  3545. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3546. // $zh = implode(" ",$pm);
  3547. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3548. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3549. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3550. // $rows[$key]['features'] = $zh;
  3551. }
  3552. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3553. $final_list = [];
  3554. foreach ($list as $k => $v) {
  3555. if (empty($v['sku'])) {
  3556. continue;
  3557. }
  3558. $final_list[] = [
  3559. "warehouse" => $v["warehouse"],
  3560. "purchase" => $v["purchase"],
  3561. "details" => $v["details"],
  3562. "cpid" => $v["cpid"],
  3563. "dbcontent" => $v["dbcontent"],
  3564. "sku" => $v["sku"],
  3565. "cs" => $v["bm"],
  3566. "bs" => $v["jm"],
  3567. "title" => $v["title"],
  3568. "features" => $v["pm"],
  3569. "cpbz" => $v["cpbz"],
  3570. "sm" => $v["sm"],
  3571. "type" => $v["type"],
  3572. "number" => $v["number"],
  3573. "c" => $v["c"],
  3574. "x" => $v["x"],
  3575. "t" => $v["t"],
  3576. "s" => $v["s"],
  3577. "q" => $v["q"],
  3578. "z" => $v["z"],
  3579. "weight" => $v['weight'],
  3580. ];
  3581. }
  3582. $title = "总进销存统计表";
  3583. $titlename = "<table border=1>
  3584. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3585. <tr align='center'>
  3586. <td>仓库</td>
  3587. <td>供应商</td>
  3588. <td>位置</td>
  3589. <td>库存编码</td>
  3590. <td>类目</td>
  3591. <td>SKU</td>
  3592. <td>用友编码</td>
  3593. <td>用友料号</td>
  3594. <td>商品名称</td>
  3595. <td>商品中文</td>
  3596. <td>产品备注</td>
  3597. <td>库位负责人</td>
  3598. <td>类型</td>
  3599. <td>入库总量</td>
  3600. <td>库存数量</td>
  3601. <td>销售数量</td>
  3602. <td>退货数量</td>
  3603. <td>删除数量</td>
  3604. <td>其它操作</td>
  3605. <td>占单数量</td>
  3606. <td>重量(g)</td>
  3607. </tr>
  3608. </table>";
  3609. $filename = $title . ".xls";
  3610. $tail = "";
  3611. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3612. }
  3613. }
  3614. //入库导出
  3615. public function _excelr()
  3616. {
  3617. if (isset($_GET['excel'])) {
  3618. $category = $this->input->get('category', true);
  3619. $size = $this->input->get('size', true);
  3620. $grade = $this->input->get('grade', true);
  3621. $color = $this->input->get('color', true);
  3622. $lowe = $this->input->get('lowe', true);
  3623. $sku = $this->input->get('sku', true);
  3624. $warehouse = $this->input->get('warehouse', true);
  3625. $purchase = $this->input->get('purchase', true);
  3626. $ktime = $this->input->get('ktime', true);
  3627. $jtime = $this->input->get('jtime', true);
  3628. $ktime = strtotime($ktime);
  3629. $jtime = strtotime($jtime);
  3630. $where = "1=1";
  3631. $gj = "";
  3632. $ck = "";
  3633. if ($category) {
  3634. $where .= " and features like '%-$category-%'";
  3635. }
  3636. if ($size) {
  3637. $where .= " and features like '%-$size-%'";
  3638. }
  3639. if ($grade) {
  3640. $where .= " and features like '%-$grade-%'";
  3641. }
  3642. if ($color) {
  3643. $where .= " and features like '%-$color-%'";
  3644. }
  3645. if ($lowe) {
  3646. $where .= " and features like '%-$lowe-%'";
  3647. }
  3648. if ($warehouse) {
  3649. $where .= " and warehouse = '$warehouse'";
  3650. }
  3651. if ($purchase) {
  3652. $where .= " and purchase = '$purchase'";
  3653. }
  3654. if ($sku) {
  3655. $where .= " and sku = '$sku'";
  3656. }
  3657. if ($ktime && $jtime) {
  3658. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3659. }
  3660. //数据排序
  3661. $order_str = "id desc";
  3662. if (empty($page)) {
  3663. $start = 0;
  3664. $perpage = 1;
  3665. } else {
  3666. $start = ($page - 1) * $perpage;
  3667. }
  3668. $list = array();
  3669. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3670. foreach ($rows as $value) {
  3671. $ck = $this->warehouse->read($value['warehouse']);
  3672. $warehouse = $ck['title'];
  3673. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3674. $retreatwarehouse = $tkck['title'];
  3675. $gy = $this->purchase->read($value['purchase']);
  3676. $purchase = $gy['title'];
  3677. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3678. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3679. }
  3680. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3681. $titlename = "<table border=1>
  3682. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3683. <tr align='center'>
  3684. <td>仓库</td>
  3685. <td>SKU</td>
  3686. <td>产品</td>
  3687. <td>时间</td>
  3688. <td>数量</td>
  3689. </tr>
  3690. </table>";
  3691. $filename = $title . ".xls";
  3692. $tail = "";
  3693. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3694. }
  3695. }
  3696. //出库、退库导出
  3697. public function _excelct()
  3698. {
  3699. $classid = $this->classid->sku();
  3700. $pm = $classid;
  3701. $typeclass = array();
  3702. $tc = $this->typeclass->find_all();
  3703. foreach ($tc as $v) {
  3704. $typeclass[$v['id']] = $v;
  3705. }
  3706. $prc = array();
  3707. $purchase = $this->purchase->find_all();
  3708. foreach ($purchase as $k => $v) {
  3709. $prc[$v['id']] = $v['title'];
  3710. }
  3711. if (isset($_GET['excel'])) {
  3712. $wh = array();
  3713. $w = $this->warehouse->find_all('1=1', 'id,title');
  3714. foreach ($w as $v) {
  3715. $wh[$v['id']] = $v['title'];
  3716. }
  3717. $type = $this->input->get('excel', true);
  3718. $category = $this->input->get('category', true);
  3719. $size = $this->input->get('size', true);
  3720. $grade = $this->input->get('grade', true);
  3721. $color = $this->input->get('color', true);
  3722. $lowe = $this->input->get('lowe', true);
  3723. $sku = $this->input->get('sku', true);
  3724. $title = $this->input->get('title', true);
  3725. $warehouse = $this->input->get('warehouse', true);
  3726. $purchase = $this->input->get('purchase', true);
  3727. $lacetype = $this->input->get('lacetype', true);
  3728. $haircap = $this->input->get('haircap', true);
  3729. $lacecolor = $this->input->get('lacecolor', true);
  3730. $density = $this->input->get('density', true);
  3731. $details = $this->input->get('details', true);
  3732. $state = $this->input->get('state', true);
  3733. $shop = $this->input->get('shop', true);
  3734. $hairnumber = $this->input->get('hairnumber', true);
  3735. $type_leixi = $this->input->get('type', true);
  3736. $cpbz = $this->input->get('cpbz', true);
  3737. $sm = $this->input->get('sm', true);
  3738. $sid = $this->input->get('sid', true);
  3739. $ktime = $this->input->get('ktime', true);
  3740. $jtime = $this->input->get('jtime', true);
  3741. $ktime = strtotime($ktime);
  3742. $jtime = strtotime($jtime);
  3743. //$where = " 1=1 ";
  3744. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3745. $where = " sku != '' ";
  3746. $gj = "";
  3747. $ck = "";
  3748. if ($category) {
  3749. $where .= " and features like '%-$category-%'";
  3750. }
  3751. if ($size) {
  3752. $where .= " and features like '%-$size-%'";
  3753. }
  3754. if ($grade) {
  3755. $where .= " and features like '%-$grade-%'";
  3756. }
  3757. if ($color) {
  3758. $where .= " and features like '%-$color-%'";
  3759. }
  3760. if ($lowe) {
  3761. $where .= " and features like '%-$lowe-%'";
  3762. }
  3763. if ($warehouse) {
  3764. $where .= " and warehouse = '$warehouse'";
  3765. }
  3766. if ($purchase) {
  3767. $where .= " and purchase = '$purchase'";
  3768. }
  3769. if ($state) {
  3770. $where .= " and state = '$state'";
  3771. }
  3772. if ($lacetype) {
  3773. $where .= " and features like '%-$lacetype-%'";
  3774. }
  3775. if ($lacecolor) {
  3776. $where .= " and features like '%-$lacecolor-%'";
  3777. }
  3778. if ($density) {
  3779. $where .= " and features like '%-$density-%'";
  3780. }
  3781. if ($haircap) {
  3782. $where .= " and features like '%-$haircap-%'";
  3783. }
  3784. if ($details) {
  3785. $where .= " and details = '$details'";
  3786. }
  3787. if ($shop) {
  3788. $where .= " and shop like '%$shop%'";
  3789. }
  3790. if ($title) {
  3791. $title = trim($title, ' ');
  3792. $title = trim($title, ' ');
  3793. $where .= " and title like '%$title%'";
  3794. }
  3795. if (!empty($hairnumber)) {
  3796. $where .= " and features like '%-128-%' ";
  3797. if ($hairnumber < 0) {
  3798. $class_list = $this->typeclass->find_all('classid = 43');
  3799. foreach ($class_list as $v) {
  3800. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3801. }
  3802. } else {
  3803. $where .= " and features like '%-$hairnumber-%'";
  3804. }
  3805. }
  3806. if ($type_leixi) {
  3807. $where .= " and type = '$type_leixi'";
  3808. }
  3809. if ($cpbz) {
  3810. $where .= " and cpbz like '%$cpbz%' ";
  3811. }
  3812. if ($sm) {
  3813. $where .= " and sm like '%$sm%' ";
  3814. }
  3815. if ($sku) {
  3816. $sku = trim($sku, ' ');
  3817. $sku = trim($sku, ' ');
  3818. $where .= " and sku like '%$sku%'";
  3819. }
  3820. if ($ktime && $jtime) {
  3821. if ($type == 1) {
  3822. $tl = '出库';
  3823. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3824. } else if ($type == 2) {
  3825. $tl = '退库';
  3826. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3827. } else if ($type == 3) {
  3828. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3829. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3830. } else if ($type == 4) {
  3831. $tl = '出库+零售';
  3832. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3833. } else if ($type == 5) {
  3834. $tl = '零售';
  3835. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3836. }
  3837. }
  3838. $sidwhere = '';
  3839. if ($sid) {
  3840. $sd = "";
  3841. $s = explode(',', trim($sid, ','));
  3842. foreach ($s as $value) {
  3843. $sd .= " id = " . $value . " or";
  3844. }
  3845. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3846. }
  3847. //数据排序
  3848. $order_str = "time desc";
  3849. if (empty($page)) {
  3850. $start = 0;
  3851. $perpage = 1;
  3852. } else {
  3853. $start = ($page - 1) * $perpage;
  3854. }
  3855. //取得信息列表
  3856. if ($type != 3 && $type != 5) {
  3857. if ($type == 1 || $type == 4) {
  3858. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3859. foreach ($info_list as $key => $value) {
  3860. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3861. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3862. $warehouse = $this->warehouse->read($value['warehouse']);
  3863. $info_list[$key]['warehouse'] = $warehouse['title'];
  3864. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3865. $features = explode('-', trim($features, '-'));
  3866. $pm = $classid;
  3867. foreach ($features as $k => $v) {
  3868. if ($v != 0) {
  3869. if (!isset($typeclass[$v])) {
  3870. continue;
  3871. }
  3872. if (isset($pm[$typeclass[$v]['classid']])) {
  3873. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3874. $tz = explode('|', $typeclass[$v]['zh']);
  3875. $pm[$typeclass[$v]['classid']] = $tz[0];
  3876. } else {
  3877. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3878. }
  3879. }
  3880. }
  3881. }
  3882. $zh = implode(" ", $pm);
  3883. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3884. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3885. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3886. $info_list[$key]['features'] = $zh;
  3887. }
  3888. $final_list = [];
  3889. foreach($info_list as $k=>$v){
  3890. $number = "";
  3891. if(!empty($v['orderinfo'])){
  3892. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3893. if(!empty($tmp_info['number'])){
  3894. $number = $tmp_info['number'];
  3895. }
  3896. }
  3897. $final_list[] = [
  3898. 'warehouse'=>$v['warehouse'],
  3899. 'purchase'=>$v['purchase'],
  3900. 'sku'=>$v['sku'],
  3901. 'title'=>$v['title'],
  3902. 'features'=>$v['features'],
  3903. 'label'=>$v['label'],
  3904. 'orderinfo'=>$v['orderinfo'],
  3905. 'number'=>$number,
  3906. 'waybill'=>$v['waybill'],
  3907. 'outk'=>$v['outk'],
  3908. ];
  3909. }
  3910. } else {
  3911. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3912. foreach ($info_list as $key => $value) {
  3913. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3914. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3915. $warehouse = $this->warehouse->read($value['warehouse']);
  3916. $info_list[$key]['warehouse'] = $warehouse['title'];
  3917. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3918. $features = explode('-', trim($features, '-'));
  3919. $pm = $classid;
  3920. foreach ($features as $k => $v) {
  3921. if ($v != 0) {
  3922. if (!isset($typeclass[$v])) {
  3923. continue;
  3924. }
  3925. if (isset($pm[$typeclass[$v]['classid']])) {
  3926. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3927. $tz = explode('|', $typeclass[$v]['zh']);
  3928. $pm[$typeclass[$v]['classid']] = $tz[0];
  3929. } else {
  3930. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3931. }
  3932. }
  3933. }
  3934. }
  3935. $zh = implode(" ", $pm);
  3936. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3937. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3938. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3939. $info_list[$key]['features'] = $zh;
  3940. }
  3941. $final_list = [];
  3942. foreach($info_list as $k=>$v){
  3943. $number = "";
  3944. if(!empty($v['orderinfo'])){
  3945. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3946. if(!empty($tmp_info['number'])){
  3947. $number = $tmp_info['number'];
  3948. }
  3949. }
  3950. $final_list[] = [
  3951. 'warehouse'=>$v['warehouse'],
  3952. 'purchase'=>$v['purchase'],
  3953. 'sku'=>$v['sku'],
  3954. 'title'=>$v['title'],
  3955. 'features'=>$v['features'],
  3956. 'label'=>$v['label'],
  3957. 'orderinfo'=>$v['orderinfo'],
  3958. 'number'=>$number,
  3959. 'waybill'=>$v['waybill'],
  3960. 'retreat'=>$v['retreat'],
  3961. ];
  3962. }
  3963. }
  3964. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3965. $titlename = "<table border=1>
  3966. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3967. <tr align='center'>
  3968. <td>仓库</td>
  3969. <td>供应商</td>
  3970. <td>SKU</td>
  3971. <td>商品名称</td>
  3972. <td>商品中文</td>
  3973. <td>标签</td>
  3974. <td>订单号</td>
  3975. <td>订单编码</td>
  3976. <td>运单号</td>
  3977. <td>" . $tl . "时间(中国时间)</td>
  3978. </tr>
  3979. </table>";
  3980. $filename = $title . ".xls";
  3981. $tail = "";
  3982. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3983. } else if ($type == 5) {
  3984. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3985. foreach ($info_list as $key => $value) {
  3986. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3987. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3988. $warehouse = $this->warehouse->read($value['warehouse']);
  3989. $info_list[$key]['warehouse'] = $warehouse['title'];
  3990. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3991. $features = explode('-', trim($features, '-'));
  3992. $pm = $classid;
  3993. foreach ($features as $k => $v) {
  3994. if ($v != 0) {
  3995. if (!isset($typeclass[$v])) {
  3996. continue;
  3997. }
  3998. if (isset($pm[$typeclass[$v]['classid']])) {
  3999. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4000. $tz = explode('|', $typeclass[$v]['zh']);
  4001. $pm[$typeclass[$v]['classid']] = $tz[0];
  4002. } else {
  4003. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4004. }
  4005. }
  4006. }
  4007. }
  4008. $zh = implode(" ", $pm);
  4009. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4010. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4011. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4012. $info_list[$key]['features'] = $zh;
  4013. }
  4014. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4015. $titlename = "<table border=1>
  4016. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4017. <tr align='center'>
  4018. <td>仓库</td>
  4019. <td>供应商</td>
  4020. <td>SKU</td>
  4021. <td>商品名称</td>
  4022. <td>商品中文</td>
  4023. <td>标签</td>
  4024. <td>" . $tl . "时间(中国时间)</td>
  4025. </tr>
  4026. </table>";
  4027. $filename = $title . ".xls";
  4028. $tail = "";
  4029. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4030. } else {
  4031. /**
  4032. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4033. $rows = array();$list = array();
  4034. foreach ($info_list as $key=>$value)
  4035. {
  4036. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4037. }
  4038. **/
  4039. $wh = array();
  4040. $w = $this->warehouse->find_all('1=1', 'id,title');
  4041. foreach ($w as $v) {
  4042. $wh[$v['id']] = $v['title'];
  4043. }
  4044. $wt = array();
  4045. $whlabel_type = $this->whlabel_type->find_all();
  4046. foreach ($whlabel_type as $v) {
  4047. $wt[$v['id']] = $v['title'];
  4048. }
  4049. $classid = $this->classid->sku();
  4050. $list = array();
  4051. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4052. foreach ($rows as $key => $value) {
  4053. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4054. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4055. $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');
  4056. $details = array();
  4057. $cpid = array();
  4058. $cpbz = array();
  4059. $c = 0;
  4060. $g = 0;
  4061. $x = 0;
  4062. $t = 0;
  4063. $s = 0;
  4064. $q = 0;
  4065. foreach ($sd as $k => $v) {
  4066. if ($v['state'] == 0) {
  4067. $c++;
  4068. }
  4069. if ($v['state'] != 9) {
  4070. $g++;
  4071. }
  4072. if ($v['outk'] > 1) {
  4073. $x++;
  4074. }
  4075. if ($v['retreat'] > 0) {
  4076. $t++;
  4077. }
  4078. if ($v['state'] == 8) {
  4079. $s++;
  4080. }
  4081. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4082. $q++;
  4083. }
  4084. $details[$v['details']] = $v['details'];
  4085. if ($v['cpid'] != 0) {
  4086. $cpid[$v['cpid']] = $v['cpid'];
  4087. }
  4088. if ($v['cpbz'] != '') {
  4089. $cpbz[$v['cpbz']] = $v['cpbz'];
  4090. }
  4091. }
  4092. if (isset($wt[$value['type']])) {
  4093. $rows[$key]['type'] = $wt[$value['type']];
  4094. } else {
  4095. $rows[$key]['type'] = '未设置';
  4096. }
  4097. $rows[$key]['details'] = implode("、", $details);
  4098. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4099. $ftime = time() - 15 * 24 * 3600;
  4100. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4101. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4102. $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);
  4103. $rows[$key]['c'] = $c;
  4104. $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);
  4105. $rows[$key]['t'] = $t;
  4106. $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'] . '"');
  4107. $rows[$key]['z'] = $z;
  4108. // $jm = $classid;
  4109. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4110. $features = explode('-', trim($features, '-'));
  4111. // $pm = $classid;
  4112. // foreach ($features as $k => $v) {
  4113. // if ($v != 0) {
  4114. // if (!isset($typeclass[$v])) {
  4115. // continue;
  4116. // }
  4117. // if (isset($pm[$typeclass[$v]['classid']])) {
  4118. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4119. // $tz = explode('|', $typeclass[$v]['zh']);
  4120. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4121. // } else {
  4122. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4123. // }
  4124. // if (isset($jm[$typeclass[$v]['classid']])) {
  4125. // if ($typeclass[$v]['jm']) {
  4126. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4127. // }
  4128. // }
  4129. // }
  4130. // }
  4131. // }
  4132. // $zh = implode(" ", $pm);
  4133. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4134. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4135. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4136. // $rows[$key]['features'] = $zh;
  4137. // $jm = array_filter($jm); //去除空值
  4138. // $jm = implode("-", $jm);
  4139. // $rows[$key]['jm'] = $jm;
  4140. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4141. }
  4142. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4143. // echo "<pre>";
  4144. // print_r($tmp_list);
  4145. // die;
  4146. $final_list =[];
  4147. foreach($tmp_list as $k=>$v){
  4148. $final_list[] = [
  4149. "warehouse"=>$v['warehouse'],
  4150. "purchase"=>$v['purchase'],
  4151. "details"=>trim($v['details'],'、'),
  4152. "cpid"=>$v['cpid'],
  4153. "sku"=>$v['sku'],
  4154. "title"=>$v['title'],
  4155. "features"=>$v['pm'],
  4156. "cpbz"=>$v['cpbz'],
  4157. "sm"=>$v['sm'],
  4158. "type"=>$v['type'],
  4159. "g"=>$v["g"],
  4160. "c"=>$v["c"],
  4161. "x"=>$v["x"],
  4162. "t"=>$v["t"],
  4163. "z"=>$v["z"],
  4164. "jm"=>$v["jm"],
  4165. "weight"=>$v["weight"],
  4166. "asd"=>$v["asd"],
  4167. ];
  4168. }
  4169. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4170. $titlename = "<table border=1>
  4171. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4172. <tr align='center'>
  4173. <td>仓库</td>
  4174. <td>供应商</td>
  4175. <td>位置</td>
  4176. <td>库存编码</td>
  4177. <td>SKU</td>
  4178. <td>商品名称</td>
  4179. <td>商品中文</td>
  4180. <td>产品备注</td>
  4181. <td>说明</td>
  4182. <td>类型</td>
  4183. <td>入库总量</td>
  4184. <td>库存数量</td>
  4185. <td>销售数量</td>
  4186. <td>退货数量</td>
  4187. <td>占单数量</td>
  4188. <td>料号</td>
  4189. <td>重量</td>
  4190. <td>类目</td>
  4191. </tr>
  4192. </table>";
  4193. $filename = $title . ".xls";
  4194. $tail = "";
  4195. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4196. }
  4197. }
  4198. }
  4199. //出库+入库数据整合
  4200. public function _excelcr()
  4201. {
  4202. if (isset($_GET['excel'])) {
  4203. $type = $this->input->get('excel', true);
  4204. $category = $this->input->get('category', true);
  4205. $size = $this->input->get('size', true);
  4206. $grade = $this->input->get('grade', true);
  4207. $color = $this->input->get('color', true);
  4208. $lowe = $this->input->get('lowe', true);
  4209. $sku = $this->input->get('sku', true);
  4210. $warehouse = $this->input->get('warehouse', true);
  4211. $purchase = $this->input->get('purchase', true);
  4212. $state = $this->input->get('state', true);
  4213. $sid = $this->input->get('sid', true);
  4214. $ktime = $this->input->get('ktime', true);
  4215. $jtime = $this->input->get('jtime', true);
  4216. $ktime = strtotime($ktime);
  4217. $jtime = strtotime($jtime);
  4218. $where = "1=1";
  4219. $gj = "";
  4220. $ck = "";
  4221. if ($category) {
  4222. $where .= " and features like '%-$category-%'";
  4223. }
  4224. if ($size) {
  4225. $where .= " and features like '%-$size-%'";
  4226. }
  4227. if ($grade) {
  4228. $where .= " and features like '%-$grade-%'";
  4229. }
  4230. if ($color) {
  4231. $where .= " and features like '%-$color-%'";
  4232. }
  4233. if ($lowe) {
  4234. $where .= " and features like '%-$lowe-%'";
  4235. }
  4236. if ($warehouse) {
  4237. $where .= " and warehouse = '$warehouse'";
  4238. }
  4239. if ($purchase) {
  4240. $where .= " and purchase = '$purchase'";
  4241. }
  4242. if ($state) {
  4243. $where .= " and state = '$state'";
  4244. }
  4245. if ($sku) {
  4246. $where .= " and sku like '%$sku%'";
  4247. }
  4248. if ($ktime && $jtime) {
  4249. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4250. }
  4251. $sidwhere = '';
  4252. if ($sid) {
  4253. $sd = "";
  4254. $s = explode(',', trim($sid, ','));
  4255. foreach ($s as $value) {
  4256. $sd .= " id = " . $value . " or";
  4257. }
  4258. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4259. }
  4260. //取得信息列表
  4261. $timeread = $ktime;
  4262. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4263. $timelist = array();
  4264. for ($i = 0; $i < $timenum; $i++) {
  4265. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4266. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4267. }
  4268. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4269. //echo "<pre>";
  4270. //print_r($info_list);
  4271. //exit();
  4272. $rows = array();
  4273. $list = array();
  4274. foreach ($info_list as $key => $value) {
  4275. $thistime = $timelist;
  4276. if (isset($rows[strtolower($value['sku'])])) {
  4277. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4278. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4279. }
  4280. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4281. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4282. }
  4283. } else {
  4284. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4285. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4286. }
  4287. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4288. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4289. }
  4290. $rows[strtolower($value['sku'])] = $thistime;
  4291. }
  4292. }
  4293. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4294. <head>
  4295. <!--[if gte mso 9]><xml>
  4296. <x:ExcelWorkbook>
  4297. <x:ExcelWorksheets>
  4298. <x:ExcelWorksheet>
  4299. <x:Name>EXCEL</x:Name>
  4300. <x:WorksheetOptions>
  4301. <x:Print>
  4302. <x:ValidPrinterInfo />
  4303. </x:Print>
  4304. </x:WorksheetOptions>
  4305. </x:ExcelWorksheet>
  4306. </x:ExcelWorksheets>
  4307. </x:ExcelWorkbook>
  4308. </xml>
  4309. <![endif]-->
  4310. </head><body>";
  4311. $str .= "<table border=1><tr><td>SKU</td>";
  4312. foreach ($timelist as $k => $v) {
  4313. $str .= "<td>" . $k . "出库</td>";
  4314. $str .= "<td>" . $k . "入库</td>";
  4315. }
  4316. $str .= "</tr></table>";
  4317. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4318. foreach ($rows as $key => $val) {
  4319. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4320. foreach ($val as $k => $v) {
  4321. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4322. if ($val[$k]['r'] > 0) {
  4323. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4324. } else {
  4325. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4326. }
  4327. }
  4328. $str .= "</tr>";
  4329. }
  4330. $str .= "</table>";
  4331. $str .= "</body></html>";
  4332. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4333. header("Content-type: application/octet-stream");
  4334. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4335. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4336. header("Pragma: no-cache");
  4337. header("Expires: 0");
  4338. exit($str);
  4339. }
  4340. }
  4341. //数量调整模板导出
  4342. public function _presetout()
  4343. {
  4344. if (isset($_GET['excel'])) {
  4345. $where = "sku != 'Preset' and purchase != 0";
  4346. //数据排序
  4347. $order_str = "id desc";
  4348. if (empty($page)) {
  4349. $start = 0;
  4350. $perpage = 1;
  4351. } else {
  4352. $start = ($page - 1) * $perpage;
  4353. }
  4354. //取得信息列表
  4355. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4356. $rows = array();
  4357. $list = array();
  4358. foreach ($info_list as $value) {
  4359. $warehouse = $this->warehouse->read($value['warehouse']);
  4360. $number = $value['number'];
  4361. $ftime = time() - 15 * 24 * 3600;
  4362. $purchase = $this->purchase->read($value['purchase']);
  4363. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4364. }
  4365. $title = "库存模板";
  4366. $titlename = "<table border=1>
  4367. <tr align='center'>
  4368. <td>仓库</td>
  4369. <td>供应商编码</td>
  4370. <td>SKU</td>
  4371. <td>增减数量(正数或负数)</td>
  4372. <td>增减备注</td>
  4373. <td>库位</td>
  4374. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4375. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4376. </tr>
  4377. </table>";
  4378. $filename = $title . ".xls";
  4379. $tail = "";
  4380. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4381. }
  4382. }
  4383. //数量调整模板导入
  4384. public function _presetedit()
  4385. {
  4386. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4387. $config['upload_path'] = '.' . $dir;
  4388. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4389. $config['allowed_types'] = 'xls|xlsx|csv';
  4390. $config['max_size'] = 10240;
  4391. $this->load->library('upload', $config);
  4392. $this->upload->initialize($config);
  4393. if ($this->upload->do_upload('userfile')) {
  4394. $full_path = $dir . $this->upload->data('file_name');
  4395. $fileName = '.' . $full_path;
  4396. if (!file_exists($fileName)) {
  4397. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4398. exit;
  4399. } else {
  4400. require_once "./data/excel/PHPExcel/IOFactory.php";
  4401. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4402. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4403. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4404. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4405. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4406. ++$column; //如果列数大于26行
  4407. $list = array();
  4408. for ($i = 2; $i <= $row; $i++) // 行数循环
  4409. {
  4410. $data = array();
  4411. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4412. {
  4413. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4414. }
  4415. $list[] = $data;
  4416. }
  4417. }
  4418. $i = 0;
  4419. $j = 0;
  4420. $ed = array();
  4421. foreach ($list as $key => $value) {
  4422. $time = time();
  4423. if ($value['0'] == "") {
  4424. continue;
  4425. }
  4426. $warehouse = $this->warehouse->get_title($value['0']);
  4427. $purchase = $this->purchase->get_bm($value['1']);
  4428. $sku = $value['2'];
  4429. $num = $value['3']; //调整数量
  4430. $text = $value['4']; //扣减说明
  4431. $type = $value['5']; //调整方式0扣减1删除
  4432. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4433. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4434. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4435. if (!$purchase) //如果没有这个SKU
  4436. {
  4437. $ed[] = array($purchase . '-不存在此供应商编码');
  4438. $j++;
  4439. continue;
  4440. }
  4441. if (!$d) //如果没有这个SKU
  4442. {
  4443. $ed[] = array($sku . '-库存中不存在此SKU');
  4444. $j++;
  4445. continue;
  4446. }
  4447. if (!isset($warehouse['id'])) {
  4448. $ed[] = array($sku . '-仓库名错误!');
  4449. $j++;
  4450. continue;
  4451. }
  4452. if ($type != '0' && $type != '1') {
  4453. $ed[] = array($sku . '-扣减方式填写错误!');
  4454. $j++;
  4455. continue;
  4456. }
  4457. if ($num < 0) //扣减库存
  4458. {
  4459. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4460. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4461. $j++;
  4462. continue;
  4463. }
  4464. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4465. if (count($data) < abs($num)) {
  4466. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4467. $j++;
  4468. continue;
  4469. }
  4470. if ($type == 0) //如果扣减方式为 扣减库存
  4471. {
  4472. for ($i = 0; $i < abs($num); $i++) {
  4473. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4474. }
  4475. } else if ($type == 1) {
  4476. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4477. if (count($zt) > 0) {
  4478. $ed[] = array($sku . '-有在途库存无法删除!');
  4479. $j++;
  4480. continue;
  4481. }
  4482. for ($i = 0; $i < abs($num); $i++) {
  4483. $this->whlabel->remove($data[$i]['id']);
  4484. }
  4485. }
  4486. } else if ($num > 0) //增加库存
  4487. {
  4488. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4489. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4490. $j++;
  4491. continue;
  4492. }
  4493. $post['sku'] = $d['sku'];
  4494. $post['shop'] = $d['shop'];
  4495. $post['warehouse'] = $warehouse['id'];
  4496. $post['purchase'] = $purchase['id'];
  4497. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4498. $post['state'] = 0;
  4499. $post['title'] = $d['title'];
  4500. $post['number'] = $d['number'];
  4501. $post['features'] = $d['features'];
  4502. $post['enter'] = $time;
  4503. $post['time'] = $time; //操作时间
  4504. $post['rktype'] = $rktype;
  4505. for ($i = 0; $i < $num; $i++) {
  4506. $post['label'] = time() . rand(100, 999) . $i;
  4507. $this->whlabel->insert($post);
  4508. }
  4509. }
  4510. sleep(1); //防止入库时间一样,需要延迟1秒
  4511. }
  4512. if ($j > 0) {
  4513. $tt = date('Ymd', time());
  4514. $title = '库存导入错误信息-' . $tt;
  4515. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4516. $tail = "\n";
  4517. $filename = $title . ".xls";
  4518. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4519. $dir = '/data/excel/' . $time . '/';
  4520. $file_name = 'error_' . $time . rand(1000, 9999);
  4521. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4522. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4523. fwrite($myfile, $ecl);
  4524. fclose($myfile);
  4525. $error = $dir . $file_name . '.xls';
  4526. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4527. exit;
  4528. } else {
  4529. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4530. exit;
  4531. }
  4532. }
  4533. }
  4534. public function _presetedittwo(){
  4535. $data = $this->input->post(NULL, TRUE);
  4536. if(empty($list)){
  4537. $raw_data = $this->input->raw_input_stream;
  4538. // 解码 JSON
  4539. $data = json_decode($raw_data, true);
  4540. }
  4541. if(empty($data)){
  4542. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4543. }
  4544. $list = [];
  4545. if(isset($data['list'])){
  4546. $list = $data['list'];
  4547. }
  4548. $i = 0;
  4549. $j = 0;
  4550. $ed = array();
  4551. foreach ($list as $key => $value) {
  4552. $time = time();
  4553. if ($value['0'] == "") {
  4554. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4555. $j++;
  4556. continue;
  4557. }
  4558. $warehouse = $this->warehouse->get_title($value['0']);
  4559. if(empty($warehouse)){
  4560. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4561. $j++;
  4562. continue;
  4563. }
  4564. $purchase = $this->purchase->get_bm($value['1']);
  4565. $sku = $value['2'];
  4566. $num = $value['3']; //调整数量
  4567. $text = $value['4']; //扣减说明
  4568. $type = 0; //调整方式0扣减1删除
  4569. $details = empty($value['5'])?'':$value['5']; //库位
  4570. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4571. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4572. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4573. if (!$purchase) //如果没有这个SKU
  4574. {
  4575. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4576. $j++;
  4577. continue;
  4578. }
  4579. if (!$d) //如果没有这个SKU
  4580. {
  4581. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4582. $j++;
  4583. continue;
  4584. }
  4585. if (!isset($warehouse['id'])) {
  4586. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4587. $j++;
  4588. continue;
  4589. }
  4590. if ($type != '0' && $type != '1') {
  4591. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4592. $j++;
  4593. continue;
  4594. }
  4595. if ($num < 0) //扣减库存
  4596. {
  4597. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4598. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4599. $j++;
  4600. continue;
  4601. }
  4602. if(!empty($details)){
  4603. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4604. }else{
  4605. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4606. }
  4607. if (count($data) < abs($num)) {
  4608. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4609. $j++;
  4610. continue;
  4611. }
  4612. if ($type == 0) //如果扣减方式为 扣减库存
  4613. {
  4614. for ($i = 0; $i < abs($num); $i++) {
  4615. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4616. }
  4617. } else if ($type == 1) {
  4618. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4619. if (count($zt) > 0) {
  4620. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4621. $j++;
  4622. continue;
  4623. }
  4624. for ($i = 0; $i < abs($num); $i++) {
  4625. $this->whlabel->remove($data[$i]['id']);
  4626. }
  4627. }
  4628. } else if ($num > 0) //增加库存
  4629. {
  4630. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4631. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4632. $j++;
  4633. continue;
  4634. }
  4635. if(empty($details)){
  4636. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  4637. if(empty($tmp_info)){
  4638. $details = '';
  4639. }else{
  4640. $details = $tmp_info[0]['details'];
  4641. }
  4642. }else{
  4643. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  4644. if(empty($tmp_info)){
  4645. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  4646. $j++;
  4647. continue;
  4648. }
  4649. }
  4650. $post['sku'] = $d['sku'];
  4651. $post['shop'] = $d['shop'];
  4652. $post['warehouse'] = $warehouse['id'];
  4653. $post['purchase'] = $purchase['id'];
  4654. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4655. $post['state'] = 0;
  4656. $post['title'] = $d['title'];
  4657. $post['number'] = $d['number'];
  4658. $post['features'] = $d['features'];
  4659. $post['details'] = $details;
  4660. $post['enter'] = $time;
  4661. $post['time'] = $time; //操作时间
  4662. $post['rktype'] = $rktype;
  4663. $post['sku_master_id'] = $d['sku_master_id'];
  4664. $post['sku_shop_id'] = $d['sku_shop_id'];
  4665. for ($i = 0; $i < $num; $i++) {
  4666. $post['label'] = time() . rand(100, 999) . $i;
  4667. $this->whlabel->insert($post);
  4668. }
  4669. }
  4670. sleep(1); //防止入库时间一样,需要延迟1秒
  4671. }
  4672. if ($j > 0) {
  4673. $tt = date('Ymd', time());
  4674. $title = '库存导入错误信息-' . $tt;
  4675. $error = $title . '.xls';
  4676. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4677. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  4678. exit;
  4679. } else {
  4680. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4681. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4682. exit;
  4683. }
  4684. }
  4685. //笛卡儿积
  4686. function cp($ps, $sets, $list)
  4687. {
  4688. $result = array();
  4689. $j = 0;
  4690. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4691. if ($i == 0) {
  4692. $result = $sets[$i];
  4693. }
  4694. $tmp = array();
  4695. foreach ($result as $res) {
  4696. foreach ($sets[$i + 1] as $set) {
  4697. $tmp[] = $res . ',' . $set;
  4698. }
  4699. }
  4700. $result = $tmp;
  4701. }
  4702. $this->db->trans_begin();
  4703. foreach ($result as $v) {
  4704. $post = array();
  4705. $title = "";
  4706. $num = "";
  4707. $data = explode(',', $v);
  4708. for ($i = 0; $i < count($list); $i++) {
  4709. $post[$list[$i]] = $data[$i];
  4710. $typeclass = $this->typeclass->read($data[$i]);
  4711. $title = $title . $typeclass['title'] . " ";
  4712. if ($data[$i] != 0) {
  4713. $num .= $data[$i]; //所有数据ID拼接
  4714. }
  4715. }
  4716. foreach ($ps as $kp => $vp) {
  4717. $post[$kp] = $vp;
  4718. }
  4719. $post['number'] = $num;
  4720. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4721. if ($info_list) {
  4722. $j++;
  4723. } else {
  4724. $skunum = $this->whlabel->find_count();
  4725. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4726. $post['title'] = rtrim($title, ' ');
  4727. $this->whlabel->insert($post);
  4728. }
  4729. }
  4730. if ($this->db->trans_status() === FALSE) {
  4731. $this->db->trans_commit();
  4732. return NULL;
  4733. } else {
  4734. $this->db->trans_commit();
  4735. return $j;
  4736. }
  4737. }
  4738. public function _kj($arg_array)
  4739. {
  4740. if (isset($_POST['sku'])) {
  4741. $time = time();
  4742. $sku = $this->input->post('sku', true);
  4743. $warehouse = $this->input->post('warehouse', true);
  4744. $num = $this->input->post('num', true);
  4745. $text = $this->input->post('text', true);
  4746. $purchase = $this->input->post('purchase', true);
  4747. $cktype = $this->input->post('cktype', true);
  4748. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4749. if ($cktype != 1 && $text == '') {
  4750. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4751. exit;
  4752. }
  4753. if ($num > count($order)) {
  4754. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4755. exit;
  4756. } else {
  4757. for ($i = 0; $i < $num; $i++) {
  4758. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4759. }
  4760. }
  4761. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4762. exit;
  4763. }
  4764. $uid = $this->whlabel->read($arg_array[0]);
  4765. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4766. $this->data['data'] = $uid;
  4767. $this->_Template('whlabel_kj', $this->data);
  4768. }
  4769. public function _summary($arg_array)
  4770. {
  4771. $prc = array();
  4772. $purchase = $this->purchase->find_all();
  4773. foreach ($purchase as $k => $v) {
  4774. $prc[$v['id']] = $v['title'];
  4775. }
  4776. if (isset($_GET['excel'])) {
  4777. $ktime = $this->input->get('ktime', true);
  4778. $jtime = $this->input->get('jtime', true);
  4779. $ktime = strtotime($ktime);
  4780. $jtime = strtotime($jtime);
  4781. $where = "1=1";
  4782. if ($ktime && $jtime) {
  4783. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4784. }
  4785. //数据排序
  4786. $order_str = "time desc";
  4787. if (empty($page)) {
  4788. $start = 0;
  4789. $perpage = 1;
  4790. } else {
  4791. $start = ($page - 1) * $perpage;
  4792. }
  4793. //取得信息列表
  4794. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4795. foreach ($info_list as $key => $value) {
  4796. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4797. $warehouse = $this->warehouse->read($value['warehouse']);
  4798. $info_list[$key]['warehouse'] = $warehouse['title'];
  4799. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4800. $details = array();
  4801. $cpid = array();
  4802. foreach ($x as $k => $v) {
  4803. if ($v['details'] != '') {
  4804. $details[$v['details']] = $v['details'];
  4805. }
  4806. if ($v['cpid'] != 0) {
  4807. $cpid[$v['cpid']] = $v['cpid'];
  4808. }
  4809. }
  4810. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4811. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4812. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4813. $info_list[$key]['s'] = $s;
  4814. $info_list[$key]['x'] = count($x);
  4815. }
  4816. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4817. $titlename = "<table border=1>
  4818. <tr align='center'>
  4819. <td>仓库</td>
  4820. <td>供应商</td>
  4821. <td>出库位置</td>
  4822. <td>出库编码</td>
  4823. <td>SKU</td>
  4824. <td>产品名</td>
  4825. <td>总剩余库存</td>
  4826. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4827. </tr>
  4828. </table>";
  4829. $filename = $title . ".xls";
  4830. $tail = "";
  4831. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4832. }
  4833. }
  4834. //usps发货清单
  4835. public function _manifest()
  4836. {
  4837. if (isset($_POST['manifest'])) {
  4838. $wltext = $this->input->post('wltext', true);
  4839. $time = time() - 16 * 3600;
  4840. $ptime = strtotime(date('Y-m-d', $time));
  4841. $waybill = array();
  4842. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4843. foreach ($fullorder as $v) {
  4844. $waybill[$v['waybill']] = $v['waybill'];
  4845. }
  4846. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4847. foreach ($fullordersmt as $v) {
  4848. $waybill[$v['waybill']] = $v['waybill'];
  4849. }
  4850. $wltext = explode(';', $wltext);
  4851. foreach ($wltext as $v) {
  4852. if (isset($waybill[$v])) {
  4853. unset($waybill[$v]);
  4854. }
  4855. }
  4856. $data = $this->usps->get_manifest($waybill);
  4857. if (isset($data['Description'])) {
  4858. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4859. exit;
  4860. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4861. $bctime = date('Ymd', time());
  4862. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4863. echo json_encode(array('msg' => $pdf, 'success' => true));
  4864. exit;
  4865. } else {
  4866. echo json_encode(array('msg' => $data, 'success' => false));
  4867. exit;
  4868. }
  4869. }
  4870. }
  4871. public function _pdf($pdf, $title, $bctime)
  4872. {
  4873. $pdf_path = './data/pdf/' . $bctime . '/';
  4874. $file_base64 = $pdf;
  4875. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4876. $file_base64 = base64_decode($file_base64);
  4877. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4878. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4879. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4880. }
  4881. /**
  4882. *
  4883. *
  4884. *
  4885. 进销存占单异常索引
  4886. *
  4887. *
  4888. *
  4889. **/
  4890. public function _abnormal()
  4891. {
  4892. $post = $this->input->post(NULL, TRUE);
  4893. if (isset($post['page'])) {
  4894. $page = $this->input->post('page', true);
  4895. $perpage = $this->input->post('perpage', true);
  4896. $sku = $this->input->post('sku', true);
  4897. $where = "1=1";
  4898. //数据排序
  4899. $order_str = "id desc";
  4900. if (empty($page)) {
  4901. $start = 0;
  4902. $perpage = 1;
  4903. } else {
  4904. $start = ($page - 1) * $perpage;
  4905. }
  4906. //取得信息列表
  4907. $info_list = $this->whlabel->find_all($where, '*');
  4908. $rows = array();
  4909. $list = array();
  4910. foreach ($info_list as $key => $value) {
  4911. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4912. }
  4913. foreach ($rows as $value) {
  4914. $warehouse = $this->warehouse->read($value['warehouse']);
  4915. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4916. $number = $value['number'];
  4917. $ftime = time() - 15 * 24 * 3600;
  4918. if ($value['shop'] != '') {
  4919. $shop = $value['shop'];
  4920. $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');
  4921. $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');
  4922. $order = array_merge($orderdlz, $ordersmt);
  4923. $od = 0;
  4924. $a = '';
  4925. $orid = '';
  4926. foreach ($order as $v) {
  4927. $or = explode('|', ltrim($v['whlabel'], '|'));
  4928. for ($i = 0; $i < count($or); $i++) {
  4929. $orod = explode('-', $or[$i]);
  4930. if ($orod[0] == $number) {
  4931. $od += $orod[1];
  4932. }
  4933. }
  4934. $orid .= $v['number'] . '-';
  4935. }
  4936. } else {
  4937. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4938. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4939. $order = array_merge($orderdlz, $ordersmt);
  4940. $od = 0;
  4941. $a = '';
  4942. $orid = '';
  4943. $qt = array();
  4944. foreach ($order as $v) {
  4945. $or = explode('|', ltrim($v['whlabel'], '|'));
  4946. for ($i = 0; $i < count($or); $i++) {
  4947. $orod = explode('-', $or[$i]);
  4948. if ($orod[0] == $number) {
  4949. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4950. if ($czzs > 0) {
  4951. if (isset($qt[$v['shop']])) {
  4952. if ($qt[$v['shop']] < $orod[1]) {
  4953. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4954. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4955. } else {
  4956. $qt[$v['shop']] -= $orod[1];
  4957. }
  4958. } else {
  4959. $qt[$v['shop']] = $czzs;
  4960. }
  4961. } else {
  4962. $od += $orod[1];
  4963. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4964. }
  4965. }
  4966. }
  4967. }
  4968. }
  4969. $z = $od . '(' . $orid . ')'; //查看订单号
  4970. //$z = $od;
  4971. if ($od > $c) {
  4972. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4973. }
  4974. }
  4975. $listdata = array_slice($list, $start, $perpage);
  4976. $total = count($list);
  4977. $pagenum = ceil($total / $perpage);
  4978. $over = $total - ($start + $perpage);
  4979. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4980. echo json_encode($rows);
  4981. exit;
  4982. }
  4983. $this->_Template('whlabel_abnormal', $this->data);
  4984. }
  4985. /**
  4986. *
  4987. *
  4988. *
  4989. 进销存占单异常索引
  4990. *
  4991. *
  4992. *
  4993. **/
  4994. public function _error()
  4995. {
  4996. $post = $this->input->post(NULL, TRUE);
  4997. if (isset($post['page'])) {
  4998. $page = $this->input->post('page', true);
  4999. $perpage = $this->input->post('perpage', true);
  5000. $sku = $this->input->post('sku', true);
  5001. $warehouse = $this->input->post('warehouse', true);
  5002. $ktime = $this->input->post('ktime', true);
  5003. $jtime = $this->input->post('jtime', true);
  5004. $ktime = strtotime($ktime);
  5005. $jtime = strtotime($jtime);
  5006. $where = "sku != 'Preset'";
  5007. $gj = '';
  5008. if ($sku) {
  5009. $where .= " and sku like '%$sku%'";
  5010. } else {
  5011. if ($ktime && $jtime) {
  5012. $gj = " and time > '$ktime' and time < '$jtime'";
  5013. }
  5014. }
  5015. if ($warehouse) {
  5016. $where .= " and warehouse = '$warehouse'";
  5017. }
  5018. //数据排序
  5019. $order_str = "id desc";
  5020. if (empty($page)) {
  5021. $start = 0;
  5022. $perpage = 1;
  5023. } else {
  5024. $start = ($page - 1) * $perpage;
  5025. }
  5026. //取得信息列表
  5027. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5028. $rows = array();
  5029. $list = array();
  5030. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5031. // foreach ($info_list as $value)
  5032. // {
  5033. // $warehouse = $this->warehouse->read($value['warehouse']);
  5034. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5035. // $number = $value['number'];$ftime = time()-15*24*3600;
  5036. // if($c < 1)
  5037. // {
  5038. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5039. // }
  5040. // }
  5041. $warehouse_list = $this->warehouse->find_all();
  5042. $warehouse_list = array_column($warehouse_list, null, 'id');
  5043. foreach ($info_list as $value) {
  5044. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5045. 'title' => "",
  5046. ];
  5047. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5048. $number = $value['number'];
  5049. $ftime = time() - 15 * 24 * 3600;
  5050. if ($c < 1) {
  5051. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5052. }
  5053. }
  5054. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5055. // $query = $this->db->query($sql);
  5056. // $info_list = $query->result_array();
  5057. // $sql_two = "select title,id from crowd_warehouse";
  5058. // $query_two = $this->db->query($sql_two);
  5059. // $warehouse_list = $query_two->result_array();
  5060. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5061. // foreach ($info_list as $value)
  5062. // {
  5063. // if(isset($warehouse_arr[$value['warehouse']])){
  5064. // $warehouse = $warehouse_arr[$value['warehouse']];
  5065. // }else{
  5066. // $warehouse = [
  5067. // 'id'=>0,
  5068. // 'title'=>"异常",
  5069. // ];
  5070. // }
  5071. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5072. // $number = $value['number'];$ftime = time()-15*24*3600;
  5073. // if($c < 1)
  5074. // {
  5075. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5076. // }
  5077. // }
  5078. $listdata = array_slice($list, $start, $perpage);
  5079. $total = count($list);
  5080. $pagenum = ceil($total / $perpage);
  5081. $over = $total - ($start + $perpage);
  5082. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5083. echo json_encode($rows);
  5084. exit;
  5085. }
  5086. if (isset($post['s'])) {
  5087. $id_arr = $this->input->post('s');
  5088. $id_arr = explode(',', trim($id_arr, ','));
  5089. if (!$id_arr) {
  5090. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5091. exit;
  5092. }
  5093. //循环删除记录
  5094. foreach ($id_arr as $v) {
  5095. $dd = $this->whlabel->read($v);
  5096. if (!isset($dd['id'])) {
  5097. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5098. exit;
  5099. }
  5100. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5101. if (isset($zt[0])) {
  5102. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5103. exit;
  5104. }
  5105. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5106. foreach ($deldd as $vv) {
  5107. $this->whlabel->remove($vv['id']);
  5108. }
  5109. }
  5110. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5111. exit;
  5112. }
  5113. $this->_Template('whlabel_error', $this->data);
  5114. }
  5115. public function _errorexcel()
  5116. {
  5117. $post = $this->input->post(NULL, TRUE);
  5118. if (isset($_GET['page'])) {
  5119. $page = $this->input->get('page', true);
  5120. $perpage = $this->input->get('perpage', true);
  5121. $sku = $this->input->get('sku', true);
  5122. $warehouse = $this->input->get('warehouse', true);
  5123. $ktime = $this->input->get('ktime', true);
  5124. $jtime = $this->input->get('jtime', true);
  5125. $ktime = strtotime($ktime);
  5126. $jtime = strtotime($jtime);
  5127. $where = "sku != 'Preset'";
  5128. $gj = '';
  5129. if ($sku) {
  5130. $where .= " and sku like '%$sku%'";
  5131. } else {
  5132. if ($ktime && $jtime) {
  5133. $gj = " and time > '$ktime' and time < '$jtime'";
  5134. }
  5135. }
  5136. if ($warehouse) {
  5137. $where .= " and warehouse = '$warehouse'";
  5138. }
  5139. //数据排序
  5140. $order_str = "id desc";
  5141. if (empty($page)) {
  5142. $start = 0;
  5143. $perpage = 1;
  5144. } else {
  5145. $start = ($page - 1) * $perpage;
  5146. }
  5147. //取得信息列表
  5148. $rows = array();
  5149. $list = array();
  5150. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5151. foreach ($info_list as $value) {
  5152. $warehouse = $this->warehouse->read($value['warehouse']);
  5153. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5154. $number = $value['number'];
  5155. $ftime = time() - 15 * 24 * 3600;
  5156. if ($c < 1) {
  5157. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5158. }
  5159. }
  5160. $title = "0库存汇总";
  5161. $titlename = "<table border=1>
  5162. <tr align='center'>
  5163. <td>仓库</td>
  5164. <td>SKU</td>
  5165. <td>产品</td>
  5166. <td>当前库存</td>
  5167. </tr>
  5168. </table>";
  5169. $filename = $title . ".xls";
  5170. $tail = "";
  5171. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5172. }
  5173. }
  5174. /**
  5175. *
  5176. *
  5177. * 占单
  5178. *
  5179. *
  5180. **/
  5181. public function _kcyz()
  5182. {
  5183. $post = $this->input->post(NULL, TRUE);
  5184. if (isset($post['warehouse'])) {
  5185. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5186. exit; //不再使用
  5187. $warehouse = $this->input->post('warehouse', true);
  5188. $whlabel = $this->input->post('whlabel', true);
  5189. $id = $this->input->post('id', true);
  5190. $shop = $this->input->post('shop', true);
  5191. $number = $this->input->post('number', true);
  5192. if (!$whlabel || $whlabel == '|') {
  5193. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5194. exit;
  5195. }
  5196. $pp = explode('|', trim($whlabel, '|'));
  5197. $x = 0;
  5198. $save = array();
  5199. foreach ($pp as $va) {
  5200. $num = explode('-', $va);
  5201. if ($number) {
  5202. $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 = '')"); //通用
  5203. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5204. } else {
  5205. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5206. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5207. }
  5208. $x++;
  5209. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5210. $save[] = $x - 1;
  5211. continue; //提前先加X不然出错,所以要减1
  5212. }
  5213. }
  5214. if (isset($save[0])) {
  5215. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5216. exit;
  5217. } else {
  5218. echo json_encode(array('success' => true));
  5219. exit;
  5220. }
  5221. }
  5222. }
  5223. public function _db()
  5224. {
  5225. $post = $this->input->post(NULL, TRUE);
  5226. if (isset($post['page'])) {
  5227. $page = $this->input->post('page', true);
  5228. $perpage = $this->input->post('perpage', true);
  5229. $sku = $this->input->post('sku', true);
  5230. $number = $this->input->post('number', true);
  5231. $warehouse = $this->input->post('warehouse', true);
  5232. $purchase = $this->input->post('purchase', true);
  5233. $orderinfo = $this->input->post('orderinfo', true);
  5234. $waybill = $this->input->post('waybill', true);
  5235. $category = $this->input->post('category', true);
  5236. $size = $this->input->post('size', true);
  5237. $grade = $this->input->post('grade', true);
  5238. $color = $this->input->post('color', true);
  5239. $lowe = $this->input->post('lowe', true);
  5240. $state = $this->input->post('state', true);
  5241. $label = $this->input->post('label', true);
  5242. $timetk = $this->input->post('timetkk', true);
  5243. $timetj = $this->input->post('timetjj', true);
  5244. $timetk = strtotime($timetk);
  5245. $timetj = strtotime($timetj);
  5246. $where = "dbtime > 0";
  5247. if ($timetk && $timetj) {
  5248. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5249. }
  5250. if ($sku) {
  5251. $where .= " and sku = '$sku'";
  5252. }
  5253. if ($warehouse) {
  5254. $where .= " and warehouse = '$warehouse'";
  5255. if ($warehouse == 12) {
  5256. $w = 'specialstock';
  5257. } else {
  5258. $w = 'whlabel';
  5259. }
  5260. }
  5261. if ($purchase) {
  5262. $where .= " and purchase = '$purchase'";
  5263. }
  5264. if ($category) {
  5265. $where .= " and features like '%-$category-%'";
  5266. }
  5267. if ($size) {
  5268. $where .= " and features like '%-$size-%'";
  5269. }
  5270. if ($grade) {
  5271. $where .= " and features like '%-$grade-%'";
  5272. }
  5273. if ($color) {
  5274. $where .= " and features like '%-$color-%'";
  5275. }
  5276. if ($lowe) {
  5277. $where .= " and features like '%-$lowe-%'";
  5278. }
  5279. if ($state != '') {
  5280. $where .= " and state = '$state'";
  5281. }
  5282. //数据排序
  5283. $order_str = "dbtime desc";
  5284. if (empty($page)) {
  5285. $start = 0;
  5286. $perpage = 1;
  5287. } else {
  5288. $start = ($page - 1) * $perpage;
  5289. }
  5290. //取得信息列表
  5291. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5292. foreach ($info_list as $key => $value) {
  5293. $warehouse = $this->$w->read($value['warehouse']);
  5294. $info_list[$key]['warehouse'] = $warehouse['title'];
  5295. $purchase = $this->purchase->read($value['purchase']);
  5296. $info_list[$key]['purchase'] = $purchase['title'];
  5297. if ($value['enter'] != 0) {
  5298. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5299. } else {
  5300. $info_list[$key]['enter'] = "";
  5301. }
  5302. if ($value['dbtime'] != 0) {
  5303. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5304. } else {
  5305. $info_list[$key]['dbtime'] = "";
  5306. }
  5307. if ($value['state'] == 0) {
  5308. $info_list[$key]['state'] = "在库";
  5309. } else if ($value['state'] == 1) {
  5310. $info_list[$key]['state'] = "出库";
  5311. } else if ($value['state'] == 2) {
  5312. $info_list[$key]['state'] = "退库";
  5313. } else if ($value['state'] == 3) {
  5314. $info_list[$key]['state'] = "调拨中";
  5315. } else if ($value['state'] == 4) {
  5316. $info_list[$key]['state'] = "再加工";
  5317. } else if ($value['state'] == 5) {
  5318. $info_list[$key]['state'] = "维修中";
  5319. } else if ($value['state'] == 6) {
  5320. $info_list[$key]['state'] = "盘亏";
  5321. } else if ($value['state'] == 7) {
  5322. $info_list[$key]['state'] = "更换标签";
  5323. } else if ($value['state'] == 8) {
  5324. $info_list[$key]['state'] = "其它";
  5325. } else if ($value['state'] == 9) {
  5326. $info_list[$key]['state'] = "预设";
  5327. }
  5328. }
  5329. $total = $this->whlabel->find_count($where);
  5330. $pagenum = ceil($total / $perpage);
  5331. $over = $total - ($start + $perpage);
  5332. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5333. echo json_encode($rows);
  5334. exit;
  5335. }
  5336. if (isset($post['outsku'])) {
  5337. $time = time();
  5338. $cz = $this->input->post('cz', true);
  5339. $label = $this->input->post('outsku', true);
  5340. $sl = $this->input->post('sl', true);
  5341. $num = $this->input->post('num', true);
  5342. //$warehouse = $this->input->post('warehouse',true);
  5343. if (!$sl) {
  5344. $sl = 1;
  5345. }
  5346. if (!$warehouse) {
  5347. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5348. exit;
  5349. }
  5350. $dblabel = $this->whlabellabel->get_label($label);
  5351. if ($dblabel) {
  5352. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5353. if (count($data) < 1) {
  5354. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5355. exit;
  5356. }
  5357. if (count($data) < $num) {
  5358. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5359. exit;
  5360. }
  5361. for ($i = 0; $i < $sl; $i++) {
  5362. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5363. }
  5364. echo json_encode(array('success' => true));
  5365. exit;
  5366. } else {
  5367. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5368. exit;
  5369. }
  5370. }
  5371. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5372. $this->_Template('whlabel_db', $this->data);
  5373. }
  5374. public function _dbrk()
  5375. {
  5376. $post = $this->input->post(NULL, TRUE);
  5377. if (isset($post['page'])) {
  5378. $page = $this->input->post('page', true);
  5379. $perpage = $this->input->post('perpage', true);
  5380. $sku = $this->input->post('sku', true);
  5381. $number = $this->input->post('number', true);
  5382. $warehouse = $this->input->post('warehouse', true);
  5383. $purchase = $this->input->post('purchase', true);
  5384. $orderinfo = $this->input->post('orderinfo', true);
  5385. $waybill = $this->input->post('waybill', true);
  5386. $category = $this->input->post('category', true);
  5387. $size = $this->input->post('size', true);
  5388. $grade = $this->input->post('grade', true);
  5389. $color = $this->input->post('color', true);
  5390. $lowe = $this->input->post('lowe', true);
  5391. $state = $this->input->post('state', true);
  5392. $label = $this->input->post('label', true);
  5393. $ctime = $this->input->post('ctime', true);
  5394. $timetk = $this->input->post('timetkk', true);
  5395. $timetj = $this->input->post('timetjj', true);
  5396. $timetk = strtotime($timetk);
  5397. $timetj = strtotime($timetj);
  5398. $where = "dbtime > 0";
  5399. if ($timetk && $timetj) {
  5400. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5401. }
  5402. if ($sku) {
  5403. $where .= " and sku = '$sku'";
  5404. }
  5405. if ($warehouse) {
  5406. $where .= " and warehouse = '$warehouse'";
  5407. }
  5408. if ($purchase) {
  5409. $where .= " and purchase = '$purchase'";
  5410. }
  5411. if ($category) {
  5412. $where .= " and features like '%-$category-%'";
  5413. }
  5414. if ($size) {
  5415. $where .= " and features like '%-$size-%'";
  5416. }
  5417. if ($grade) {
  5418. $where .= " and features like '%-$grade-%'";
  5419. }
  5420. if ($color) {
  5421. $where .= " and features like '%-$color-%'";
  5422. }
  5423. if ($lowe) {
  5424. $where .= " and features like '%-$lowe-%'";
  5425. }
  5426. if ($state != '') {
  5427. $where .= " and state = '$state'";
  5428. }
  5429. //数据排序
  5430. $order_str = "dbtime desc";
  5431. if (empty($page)) {
  5432. $start = 0;
  5433. $perpage = 1;
  5434. } else {
  5435. $start = ($page - 1) * $perpage;
  5436. }
  5437. //取得信息列表
  5438. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5439. foreach ($info_list as $key => $value) {
  5440. $warehouse = $this->warehouse->read($value['warehouse']);
  5441. $info_list[$key]['warehouse'] = $warehouse['title'];
  5442. $purchase = $this->purchase->read($value['purchase']);
  5443. $info_list[$key]['purchase'] = $purchase['title'];
  5444. if ($value['enter'] != 0) {
  5445. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5446. } else {
  5447. $info_list[$key]['enter'] = "";
  5448. }
  5449. if ($value['dbtime'] != 0) {
  5450. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5451. } else {
  5452. $info_list[$key]['dbtime'] = "";
  5453. }
  5454. if ($value['state'] == 0) {
  5455. $info_list[$key]['state'] = "在库";
  5456. } else if ($value['state'] == 1) {
  5457. $info_list[$key]['state'] = "出库";
  5458. } else if ($value['state'] == 2) {
  5459. $info_list[$key]['state'] = "退库";
  5460. } else if ($value['state'] == 3) {
  5461. $info_list[$key]['state'] = "调拨中";
  5462. } else if ($value['state'] == 4) {
  5463. $info_list[$key]['state'] = "再加工";
  5464. } else if ($value['state'] == 5) {
  5465. $info_list[$key]['state'] = "维修中";
  5466. } else if ($value['state'] == 6) {
  5467. $info_list[$key]['state'] = "盘亏";
  5468. } else if ($value['state'] == 7) {
  5469. $info_list[$key]['state'] = "更换标签";
  5470. } else if ($value['state'] == 8) {
  5471. $info_list[$key]['state'] = "其它";
  5472. } else if ($value['state'] == 9) {
  5473. $info_list[$key]['state'] = "预设";
  5474. }
  5475. }
  5476. $total = $this->whlabel->find_count($where);
  5477. $pagenum = ceil($total / $perpage);
  5478. $over = $total - ($start + $perpage);
  5479. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5480. echo json_encode($rows);
  5481. exit;
  5482. }
  5483. if (isset($post['rsku'])) {
  5484. $cz = $this->input->post('cz', true);
  5485. $label = $this->input->post('rsku', true);
  5486. $sl = $this->input->post('sl', true);
  5487. $warehouse = $this->input->post('warehouse', true);
  5488. if (!$sl) {
  5489. $sl = 1;
  5490. }
  5491. if (!$warehouse) {
  5492. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5493. exit;
  5494. }
  5495. $dblabel = $this->whlabellabel->get_label($label);
  5496. if ($dblabel) {
  5497. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5498. if (count($data) < 1) {
  5499. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5500. exit;
  5501. }
  5502. if ($sl > count($data)) {
  5503. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5504. exit;
  5505. }
  5506. $time = time();
  5507. for ($i = 0; $i < $sl; $i++) {
  5508. $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']);
  5509. }
  5510. echo json_encode(array('success' => true));
  5511. exit;
  5512. } else {
  5513. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5514. exit;
  5515. }
  5516. }
  5517. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5518. $this->_Template('whlabel_dbrk', $this->data);
  5519. }
  5520. public function _whlabelczdc()
  5521. {
  5522. if (isset($_GET['excel'])) {
  5523. //数据排序
  5524. $order_str = "id desc";
  5525. if (empty($page)) {
  5526. $start = 0;
  5527. $perpage = 1;
  5528. } else {
  5529. $start = ($page - 1) * $perpage;
  5530. }
  5531. $state = $this->input->get('state', true);
  5532. $sku = $this->input->get('sku', true);
  5533. $ctime = $this->input->get('ctime', true);
  5534. $category = $this->input->get('category', true);
  5535. $size = $this->input->get('size', true);
  5536. $grade = $this->input->get('grade', true);
  5537. $color = $this->input->get('color', true);
  5538. $lowe = $this->input->get('lowe', true);
  5539. $timetk = $this->input->get('timetkk', true);
  5540. $timetj = $this->input->get('timetjj', true);
  5541. $timetk = strtotime($timetk);
  5542. $timetj = strtotime($timetj);
  5543. $where = "dbtime > 0";
  5544. if ($timetk && $timetj) {
  5545. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5546. }
  5547. if ($category) {
  5548. $where .= " and features like '%-$category-%'";
  5549. }
  5550. if ($size) {
  5551. $where .= " and features like '%-$size-%'";
  5552. }
  5553. if ($grade) {
  5554. $where .= " and features like '%-$grade-%'";
  5555. }
  5556. if ($color) {
  5557. $where .= " and features like '%-$color-%'";
  5558. }
  5559. if ($lowe) {
  5560. $where .= " and features like '%-$lowe-%'";
  5561. }
  5562. //取得信息列表
  5563. $info_list = $this->whlabel->find_all($where, '*');
  5564. $rows = array();
  5565. $list = array();
  5566. foreach ($info_list as $key => $value) {
  5567. $rows[$value['sku']] = $value; //所有数据sku
  5568. }
  5569. foreach ($rows as $value) {
  5570. $warehouse = $this->warehouse->read($value['warehouse']);
  5571. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5572. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5573. if ($value['orderinfo'] == 0) {
  5574. $info_list[$key]['orderinfo'] = "";
  5575. }
  5576. if ($value['waybill'] == 0) {
  5577. $info_list[$key]['waybill'] = "";
  5578. }
  5579. if ($value['state'] == 0) {
  5580. $value['state'] = "在库";
  5581. } else if ($value['state'] == 3) {
  5582. $value['state'] = "调拨中";
  5583. }
  5584. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5585. }
  5586. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5587. $titlename = "<table border=1>
  5588. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5589. <tr align='center'>
  5590. <td>SKU</td>
  5591. <td>产品</td>
  5592. <td>调拨数量</td>
  5593. <td>入库数量</td>
  5594. </tr>
  5595. </table>";
  5596. $filename = $title . ".xls";
  5597. $tail = "";
  5598. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5599. }
  5600. }
  5601. public function _print($arg_array)
  5602. {
  5603. if (isset($_SESSION['api'])) {
  5604. $user = $this->user->get_api($_SESSION['api']);
  5605. $usp = $user;
  5606. $fgshop = "";
  5607. $sid = "";
  5608. $wid = "";
  5609. $wtype = "";
  5610. $usersp = explode('|', trim($user['shop'], '|'));
  5611. $userwh = explode('|', trim($user['warehouse'], '|'));
  5612. foreach ($usersp as $value) {
  5613. $fgshop .= " shop = " . $value . " or";
  5614. $sid .= " id = " . $value . " or";
  5615. }
  5616. foreach ($userwh as $value) {
  5617. $wid .= " id = " . $value . " or";
  5618. $wtype .= " type = " . $value . " or";
  5619. }
  5620. }
  5621. $post = $this->input->post(NULL, TRUE);
  5622. if (isset($post['tmsku'])) {
  5623. $tmsku = $this->input->post('tmsku', true);
  5624. if (is_numeric($tmsku)) {
  5625. $yyh = $this->whlabellabel->get_label($tmsku);
  5626. } else {
  5627. $yyh = $this->whlabellabel->get_sku($tmsku);
  5628. if(empty($yyh)){
  5629. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5630. if($r['code'] == -1 ){
  5631. echo json_encode(array('success' => false));
  5632. exit;
  5633. }else{
  5634. echo json_encode(array('features' => $r['data'], 'success' => true));
  5635. exit;
  5636. }
  5637. }
  5638. }
  5639. if ($yyh) {
  5640. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5641. exit;
  5642. } else {
  5643. echo json_encode(array('success' => false));
  5644. exit;
  5645. }
  5646. }
  5647. $classid = $this->classid->sku();
  5648. $pm = $classid;
  5649. $scsku = $classid;
  5650. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5651. if (isset($post['warehouse'])) {
  5652. if ($post['warehouse']) {
  5653. $list = array();
  5654. $num = "";
  5655. $title = "";
  5656. $features = "";
  5657. $order = 0;
  5658. $post['shop'] = '';
  5659. $brand = $this->input->post('brand', true);
  5660. if ($brand != '0,') {
  5661. $b = $this->brand->read(rtrim($brand, ','));
  5662. if ($b) {
  5663. $post['shop'] = str_replace('|', ',', $b['shop']);
  5664. }
  5665. }
  5666. $post['details'] = $this->input->post('details', true); //打印数量
  5667. $xbqnum = $this->input->post('xbqnum', true);
  5668. $post['purchase'] = $this->input->post('purchase', true);
  5669. $post['warehouse'] = $this->input->post('warehouse', true);
  5670. $post['purchase'] = $this->input->post('purchase', true);
  5671. $post['retreatwarehouse'] = $post['warehouse'];
  5672. $post['cpbz'] = $this->input->post('cpbz', true);
  5673. $post['state'] = 9;
  5674. $category = $this->input->post('category', true);
  5675. $list['category'] = $category;
  5676. $list['hairtype'] = $this->input->post('hairtype', true);
  5677. $list['grade'] = $this->input->post('grade', true);
  5678. $size = $this->input->post('size', true);
  5679. $list['size'] = rtrim($size, ',');
  5680. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5681. $list['extension'] = $this->input->post('extension', true);
  5682. if ($category == 1297) {
  5683. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5684. }
  5685. if ($category == 1702) {
  5686. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5687. $list['syother'] = $this->input->post('syother', true);
  5688. }
  5689. if ($category == 133) {
  5690. $list['fittype'] = $this->input->post('fittype', true);
  5691. $list['acother'] = $this->input->post('acother', true);
  5692. }
  5693. $list['color'] = $this->input->post('color', true);
  5694. $list['lowe'] = $this->input->post('lowe', true);
  5695. if ($category == 127) {
  5696. $list['type'] = $this->input->post('type', true);
  5697. $list['headroad'] = $this->input->post('headroad', true);
  5698. $list['density'] = $this->input->post('density', true);
  5699. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5700. $list['lacesize'] = $this->input->post('lacesize', true);
  5701. }
  5702. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5703. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5704. }
  5705. if ($category == 128) {
  5706. $list['lacetype'] = $this->input->post('lacetype', true);
  5707. $list['haircap'] = $this->input->post('haircap', true);
  5708. $list['density'] = $this->input->post('density', true);
  5709. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5710. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5711. $list['wigother'] = $this->input->post('wigother', true);
  5712. $list['wigother1'] = $this->input->post('wigother1', true);
  5713. $list['wigother2'] = $this->input->post('wigother2', true);
  5714. $list['product_related'] = $this->input->post('product_related', true);
  5715. }
  5716. if ($category == 129) {
  5717. $list['wide'] = $this->input->post('wide', true);
  5718. }
  5719. if ($category == 131) {
  5720. $list['gifttype'] = $this->input->post('gifttype', true);
  5721. $list['giftother'] = $this->input->post('giftother', true);
  5722. }
  5723. if ($category == 134) {
  5724. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5725. }
  5726. if ($category == 1297) {
  5727. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5728. $list['sywigother'] = $this->input->post('sywigother', true);
  5729. }
  5730. if ($category == 130 || $category == 133 || $category == 1702) {
  5731. $list['items'] = $this->input->post('items', true);
  5732. $list['weight'] = $this->input->post('weight', true);
  5733. }
  5734. if ($category == 1702) {
  5735. $list['syhairther'] = $this->input->post('syhairther', true);
  5736. }
  5737. if($category == 130){
  5738. $list['jfother'] = $this->input->post('jfother', true);
  5739. }
  5740. foreach ($list as $k => $v) {
  5741. if ($v != 0) {
  5742. $num .= $v;
  5743. $features .= $v . '-';
  5744. $post[$k] = $v;
  5745. $typeclass = $this->typeclass->read($v);
  5746. if (isset($pm[$typeclass['classid']])) {
  5747. if (stripos($typeclass['zh'], '|') !== false) {
  5748. $exzh = explode('|', $typeclass['zh']);
  5749. $pm[$typeclass['classid']] = $exzh[0];
  5750. } else {
  5751. $pm[$typeclass['classid']] = $typeclass['zh'];
  5752. }
  5753. }
  5754. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5755. if ($k != 'size') {
  5756. $title .= $typeclass['title'] . " ";
  5757. }
  5758. }
  5759. }
  5760. $typeclass = $this->typeclass->read($list['size']);
  5761. $title .= $typeclass['title'];
  5762. $time = time();
  5763. $post['title'] = rtrim($title, ' ');
  5764. $post['number'] = $num;
  5765. $post['features'] = '-' . $features;
  5766. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5767. $featurespp = explode('-', trim($featurespp, '-'));
  5768. if (isset($featurespp[5])) {
  5769. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5770. } else {
  5771. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5772. }
  5773. $post['enter'] = $time;
  5774. $post['time'] = $time; //操作时间
  5775. $scsku = implode("-", $scsku);
  5776. $zh = implode(" ", $pm);
  5777. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5778. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5779. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5780. $post['sku'] = $bqsku;
  5781. $label = time() . rand(0, 9);
  5782. $post['label'] = $label;
  5783. $cpid = $this->whlabellabel->find_count();
  5784. $post['cpid'] = $cpid + 1;
  5785. $cpid = $post['cpid'];
  5786. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5787. //if($whlabelbarcode)
  5788. //{
  5789. //$post['label'] = $whlabelbarcode['label'];
  5790. //if(!$this->whlabellabel->insert($post))
  5791. //{
  5792. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5793. //}
  5794. //}
  5795. //else
  5796. //{
  5797. $this->db->trans_begin();
  5798. $this->whlabellabel->insert($post);
  5799. //$this->whlabelbarcode->insert($post);
  5800. if ($this->db->trans_status() === TRUE) {
  5801. $this->db->trans_commit();
  5802. } else {
  5803. $this->db->trans_rollback();
  5804. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5805. exit;
  5806. }
  5807. //}
  5808. $warehouse_name = "";
  5809. $warehouse = $post['warehouse'];
  5810. if($warehouse == 12){
  5811. $warehouse_name = "特殊库存库";
  5812. }
  5813. // if($warehouse == 13){
  5814. // $warehouse_name = "许昌仓";
  5815. // }
  5816. // if($warehouse == 5){
  5817. // $warehouse_name = "美国店";
  5818. // }
  5819. // if($warehouse == 16){
  5820. // $warehouse_name = "定制头套仓";
  5821. // }
  5822. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5823. if(!empty($warehouse_name)){
  5824. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5825. }
  5826. $purchase = $this->purchase->read($post['purchase']);
  5827. 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));
  5828. exit; //特殊仓目前不需要仓库选项
  5829. }
  5830. }
  5831. if (isset($_SESSION['api'])) {
  5832. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5833. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5834. $this->data['wlshop'] = $wlshop;
  5835. $this->data['warehouse'] = $warehouse;
  5836. }
  5837. $whlabelwz = $this->whlabelwz->find_all();
  5838. $this->data['whlabelwz'] = $whlabelwz;
  5839. $this->_Template('whlabel_print', $this->data);
  5840. }
  5841. public function _usaprint($arg_array)
  5842. {
  5843. if (isset($_SESSION['api'])) {
  5844. $user = $this->user->get_api($_SESSION['api']);
  5845. $usp = $user;
  5846. $fgshop = "";
  5847. $sid = "";
  5848. $wid = "";
  5849. $wtype = "";
  5850. $usersp = explode('|', trim($user['shop'], '|'));
  5851. $userwh = explode('|', trim($user['warehouse'], '|'));
  5852. foreach ($usersp as $value) {
  5853. $fgshop .= " shop = " . $value . " or";
  5854. $sid .= " id = " . $value . " or";
  5855. }
  5856. foreach ($userwh as $value) {
  5857. $wid .= " id = " . $value . " or";
  5858. $wtype .= " type = " . $value . " or";
  5859. }
  5860. }
  5861. $post = $this->input->post(NULL, TRUE);
  5862. if (isset($post['tmsku'])) {
  5863. $tmsku = $this->input->post('tmsku', true);
  5864. if (is_numeric($tmsku)) {
  5865. $yyh = $this->whlabellabel->get_label($tmsku);
  5866. } else {
  5867. $yyh = $this->whlabellabel->get_sku($tmsku);
  5868. }
  5869. if ($yyh) {
  5870. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5871. exit;
  5872. } else {
  5873. echo json_encode(array('success' => false));
  5874. exit;
  5875. }
  5876. }
  5877. $classid = $this->classid->sku();
  5878. $pm = $classid;
  5879. $scsku = $classid;
  5880. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5881. if (isset($post['warehouse'])) {
  5882. if ($post['warehouse']) {
  5883. $list = array();
  5884. $num = "";
  5885. $title = "";
  5886. $features = "";
  5887. $order = 0;
  5888. $post['shop'] = '';
  5889. $brand = $this->input->post('brand', true);
  5890. if ($brand != '0,') {
  5891. $b = $this->brand->read(rtrim($brand, ','));
  5892. if ($b) {
  5893. $post['shop'] = str_replace('|', ',', $b['shop']);
  5894. }
  5895. }
  5896. $post['details'] = $this->input->post('details', true); //打印数量
  5897. $xbqnum = $this->input->post('xbqnum', true);
  5898. $post['purchase'] = $this->input->post('purchase', true);
  5899. $post['warehouse'] = $this->input->post('warehouse', true);
  5900. $post['purchase'] = $this->input->post('purchase', true);
  5901. $post['retreatwarehouse'] = $post['warehouse'];
  5902. $post['cpbz'] = $this->input->post('cpbz', true);
  5903. $post['state'] = 9;
  5904. $category = $this->input->post('category', true);
  5905. $list['category'] = $category;
  5906. $list['hairtype'] = $this->input->post('hairtype', true);
  5907. $list['grade'] = $this->input->post('grade', true);
  5908. $size = $this->input->post('size', true);
  5909. $list['size'] = rtrim($size, ',');
  5910. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5911. $list['extension'] = $this->input->post('extension', true);
  5912. if ($category == 1297) {
  5913. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5914. }
  5915. if ($category == 1702) {
  5916. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5917. $list['syother'] = $this->input->post('syother', true);
  5918. }
  5919. if ($category == 133) {
  5920. $list['fittype'] = $this->input->post('fittype', true);
  5921. $list['acother'] = $this->input->post('acother', true);
  5922. }
  5923. $list['color'] = $this->input->post('color', true);
  5924. $list['lowe'] = $this->input->post('lowe', true);
  5925. if ($category == 127) {
  5926. $list['type'] = $this->input->post('type', true);
  5927. $list['headroad'] = $this->input->post('headroad', true);
  5928. $list['density'] = $this->input->post('density', true);
  5929. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5930. $list['lacesize'] = $this->input->post('lacesize', true);
  5931. }
  5932. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5933. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5934. }
  5935. if ($category == 128) {
  5936. $list['lacetype'] = $this->input->post('lacetype', true);
  5937. $list['haircap'] = $this->input->post('haircap', true);
  5938. $list['density'] = $this->input->post('density', true);
  5939. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5940. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5941. $list['wigother'] = $this->input->post('wigother', true);
  5942. $list['wigother1'] = $this->input->post('wigother1', true);
  5943. $list['wigother2'] = $this->input->post('wigother2', true);
  5944. $list['product_related'] = $this->input->post('product_related', true);
  5945. }
  5946. if ($category == 129) {
  5947. $list['wide'] = $this->input->post('wide', true);
  5948. }
  5949. if ($category == 131) {
  5950. $list['gifttype'] = $this->input->post('gifttype', true);
  5951. $list['giftother'] = $this->input->post('giftother', true);
  5952. }
  5953. if ($category == 134) {
  5954. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5955. }
  5956. if ($category == 1297) {
  5957. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5958. $list['sywigother'] = $this->input->post('sywigother', true);
  5959. }
  5960. if ($category == 130 || $category == 133 || $category == 1702) {
  5961. $list['items'] = $this->input->post('items', true);
  5962. $list['weight'] = $this->input->post('weight', true);
  5963. }
  5964. if ($category == 1702) {
  5965. $list['syhairther'] = $this->input->post('syhairther', true);
  5966. }
  5967. foreach ($list as $k => $v) {
  5968. if ($v != 0) {
  5969. $num .= $v;
  5970. $features .= $v . '-';
  5971. $post[$k] = $v;
  5972. $typeclass = $this->typeclass->read($v);
  5973. if (isset($pm[$typeclass['classid']])) {
  5974. if (stripos($typeclass['zh'], '|') !== false) {
  5975. $exzh = explode('|', $typeclass['zh']);
  5976. $pm[$typeclass['classid']] = $exzh[0];
  5977. } else {
  5978. $pm[$typeclass['classid']] = $typeclass['zh'];
  5979. }
  5980. }
  5981. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5982. if ($k != 'size') {
  5983. $title .= $typeclass['title'] . " ";
  5984. }
  5985. }
  5986. }
  5987. $typeclass = $this->typeclass->read($list['size']);
  5988. $title .= $typeclass['title'];
  5989. $time = time();
  5990. $post['title'] = rtrim($title, ' ');
  5991. $post['number'] = $num;
  5992. $post['features'] = '-' . $features;
  5993. $fp = $this->whlabel->get_features($post['features']);
  5994. if (!$fp) {
  5995. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5996. exit;
  5997. }
  5998. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5999. $featurespp = explode('-', trim($featurespp, '-'));
  6000. if (isset($featurespp[5])) {
  6001. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6002. } else {
  6003. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6004. }
  6005. $post['enter'] = $time;
  6006. $post['time'] = $time; //操作时间
  6007. $scsku = implode("-", $scsku);
  6008. $zh = implode(" ", $pm);
  6009. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6010. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6011. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6012. $post['sku'] = $fp['sku'];
  6013. $post['label'] = $fp['sku'];
  6014. $cpid = $this->whlabellabel->find_count();
  6015. $post['cpid'] = $cpid + 1;
  6016. $cpid = $post['cpid'];
  6017. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6018. //if($whlabelbarcode)
  6019. //{
  6020. //$post['label'] = $whlabelbarcode['label'];
  6021. //if(!$this->whlabellabel->insert($post))
  6022. //{
  6023. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6024. //}
  6025. //}
  6026. //else
  6027. //{
  6028. $this->db->trans_begin();
  6029. $this->whlabellabel->insert($post);
  6030. //$this->whlabelbarcode->insert($post);
  6031. if ($this->db->trans_status() === TRUE) {
  6032. $this->db->trans_commit();
  6033. } else {
  6034. $this->db->trans_rollback();
  6035. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6036. exit;
  6037. }
  6038. //}
  6039. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6040. $purchase = $this->purchase->read($post['purchase']);
  6041. 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));
  6042. exit; //特殊仓目前不需要仓库选项
  6043. }
  6044. }
  6045. if (isset($_SESSION['api'])) {
  6046. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6047. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6048. $this->data['wlshop'] = $wlshop;
  6049. $this->data['warehouse'] = $warehouse;
  6050. }
  6051. $whlabelwz = $this->whlabelwz->find_all();
  6052. $this->data['whlabelwz'] = $whlabelwz;
  6053. $this->_Template('whlabel_usaprint', $this->data);
  6054. }
  6055. public function _printrk($arg_array)
  6056. {
  6057. $prc = array();
  6058. $purchase = $this->purchase->find_all();
  6059. foreach ($purchase as $k => $v) {
  6060. $prc[$v['id']] = $v['title'];
  6061. }
  6062. $post = $this->input->post(NULL, TRUE);
  6063. if (isset($post['page'])) {
  6064. $page = $this->input->post('page', true);
  6065. $perpage = $this->input->post('perpage', true);
  6066. $sku = $this->input->post('sku', true);
  6067. $bs = $this->input->post('bs', true);
  6068. $number = $this->input->post('number', true);
  6069. $warehouse = $this->input->post('warehouse', true);
  6070. $purchase = $this->input->post('purchase', true);
  6071. $orderinfo = $this->input->post('orderinfo', true);
  6072. $waybill = $this->input->post('waybill', true);
  6073. $category = $this->input->post('category', true);
  6074. $size = $this->input->post('size', true);
  6075. $grade = $this->input->post('grade', true);
  6076. $color = $this->input->post('color', true);
  6077. $lowe = $this->input->post('lowe', true);
  6078. $state = $this->input->post('state', true);
  6079. $label = $this->input->post('label', true);
  6080. $timetk = $this->input->post('ktime', true);
  6081. $timetj = $this->input->post('jtime', true);
  6082. $timetk = strtotime($timetk);
  6083. $timetj = strtotime($timetj);
  6084. $where = "1=1 ";
  6085. if ($timetk && $timetj) {
  6086. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6087. }
  6088. if ($sku) {
  6089. $where .= " and sku = '$sku'";
  6090. }
  6091. if ($bs != '') {
  6092. $where .= " and bs = '$bs'";
  6093. }
  6094. if ($number) {
  6095. $where .= " and number = '$number'";
  6096. }
  6097. if ($warehouse) {
  6098. $where .= " and warehouse = '$warehouse'";
  6099. }
  6100. if ($purchase) {
  6101. $where .= " and purchase = '$purchase'";
  6102. }
  6103. if ($orderinfo) {
  6104. $where .= " and orderinfo = '$orderinfo'";
  6105. }
  6106. if ($waybill) {
  6107. $where .= " and waybill = '$waybill'";
  6108. }
  6109. if ($category) {
  6110. $where .= " and features like '%-$category-%'";
  6111. }
  6112. if ($size) {
  6113. $where .= " and features like '%-$size-%'";
  6114. }
  6115. if ($grade) {
  6116. $where .= " and features like '%-$grade-%'";
  6117. }
  6118. if ($color) {
  6119. $where .= " and features like '%-$color-%'";
  6120. }
  6121. if ($lowe) {
  6122. $where .= " and features like '%-$lowe-%'";
  6123. }
  6124. if ($label) {
  6125. $where .= " and label = '$label'";
  6126. }
  6127. if ($state || $state == 0) {
  6128. $where .= " and state = '$state'";
  6129. }
  6130. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6131. //数据排序
  6132. $order_str = "enter desc";
  6133. if (empty($page)) {
  6134. $start = 0;
  6135. $perpage = 1;
  6136. } else {
  6137. $start = ($page - 1) * $perpage;
  6138. }
  6139. //取得信息列表
  6140. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6141. foreach ($info_list as $key => $value) {
  6142. $warehouse = $this->warehouse->read($value['warehouse']);
  6143. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6144. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6145. if ($value['state'] == 0) {
  6146. $info_list[$key]['state'] = "在库";
  6147. } else if ($value['state'] == 1) {
  6148. $info_list[$key]['state'] = "出库";
  6149. } else if ($value['state'] == 2) {
  6150. $info_list[$key]['state'] = "退库";
  6151. } else if ($value['state'] == 3) {
  6152. $info_list[$key]['state'] = "调拨中";
  6153. } else if ($value['state'] == 4) {
  6154. $info_list[$key]['state'] = "再加工";
  6155. } else if ($value['state'] == 5) {
  6156. $info_list[$key]['state'] = "维修中";
  6157. } else if ($value['state'] == 6) {
  6158. $info_list[$key]['state'] = "盘亏";
  6159. } else if ($value['state'] == 7) {
  6160. $info_list[$key]['state'] = "更换标签";
  6161. } else if ($value['state'] == 8) {
  6162. $info_list[$key]['state'] = "其它";
  6163. } else if ($value['state'] == 9) {
  6164. $info_list[$key]['state'] = "预设";
  6165. } else if ($value['state'] == 10) {
  6166. $info_list[$key]['state'] = "美店零售";
  6167. }
  6168. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6169. }
  6170. $total = $this->$ck->find_count($where);
  6171. $pagenum = ceil($total / $perpage);
  6172. $over = $total - ($start + $perpage);
  6173. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6174. echo json_encode($rows);
  6175. exit;
  6176. }
  6177. if (isset($post['tmsku'])) {
  6178. $time = time();
  6179. $tmsku = $this->input->post('tmsku', true);
  6180. //$post['shop'] = $this->input->post('shop',true);
  6181. $num = $this->input->post('num', true);
  6182. $rktype = $this->input->post('rktype', true);
  6183. if ($num > 200) {
  6184. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6185. exit;
  6186. }
  6187. if (!$rktype) {
  6188. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6189. }
  6190. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6191. /**
  6192. $wz = array();
  6193. foreach ($rk as $key=>$value)
  6194. {
  6195. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6196. }
  6197. if(count($wz) > 1)
  6198. {
  6199. $wz = array_values($wz);
  6200. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6201. }
  6202. **/
  6203. if (isset($rk[0]['purchase'])) {
  6204. $rk = $rk[0];
  6205. $j = 0;
  6206. $post['purchase'] = $rk['purchase'];
  6207. $post['warehouse'] = $rk['warehouse'];
  6208. $post['retreatwarehouse'] = $rk['warehouse'];
  6209. $post['sku'] = $rk['sku'];
  6210. $post['number'] = $rk['number'];
  6211. $post['features'] = $rk['features'];
  6212. $post['title'] = $rk['title'];
  6213. $post['enter'] = $time;
  6214. $post['time'] = $time;
  6215. $post['bs'] = 1;
  6216. $post['shop'] = $rk['shop'];
  6217. $post['details'] = $rk['details'];
  6218. $post['cpid'] = $rk['cpid'];
  6219. $post['cpbz'] = $rk['cpbz'];
  6220. $post['rktype'] = $rktype;
  6221. $warehouse = $this->warehouse->read($rk['warehouse']);
  6222. if ($warehouse['bdck'] == '') {
  6223. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6224. exit;
  6225. } else {
  6226. $bdck = $warehouse['bdck'];
  6227. }
  6228. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6229. if (isset($pdwz['details'])) {
  6230. if ($pdwz['details'] != $post['details']) {
  6231. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6232. }else{
  6233. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6234. exit;
  6235. }
  6236. }
  6237. }
  6238. $post['featurespp'] = $rk['featurespp'];
  6239. if ($post['warehouse'] == '5') {
  6240. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6241. if ($yza) {
  6242. if ($post['features'] != $yza[0]['features']) {
  6243. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6244. exit;
  6245. }
  6246. }
  6247. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6248. if ($yzb) {
  6249. if ($post['sku'] != $yzb[0]['sku']) {
  6250. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6251. exit;
  6252. }
  6253. }
  6254. }
  6255. for ($i = 0; $i < $num; $i++) {
  6256. $post['label'] = time() . rand(100, 999) . $i;
  6257. if ($this->$bdck->insert($post)) {
  6258. $j++;
  6259. }
  6260. }
  6261. /**
  6262. if($post['warehouse'] != 12)
  6263. {
  6264. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6265. }
  6266. **/
  6267. $this->whlabelscanlog->insert([
  6268. 'shop'=>$rk['shop'],
  6269. 'type'=>1,
  6270. 'purchase'=>$rk['purchase'],
  6271. 'sku'=>$rk['sku'],
  6272. 'features'=>$rk['features'],
  6273. 'title'=>$rk['title'],
  6274. 'label'=>$rk['label'],
  6275. 'warehouse'=>$rk['warehouse'],
  6276. 'wlid'=>$rk['id'],
  6277. 'num'=>$num,
  6278. 'addtime'=>time()
  6279. ]);
  6280. if ($j == $num) {
  6281. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6282. exit;
  6283. } else {
  6284. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6285. exit;
  6286. }
  6287. } else {
  6288. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6289. exit;
  6290. }
  6291. }
  6292. $this->_Template('whlabel_printrk', $this->data);
  6293. }
  6294. public function _printxzrk($arg_array)
  6295. {
  6296. $post = $this->input->post(NULL, TRUE);
  6297. if (isset($post['wzid'])) {
  6298. $time = time();
  6299. $id = $this->input->post('wzid', true);
  6300. //$post['shop'] = $this->input->post('shop',true);
  6301. $num = 1;
  6302. $rk = $this->whlabellabel->read($id);
  6303. if (isset($rk['purchase'])) {
  6304. $x = 0;
  6305. $post['purchase'] = $rk['purchase'];
  6306. $post['warehouse'] = $rk['warehouse'];
  6307. $post['retreatwarehouse'] = $rk['warehouse'];
  6308. $post['sku'] = $rk['sku'];
  6309. $post['number'] = $rk['number'];
  6310. $post['features'] = $rk['features'];
  6311. $post['title'] = $rk['title'];
  6312. $post['enter'] = $time;
  6313. $post['time'] = $time;
  6314. $post['bs'] = 1;
  6315. $post['shop'] = $rk['shop'];
  6316. $post['details'] = $rk['details'];
  6317. $post['cpid'] = $rk['cpid'];
  6318. $post['cpbz'] = $rk['cpbz'];
  6319. $warehouse = $this->warehouse->read($rk['warehouse']);
  6320. if ($warehouse['bdck'] == '') {
  6321. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6322. exit;
  6323. } else {
  6324. $bdck = $warehouse['bdck'];
  6325. }
  6326. $post['featurespp'] = $rk['featurespp'];
  6327. $this->db->trans_begin();
  6328. for ($i = 0; $i < $num; $i++) {
  6329. $post['label'] = time() . rand(100, 999) . $i;
  6330. $this->$bdck->insert($post);
  6331. }
  6332. /**
  6333. if($post['warehouse'] != 12)
  6334. {
  6335. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6336. }
  6337. **/
  6338. if ($this->db->trans_status() === TRUE) {
  6339. $this->db->trans_commit();
  6340. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6341. exit;
  6342. } else {
  6343. $this->db->trans_rollback();
  6344. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6345. exit;
  6346. }
  6347. } else {
  6348. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6349. exit;
  6350. }
  6351. }
  6352. }
  6353. public function _printck($arg_array)
  6354. {
  6355. $prc = array();
  6356. $purchase = $this->purchase->find_all();
  6357. foreach ($purchase as $k => $v) {
  6358. $prc[$v['id']] = $v['title'];
  6359. }
  6360. $post = $this->input->post(NULL, TRUE);
  6361. if (isset($post['page'])) {
  6362. $page = $this->input->post('page', true);
  6363. $perpage = $this->input->post('perpage', true);
  6364. $sku = $this->input->post('sku', true);
  6365. $bs = $this->input->post('bs', true);
  6366. $number = $this->input->post('number', true);
  6367. $warehouse = $this->input->post('warehouse', true);
  6368. $purchase = $this->input->post('purchase', true);
  6369. $orderinfo = $this->input->post('orderinfo', true);
  6370. $waybill = $this->input->post('waybill', true);
  6371. $category = $this->input->post('category', true);
  6372. $size = $this->input->post('size', true);
  6373. $grade = $this->input->post('grade', true);
  6374. $color = $this->input->post('color', true);
  6375. $lowe = $this->input->post('lowe', true);
  6376. $state = $this->input->post('state', true);
  6377. $label = $this->input->post('label', true);
  6378. $timetk = $this->input->post('ktime', true);
  6379. $timetj = $this->input->post('jtime', true);
  6380. $timetk = strtotime($timetk);
  6381. $timetj = strtotime($timetj);
  6382. $where = "state=1 ";
  6383. if ($timetk && $timetj) {
  6384. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6385. }
  6386. if ($sku) {
  6387. $where .= " and sku = '$sku'";
  6388. }
  6389. if ($bs != '') {
  6390. $where .= " and bs = '$bs'";
  6391. }
  6392. if ($number) {
  6393. $where .= " and number = '$number'";
  6394. }
  6395. if ($warehouse) {
  6396. $where .= " and warehouse = '$warehouse'";
  6397. }
  6398. if ($purchase) {
  6399. $where .= " and purchase = '$purchase'";
  6400. }
  6401. if ($orderinfo) {
  6402. $where .= " and orderinfo = '$orderinfo'";
  6403. }
  6404. if ($waybill) {
  6405. $where .= " and waybill = '$waybill'";
  6406. }
  6407. if ($category) {
  6408. $where .= " and features like '%-$category-%'";
  6409. }
  6410. if ($size) {
  6411. $where .= " and features like '%-$size-%'";
  6412. }
  6413. if ($grade) {
  6414. $where .= " and features like '%-$grade-%'";
  6415. }
  6416. if ($color) {
  6417. $where .= " and features like '%-$color-%'";
  6418. }
  6419. if ($lowe) {
  6420. $where .= " and features like '%-$lowe-%'";
  6421. }
  6422. if ($label) {
  6423. $where .= " and label = '$label'";
  6424. }
  6425. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6426. //数据排序
  6427. $order_str = "outk desc";
  6428. if (empty($page)) {
  6429. $start = 0;
  6430. $perpage = 1;
  6431. } else {
  6432. $start = ($page - 1) * $perpage;
  6433. }
  6434. //取得信息列表
  6435. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6436. foreach ($info_list as $key => $value) {
  6437. $warehouse = $this->warehouse->read($value['warehouse']);
  6438. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6439. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6440. if ($value['state'] == 0) {
  6441. $info_list[$key]['state'] = "在库";
  6442. } else if ($value['state'] == 1) {
  6443. $info_list[$key]['state'] = "出库";
  6444. } else if ($value['state'] == 2) {
  6445. $info_list[$key]['state'] = "退库";
  6446. } else if ($value['state'] == 3) {
  6447. $info_list[$key]['state'] = "调拨中";
  6448. } else if ($value['state'] == 4) {
  6449. $info_list[$key]['state'] = "再加工";
  6450. } else if ($value['state'] == 5) {
  6451. $info_list[$key]['state'] = "维修中";
  6452. } else if ($value['state'] == 6) {
  6453. $info_list[$key]['state'] = "盘亏";
  6454. } else if ($value['state'] == 7) {
  6455. $info_list[$key]['state'] = "更换标签";
  6456. } else if ($value['state'] == 8) {
  6457. $info_list[$key]['state'] = "其它";
  6458. } else if ($value['state'] == 9) {
  6459. $info_list[$key]['state'] = "预设";
  6460. } else if ($value['state'] == 10) {
  6461. $info_list[$key]['state'] = "美店零售";
  6462. }
  6463. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6464. }
  6465. $total = $this->$ck->find_count($where);
  6466. $pagenum = ceil($total / $perpage);
  6467. $over = $total - ($start + $perpage);
  6468. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6469. echo json_encode($rows);
  6470. exit;
  6471. }
  6472. if (isset($post['tmsku'])) {
  6473. $time = time();
  6474. $tmsku = $this->input->post('tmsku', true);
  6475. //$post['shop'] = $this->input->post('shop',true);
  6476. $num = $this->input->post('num', true);
  6477. $cktype = $this->input->post('cktype', true);
  6478. $label = $this->whlabellabel->get_label($tmsku);
  6479. if (!$cktype) {
  6480. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6481. }
  6482. if (!isset($label['warehouse'])) {
  6483. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6484. exit;
  6485. }
  6486. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6487. $extra_where = "";
  6488. if(!empty($label['details'])){
  6489. $extra_where .= " and details = '" . $label['details'] . "'";
  6490. }
  6491. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6492. if (stripos($label['features'], '-126-') !== false) {
  6493. $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);
  6494. } else {
  6495. $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);
  6496. }
  6497. $j = 0;
  6498. if (count($ck) >= $num) {
  6499. for ($i = 0; $i < $num; $i++) {
  6500. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6501. {
  6502. $j++;
  6503. }
  6504. }
  6505. $this->whlabelscanlog->insert([
  6506. 'shop'=>$label['shop'],
  6507. 'type'=>2,
  6508. 'purchase'=>$label['purchase'],
  6509. 'sku'=>$label['sku'],
  6510. 'features'=>$label['features'],
  6511. 'title'=>$label['title'],
  6512. 'label'=>$label['label'],
  6513. 'warehouse'=>$label['warehouse'],
  6514. 'wlid'=>$label['id'],
  6515. 'num'=>$num,
  6516. 'addtime'=>time()
  6517. ]);
  6518. if ($j == $num) {
  6519. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6520. exit;
  6521. } else {
  6522. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6523. exit;
  6524. }
  6525. } else {
  6526. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6527. exit;
  6528. }
  6529. }
  6530. if(isset($_SESSION['api']))
  6531. {
  6532. $user = $this->user->get_api($_SESSION['api']);
  6533. if(in_array($user['power'],[1,27])){
  6534. $vip = 1;
  6535. }
  6536. }
  6537. else
  6538. {
  6539. $vip = 0;
  6540. header('Location: /');exit;
  6541. }
  6542. $this->data['vip'] = $vip;
  6543. $this->_Template('whlabel_printck', $this->data);
  6544. }
  6545. public function _printexcel()
  6546. {
  6547. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6548. $config['upload_path'] = '.' . $dir;
  6549. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6550. $config['allowed_types'] = 'xls|xlsx|csv';
  6551. $config['max_size'] = 10240;
  6552. $this->load->library('upload', $config);
  6553. $this->upload->initialize($config);
  6554. if ($this->upload->do_upload('userfile')) {
  6555. $full_path = $dir . $this->upload->data('file_name');
  6556. $fileName = '.' . $full_path;
  6557. if (!file_exists($fileName)) {
  6558. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6559. exit;
  6560. } else {
  6561. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6562. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6563. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6564. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6565. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6566. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6567. ++$column; //如果列数大于26行
  6568. $list = array();
  6569. for ($i = 2; $i <= $row; $i++) // 行数循环
  6570. {
  6571. $data = array();
  6572. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6573. {
  6574. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6575. }
  6576. $list[] = $data;
  6577. }
  6578. }
  6579. $ed = array();
  6580. $i = 0;
  6581. $j = 0;
  6582. $dcdata = array();
  6583. $yc = '';
  6584. $cmf_arr = array_column($list, '1');
  6585. array_multisort($cmf_arr, SORT_ASC, $list);
  6586. foreach ($list as $key => $value) {
  6587. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6588. if ($typeclass) {
  6589. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6590. } else {
  6591. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6592. $i++;
  6593. continue;
  6594. }
  6595. }
  6596. if ($i > 0) {
  6597. $yc = $i . '条异常';
  6598. }
  6599. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6600. exit;
  6601. }
  6602. }
  6603. public function _uck()
  6604. {
  6605. if (isset($_GET['excel'])) {
  6606. $tc = array();
  6607. $typeclass = $this->typeclass->find_all();
  6608. foreach ($typeclass as $v) {
  6609. $tc[$v['id']] = $v['zh'];
  6610. }
  6611. $data = array();
  6612. $t = array();
  6613. $rq = '';
  6614. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6615. $ts = $ts / (24 * 3600);
  6616. for ($i = 0; $i < $ts; $i++) {
  6617. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6618. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6619. }
  6620. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6621. foreach ($info_list as $k => $v) {
  6622. $features = explode('-', trim($v['features'], '-'));
  6623. if (!isset($features[3]) || !isset($features[4])) {
  6624. continue;
  6625. }
  6626. $data[$k][0] = $tc[$features[0]]; //类型
  6627. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6628. $data[$k][2] = $tc[$features[4]]; //曲度
  6629. $data[$k][3] = '';
  6630. if (isset($data[$k][1])) {
  6631. $data[$k][3] .= $data[$k][1];
  6632. }
  6633. if (isset($data[$k][2])) {
  6634. $data[$k][3] .= $data[$k][2];
  6635. }
  6636. if (isset($features[5])) {
  6637. $data[$k][3] .= $tc[$features[5]];
  6638. }
  6639. if (isset($features[2])) {
  6640. $data[$k][3] .= $tc[$features[2]];
  6641. }
  6642. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6643. $data[$k][4] = $v['sku'];
  6644. $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())) . '))'); //月初库存
  6645. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6646. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6647. $ztrq = '';
  6648. $ztsl = '';
  6649. if (count($zt) > 0) {
  6650. foreach ($zt as $vv) {
  6651. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6652. $ztsl .= $vv['num'] . '<br>';
  6653. }
  6654. }
  6655. $data[$k][] = trim($ztsl, '<br>');
  6656. $data[$k][] = trim($ztrq, '<br>');
  6657. $byck = 0;
  6658. foreach ($t as $vv) {
  6659. $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));
  6660. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6661. $byck += $sl;
  6662. }
  6663. $data[$k][] = ($byck > 0) ? $byck : '';
  6664. }
  6665. $title = "详情 " . date("Y-m-d", time());
  6666. $titlename = "<table border=1>
  6667. <tr align='center'>
  6668. <td>类别</td>
  6669. <td>颜色</td>
  6670. <td>曲度</td>
  6671. <td>名称</td>
  6672. <td>SKU</td>
  6673. <td>月初库存</td>
  6674. <td>剩余库存</td>
  6675. <td>在途数量</td>
  6676. <td>预达日期</td>" .
  6677. $rq
  6678. . "<td>本月出库</td></tr>
  6679. </table>";
  6680. $filename = $title . ".xls";
  6681. $tail = "";
  6682. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6683. }
  6684. }
  6685. public function _whlabelexcelzh()
  6686. {
  6687. if (isset($_GET['excel'])) {
  6688. $where = "sku != 'Preset'";
  6689. //数据排序
  6690. $order_str = "id desc";
  6691. if (empty($page)) {
  6692. $start = 0;
  6693. $perpage = 1;
  6694. } else {
  6695. $start = ($page - 1) * $perpage;
  6696. }
  6697. $category = $this->input->get('category', true);
  6698. $warehouse = $this->input->get('warehouse', true);
  6699. $excelid = $this->input->get('sid', true);
  6700. if ($category) {
  6701. $where .= " and features like '%-$category-%'";
  6702. }
  6703. if ($warehouse) {
  6704. $where .= " and warehouse = '$warehouse'";
  6705. }
  6706. $xzid = '';
  6707. if ($excelid) {
  6708. $excelid = explode(',', trim($excelid, ','));
  6709. foreach ($excelid as $key => $value) {
  6710. $xzid .= " id = " . $value . " or";
  6711. }
  6712. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6713. }
  6714. //取得信息列表
  6715. /**
  6716. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6717. $rows = array();$list = array();
  6718. foreach ($info_list as $key=>$value)
  6719. {
  6720. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6721. }
  6722. **/
  6723. $list = array();
  6724. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6725. foreach ($rows as $key => $value) {
  6726. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6727. $zh = '';
  6728. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6729. foreach ($zt as $v) {
  6730. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6731. }
  6732. $zt = array_sum(array_column($zt, 'num'));
  6733. $number = $value['number'];
  6734. $ftime = time() - 15 * 24 * 3600;
  6735. $warehouse = $this->warehouse->read($value['warehouse']);
  6736. $rows[$key]['warehouse'] = $warehouse['title'];
  6737. $rows[$key]['number'] = $c;
  6738. $rows[$key]['features'] = $zh;
  6739. $rows[$key]['hb'] = $c + $zt;
  6740. }
  6741. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6742. $titlename = "<table border=1>
  6743. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6744. <tr align='center'>
  6745. <td>仓库</td>
  6746. <td>SKU</td>
  6747. <td>产品</td>
  6748. <td>库存数量</td>
  6749. <td>在途数量及预达日期</td>
  6750. <td>在途+库存数量</td>
  6751. </tr>
  6752. </table>";
  6753. $filename = $title . ".xls";
  6754. $tail = "";
  6755. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6756. }
  6757. if (isset($_GET['excel'])) {
  6758. $warehouse = $this->input->get('warehouse', true);
  6759. $sku = $this->input->get('sku', true);
  6760. $cz = $this->input->get('cz', true);
  6761. $text = $this->input->post('text', true);
  6762. $xztime = $this->input->get('xztime', true);
  6763. $timetk = $this->input->get('timetk', true);
  6764. $timetj = $this->input->get('timetj', true);
  6765. $timetk = strtotime($timetk);
  6766. $timetj = strtotime($timetj);
  6767. $where = "time = '0' ";
  6768. if ($warehouse) {
  6769. $where .= " and warehouse = '$warehouse'";
  6770. }
  6771. if ($sku) {
  6772. $where .= " and sku = '$sku'";
  6773. }
  6774. if ($text) {
  6775. $where .= " and text like '%$text%'";
  6776. }
  6777. if ($cz != '') {
  6778. $where .= " and cz = '$cz'";
  6779. }
  6780. if ($timetk && $timetj) {
  6781. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6782. }
  6783. //数据排序
  6784. $order_str = $xztime . " desc";
  6785. //取得信息列表
  6786. $zh = array();
  6787. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6788. foreach ($info_list as $v) {
  6789. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6790. $warehouse = $this->warehouse->read($v['warehouse']);
  6791. $v['warehouse'] = $warehouse['title'];
  6792. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6793. $v['stime'] = date('Y-m-d', $v['stime']);
  6794. if (isset($zh[$v['features']])) {
  6795. $zh[$v['features']]['num'] += $v['num'];
  6796. } else {
  6797. $zh[$v['features']] = $v;
  6798. }
  6799. $zh[$v['features']]['features'] = $c;
  6800. }
  6801. $title = "在途数据" . date('Y-m-d', time());
  6802. $titlename = "<table border=1>
  6803. <tr align='center'>
  6804. <td>仓库</td>
  6805. <td>SKU</td>
  6806. <td>名称</td>
  6807. <td>在途数量</td>
  6808. <td>库存数量</td>
  6809. <td>添加在途日期</td>
  6810. <td>预达日期</td>
  6811. <td>备注</td>
  6812. </tr>
  6813. </table>";
  6814. $filename = $title . ".xls";
  6815. $tail = "";
  6816. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6817. }
  6818. }
  6819. public function _fc()
  6820. {
  6821. $vip = 0;
  6822. if (isset($_SESSION['api'])) {
  6823. $user = $this->user->get_api($_SESSION['api']);
  6824. if ($user['vip'] == 1) {
  6825. $vip = 1;
  6826. }
  6827. } else {
  6828. header('Location: /');
  6829. exit;
  6830. }
  6831. $post = $this->input->post(NULL, TRUE);
  6832. if (isset($post['page'])) {
  6833. $page = $this->input->post('page', true);
  6834. $perpage = $this->input->post('perpage', true);
  6835. $category = $this->input->post('category', true);
  6836. $size = $this->input->post('size', true);
  6837. $grade = $this->input->post('grade', true);
  6838. $color = $this->input->post('color', true);
  6839. $lowe = $this->input->post('lowe', true);
  6840. $sku = $this->input->post('sku');
  6841. $title = $this->input->post('title');
  6842. $warehouse = $this->input->post('warehouse', true);
  6843. $usa = $this->input->post('usa', true);
  6844. $purchase = $this->input->post('purchase', true);
  6845. $lacetype = $this->input->post('lacetype', true);
  6846. $haircap = $this->input->post('haircap', true);
  6847. $density = $this->input->post('density', true);
  6848. $details = $this->input->post('details', true);
  6849. $state = $this->input->post('state', true);
  6850. $ktime = $this->input->post('ktime', true);
  6851. $jtime = $this->input->post('jtime', true);
  6852. $ktime = strtotime($ktime);
  6853. $jtime = strtotime($jtime);
  6854. $where = "state = '11'";
  6855. $gj = "";
  6856. $ck = "";
  6857. if ($lacetype) {
  6858. $where .= " and features like '%-$lacetype-%'";
  6859. }
  6860. if ($category) {
  6861. $where .= " and features like '%-$category-%'";
  6862. }
  6863. if ($size) {
  6864. $where .= " and features like '%-$size-%'";
  6865. }
  6866. if ($grade) {
  6867. $where .= " and features like '%-$grade-%'";
  6868. }
  6869. if ($color) {
  6870. $where .= " and features like '%-$color-%'";
  6871. }
  6872. if ($lowe) {
  6873. $where .= " and features like '%-$lowe-%'";
  6874. }
  6875. if ($haircap) {
  6876. $where .= " and features like '%-$haircap-%'";
  6877. }
  6878. if ($density) {
  6879. $where .= " and features like '%-$density-%'";
  6880. }
  6881. if ($usa) {
  6882. if (!$warehouse) {
  6883. $where .= " and (warehouse = '5' or warehouse = '8')";
  6884. }
  6885. }
  6886. if ($warehouse) {
  6887. $where .= " and warehouse = '$warehouse'";
  6888. }
  6889. if ($details) {
  6890. $where .= " and details = '$details'";
  6891. }
  6892. if ($purchase) {
  6893. $where .= " and purchase = '$purchase'";
  6894. }
  6895. if ($state) {
  6896. $where .= " and state = '$state'";
  6897. }
  6898. if ($ktime && $jtime) {
  6899. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6900. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6901. }
  6902. //数据排序
  6903. $order_str = "id desc";
  6904. if (empty($page)) {
  6905. $start = 0;
  6906. $perpage = 1;
  6907. } else {
  6908. $start = ($page - 1) * $perpage;
  6909. }
  6910. if ($sku) {
  6911. $sku = trim($sku, ' ');
  6912. $sku = trim($sku, ' ');
  6913. $where .= " and sku like '%$sku%'";
  6914. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6915. } else if ($title) {
  6916. $title = trim($title, ' ');
  6917. $title = trim($title, ' ');
  6918. $where .= " and title like '%$title%'";
  6919. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6920. } else {
  6921. //$where .= " and time > '$ktime' and time < '$jtime'";
  6922. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6923. }
  6924. //取得信息列表
  6925. $rows = array();
  6926. $list = array();
  6927. foreach ($info_list as $key => $value) {
  6928. $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'] . '"');
  6929. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6930. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6931. $warehouse = $this->warehouse->read($value['warehouse']);
  6932. $info_list[$key]['warehouse'] = $warehouse['title'];
  6933. $info_list[$key]['number'] = $g;
  6934. $info_list[$key]['features'] = $x;
  6935. $info_list[$key]['x'] = $s;
  6936. }
  6937. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6938. $pagenum = ceil($total / $perpage);
  6939. $over = $total - ($start + $perpage);
  6940. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6941. echo json_encode($rows);
  6942. exit;
  6943. }
  6944. $this->data['vip'] = $vip;
  6945. $this->_Template('whlabel_fc', $this->data);
  6946. }
  6947. public function _fcmb()
  6948. {
  6949. $where = "sku != 'Preset'";
  6950. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6951. foreach ($rows as $k => $v) {
  6952. $warehouse = $this->warehouse->read($v['warehouse']);
  6953. $rows[$k]['warehouse'] = $warehouse['title'];
  6954. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6955. $rows[$k]['t'] = '';
  6956. $rows[$k]['n'] = '';
  6957. }
  6958. $title = "封货产品数据导入模板";
  6959. $titlename = "<table border=1>
  6960. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6961. <tr align='center'>
  6962. <td>仓库</td>
  6963. <td>SKU</td>
  6964. <td>产品</td>
  6965. <td>封存产品总数量</td>
  6966. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6967. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6968. </tr>
  6969. </table>";
  6970. $filename = $title . ".xls";
  6971. $tail = "";
  6972. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6973. }
  6974. public function _fcexcel()
  6975. {
  6976. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6977. $config['upload_path'] = '.' . $dir;
  6978. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6979. $config['allowed_types'] = 'xls|xlsx|csv';
  6980. $config['max_size'] = 10240;
  6981. $this->load->library('upload', $config);
  6982. $this->upload->initialize($config);
  6983. if ($this->upload->do_upload('userfile')) {
  6984. $full_path = $dir . $this->upload->data('file_name');
  6985. $fileName = '.' . $full_path;
  6986. if (!file_exists($fileName)) {
  6987. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6988. exit;
  6989. } else {
  6990. libxml_use_internal_errors(true);
  6991. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6992. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6993. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6994. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6995. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6996. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6997. ++$column; //如果列数大于26行
  6998. $list = array();
  6999. for ($i = 2; $i <= $row; $i++) // 行数循环
  7000. {
  7001. $data = array();
  7002. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7003. {
  7004. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7005. }
  7006. $list[] = $data;
  7007. }
  7008. }
  7009. $i = 0;
  7010. $j = 0;
  7011. $ed = array();
  7012. foreach ($list as $key => $value) {
  7013. $time = time();
  7014. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7015. continue;
  7016. }
  7017. $warehouse = $this->warehouse->get_title($value['0']);
  7018. $sku = $value['1'];
  7019. $type = $value['4']; //调整方式0扣减1删除
  7020. $num = $value['5']; //调整数量
  7021. //$text = $value['4'];//扣减说明
  7022. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7023. if (!$d) //如果没有这个SKU
  7024. {
  7025. $ed[] = array($sku . '-库存中不存在此SKU');
  7026. $j++;
  7027. continue;
  7028. }
  7029. if (!isset($warehouse['id'])) {
  7030. $ed[] = array($sku . '-仓库名错误!');
  7031. $j++;
  7032. continue;
  7033. }
  7034. if ($type == 1 || $type == 2) //扣减库存
  7035. {
  7036. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7037. if (count($data) < abs($num)) {
  7038. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7039. $j++;
  7040. continue;
  7041. }
  7042. if ($type == 1) //转入库存
  7043. {
  7044. for ($i = 0; $i < abs($num); $i++) {
  7045. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7046. }
  7047. } else if ($type == 2) //删除
  7048. {
  7049. for ($i = 0; $i < abs($num); $i++) {
  7050. $this->whlabel->remove($data[$i]['id']);
  7051. }
  7052. }
  7053. } else if ($type == 0) //增加库存
  7054. {
  7055. $post['sku'] = $d['sku'];
  7056. $post['shop'] = '';
  7057. $post['warehouse'] = $warehouse['id'];
  7058. $post['purchase'] = $d['purchase'];
  7059. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7060. $post['state'] = 11;
  7061. $post['title'] = $d['title'];
  7062. $post['number'] = $d['number'];
  7063. $post['features'] = $d['features'];
  7064. $post['enter'] = $time;
  7065. $post['time'] = $time; //操作时间
  7066. for ($i = 0; $i < $num; $i++) {
  7067. $post['label'] = time() . rand(100, 999) . $i;
  7068. $this->whlabel->insert($post);
  7069. }
  7070. }
  7071. sleep(1); //防止入库时间一样,需要延迟1秒
  7072. }
  7073. if ($j > 0) {
  7074. $tt = date('Ymd', time());
  7075. $title = '库存导入错误信息-' . $tt;
  7076. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7077. $tail = "\n";
  7078. $filename = $title . ".xls";
  7079. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7080. $dir = '/data/excel/' . $time . '/';
  7081. $file_name = 'error_' . $time . rand(1000, 9999);
  7082. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7083. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7084. fwrite($myfile, $ecl);
  7085. fclose($myfile);
  7086. $error = $dir . $file_name . '.xls';
  7087. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7088. exit;
  7089. } else {
  7090. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7091. exit;
  7092. }
  7093. }
  7094. }
  7095. public function _fcjxc($arg_array)
  7096. {
  7097. if (isset($_GET['excel'])) {
  7098. $category = $this->input->get('category', true);
  7099. $size = $this->input->get('size', true);
  7100. $grade = $this->input->get('grade', true);
  7101. $color = $this->input->get('color', true);
  7102. $lowe = $this->input->get('lowe', true);
  7103. $sku = $this->input->get('sku');
  7104. $title = $this->input->get('title');
  7105. $warehouse = $arg_array[0];
  7106. $usa = $this->input->get('usa', true);
  7107. $purchase = $this->input->get('purchase', true);
  7108. $lacetype = $this->input->get('lacetype', true);
  7109. $haircap = $this->input->get('haircap', true);
  7110. $density = $this->input->get('density', true);
  7111. $title = $this->input->get('title', true);
  7112. $state = $this->input->get('state', true);
  7113. $ktime = $this->input->get('ktime', true);
  7114. $jtime = $this->input->get('jtime', true);
  7115. $where = "state=11";
  7116. $gj = "";
  7117. $ck = "";
  7118. if ($lacetype) {
  7119. $where .= " and features like '%-$lacetype-%'";
  7120. }
  7121. if ($category) {
  7122. $where .= " and features like '%-$category-%'";
  7123. }
  7124. if ($size) {
  7125. $where .= " and features like '%-$size-%'";
  7126. }
  7127. if ($grade) {
  7128. $where .= " and features like '%-$grade-%'";
  7129. }
  7130. if ($color) {
  7131. $where .= " and features like '%-$color-%'";
  7132. }
  7133. if ($lowe) {
  7134. $where .= " and features like '%-$lowe-%'";
  7135. }
  7136. if ($haircap) {
  7137. $where .= " and features like '%-$haircap-%'";
  7138. }
  7139. if ($density) {
  7140. $where .= " and features like '%-$density-%'";
  7141. }
  7142. if ($usa) {
  7143. if (!$warehouse) {
  7144. $where .= " and (warehouse = '5' or warehouse = '8')";
  7145. }
  7146. }
  7147. if ($warehouse) {
  7148. $where .= " and warehouse = '$warehouse'";
  7149. }
  7150. if ($purchase) {
  7151. $where .= " and purchase = '$purchase'";
  7152. }
  7153. if ($state) {
  7154. $where .= " and state = '$state'";
  7155. }
  7156. $order_str = "id desc";
  7157. if ($sku) {
  7158. $sku = trim($sku, ' ');
  7159. $sku = trim($sku, ' ');
  7160. $where .= " and sku like '%$sku%'";
  7161. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7162. } else if ($title) {
  7163. $title = trim($title, ' ');
  7164. $title = trim($title, ' ');
  7165. $where .= " and title like '%$title%'";
  7166. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7167. } else {
  7168. //$where .= " and time > '$ktime' and time < '$jtime'";
  7169. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7170. }
  7171. //取得信息列表
  7172. $rows = array();
  7173. $list = array();
  7174. foreach ($info_list as $key => $value) {
  7175. $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'] . '"');
  7176. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7177. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7178. $rows[$key] = $value;
  7179. $warehouse = $this->warehouse->read($value['warehouse']);
  7180. $rows[$key]['warehouse'] = $warehouse['title'];
  7181. $rows[$key]['features'] = $g;
  7182. $rows[$key]['a'] = $x;
  7183. $rows[$key]['b'] = $s;
  7184. }
  7185. $title = "总统计表";
  7186. $titlename = "<table border=1>
  7187. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7188. <tr align='center'>
  7189. <td>仓库</td>
  7190. <td>SKU</td>
  7191. <td>产品名称</td>
  7192. <td>录入总量</td>
  7193. <td>取出总量</td>
  7194. <td>剩余总量</td>
  7195. </tr>
  7196. </table>";
  7197. $filename = $title . ".xls";
  7198. $tail = "";
  7199. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7200. }
  7201. $vip = 0;
  7202. if (isset($_SESSION['api'])) {
  7203. $user = $this->user->get_api($_SESSION['api']);
  7204. if ($user['vip'] == 1) {
  7205. $vip = 1;
  7206. }
  7207. } else {
  7208. header('Location: /');
  7209. exit;
  7210. }
  7211. $post = $this->input->post(NULL, TRUE);
  7212. if (isset($post['page'])) {
  7213. $page = $this->input->post('page', true);
  7214. $perpage = $this->input->post('perpage', true);
  7215. $category = $this->input->post('category', true);
  7216. $size = $this->input->post('size', true);
  7217. $grade = $this->input->post('grade', true);
  7218. $color = $this->input->post('color', true);
  7219. $lowe = $this->input->post('lowe', true);
  7220. $sku = $this->input->post('sku');
  7221. $title = $this->input->post('title');
  7222. $warehouse = $arg_array[0];
  7223. $usa = $this->input->post('usa', true);
  7224. $purchase = $this->input->post('purchase', true);
  7225. $lacetype = $this->input->post('lacetype', true);
  7226. $haircap = $this->input->post('haircap', true);
  7227. $density = $this->input->post('density', true);
  7228. $title = $this->input->post('title', true);
  7229. $state = $this->input->post('state', true);
  7230. $ktime = $this->input->post('ktime', true);
  7231. $jtime = $this->input->post('jtime', true);
  7232. $ktime = strtotime($ktime);
  7233. $jtime = strtotime($jtime);
  7234. $where = "state=11";
  7235. $gj = "";
  7236. $ck = "";
  7237. if ($lacetype) {
  7238. $where .= " and features like '%-$lacetype-%'";
  7239. }
  7240. if ($category) {
  7241. $where .= " and features like '%-$category-%'";
  7242. }
  7243. if ($size) {
  7244. $where .= " and features like '%-$size-%'";
  7245. }
  7246. if ($grade) {
  7247. $where .= " and features like '%-$grade-%'";
  7248. }
  7249. if ($color) {
  7250. $where .= " and features like '%-$color-%'";
  7251. }
  7252. if ($lowe) {
  7253. $where .= " and features like '%-$lowe-%'";
  7254. }
  7255. if ($haircap) {
  7256. $where .= " and features like '%-$haircap-%'";
  7257. }
  7258. if ($density) {
  7259. $where .= " and features like '%-$density-%'";
  7260. }
  7261. if ($usa) {
  7262. if (!$warehouse) {
  7263. $where .= " and (warehouse = '5' or warehouse = '8')";
  7264. }
  7265. }
  7266. if ($warehouse) {
  7267. $where .= " and warehouse = '$warehouse'";
  7268. }
  7269. if ($purchase) {
  7270. $where .= " and purchase = '$purchase'";
  7271. }
  7272. if ($state) {
  7273. $where .= " and state = '$state'";
  7274. }
  7275. if ($ktime && $jtime) {
  7276. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7277. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7278. }
  7279. //数据排序
  7280. $order_str = "id desc";
  7281. $xs = 0;
  7282. $rows = array();
  7283. $list = array();
  7284. if (empty($page)) {
  7285. $start = 0;
  7286. $perpage = 1;
  7287. } else {
  7288. $start = ($page - 1) * $perpage;
  7289. }
  7290. if ($sku || $title) {
  7291. if ($title) {
  7292. $title = trim($title, ' ');
  7293. $title = trim($title, ' ');
  7294. $where .= " and title like '%$title%'";
  7295. } else {
  7296. $sku = trim($sku, ' ');
  7297. $sku = trim($sku, ' ');
  7298. $where .= " and sku like '%$sku%'";
  7299. }
  7300. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7301. foreach ($info_list as $key => $value) {
  7302. $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'] . '"');
  7303. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7304. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7305. $rows[$key] = $value;
  7306. $warehouse = $this->warehouse->read($value['warehouse']);
  7307. $rows[$key]['warehouse'] = $warehouse['title'];
  7308. $rows[$key]['features'] = $g;
  7309. $rows[$key]['a'] = $x;
  7310. $rows[$key]['b'] = $s;
  7311. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7312. $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天销量
  7313. $yj = $c / ($xl / 30);
  7314. if ($yj < 7) {
  7315. $rows[$key]['y'] = round($yj) . '天销量';
  7316. } else {
  7317. $rows[$key]['y'] = '正常';
  7318. }
  7319. }
  7320. } else {
  7321. //$where .= " and time > '$ktime' and time < '$jtime'";
  7322. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7323. foreach ($info_list as $key => $value) {
  7324. $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'] . '"');
  7325. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7326. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7327. $zs[$key] = $value;
  7328. $warehouse = $this->warehouse->read($value['warehouse']);
  7329. $zs[$key]['warehouse'] = $warehouse['title'];
  7330. $zs[$key]['features'] = $g;
  7331. $zs[$key]['a'] = $x;
  7332. $zs[$key]['b'] = $s;
  7333. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7334. $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天销量
  7335. $yj = $c / ($xl / 30);
  7336. if ($yj < 7) {
  7337. $zs[$key]['y'] = round($yj) . '天销量';
  7338. $rows[$key] = $zs[$key];
  7339. }
  7340. }
  7341. }
  7342. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7343. $pagenum = ceil($total / $perpage);
  7344. $over = $total - ($start + $perpage);
  7345. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7346. echo json_encode($rows);
  7347. exit;
  7348. }
  7349. $this->data['arg_array'] = $arg_array[0];
  7350. $this->_Template('whlabel_fcjxc', $this->data);
  7351. }
  7352. public function _0kcdel()
  7353. {
  7354. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7355. $config['upload_path'] = '.' . $dir;
  7356. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7357. $config['allowed_types'] = 'xls|xlsx|csv';
  7358. $config['max_size'] = 10240;
  7359. $this->load->library('upload', $config);
  7360. $this->upload->initialize($config);
  7361. if ($this->upload->do_upload('userfile')) {
  7362. $full_path = $dir . $this->upload->data('file_name');
  7363. $fileName = '.' . $full_path;
  7364. if (!file_exists($fileName)) {
  7365. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7366. exit;
  7367. } else {
  7368. require_once "./data/excel/PHPExcel/IOFactory.php";
  7369. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7370. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7371. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7372. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7373. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7374. ++$column; //如果列数大于26行
  7375. $list = array();
  7376. for ($i = 2; $i <= $row; $i++) // 行数循环
  7377. {
  7378. $data = array();
  7379. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7380. {
  7381. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7382. }
  7383. $list[] = $data;
  7384. }
  7385. }
  7386. $i = 0;
  7387. $j = 0;
  7388. $ed = array();
  7389. foreach ($list as $key => $value) {
  7390. $time = time();
  7391. if ($value['0'] == "" || $value['1'] == "") {
  7392. continue;
  7393. }
  7394. $warehouse = $this->warehouse->get_title($value['0']);
  7395. $sku = $value['1'];
  7396. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7397. if (!$d) //如果没有这个SKU
  7398. {
  7399. $ed[] = array($sku . '-库存中不存在此SKU');
  7400. $j++;
  7401. continue;
  7402. }
  7403. if (!isset($warehouse['id'])) {
  7404. $ed[] = array($sku . '-仓库名错误!');
  7405. $j++;
  7406. continue;
  7407. }
  7408. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7409. if ($z < 1) {
  7410. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7411. foreach ($z as $v) {
  7412. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7413. if (count($zt) > 0) {
  7414. $ed[] = array($sku . '-有在途库存无法删除!');
  7415. $j++;
  7416. continue;
  7417. }
  7418. $this->whlabel->remove($v['id']);
  7419. }
  7420. } else {
  7421. $ed[] = array($sku . '-非0库存!');
  7422. $j++;
  7423. continue;
  7424. }
  7425. }
  7426. if ($j > 0) {
  7427. $tt = date('Ymd', time());
  7428. $title = '删除0库存错误信息-' . $tt;
  7429. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7430. $tail = "\n";
  7431. $filename = $title . ".xls";
  7432. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7433. $dir = '/data/excel/' . $time . '/';
  7434. $file_name = 'error_' . $time . rand(1000, 9999);
  7435. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7436. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7437. fwrite($myfile, $ecl);
  7438. fclose($myfile);
  7439. $error = $dir . $file_name . '.xls';
  7440. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7441. exit;
  7442. } else {
  7443. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7444. exit;
  7445. }
  7446. }
  7447. }
  7448. public function _gbhtype()
  7449. {
  7450. $post = $this->input->post(NULL, TRUE);
  7451. if (isset($post['s'])) {
  7452. $n = $this->input->post('n');
  7453. $d = $this->input->post('s');
  7454. if (!$d) {
  7455. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7456. exit;
  7457. }
  7458. $d = explode(',', trim($d, ','));
  7459. $t = $this->whlabel_type->read($n);
  7460. //循环删除记录
  7461. foreach ($d as $v) {
  7462. $u = $this->whlabel->read($v);
  7463. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7464. foreach ($data as $val) {
  7465. $this->whlabel->save(array('type' => $n), $val['id']);
  7466. }
  7467. }
  7468. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7469. }
  7470. }
  7471. //出库、退库导出
  7472. public function _dccrtype()
  7473. {
  7474. $classid = $this->classid->sku();
  7475. $pm = $classid;
  7476. $typeclass = array();
  7477. $tc = $this->typeclass->find_all();
  7478. foreach ($tc as $v) {
  7479. $typeclass[$v['id']] = $v;
  7480. }
  7481. $prc = array();
  7482. $purchase = $this->purchase->find_all();
  7483. foreach ($purchase as $k => $v) {
  7484. $prc[$v['id']] = $v['title'];
  7485. }
  7486. if (isset($_GET['sid'])) {
  7487. $wh = array();
  7488. $w = $this->warehouse->find_all('1=1', 'id,title');
  7489. foreach ($w as $v) {
  7490. $wh[$v['id']] = $v['title'];
  7491. }
  7492. $type = $this->input->get('excel', true);
  7493. $category = $this->input->get('category', true);
  7494. $size = $this->input->get('size', true);
  7495. $grade = $this->input->get('grade', true);
  7496. $color = $this->input->get('color', true);
  7497. $lowe = $this->input->get('lowe', true);
  7498. $sku = $this->input->get('sku', true);
  7499. $warehouse = $this->input->get('warehouse', true);
  7500. $lacetype = $this->input->get('lacetype', true);
  7501. $lacecolor = $this->input->get('lacecolor', true);
  7502. $density = $this->input->get('density', true);
  7503. $haircap = $this->input->get('haircap', true);
  7504. $purchase = $this->input->get('purchase', true);
  7505. $title = $this->input->get('title', true);
  7506. $state = $this->input->get('state', true);
  7507. $sid = $this->input->get('sid', true);
  7508. $ktime = $this->input->get('ktime', true);
  7509. $jtime = $this->input->get('jtime', true);
  7510. $ktime = strtotime($ktime);
  7511. $jtime = strtotime($jtime);
  7512. $where = "1=1";
  7513. $gj = "";
  7514. $ck = "";
  7515. if ($category) {
  7516. $where .= " and features like '%-$category-%'";
  7517. }
  7518. if ($size) {
  7519. $where .= " and features like '%-$size-%'";
  7520. }
  7521. if ($grade) {
  7522. $where .= " and features like '%-$grade-%'";
  7523. }
  7524. if ($color) {
  7525. $where .= " and features like '%-$color-%'";
  7526. }
  7527. if ($lowe) {
  7528. $where .= " and features like '%-$lowe-%'";
  7529. }
  7530. if ($warehouse) {
  7531. $where .= " and warehouse = '$warehouse'";
  7532. }
  7533. if ($purchase) {
  7534. $where .= " and purchase = '$purchase'";
  7535. }
  7536. if ($state) {
  7537. $where .= " and state = '$state'";
  7538. }
  7539. if ($lacetype) {
  7540. $where .= " and features like '%-$lacetype-%'";
  7541. }
  7542. if ($lacecolor) {
  7543. $where .= " and features like '%-$lacecolor-%'";
  7544. }
  7545. if ($density) {
  7546. $where .= " and features like '%-$density-%'";
  7547. }
  7548. if ($haircap) {
  7549. $where .= " and features like '%-$haircap-%'";
  7550. }
  7551. if ($title) {
  7552. $title = trim($title, ' ');
  7553. $title = trim($title, ' ');
  7554. $where .= " and title like '%$title%'";
  7555. }
  7556. if ($sku) {
  7557. $sku = trim($sku, ' ');
  7558. $sku = trim($sku, ' ');
  7559. $where .= " and sku like '%$sku%'";
  7560. }
  7561. if ($ktime && $jtime) {
  7562. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7563. }
  7564. $sidwhere = '';
  7565. if ($sid) {
  7566. $sd = "";
  7567. $s = explode(',', trim($sid, ','));
  7568. foreach ($s as $value) {
  7569. $sd .= " id = " . $value . " or";
  7570. }
  7571. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7572. }
  7573. //数据排序
  7574. $order_str = "time desc";
  7575. if (empty($page)) {
  7576. $start = 0;
  7577. $perpage = 1;
  7578. } else {
  7579. $start = ($page - 1) * $perpage;
  7580. }
  7581. $wh = array();
  7582. $w = $this->warehouse->find_all('1=1', 'id,title');
  7583. foreach ($w as $v) {
  7584. $wh[$v['id']] = $v['title'];
  7585. }
  7586. $wt = array();
  7587. $whlabel_type = $this->whlabel_type->find_all();
  7588. foreach ($whlabel_type as $v) {
  7589. $wt[$v['id']] = $v['title'];
  7590. }
  7591. $classid = $this->classid->sku();
  7592. $list = array();
  7593. $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');
  7594. foreach ($rows_r as $key => $value) {
  7595. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7596. $pm = $classid;
  7597. $jm = $classid;
  7598. $rows_r[$key]['enter'] = '入库';
  7599. $rows_r[$key]['time'] = $value['enter'];
  7600. if ($value['rktype'] == 1) {
  7601. $rows_r[$key]['rktype'] = '采购入库';
  7602. } else if ($value['rktype'] == 2) {
  7603. $rows_r[$key]['rktype'] = '盘盈调整';
  7604. } else if ($value['rktype'] == 3) {
  7605. $rows_r[$key]['rktype'] = '其他调整入库';
  7606. } else if ($value['rktype'] == 4) {
  7607. $rows_r[$key]['rktype'] = '其他调整入库';
  7608. } else if ($value['rktype'] == 5) {
  7609. $rows_r[$key]['rktype'] = '退库入库';
  7610. } else if ($value['rktype'] == 6) {
  7611. $rows_r[$key]['rktype'] = '退货可用入库';
  7612. } else if ($value['rktype'] == 7) {
  7613. $rows_r[$key]['rktype'] = '形态转换入库';
  7614. } else {
  7615. $rows_r[$key]['rktype'] = '';
  7616. }
  7617. $features = explode('-', trim($value['features'], '-'));
  7618. foreach ($features as $v) {
  7619. if (isset($typeclass[$v])) {
  7620. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7621. $pm[$typeclass[$v]['classid']] = $zh[0];
  7622. }
  7623. if (isset($typeclass[$v])) {
  7624. if (isset($jm[$typeclass[$v]['classid']])) {
  7625. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7626. }
  7627. }
  7628. }
  7629. $zh = implode(" ", $pm);
  7630. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7631. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7632. $rows_r[$key]['zh'] = $zh;
  7633. $jm = array_filter($jm);
  7634. $rows_r[$key]['features'] = implode("-", $jm);
  7635. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7636. }
  7637. $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');
  7638. foreach ($rows_c as $key => $value) {
  7639. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7640. $pm = $classid;
  7641. $jm = $classid;
  7642. $rows_c[$key]['time'] = $value['outk'];
  7643. $rows_c[$key]['outk'] = '出库';
  7644. if ($value['cktype'] == 1) {
  7645. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7646. } else if ($value['cktype'] == 2) {
  7647. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7648. } else if ($value['cktype'] == 3) {
  7649. $rows_c[$key]['cktype'] = '盘亏调整';
  7650. } else if ($value['cktype'] == 4) {
  7651. $rows_c[$key]['cktype'] = '其他调整出库';
  7652. } else if ($value['cktype'] == 5) {
  7653. $rows_c[$key]['cktype'] = '形态转换出库';
  7654. } else {
  7655. $rows_c[$key]['cktype'] = '';
  7656. }
  7657. unset($rows_c[$key]['state']);
  7658. $features = explode('-', trim($value['features'], '-'));
  7659. foreach ($features as $v) {
  7660. if (isset($typeclass[$v])) {
  7661. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7662. $pm[$typeclass[$v]['classid']] = $zh[0];
  7663. }
  7664. if (isset($typeclass[$v])) {
  7665. if (isset($jm[$typeclass[$v]['classid']])) {
  7666. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7667. }
  7668. }
  7669. }
  7670. $zh = implode(" ", $pm);
  7671. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7672. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7673. $rows_c[$key]['zh'] = $zh;
  7674. $jm = array_filter($jm);
  7675. $rows_c[$key]['features'] = implode("-", $jm);
  7676. $rows_c[$key]['number'] = 1;
  7677. }
  7678. $merged = $rows_r;
  7679. foreach ($rows_c as $key => $value) {
  7680. if (isset($merged[$key])) {
  7681. $merged[] = $value;
  7682. } else {
  7683. $merged[$key] = $value;
  7684. }
  7685. }
  7686. usort($merged, function ($a, $b) {
  7687. return $a['time'] - $b['time'];
  7688. });
  7689. foreach ($merged as $key => $value) {
  7690. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7691. }
  7692. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7693. $titlename = "<table border=1>
  7694. <tr align='center'>
  7695. <td>仓库</td>
  7696. <td>SKU</td>
  7697. <td>商品名称</td>
  7698. <td>仓库品名</td>
  7699. <td>料号</td>
  7700. <td>时间</td>
  7701. <td>操作</td>
  7702. <td>类型</td>
  7703. <td>数量</td>
  7704. <td>备注</td>
  7705. </tr>
  7706. </table>";
  7707. $filename = $title . ".xlsx";
  7708. $tail = "";
  7709. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7710. }
  7711. }
  7712. /*************************************处理exceljs导出****************************************************/
  7713. public function _excelrjs(){
  7714. if (isset($_GET['excel'])) {
  7715. $category = $this->input->get('category', true);
  7716. $size = $this->input->get('size', true);
  7717. $grade = $this->input->get('grade', true);
  7718. $color = $this->input->get('color', true);
  7719. $lowe = $this->input->get('lowe', true);
  7720. $sku = $this->input->get('sku', true);
  7721. $warehouse = $this->input->get('warehouse', true);
  7722. $purchase = $this->input->get('purchase', true);
  7723. $ktime = $this->input->get('ktime', true);
  7724. $jtime = $this->input->get('jtime', true);
  7725. $ktime = strtotime($ktime);
  7726. $jtime = strtotime($jtime);
  7727. $where = "1=1";
  7728. $gj = "";
  7729. $ck = "";
  7730. if ($category) {
  7731. $where .= " and features like '%-$category-%'";
  7732. }
  7733. if ($size) {
  7734. $where .= " and features like '%-$size-%'";
  7735. }
  7736. if ($grade) {
  7737. $where .= " and features like '%-$grade-%'";
  7738. }
  7739. if ($color) {
  7740. $where .= " and features like '%-$color-%'";
  7741. }
  7742. if ($lowe) {
  7743. $where .= " and features like '%-$lowe-%'";
  7744. }
  7745. if ($warehouse) {
  7746. $where .= " and warehouse = '$warehouse'";
  7747. }
  7748. if ($purchase) {
  7749. $where .= " and purchase = '$purchase'";
  7750. }
  7751. if ($sku) {
  7752. $where .= " and sku = '$sku'";
  7753. }
  7754. if ($ktime && $jtime) {
  7755. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7756. }
  7757. //数据排序
  7758. $order_str = "id desc";
  7759. if (empty($page)) {
  7760. $start = 0;
  7761. $perpage = 1;
  7762. } else {
  7763. $start = ($page - 1) * $perpage;
  7764. }
  7765. $list = array();
  7766. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7767. foreach ($rows as $value) {
  7768. $ck = $this->warehouse->read($value['warehouse']);
  7769. $warehouse = $ck['title'];
  7770. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7771. $retreatwarehouse = $tkck['title'];
  7772. $gy = $this->purchase->read($value['purchase']);
  7773. $purchase = $gy['title'];
  7774. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7775. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7776. }
  7777. if(empty($list)){
  7778. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7779. }else{
  7780. $final_list = [];
  7781. foreach($list as $v){
  7782. $final_list[] = array_values($v);
  7783. }
  7784. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7785. array_unshift($final_list,[
  7786. "仓库","SKU","商品名称","时间","数量"
  7787. ]);
  7788. array_unshift($final_list,[
  7789. $title,"","","",""
  7790. ]);
  7791. $merges = [
  7792. [
  7793. "s"=>["r"=>0,"c"=>0],
  7794. "e"=>["r"=>0,"c"=>4]
  7795. ]
  7796. ];
  7797. $cols = [
  7798. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7799. ];
  7800. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7801. }
  7802. }
  7803. }
  7804. //出库、退库导出
  7805. public function _excelctjs()
  7806. {
  7807. $classid = $this->classid->sku();
  7808. $pm = $classid;
  7809. $typeclass = array();
  7810. $tc = $this->typeclass->find_all();
  7811. foreach ($tc as $v) {
  7812. $typeclass[$v['id']] = $v;
  7813. }
  7814. $prc = array();
  7815. $purchase = $this->purchase->find_all();
  7816. foreach ($purchase as $k => $v) {
  7817. $prc[$v['id']] = $v['title'];
  7818. }
  7819. if (isset($_GET['excel'])) {
  7820. $wh = array();
  7821. $w = $this->warehouse->find_all('1=1', 'id,title');
  7822. foreach ($w as $v) {
  7823. $wh[$v['id']] = $v['title'];
  7824. }
  7825. $type = $this->input->get('excel', true);
  7826. $category = $this->input->get('category', true);
  7827. $size = $this->input->get('size', true);
  7828. $grade = $this->input->get('grade', true);
  7829. $color = $this->input->get('color', true);
  7830. $lowe = $this->input->get('lowe', true);
  7831. $sku = $this->input->get('sku', true);
  7832. $title = $this->input->get('title', true);
  7833. $warehouse = $this->input->get('warehouse', true);
  7834. $purchase = $this->input->get('purchase', true);
  7835. $lacetype = $this->input->get('lacetype', true);
  7836. $haircap = $this->input->get('haircap', true);
  7837. $lacecolor = $this->input->get('lacecolor', true);
  7838. $density = $this->input->get('density', true);
  7839. $details = $this->input->get('details', true);
  7840. $state = $this->input->get('state', true);
  7841. $shop = $this->input->get('shop', true);
  7842. $hairnumber = $this->input->get('hairnumber', true);
  7843. $type_leixi = $this->input->get('type', true);
  7844. $cpbz = $this->input->get('cpbz', true);
  7845. $sm = $this->input->get('sm', true);
  7846. $sid = $this->input->get('sid', true);
  7847. $ktime = $this->input->get('ktime', true);
  7848. $jtime = $this->input->get('jtime', true);
  7849. $ktime = strtotime($ktime);
  7850. $jtime = strtotime($jtime);
  7851. //$where = " 1=1 ";
  7852. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7853. $where = " sku != '' ";
  7854. $gj = "";
  7855. $ck = "";
  7856. if ($category) {
  7857. $where .= " and features like '%-$category-%'";
  7858. }
  7859. if ($size) {
  7860. $where .= " and features like '%-$size-%'";
  7861. }
  7862. if ($grade) {
  7863. $where .= " and features like '%-$grade-%'";
  7864. }
  7865. if ($color) {
  7866. $where .= " and features like '%-$color-%'";
  7867. }
  7868. if ($lowe) {
  7869. $where .= " and features like '%-$lowe-%'";
  7870. }
  7871. if ($warehouse) {
  7872. $where .= " and warehouse = '$warehouse'";
  7873. }
  7874. if ($purchase) {
  7875. $where .= " and purchase = '$purchase'";
  7876. }
  7877. if ($state) {
  7878. $where .= " and state = '$state'";
  7879. }
  7880. if ($lacetype) {
  7881. $where .= " and features like '%-$lacetype-%'";
  7882. }
  7883. if ($lacecolor) {
  7884. $where .= " and features like '%-$lacecolor-%'";
  7885. }
  7886. if ($density) {
  7887. $where .= " and features like '%-$density-%'";
  7888. }
  7889. if ($haircap) {
  7890. $where .= " and features like '%-$haircap-%'";
  7891. }
  7892. if ($details) {
  7893. $where .= " and details = '$details'";
  7894. }
  7895. if ($shop) {
  7896. $where .= " and shop like '%$shop%'";
  7897. }
  7898. if ($title) {
  7899. $title = trim($title, ' ');
  7900. $title = trim($title, ' ');
  7901. $where .= " and title like '%$title%'";
  7902. }
  7903. if (!empty($hairnumber)) {
  7904. $where .= " and features like '%-128-%' ";
  7905. if ($hairnumber < 0) {
  7906. $class_list = $this->typeclass->find_all('classid = 43');
  7907. foreach ($class_list as $v) {
  7908. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7909. }
  7910. } else {
  7911. $where .= " and features like '%-$hairnumber-%'";
  7912. }
  7913. }
  7914. if ($type_leixi) {
  7915. $where .= " and type = '$type_leixi'";
  7916. }
  7917. if ($cpbz) {
  7918. $where .= " and cpbz like '%$cpbz%' ";
  7919. }
  7920. if ($sm) {
  7921. $where .= " and sm like '%$sm%' ";
  7922. }
  7923. if ($sku) {
  7924. $sku = trim($sku, ' ');
  7925. $sku = trim($sku, ' ');
  7926. $where .= " and sku like '%$sku%'";
  7927. }
  7928. if ($ktime && $jtime) {
  7929. if ($type == 1) {
  7930. $tl = '出库';
  7931. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7932. } else if ($type == 2) {
  7933. $tl = '退库';
  7934. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7935. } else if ($type == 3) {
  7936. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7937. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7938. } else if ($type == 4) {
  7939. $tl = '出库+零售';
  7940. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7941. } else if ($type == 5) {
  7942. $tl = '零售';
  7943. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7944. }
  7945. }
  7946. $sidwhere = '';
  7947. if ($sid) {
  7948. $sd = "";
  7949. $s = explode(',', trim($sid, ','));
  7950. foreach ($s as $value) {
  7951. $sd .= " id = " . $value . " or";
  7952. }
  7953. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7954. }
  7955. //数据排序
  7956. $order_str = "time desc";
  7957. if (empty($page)) {
  7958. $start = 0;
  7959. $perpage = 1;
  7960. } else {
  7961. $start = ($page - 1) * $perpage;
  7962. }
  7963. //取得信息列表
  7964. if ($type != 3 && $type != 5) {
  7965. if ($type == 1 || $type == 4) {
  7966. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7967. foreach ($info_list as $key => $value) {
  7968. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7969. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7970. $warehouse = $this->warehouse->read($value['warehouse']);
  7971. $info_list[$key]['warehouse'] = $warehouse['title'];
  7972. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7973. $features = explode('-', trim($features, '-'));
  7974. $pm = $classid;
  7975. foreach ($features as $k => $v) {
  7976. if ($v != 0) {
  7977. if (!isset($typeclass[$v])) {
  7978. continue;
  7979. }
  7980. if (isset($pm[$typeclass[$v]['classid']])) {
  7981. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7982. $tz = explode('|', $typeclass[$v]['zh']);
  7983. $pm[$typeclass[$v]['classid']] = $tz[0];
  7984. } else {
  7985. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7986. }
  7987. }
  7988. }
  7989. }
  7990. $zh = implode(" ", $pm);
  7991. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7992. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7993. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7994. $info_list[$key]['features'] = $zh;
  7995. }
  7996. $final_list = [];
  7997. foreach($info_list as $k=>$v){
  7998. $number = "";
  7999. if(!empty($v['orderinfo'])){
  8000. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8001. if(!empty($tmp_info['number'])){
  8002. $number = $tmp_info['number'];
  8003. }
  8004. }
  8005. $final_list[] = [
  8006. 'warehouse'=>$v['warehouse'],
  8007. 'purchase'=>$v['purchase'],
  8008. 'sku'=>$v['sku'],
  8009. 'title'=>$v['title'],
  8010. 'features'=>$v['features'],
  8011. 'label'=>$v['label'],
  8012. 'orderinfo'=>$v['orderinfo'],
  8013. 'number'=>$number,
  8014. 'waybill'=>$v['waybill'],
  8015. 'outk'=>$v['outk'],
  8016. ];
  8017. }
  8018. } else {
  8019. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8020. foreach ($info_list as $key => $value) {
  8021. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8022. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8023. $warehouse = $this->warehouse->read($value['warehouse']);
  8024. $info_list[$key]['warehouse'] = $warehouse['title'];
  8025. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8026. $features = explode('-', trim($features, '-'));
  8027. $pm = $classid;
  8028. foreach ($features as $k => $v) {
  8029. if ($v != 0) {
  8030. if (!isset($typeclass[$v])) {
  8031. continue;
  8032. }
  8033. if (isset($pm[$typeclass[$v]['classid']])) {
  8034. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8035. $tz = explode('|', $typeclass[$v]['zh']);
  8036. $pm[$typeclass[$v]['classid']] = $tz[0];
  8037. } else {
  8038. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8039. }
  8040. }
  8041. }
  8042. }
  8043. $zh = implode(" ", $pm);
  8044. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8045. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8046. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8047. $info_list[$key]['features'] = $zh;
  8048. }
  8049. $final_list = [];
  8050. foreach($info_list as $k=>$v){
  8051. $number = "";
  8052. if(!empty($v['orderinfo'])){
  8053. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8054. if(!empty($tmp_info['number'])){
  8055. $number = $tmp_info['number'];
  8056. }
  8057. }
  8058. $final_list[] = [
  8059. 'warehouse'=>$v['warehouse'],
  8060. 'purchase'=>$v['purchase'],
  8061. 'sku'=>$v['sku'],
  8062. 'title'=>$v['title'],
  8063. 'features'=>$v['features'],
  8064. 'label'=>$v['label'],
  8065. 'orderinfo'=>$v['orderinfo'],
  8066. 'number'=>$number,
  8067. 'waybill'=>$v['waybill'],
  8068. 'retreat'=>$v['retreat'],
  8069. ];
  8070. }
  8071. }
  8072. if(empty($final_list)){
  8073. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8074. }else{
  8075. $end_list = [];
  8076. foreach($final_list as $v){
  8077. $end_list[] = array_values($v);
  8078. }
  8079. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8080. array_unshift($end_list,[
  8081. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8082. ]);
  8083. array_unshift($end_list,[
  8084. $title,"","","","","","","","",""
  8085. ]);
  8086. $merges = [
  8087. [
  8088. "s"=>["r"=>0,"c"=>0],
  8089. "e"=>["r"=>0,"c"=>9]
  8090. ]
  8091. ];
  8092. $cols = [
  8093. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8094. ];
  8095. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8096. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8097. ] )));
  8098. }
  8099. } else if ($type == 5) {
  8100. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8101. foreach ($info_list as $key => $value) {
  8102. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8103. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8104. $warehouse = $this->warehouse->read($value['warehouse']);
  8105. $info_list[$key]['warehouse'] = $warehouse['title'];
  8106. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8107. $features = explode('-', trim($features, '-'));
  8108. $pm = $classid;
  8109. foreach ($features as $k => $v) {
  8110. if ($v != 0) {
  8111. if (!isset($typeclass[$v])) {
  8112. continue;
  8113. }
  8114. if (isset($pm[$typeclass[$v]['classid']])) {
  8115. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8116. $tz = explode('|', $typeclass[$v]['zh']);
  8117. $pm[$typeclass[$v]['classid']] = $tz[0];
  8118. } else {
  8119. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8120. }
  8121. }
  8122. }
  8123. }
  8124. $zh = implode(" ", $pm);
  8125. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8126. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8127. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8128. $info_list[$key]['features'] = $zh;
  8129. }
  8130. if(empty($info_list)){
  8131. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8132. }else{
  8133. $final_list = [];
  8134. foreach($info_list as $v){
  8135. $final_list[] = array_values($v);
  8136. }
  8137. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8138. array_unshift($final_list,[
  8139. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8140. ]);
  8141. array_unshift($final_list,[
  8142. $title,"","","","","","",
  8143. ]);
  8144. $merges = [
  8145. [
  8146. "s"=>["r"=>0,"c"=>0],
  8147. "e"=>["r"=>0,"c"=>6]
  8148. ]
  8149. ];
  8150. $cols = [
  8151. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8152. ];
  8153. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8154. }
  8155. } else {
  8156. $wh = array();
  8157. $w = $this->warehouse->find_all('1=1', 'id,title');
  8158. foreach ($w as $v) {
  8159. $wh[$v['id']] = $v['title'];
  8160. }
  8161. $wt = array();
  8162. $whlabel_type = $this->whlabel_type->find_all();
  8163. foreach ($whlabel_type as $v) {
  8164. $wt[$v['id']] = $v['title'];
  8165. }
  8166. $classid = $this->classid->sku();
  8167. $list = array();
  8168. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8169. foreach ($rows as $key => $value) {
  8170. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8171. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8172. $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');
  8173. $details = array();
  8174. $cpid = array();
  8175. $cpbz = array();
  8176. $c = 0;
  8177. $g = 0;
  8178. $x = 0;
  8179. $t = 0;
  8180. $s = 0;
  8181. $q = 0;
  8182. foreach ($sd as $k => $v) {
  8183. if ($v['state'] == 0) {
  8184. $c++;
  8185. }
  8186. if ($v['state'] != 9) {
  8187. $g++;
  8188. }
  8189. if ($v['outk'] > 1) {
  8190. $x++;
  8191. }
  8192. if ($v['retreat'] > 0) {
  8193. $t++;
  8194. }
  8195. if ($v['state'] == 8) {
  8196. $s++;
  8197. }
  8198. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8199. $q++;
  8200. }
  8201. $details[$v['details']] = $v['details'];
  8202. if ($v['cpid'] != 0) {
  8203. $cpid[$v['cpid']] = $v['cpid'];
  8204. }
  8205. if ($v['cpbz'] != '') {
  8206. $cpbz[$v['cpbz']] = $v['cpbz'];
  8207. }
  8208. }
  8209. if (isset($wt[$value['type']])) {
  8210. $rows[$key]['type'] = $wt[$value['type']];
  8211. } else {
  8212. $rows[$key]['type'] = '未设置';
  8213. }
  8214. $rows[$key]['details'] = implode("、", $details);
  8215. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8216. $ftime = time() - 15 * 24 * 3600;
  8217. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8218. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8219. $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);
  8220. $rows[$key]['c'] = $c;
  8221. $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);
  8222. $rows[$key]['t'] = $t;
  8223. $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'] . '"');
  8224. $rows[$key]['z'] = $z;
  8225. // $jm = $classid;
  8226. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8227. $features = explode('-', trim($features, '-'));
  8228. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8229. }
  8230. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8231. $final_list =[];
  8232. foreach($tmp_list as $k=>$v){
  8233. $final_list[] = [
  8234. "warehouse"=>$v['warehouse'],
  8235. "purchase"=>$v['purchase'],
  8236. "details"=>$v['details'],
  8237. "cpid"=>$v['cpid'],
  8238. "sku"=>$v['sku'],
  8239. "title"=>$v['title'],
  8240. "features"=>$v['pm'],
  8241. "cpbz"=>$v['cpbz'],
  8242. "sm"=>$v['sm'],
  8243. "type"=>$v['type'],
  8244. "g"=>$v["g"],
  8245. "c"=>$v["c"],
  8246. "x"=>$v["x"],
  8247. "t"=>$v["t"],
  8248. "z"=>$v["z"],
  8249. "jm"=>$v["jm"],
  8250. "weight"=>$v["weight"],
  8251. "asd"=>$v["asd"],
  8252. ];
  8253. }
  8254. if(empty($final_list)){
  8255. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8256. }else{
  8257. $end_list = [];
  8258. foreach($final_list as $v){
  8259. $end_list[] = array_values($v);
  8260. }
  8261. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8262. array_unshift($end_list,[
  8263. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8264. ]);
  8265. array_unshift($end_list,[
  8266. $title,"","","","","","","","","","","","","","","","","",""
  8267. ]);
  8268. $merges = [
  8269. [
  8270. "s"=>["r"=>0,"c"=>0],
  8271. "e"=>["r"=>0,"c"=>6]
  8272. ]
  8273. ];
  8274. $cols = [
  8275. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8276. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8277. ];
  8278. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8279. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8280. ])));
  8281. }
  8282. }
  8283. }
  8284. }
  8285. public function _exceljxcjs(){
  8286. $classid = $this->classid->sku();
  8287. $pm = $classid;
  8288. $typeclass = array();
  8289. $tc = $this->typeclass->find_all();
  8290. foreach ($tc as $v) {
  8291. $typeclass[$v['id']] = $v;
  8292. }
  8293. $prc = array();
  8294. $purchase = $this->purchase->find_all();
  8295. foreach ($purchase as $k => $v) {
  8296. $prc[$v['id']] = $v['title'];
  8297. }
  8298. if(!isset($_GET['excel'])){
  8299. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8300. }
  8301. $where = "sku != 'Preset'";
  8302. //数据排序
  8303. $order_str = "id desc";
  8304. if (empty($page)) {
  8305. $start = 0;
  8306. $perpage = 1;
  8307. } else {
  8308. $start = ($page - 1) * $perpage;
  8309. }
  8310. $category = $this->input->get('category', true);
  8311. $warehouse = $this->input->get('warehouse', true);
  8312. $excelid = $this->input->get('sid', true);
  8313. if ($category) {
  8314. $where .= " and features like '%-$category-%'";
  8315. }
  8316. if ($warehouse) {
  8317. $where .= " and warehouse = '$warehouse'";
  8318. }
  8319. $xzid = '';
  8320. if ($excelid) {
  8321. $excelid = explode(',', trim($excelid, ','));
  8322. foreach ($excelid as $key => $value) {
  8323. $xzid .= " id = " . $value . " or";
  8324. }
  8325. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8326. }
  8327. $wt = array();
  8328. $whlabel_type = $this->whlabel_type->find_all();
  8329. foreach ($whlabel_type as $v) {
  8330. $wt[$v['id']] = $v['title'];
  8331. }
  8332. $wh = array();
  8333. $w = $this->warehouse->find_all('1=1', 'id,title');
  8334. foreach ($w as $v) {
  8335. $wh[$v['id']] = $v['title'];
  8336. }
  8337. $list = array();
  8338. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8339. foreach ($rows as $key => $value) {
  8340. if (isset($wt[$value['type']])) {
  8341. $rows[$key]['type'] = $wt[$value['type']];
  8342. } else {
  8343. $rows[$key]['type'] = '未设置';
  8344. }
  8345. $bm = '03';
  8346. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8347. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8348. $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');
  8349. $details = array();
  8350. $cpid = array();
  8351. $cpbz = array();
  8352. $c = 0;
  8353. $g = 0;
  8354. $x = 0;
  8355. $t = 0;
  8356. $s = 0;
  8357. $q = 0;
  8358. foreach ($sd as $k => $v) {
  8359. if ($v['state'] == 0) {
  8360. $c++;
  8361. if ($v['cpid'] != 0) {
  8362. $cpid[$v['cpid']] = $v['cpid'];
  8363. }
  8364. if ($v['cpbz'] != '') {
  8365. $cpbz[$v['cpbz']] = $v['cpbz'];
  8366. }
  8367. }
  8368. if ($v['state'] != 9) {
  8369. $g++;
  8370. }
  8371. if ($v['state'] == 1) {
  8372. $x++;
  8373. }
  8374. if ($v['state'] == 2) {
  8375. $t++;
  8376. }
  8377. if ($v['state'] == 8) {
  8378. $s++;
  8379. }
  8380. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8381. $q++;
  8382. }
  8383. $details[$v['details']] = $v['details'];
  8384. }
  8385. $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'] . '"');
  8386. $rows[$key]['details'] = implode("、", $details);
  8387. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8388. $number = $value['number'];
  8389. $ftime = time() - 15 * 24 * 3600;
  8390. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8391. $rows[$key]['number'] = $g;
  8392. $rows[$key]['c'] = $c;
  8393. $rows[$key]['x'] = $x;
  8394. $rows[$key]['t'] = $t;
  8395. $rows[$key]['s'] = $s;
  8396. $rows[$key]['q'] = $q;
  8397. $rows[$key]['z'] = $z;
  8398. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8399. $features = explode('-', trim($features, '-'));
  8400. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8401. }
  8402. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8403. $final_list = [];
  8404. foreach ($list as $k => $v) {
  8405. if (empty($v['sku'])) {
  8406. continue;
  8407. }
  8408. $final_list[] = [
  8409. $v["warehouse"],
  8410. $v["purchase"],
  8411. $v["details"],
  8412. $v["cpid"],
  8413. $v["dbcontent"],
  8414. $v["sku"],
  8415. $v["bm"],
  8416. $v["jm"],
  8417. $v["title"],
  8418. $v["pm"],
  8419. $v["cpbz"],
  8420. $v["sm"],
  8421. $v["type"],
  8422. $v["number"],
  8423. $v["c"],
  8424. $v["x"],
  8425. $v["t"],
  8426. $v["s"],
  8427. $v["q"],
  8428. $v["z"],
  8429. $v['weight'],
  8430. ];
  8431. }
  8432. if(empty($final_list)){
  8433. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8434. }
  8435. $title = "总进销存统计表";
  8436. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8437. $merges = [
  8438. [
  8439. "s"=>["r"=>0,"c"=>0],
  8440. "e"=>["r"=>0,"c"=>21]
  8441. ]
  8442. ];
  8443. $cols = [
  8444. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8445. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8446. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8447. ];
  8448. array_unshift($final_list, $first_row);
  8449. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8450. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8451. }
  8452. public function _summaryjs($arg_array)
  8453. {
  8454. $prc = array();
  8455. $purchase = $this->purchase->find_all();
  8456. foreach ($purchase as $k => $v) {
  8457. $prc[$v['id']] = $v['title'];
  8458. }
  8459. if (isset($_GET['excel'])) {
  8460. $ktime = $this->input->get('ktime', true);
  8461. $jtime = $this->input->get('jtime', true);
  8462. $ktime = strtotime($ktime);
  8463. $jtime = strtotime($jtime);
  8464. $where = "1=1";
  8465. if ($ktime && $jtime) {
  8466. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8467. }
  8468. //数据排序
  8469. $order_str = "time desc";
  8470. if (empty($page)) {
  8471. $start = 0;
  8472. $perpage = 1;
  8473. } else {
  8474. $start = ($page - 1) * $perpage;
  8475. }
  8476. //取得信息列表
  8477. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8478. foreach ($info_list as $key => $value) {
  8479. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8480. $warehouse = $this->warehouse->read($value['warehouse']);
  8481. $info_list[$key]['warehouse'] = $warehouse['title'];
  8482. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8483. $details = array();
  8484. $cpid = array();
  8485. foreach ($x as $k => $v) {
  8486. if ($v['details'] != '') {
  8487. $details[$v['details']] = $v['details'];
  8488. }
  8489. if ($v['cpid'] != 0) {
  8490. $cpid[$v['cpid']] = $v['cpid'];
  8491. }
  8492. }
  8493. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8494. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8495. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8496. $info_list[$key]['s'] = $s;
  8497. $info_list[$key]['x'] = count($x);
  8498. }
  8499. if(empty($info_list)){
  8500. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8501. }
  8502. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8503. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8504. $merges = [
  8505. [
  8506. "s"=>["r"=>0,"c"=>0],
  8507. "e"=>["r"=>0,"c"=>7]
  8508. ]
  8509. ];
  8510. $cols = [
  8511. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8512. ];
  8513. $final_list = [];
  8514. foreach($info_list as $k => $v){
  8515. $final_list[] = array_values($v);
  8516. }
  8517. array_unshift($final_list, $first_row);
  8518. array_unshift($final_list,[
  8519. $title,"","","","","","","","",
  8520. ]);
  8521. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8522. $titlename = "<table border=1>
  8523. <tr align='center'>
  8524. <td>仓库</td>
  8525. <td>供应商</td>
  8526. <td>出库位置</td>
  8527. <td>出库编码</td>
  8528. <td>SKU</td>
  8529. <td>产品名</td>
  8530. <td>总剩余库存</td>
  8531. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8532. </tr>
  8533. </table>";
  8534. $filename = $title . ".xls";
  8535. $tail = "";
  8536. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8537. }
  8538. }
  8539. public function _uckjs()
  8540. {
  8541. if (isset($_GET['excel'])) {
  8542. $tc = array();
  8543. $typeclass = $this->typeclass->find_all();
  8544. foreach ($typeclass as $v) {
  8545. $tc[$v['id']] = $v['zh'];
  8546. }
  8547. $first_row = [
  8548. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8549. ];
  8550. $t = array();
  8551. $rq = '';
  8552. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8553. $ts = $ts / (24 * 3600);
  8554. for ($i = 0; $i < $ts; $i++) {
  8555. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8556. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8557. }
  8558. $day_len = count($t);
  8559. $first_row[] = "本月出库";
  8560. $merges = [
  8561. ];
  8562. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8563. $excel_key = 1;
  8564. $final_list = [];
  8565. foreach ($info_list as $k => $v) {
  8566. $features = explode('-', trim($v['features'], '-'));
  8567. if (!isset($features[3]) || !isset($features[4])) {
  8568. continue;
  8569. }
  8570. $tmp = [];
  8571. $tmp[0] = $tc[$features[0]]; //类型
  8572. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8573. $tmp[2] = $tc[$features[4]]; //曲度
  8574. $tmp[3] = '';
  8575. if (isset($data[$k][1])) {
  8576. $tmp[3] .=$tmp[1];
  8577. }
  8578. if (isset($data[$k][2])) {
  8579. $tmp[3] .= $tmp[2];
  8580. }
  8581. if (isset($features[5])) {
  8582. $tmp[3] .= $tc[$features[5]];
  8583. }
  8584. if (isset($features[2])) {
  8585. $tmp[3] .= $tc[$features[2]];
  8586. }
  8587. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8588. $tmp[4] = $v['sku'];
  8589. $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())) . '))'); //月初库存
  8590. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8591. $tmp[7] ="";
  8592. $tmp[8] ="";
  8593. $byck = 0;
  8594. foreach ($t as $vv) {
  8595. $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));
  8596. $tmp[] = ($sl > 0) ? $sl : '';
  8597. $byck += $sl;
  8598. }
  8599. $tmp[] = ($byck > 0) ? $byck : '';
  8600. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8601. // $ztrq = '';
  8602. // $ztsl = '';
  8603. // if (count($zt) > 0) {
  8604. // foreach ($zt as $vv) {
  8605. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8606. // $ztsl .= $vv['num'] . '<br>';
  8607. // }
  8608. // }
  8609. if(empty($zt)){
  8610. $final_list[] = $tmp;
  8611. $excel_key = $excel_key + 1;
  8612. }else{
  8613. $len = count($zt);
  8614. if($len == 1){
  8615. $tmp[7] = $zt[0]['num'] ;
  8616. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8617. $final_list[] = $tmp;
  8618. $excel_key = $excel_key + 1;
  8619. }else{
  8620. foreach($zt as $vv){
  8621. $tmp[7] = "";
  8622. $tmp[8] = "";
  8623. $tmp[7] = $vv['num'];
  8624. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8625. $final_list[] = $tmp;
  8626. }
  8627. $merges[] = [
  8628. "s"=>["r"=>$excel_key,"c"=>0],
  8629. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8630. ];
  8631. $merges[] = [
  8632. "s"=>["r"=>$excel_key,"c"=>1],
  8633. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8634. ];
  8635. $merges[] = [
  8636. "s"=>["r"=>$excel_key,"c"=>2],
  8637. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8638. ];
  8639. $merges[] = [
  8640. "s"=>["r"=>$excel_key,"c"=>3],
  8641. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8642. ];
  8643. $merges[] = [
  8644. "s"=>["r"=>$excel_key,"c"=>4],
  8645. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8646. ];
  8647. $merges[] = [
  8648. "s"=>["r"=>$excel_key,"c"=>5],
  8649. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8650. ];
  8651. $merges[] = [
  8652. "s"=>["r"=>$excel_key,"c"=>6],
  8653. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8654. ];
  8655. for($i=1;$i<=$day_len;$i++){
  8656. $merges[] = [
  8657. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8658. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8659. ];
  8660. }
  8661. $merges[] = [
  8662. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8663. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8664. ];
  8665. $excel_key = $excel_key + $len;
  8666. }
  8667. }
  8668. }
  8669. $title = "详情 " . date("Y-m-d", time());
  8670. if(empty($final_list)){
  8671. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8672. }
  8673. $cols = [
  8674. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8675. ];
  8676. array_unshift($final_list, $first_row);
  8677. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8678. }
  8679. }
  8680. public function _whlabelexcelzhjs(){
  8681. if(empty($_GET['excel'])){
  8682. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8683. }
  8684. $where = "sku != 'Preset' and sku != '' ";
  8685. //数据排序
  8686. $order_str = "id desc";
  8687. if (empty($page)) {
  8688. $start = 0;
  8689. $perpage = 1;
  8690. } else {
  8691. $start = ($page - 1) * $perpage;
  8692. }
  8693. $category = $this->input->get('category', true);
  8694. $warehouse = $this->input->get('warehouse', true);
  8695. $excelid = $this->input->get('sid', true);
  8696. if ($category) {
  8697. $where .= " and features like '%-$category-%'";
  8698. }
  8699. if ($warehouse) {
  8700. $where .= " and warehouse = '$warehouse'";
  8701. }
  8702. $xzid = '';
  8703. if ($excelid) {
  8704. $excelid = explode(',', trim($excelid, ','));
  8705. foreach ($excelid as $key => $value) {
  8706. $xzid .= " id = " . $value . " or";
  8707. }
  8708. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8709. }
  8710. $merges = [
  8711. [
  8712. "s"=>["r"=>0,"c"=>0],
  8713. "e"=>["r"=>0,"c"=>6]
  8714. ]
  8715. ];
  8716. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8717. $excel_index = 2;
  8718. $final_list = [];
  8719. foreach ($rows as $key => $value) {
  8720. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8721. $zh = '';
  8722. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8723. // foreach ($zt_list as $v) {
  8724. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8725. // }
  8726. $zt = array_sum(array_column($zt_list, 'num'));
  8727. $number = $value['number'];
  8728. $ftime = time() - 15 * 24 * 3600;
  8729. $warehouse = $this->warehouse->read($value['warehouse']);
  8730. // $rows[$key]['warehouse'] = $warehouse['title'];
  8731. // $rows[$key]['number'] = $c;
  8732. // $rows[$key]['features'] = $zh;
  8733. //$rows[$key]['hb'] = $c + $zt;
  8734. $tmp = [];
  8735. $tmp[0] = $warehouse['title'];
  8736. $tmp[1] = $value['sku'];
  8737. $tmp[2] = $value['title'];
  8738. $tmp[3] = $c;
  8739. $tmp[4] = "";
  8740. $tmp[5] = $c + $zt;
  8741. if(empty($zt_list)){
  8742. $tmp[4] = "";
  8743. $final_list[] = $tmp;
  8744. $excel_index = $excel_index + 1;
  8745. }else{
  8746. if(count($zt_list) == 1){
  8747. $tmp[4] = "";
  8748. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8749. $final_list[] = $tmp;
  8750. $excel_index = $excel_index + 1;
  8751. }else{
  8752. $len = count($zt_list);
  8753. foreach ($zt_list as $v){
  8754. $tmp[4] = "";
  8755. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8756. $final_list[] = $tmp;
  8757. }
  8758. $merges[] = [
  8759. "s"=>["r"=>$excel_index,"c"=>0],
  8760. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8761. ];
  8762. $merges[] = [
  8763. "s"=>["r"=>$excel_index,"c"=>1],
  8764. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8765. ];
  8766. $merges[] = [
  8767. "s"=>["r"=>$excel_index,"c"=>2],
  8768. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8769. ];
  8770. $merges[] = [
  8771. "s"=>["r"=>$excel_index,"c"=>3],
  8772. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8773. ];
  8774. $merges[] = [
  8775. "s"=>["r"=>$excel_index,"c"=>5],
  8776. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8777. ];
  8778. $excel_index = $excel_index + $len;
  8779. }
  8780. }
  8781. }
  8782. $first_row = [
  8783. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8784. ];
  8785. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8786. if(empty($final_list)){
  8787. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8788. }
  8789. $cols = [
  8790. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8791. ];
  8792. array_unshift($final_list, $first_row);
  8793. array_unshift($final_list, [
  8794. $title,"","","","",""
  8795. ]);
  8796. $end_list = [];
  8797. foreach ($final_list as $key => $value) {
  8798. $end_list[] = array_values($value);
  8799. }
  8800. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8801. }
  8802. //出库、退库导出
  8803. public function _dccrtypejs()
  8804. {
  8805. $classid = $this->classid->sku();
  8806. $pm = $classid;
  8807. $typeclass = array();
  8808. $tc = $this->typeclass->find_all();
  8809. foreach ($tc as $v) {
  8810. $typeclass[$v['id']] = $v;
  8811. }
  8812. $prc = array();
  8813. $purchase = $this->purchase->find_all();
  8814. foreach ($purchase as $k => $v) {
  8815. $prc[$v['id']] = $v['title'];
  8816. }
  8817. if (isset($_GET['sid'])) {
  8818. $wh = array();
  8819. $w = $this->warehouse->find_all('1=1', 'id,title');
  8820. foreach ($w as $v) {
  8821. $wh[$v['id']] = $v['title'];
  8822. }
  8823. $type = $this->input->get('excel', true);
  8824. $category = $this->input->get('category', true);
  8825. $size = $this->input->get('size', true);
  8826. $grade = $this->input->get('grade', true);
  8827. $color = $this->input->get('color', true);
  8828. $lowe = $this->input->get('lowe', true);
  8829. $sku = $this->input->get('sku', true);
  8830. $warehouse = $this->input->get('warehouse', true);
  8831. $lacetype = $this->input->get('lacetype', true);
  8832. $lacecolor = $this->input->get('lacecolor', true);
  8833. $density = $this->input->get('density', true);
  8834. $haircap = $this->input->get('haircap', true);
  8835. $purchase = $this->input->get('purchase', true);
  8836. $title = $this->input->get('title', true);
  8837. $state = $this->input->get('state', true);
  8838. $sid = $this->input->get('sid', true);
  8839. $ktime = $this->input->get('ktime', true);
  8840. $jtime = $this->input->get('jtime', true);
  8841. $ktime = strtotime($ktime);
  8842. $jtime = strtotime($jtime);
  8843. $where = "1=1";
  8844. $gj = "";
  8845. $ck = "";
  8846. if ($category) {
  8847. $where .= " and features like '%-$category-%'";
  8848. }
  8849. if ($size) {
  8850. $where .= " and features like '%-$size-%'";
  8851. }
  8852. if ($grade) {
  8853. $where .= " and features like '%-$grade-%'";
  8854. }
  8855. if ($color) {
  8856. $where .= " and features like '%-$color-%'";
  8857. }
  8858. if ($lowe) {
  8859. $where .= " and features like '%-$lowe-%'";
  8860. }
  8861. if ($warehouse) {
  8862. $where .= " and warehouse = '$warehouse'";
  8863. }
  8864. if ($purchase) {
  8865. $where .= " and purchase = '$purchase'";
  8866. }
  8867. if ($state) {
  8868. $where .= " and state = '$state'";
  8869. }
  8870. if ($lacetype) {
  8871. $where .= " and features like '%-$lacetype-%'";
  8872. }
  8873. if ($lacecolor) {
  8874. $where .= " and features like '%-$lacecolor-%'";
  8875. }
  8876. if ($density) {
  8877. $where .= " and features like '%-$density-%'";
  8878. }
  8879. if ($haircap) {
  8880. $where .= " and features like '%-$haircap-%'";
  8881. }
  8882. if ($title) {
  8883. $title = trim($title, ' ');
  8884. $title = trim($title, ' ');
  8885. $where .= " and title like '%$title%'";
  8886. }
  8887. if ($sku) {
  8888. $sku = trim($sku, ' ');
  8889. $sku = trim($sku, ' ');
  8890. $where .= " and sku like '%$sku%'";
  8891. }
  8892. if ($ktime && $jtime) {
  8893. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8894. }
  8895. $sidwhere = '';
  8896. if ($sid) {
  8897. $sd = "";
  8898. $s = explode(',', trim($sid, ','));
  8899. foreach ($s as $value) {
  8900. $sd .= " id = " . $value . " or";
  8901. }
  8902. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8903. }
  8904. //数据排序
  8905. $order_str = "time desc";
  8906. if (empty($page)) {
  8907. $start = 0;
  8908. $perpage = 1;
  8909. } else {
  8910. $start = ($page - 1) * $perpage;
  8911. }
  8912. $wh = array();
  8913. $w = $this->warehouse->find_all('1=1', 'id,title');
  8914. foreach ($w as $v) {
  8915. $wh[$v['id']] = $v['title'];
  8916. }
  8917. $wt = array();
  8918. $whlabel_type = $this->whlabel_type->find_all();
  8919. foreach ($whlabel_type as $v) {
  8920. $wt[$v['id']] = $v['title'];
  8921. }
  8922. $classid = $this->classid->sku();
  8923. $list = array();
  8924. $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');
  8925. foreach ($rows_r as $key => $value) {
  8926. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8927. $pm = $classid;
  8928. $jm = $classid;
  8929. $rows_r[$key]['enter'] = '入库';
  8930. $rows_r[$key]['time'] = $value['enter'];
  8931. if ($value['rktype'] == 1) {
  8932. $rows_r[$key]['rktype'] = '采购入库';
  8933. } else if ($value['rktype'] == 2) {
  8934. $rows_r[$key]['rktype'] = '盘盈调整';
  8935. } else if ($value['rktype'] == 3) {
  8936. $rows_r[$key]['rktype'] = '其他调整入库';
  8937. } else if ($value['rktype'] == 4) {
  8938. $rows_r[$key]['rktype'] = '其他调整入库';
  8939. } else if ($value['rktype'] == 5) {
  8940. $rows_r[$key]['rktype'] = '退库入库';
  8941. } else if ($value['rktype'] == 6) {
  8942. $rows_r[$key]['rktype'] = '退货可用入库';
  8943. } else if ($value['rktype'] == 7) {
  8944. $rows_r[$key]['rktype'] = '形态转换入库';
  8945. } else {
  8946. $rows_r[$key]['rktype'] = '';
  8947. }
  8948. $features = explode('-', trim($value['features'], '-'));
  8949. foreach ($features as $v) {
  8950. if (isset($typeclass[$v])) {
  8951. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8952. $pm[$typeclass[$v]['classid']] = $zh[0];
  8953. }
  8954. if (isset($typeclass[$v])) {
  8955. if (isset($jm[$typeclass[$v]['classid']])) {
  8956. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8957. }
  8958. }
  8959. }
  8960. $zh = implode(" ", $pm);
  8961. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8962. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8963. $rows_r[$key]['zh'] = $zh;
  8964. $jm = array_filter($jm);
  8965. $rows_r[$key]['features'] = implode("-", $jm);
  8966. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8967. }
  8968. $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');
  8969. foreach ($rows_c as $key => $value) {
  8970. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8971. $pm = $classid;
  8972. $jm = $classid;
  8973. $rows_c[$key]['time'] = $value['outk'];
  8974. $rows_c[$key]['outk'] = '出库';
  8975. if ($value['cktype'] == 1) {
  8976. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8977. } else if ($value['cktype'] == 2) {
  8978. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8979. } else if ($value['cktype'] == 3) {
  8980. $rows_c[$key]['cktype'] = '盘亏调整';
  8981. } else if ($value['cktype'] == 4) {
  8982. $rows_c[$key]['cktype'] = '其他调整出库';
  8983. } else if ($value['cktype'] == 5) {
  8984. $rows_c[$key]['cktype'] = '形态转换出库';
  8985. } else {
  8986. $rows_c[$key]['cktype'] = '';
  8987. }
  8988. unset($rows_c[$key]['state']);
  8989. $features = explode('-', trim($value['features'], '-'));
  8990. foreach ($features as $v) {
  8991. if (isset($typeclass[$v])) {
  8992. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8993. $pm[$typeclass[$v]['classid']] = $zh[0];
  8994. }
  8995. if (isset($typeclass[$v])) {
  8996. if (isset($jm[$typeclass[$v]['classid']])) {
  8997. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8998. }
  8999. }
  9000. }
  9001. $zh = implode(" ", $pm);
  9002. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9003. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9004. $rows_c[$key]['zh'] = $zh;
  9005. $jm = array_filter($jm);
  9006. $rows_c[$key]['features'] = implode("-", $jm);
  9007. $rows_c[$key]['number'] = 1;
  9008. }
  9009. $merged = $rows_r;
  9010. foreach ($rows_c as $key => $value) {
  9011. if (isset($merged[$key])) {
  9012. $merged[] = $value;
  9013. } else {
  9014. $merged[$key] = $value;
  9015. }
  9016. }
  9017. usort($merged, function ($a, $b) {
  9018. return $a['time'] - $b['time'];
  9019. });
  9020. foreach ($merged as $key => $value) {
  9021. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9022. }
  9023. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9024. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9025. $cols = [
  9026. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9027. ];
  9028. $final_list= [];
  9029. foreach($merged as $key => $value){
  9030. $final_list[] = array_values($value) ;
  9031. }
  9032. if(empty($merged)){
  9033. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9034. }
  9035. array_unshift($final_list, $first_row);
  9036. $end_list = [];
  9037. foreach ($final_list as $key => $value) {
  9038. $end_list[] = array_values($value);
  9039. }
  9040. $merges = [];
  9041. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9042. }
  9043. }
  9044. public function _errorexceljs()
  9045. {
  9046. $post = $this->input->post(NULL, TRUE);
  9047. if (isset($_GET['page'])) {
  9048. $page = $this->input->get('page', true);
  9049. $perpage = $this->input->get('perpage', true);
  9050. $sku = $this->input->get('sku', true);
  9051. $warehouse = $this->input->get('warehouse', true);
  9052. $ktime = $this->input->get('ktime', true);
  9053. $jtime = $this->input->get('jtime', true);
  9054. $ktime = strtotime($ktime);
  9055. $jtime = strtotime($jtime);
  9056. $where = "sku != 'Preset'";
  9057. $gj = '';
  9058. if ($sku) {
  9059. $where .= " and sku like '%$sku%'";
  9060. } else {
  9061. if ($ktime && $jtime) {
  9062. $gj = " and time > '$ktime' and time < '$jtime'";
  9063. }
  9064. }
  9065. if ($warehouse) {
  9066. $where .= " and warehouse = '$warehouse'";
  9067. }
  9068. //数据排序
  9069. $order_str = "id desc";
  9070. if (empty($page)) {
  9071. $start = 0;
  9072. $perpage = 1;
  9073. } else {
  9074. $start = ($page - 1) * $perpage;
  9075. }
  9076. //取得信息列表
  9077. $rows = array();
  9078. $list = array();
  9079. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9080. foreach ($info_list as $value) {
  9081. $warehouse = $this->warehouse->read($value['warehouse']);
  9082. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9083. $number = $value['number'];
  9084. $ftime = time() - 15 * 24 * 3600;
  9085. if ($c < 1) {
  9086. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9087. }
  9088. }
  9089. $title = "0库存汇总";
  9090. $first_row = ["仓库","SKU","产品","当前库存"];
  9091. $cols = [
  9092. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9093. ];
  9094. $final_list= [];
  9095. foreach($list as $key => $value){
  9096. $final_list[] = array_values($value) ;
  9097. }
  9098. if(empty($final_list)){
  9099. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9100. }
  9101. array_unshift($final_list, $first_row);
  9102. $merges = [];
  9103. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9104. }
  9105. }
  9106. }