Whlabel.php 315 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310
  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. }
  47. //定义方法的调用规则 获取URI第二段值
  48. public function _remap($arg, $arg_array)
  49. {
  50. if ($arg == 'existence') //在库标签
  51. {
  52. $this->_existence();
  53. } else if ($arg == 'cpbqdc') //在库标签
  54. {
  55. $this->_cpbqdc();
  56. } else if ($arg == 'type') //进销存浏览
  57. {
  58. $this->_type();
  59. } else if ($arg == 'typedy') //进销存浏览店员页面
  60. {
  61. $this->_typedy($arg_array);
  62. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  63. {
  64. $this->_typedy_ck($arg_array);
  65. } else if ($arg == 'typeck') {
  66. $this->_typeck($arg_array);
  67. } else if ($arg == 'whlabeckdc') {
  68. $this->_whlabeckdc($arg_array);
  69. } else if ($arg == 'usatype') //美仓进销存浏览
  70. {
  71. $this->_usatype();
  72. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  73. {
  74. $this->_usatypeapp();
  75. } else if ($arg == 'enteradd') //入库操作
  76. {
  77. $this->_enteradd();
  78. } else if ($arg == 'enteredit') //修改
  79. {
  80. $this->_enteredit($arg_array);
  81. } else if ($arg == 'enter') //入库浏览
  82. {
  83. $this->_enter();
  84. } else if ($arg == 'out') //出库浏览
  85. {
  86. $this->_out();
  87. } else if ($arg == 'label') //出库标签浏览
  88. {
  89. $this->_label();
  90. } else if ($arg == 'outorder') //独立站出库订单
  91. {
  92. $this->_outorder();
  93. } else if ($arg == 'soutorder') //速卖通出库订单
  94. {
  95. $this->_soutorder();
  96. } else if ($arg == 'toutorder') //TT出库订单
  97. {
  98. $this->_toutorder();
  99. }else if ($arg == 'aoutorder') //amz出库订单
  100. {
  101. $this->_aoutorder();
  102. } else if ($arg == 'retreat') //退库订单
  103. {
  104. $this->_retreat();
  105. } else if ($arg == 'retreatlk') //退库订单
  106. {
  107. $this->_retreatlk();
  108. } else if ($arg == 'change') //更换标签
  109. {
  110. $this->_change();
  111. } else if ($arg == 'del') //删除
  112. {
  113. $this->_del();
  114. } else if ($arg == 'exceljxc') //进销存信息导出
  115. {
  116. $this->_exceljxc();
  117. } else if ($arg == 'excelr') //入库信息导出
  118. {
  119. $this->_excelr();
  120. } else if ($arg == 'excelct') //出库、退库信息导出
  121. {
  122. $this->_excelct();
  123. } else if ($arg == 'dccrtype') //根据出入库类型导出
  124. {
  125. $this->_dccrtype();
  126. } else if ($arg == 'excelcr') //出库、退库信息导出
  127. {
  128. $this->_excelcr();
  129. } else if ($arg == 'kcyz') //库存验证
  130. {
  131. $this->_kcyz();
  132. } else if ($arg == 'kj') //库存扣减
  133. {
  134. $this->_kj($arg_array);
  135. } else if ($arg == 'presetout') //预设库存导入
  136. {
  137. $this->_presetout($arg_array);
  138. } else if ($arg == 'presetedit') //预设库存导入
  139. {
  140. $this->_presetedit($arg_array);
  141. }else if ($arg == 'presetedittwo') //预设库存导入
  142. {
  143. $this->_presetedittwo($arg_array);
  144. } else if ($arg == 'summary') //汇总导出
  145. {
  146. $this->_summary($arg_array);
  147. } else if ($arg == 'manifest') //usps发货清单
  148. {
  149. $this->_manifest();
  150. } else if ($arg == 'abnormal') //占单异常
  151. {
  152. $this->_abnormal();
  153. } else if ($arg == 'error') //0库存SKU
  154. {
  155. $this->_error();
  156. } else if ($arg == 'errorexcel') //0库存SKU导出
  157. {
  158. $this->_errorexcel();
  159. } else if ($arg == 'db') {
  160. $this->_db();
  161. } else if ($arg == 'dbrk') {
  162. $this->_dbrk();
  163. } else if ($arg == 'whlabelczdc') {
  164. $this->_whlabelczdc();
  165. } else if ($arg == 'print') {
  166. $this->_print($arg_array);
  167. } else if ($arg == 'usaprint') {
  168. $this->_usaprint($arg_array);
  169. } else if ($arg == 'printck') {
  170. $this->_printck($arg_array);
  171. } else if ($arg == 'printrk') {
  172. $this->_printrk($arg_array);
  173. } else if ($arg == 'printxzrk') {
  174. $this->_printxzrk($arg_array);
  175. } else if ($arg == 'printexcel') {
  176. $this->_printexcel($arg_array);
  177. } else if ($arg == 'uck') {
  178. $this->_uck();
  179. } else if ($arg == 'whlabelexcelzh') {
  180. $this->_whlabelexcelzh();
  181. } else if ($arg == 'fc') {
  182. $this->_fc();
  183. } else if ($arg == 'fcmb') {
  184. $this->_fcmb();
  185. } else if ($arg == 'fcexcel') {
  186. $this->_fcexcel();
  187. } else if ($arg == 'fcjxc') {
  188. $this->_fcjxc($arg_array);
  189. } else if ($arg == '0kcdel') {
  190. $this->_0kcdel(); //导表删除0库存
  191. } else if ($arg == 'gbhtype') {
  192. $this->_gbhtype(); //更改备货状态
  193. } else if($arg == 'excelrjs'){
  194. $this->_excelrjs();
  195. } else if($arg == 'excelctjs'){
  196. $this->_excelctjs();
  197. }else if ($arg == 'exceljxcjs') //进销存信息导出
  198. {
  199. $this->_exceljxcjs();
  200. } else if ($arg == 'summaryjs') //汇总导出
  201. {
  202. $this->_summaryjs($arg_array);
  203. }else if($arg == 'uckjs'){
  204. $this->_uckjs();
  205. }else if ($arg == 'whlabelexcelzhjs') {
  206. $this->_whlabelexcelzhjs();
  207. }else if($arg == 'dccrtypejs'){
  208. $this->_dccrtypejs();
  209. }else if($arg == 'errorexceljs'){
  210. $this->_errorexceljs();
  211. }else if($arg == "w_t_cs"){
  212. $this->_w_t_cs(); //首页
  213. }else {
  214. $this->_index();
  215. }
  216. }
  217. public function _w_t_cs(){
  218. $vip = 0;
  219. if (isset($_SESSION['api'])) {
  220. $user = $this->user->get_api($_SESSION['api']);
  221. $fgshop = "";
  222. $sid = "";
  223. $usersp = explode('|', trim($user['shop'], '|'));
  224. foreach ($usersp as $value) {
  225. $fgshop .= " shop = " . $value . " or";
  226. $sid .= " id = " . $value . " or";
  227. }
  228. if ($user['vip'] == 1) {
  229. $vip = 1;
  230. }
  231. } else {
  232. header('Location: /');
  233. exit;
  234. }
  235. $prc = array();
  236. $purchase = $this->purchase->find_all();
  237. foreach ($purchase as $k => $v) {
  238. $prc[$v['id']] = $v['title'];
  239. }
  240. $company = array();
  241. $ct = $this->company->find_all();
  242. foreach ($ct as $k => $v) {
  243. $company[$v['id']] = $v['title'];
  244. }
  245. $sp = array();
  246. $s = $this->shop->find_all('1=1', 'id,shopname');
  247. foreach ($s as $v) {
  248. $sp[$v['id']] = $v['shopname'];
  249. }
  250. $wh = array();
  251. $w = $this->warehouse->find_all('1=1', 'id,title');
  252. foreach ($w as $v) {
  253. $wh[$v['id']] = $v['title'];
  254. }
  255. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  256. $this->data['shop'] = $wlshop;
  257. $this->data['vip'] = $vip;
  258. $this->_Template('whlabel_typejs', $this->data);
  259. }
  260. //管理
  261. public function _index()
  262. {
  263. $post = $this->input->post(NULL, TRUE);
  264. if (isset($post['page'])) {
  265. $page = $this->input->post('page', true);
  266. $perpage = $this->input->post('perpage', true);
  267. $sku = $this->input->post('sku', true);
  268. $number = $this->input->post('number', true);
  269. $warehouse = $this->input->post('warehouse', true);
  270. $purchase = $this->input->post('purchase', true);
  271. $orderinfo = $this->input->post('orderinfo', true);
  272. $waybill = $this->input->post('waybill', true);
  273. $category = $this->input->post('category', true);
  274. $size = $this->input->post('size', true);
  275. $grade = $this->input->post('grade', true);
  276. $color = $this->input->post('color', true);
  277. $lowe = $this->input->post('lowe', true);
  278. $state = $this->input->post('state', true);
  279. $label = $this->input->post('label', true);
  280. $timetk = $this->input->post('timetkk', true);
  281. $timetj = $this->input->post('timetjj', true);
  282. $timetk = strtotime($timetk);
  283. $timetj = strtotime($timetj);
  284. $where = "1=1 ";
  285. if ($timetk && $timetj) {
  286. $where .= " and time > '$timetk' and time < '$timetj'";
  287. }
  288. if ($sku) {
  289. $where .= " and sku = '$sku'";
  290. }
  291. if ($number) {
  292. $where .= " and number = '$number'";
  293. }
  294. if ($warehouse) {
  295. $where .= " and warehouse = '$warehouse'";
  296. }
  297. if ($purchase) {
  298. $where .= " and purchase = '$purchase'";
  299. }
  300. if ($orderinfo) {
  301. $where .= " and orderinfo = '$orderinfo'";
  302. }
  303. if ($waybill) {
  304. $where .= " and waybill = '$waybill'";
  305. }
  306. if ($category) {
  307. $where .= " and features like '%-$category-%'";
  308. }
  309. if ($size) {
  310. $where .= " and features like '%-$size-%'";
  311. }
  312. if ($grade) {
  313. $where .= " and features like '%-$grade-%'";
  314. }
  315. if ($color) {
  316. $where .= " and features like '%-$color-%'";
  317. }
  318. if ($lowe) {
  319. $where .= " and features like '%-$lowe-%'";
  320. }
  321. if ($label) {
  322. $where .= " and label = '$label'";
  323. }
  324. if ($state != '') {
  325. $where .= " and state = '$state'";
  326. }
  327. //数据排序
  328. $order_str = "time desc";
  329. if (empty($page)) {
  330. $start = 0;
  331. $perpage = 1;
  332. } else {
  333. $start = ($page - 1) * $perpage;
  334. }
  335. //取得信息列表
  336. $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);
  337. foreach ($info_list as $key => $value) {
  338. $warehouse = $this->warehouse->read($value['warehouse']);
  339. $info_list[$key]['warehouse'] = $warehouse['title'];
  340. $purchase = $this->purchase->read($value['purchase']);
  341. $info_list[$key]['purchase'] = $purchase['title'];
  342. if ($value['enter'] != 0) {
  343. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  344. } else {
  345. $info_list[$key]['enter'] = "";
  346. }
  347. if ($value['outk'] != 0) {
  348. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  349. } else {
  350. $info_list[$key]['outk'] = "";
  351. }
  352. if ($value['printing'] != 0) {
  353. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  354. } else {
  355. $info_list[$key]['printing'] = "";
  356. }
  357. if ($value['orderinfo'] == 0) {
  358. $info_list[$key]['orderinfo'] = "";
  359. }
  360. if ($value['waybill'] == 0) {
  361. $info_list[$key]['waybill'] = "";
  362. }
  363. if ($value['state'] == 0) {
  364. $info_list[$key]['state'] = "在库";
  365. } else if ($value['state'] == 1) {
  366. $info_list[$key]['state'] = "出库";
  367. } else if ($value['state'] == 2) {
  368. $info_list[$key]['state'] = "退库";
  369. } else if ($value['state'] == 3) {
  370. $info_list[$key]['state'] = "调拨中";
  371. } else if ($value['state'] == 4) {
  372. $info_list[$key]['state'] = "再加工";
  373. } else if ($value['state'] == 5) {
  374. $info_list[$key]['state'] = "维修中";
  375. } else if ($value['state'] == 6) {
  376. $info_list[$key]['state'] = "盘亏";
  377. } else if ($value['state'] == 7) {
  378. $info_list[$key]['state'] = "更换标签";
  379. } else if ($value['state'] == 8) {
  380. $info_list[$key]['state'] = "其它";
  381. } else if ($value['state'] == 9) {
  382. $info_list[$key]['state'] = "预设";
  383. } else if ($value['state'] == 10) {
  384. $info_list[$key]['state'] = "美店零售";
  385. }
  386. if ($value['text'] == "") {
  387. $info_list[$key]['text'] = "";
  388. }
  389. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  390. }
  391. $total = $this->whlabel->find_count($where);
  392. $pagenum = ceil($total / $perpage);
  393. $over = $total - ($start + $perpage);
  394. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  395. echo json_encode($rows);
  396. exit;
  397. }
  398. if (isset($post['outsku'])) {
  399. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  400. $cz = $this->input->post('cz', true);
  401. if ($cz == '1') {
  402. $sku = $this->input->post('outsku', true);
  403. if ($sku) {
  404. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  405. if (count($data) < 1) {
  406. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  407. exit;
  408. }
  409. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  410. echo json_encode(array('success' => true));
  411. exit;
  412. }
  413. } else {
  414. $sku = $this->input->post('outsku', true);
  415. if ($sku) {
  416. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  417. if (count($data) < 1) {
  418. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  419. exit;
  420. }
  421. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  422. echo json_encode(array('success' => true));
  423. exit;
  424. }
  425. }
  426. }
  427. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  428. $this->_Template('whlabel', $this->data);
  429. }
  430. //在库标签
  431. public function _existence()
  432. {
  433. $post = $this->input->post(NULL, TRUE);
  434. if (isset($post['s'])) {
  435. $id_arr = $this->input->post('s');
  436. $id_arr = explode(',', $id_arr);
  437. if (!$id_arr) {
  438. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  439. exit;
  440. }
  441. //循环删除记录
  442. foreach ($id_arr as $v) {
  443. $sid = $this->whlabel->read($v);
  444. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  445. if ($count > 0) {
  446. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  447. exit;
  448. }
  449. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  450. if (count($zt) > 0) {
  451. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  452. exit;
  453. }
  454. $this->whlabel->remove($v);
  455. }
  456. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  457. exit;
  458. }
  459. if (isset($post['page'])) {
  460. $page = $this->input->post('page', true);
  461. $perpage = $this->input->post('perpage', true);
  462. $warehouse = $this->input->post('warehouse', true);
  463. $label = $this->input->post('label', true);
  464. $where = "1=1 and state = 0";
  465. if ($warehouse) {
  466. $where .= " and warehouse = '$warehouse'";
  467. }
  468. if ($label) {
  469. $where .= " and label = '$label'";
  470. }
  471. //数据排序
  472. $order_str = "time asc";
  473. if (empty($page)) {
  474. $start = 0;
  475. $perpage = 1;
  476. } else {
  477. $start = ($page - 1) * $perpage;
  478. }
  479. //取得信息列表
  480. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  481. foreach ($info_list as $key => $value) {
  482. if ($value['enter'] != 0) {
  483. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  484. } else {
  485. $info_list[$key]['enter'] = "";
  486. }
  487. if ($value['printing'] != 0) {
  488. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  489. } else {
  490. $info_list[$key]['printing'] = "";
  491. }
  492. }
  493. $total = $this->whlabel->find_count($where);
  494. $pagenum = ceil($total / $perpage);
  495. $over = $total - ($start + $perpage);
  496. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  497. echo json_encode($rows);
  498. exit;
  499. }
  500. $this->_Template('whlabel_existence', $this->data);
  501. }
  502. //进销存浏览
  503. public function _typedy($arg_array)
  504. {
  505. $prc = array();
  506. $purchase = $this->purchase->find_all();
  507. foreach ($purchase as $k => $v) {
  508. $prc[$v['id']] = $v['title'];
  509. }
  510. $post = $this->input->post(NULL, TRUE);
  511. if (isset($post['page'])) {
  512. $page = $this->input->post('page', true);
  513. $perpage = $this->input->post('perpage', true);
  514. $category = $this->input->post('category', true);
  515. $size = $this->input->post('size', true);
  516. $grade = $this->input->post('grade', true);
  517. $color = $this->input->post('color', true);
  518. $lowe = $this->input->post('lowe', true);
  519. $sku = $this->input->post('sku');
  520. $title = $this->input->post('title');
  521. $warehouse = $this->input->post('warehouse', true);
  522. $usa = $this->input->post('usa', true);
  523. $purchase = $this->input->post('purchase', true);
  524. $lacetype = $this->input->post('lacetype', true);
  525. $haircap = $this->input->post('haircap', true);
  526. $density = $this->input->post('density', true);
  527. $details = $this->input->post('details', true);
  528. $state = $this->input->post('state', true);
  529. $lacecolor = $this->input->post('lacecolor', true);
  530. $hairnumber = $this->input->post('hairnumber', true);
  531. $cklx = $this->input->post('cklx', true);
  532. $ktime = $this->input->post('ktime', true);
  533. $jtime = $this->input->post('jtime', true);
  534. $sm = $this->input->post('sm', true);
  535. $cpbz = $this->input->post('cpbz', true);
  536. $type = $this->input->post('type', true);
  537. $ktime = strtotime($ktime);
  538. $jtime = strtotime($jtime);
  539. $where = "1=1";
  540. $gj = "";
  541. $ck = "";
  542. if ($usa) {
  543. if (!$warehouse) {
  544. $where .= " and (warehouse = '5' or warehouse = '8')";
  545. }
  546. }
  547. if ($warehouse) {
  548. $where .= " and warehouse = '$warehouse'";
  549. }
  550. if ($details) {
  551. $where .= " and details = '$details'";
  552. }
  553. if ($purchase) {
  554. $where .= " and purchase = '$purchase'";
  555. }
  556. if (isset($state)) {
  557. if($state >-1){
  558. $where .= " and state = '$state'";
  559. }
  560. }
  561. if ($lacetype) {
  562. $where .= " and features like '%-$lacetype-%'";
  563. }
  564. if ($category) {
  565. $where .= " and features like '%-$category-%'";
  566. }
  567. if ($size) {
  568. $where .= " and features like '%-$size-%'";
  569. }
  570. if ($grade) {
  571. $where .= " and features like '%-$grade-%'";
  572. }
  573. if ($color) {
  574. $where .= " and features like '%-$color-%'";
  575. }
  576. if ($lowe) {
  577. $where .= " and features like '%-$lowe-%'";
  578. }
  579. if ($haircap) {
  580. $where .= " and features like '%-$haircap-%'";
  581. }
  582. if ($density) {
  583. $where .= " and features like '%-$density-%'";
  584. }
  585. if ($lacecolor) {
  586. $where .= " and features like '%-$lacecolor-%'";
  587. }
  588. if($sm){
  589. $where .= " and sm like '%".$sm."%'";
  590. }
  591. if($cpbz){
  592. $where .= " and cpbz like '%".$cpbz."%'";
  593. }
  594. if($type){
  595. $where .= " and type = ".$type."";
  596. }
  597. if (!empty($hairnumber)) {
  598. $where .= " and features like '%-128-%' ";
  599. if ($hairnumber < 0) {
  600. $class_list = $this->typeclass->find_all('classid = 43');
  601. foreach ($class_list as $v) {
  602. $where .= " and features not like '%-" . $v['id'] . "-%'";
  603. }
  604. } else {
  605. $where .= " and features like '%-$hairnumber-%'";
  606. }
  607. }
  608. $where_add = '';
  609. if ($cklx) {
  610. $shop = $this->shop->read($cklx);
  611. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  612. }
  613. if ($ktime && $jtime) {
  614. $gj = " and enter > '$ktime' and enter < '$jtime'";
  615. $ck = " and outk > '$ktime' and outk < '$jtime'";
  616. }
  617. //数据排序
  618. $order_str = "id desc";
  619. if (empty($page)) {
  620. $start = 0;
  621. $perpage = 1;
  622. } else {
  623. $start = ($page - 1) * $perpage;
  624. }
  625. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  626. if ($sku) {
  627. $sku = trim($sku, ' ');
  628. $sku = trim($sku, ' ');
  629. $where .= " and sku like '%$sku%'";
  630. $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);
  631. } else if ($title) {
  632. $title = trim($title, ' ');
  633. $title = trim($title, ' ');
  634. $where .= " and title like '%$title%'";
  635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  636. } else {
  637. //$where .= " and time > '$ktime' and time < '$jtime'";
  638. $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);
  639. }
  640. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  641. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  642. foreach ($info_list as $k => $v) {
  643. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  644. unset($info_list[$k]['pm']);
  645. unset($info_list[$k]['jm']);
  646. unset($info_list[$k]['bm']);
  647. }
  648. //取得信息列表
  649. $rows = array();
  650. $list = array();
  651. foreach ($info_list as $key => $value) {
  652. $warehouse = $this->warehouse->read($value['warehouse']);
  653. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  654. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  655. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  656. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  657. $info_list[$key]['label'] = $value['sm'];
  658. $number = $value['number'];
  659. $ftime = time() - 15 * 24 * 3600;
  660. $info_list[$key]['warehouse'] = $warehouse['title'];
  661. $info_list[$key]['features'] = count($c);
  662. $z = count($z); //查看订单号
  663. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  664. $ztdata = '';
  665. if (count($zt) > 0) {
  666. foreach ($zt as $vv) {
  667. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  668. }
  669. }
  670. $info_list[$key]['number'] = $ztdata;
  671. $info_list[$key]['sm'] = $z;
  672. $details = array();
  673. $cpid = array();
  674. foreach ($c as $k => $v) {
  675. $details[$v['details']] = $v['details'];
  676. if ($v['cpid'] != 0) {
  677. $cpid[$v['cpid']] = $v['cpid'];
  678. }
  679. }
  680. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  681. if ($value['shop'] != '') {
  682. $shop = explode(',', trim($value['shop'], ','));
  683. $shop = $this->shop->read($shop[0]);
  684. $info_list[$key]['shop'] = $shop['shopname'];
  685. }
  686. }
  687. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  688. $pagenum = ceil($total / $perpage);
  689. $over = $total - ($start + $perpage);
  690. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  691. echo json_encode($rows);
  692. exit;
  693. }
  694. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  695. $this->_Template('whlabel_typedy', $this->data);
  696. }
  697. //进销存浏览
  698. public function _typedy_ck($arg_array)
  699. {
  700. $prc = array();
  701. $purchase = $this->purchase->find_all();
  702. foreach ($purchase as $k => $v) {
  703. $prc[$v['id']] = $v['title'];
  704. }
  705. $post = $this->input->post(NULL, TRUE);
  706. if (isset($post['page'])) {
  707. $page = $this->input->post('page', true);
  708. $perpage = $this->input->post('perpage', true);
  709. $category = $this->input->post('category', true);
  710. $size = $this->input->post('size', true);
  711. $grade = $this->input->post('grade', true);
  712. $color = $this->input->post('color', true);
  713. $lowe = $this->input->post('lowe', true);
  714. $sku = $this->input->post('sku');
  715. $title = $this->input->post('title');
  716. $warehouse = $this->input->post('warehouse', true);
  717. $usa = $this->input->post('usa', true);
  718. $purchase = $this->input->post('purchase', true);
  719. $lacetype = $this->input->post('lacetype', true);
  720. $haircap = $this->input->post('haircap', true);
  721. $density = $this->input->post('density', true);
  722. $details = $this->input->post('details', true);
  723. $state = $this->input->post('state', true);
  724. $lacecolor = $this->input->post('lacecolor', true);
  725. $cklx = $this->input->post('cklx', true);
  726. $ktime = $this->input->post('ktime', true);
  727. $jtime = $this->input->post('jtime', true);
  728. $ktime = strtotime($ktime);
  729. $jtime = strtotime($jtime);
  730. $where = "1=1";
  731. $gj = "";
  732. $ck = "";
  733. if ($lacetype) {
  734. $where .= " and features like '%-$lacetype-%'";
  735. }
  736. if ($category) {
  737. $where .= " and features like '%-$category-%'";
  738. }
  739. if ($size) {
  740. $where .= " and features like '%-$size-%'";
  741. }
  742. if ($grade) {
  743. $where .= " and features like '%-$grade-%'";
  744. }
  745. if ($color) {
  746. $where .= " and features like '%-$color-%'";
  747. }
  748. if ($lowe) {
  749. $where .= " and features like '%-$lowe-%'";
  750. }
  751. if ($haircap) {
  752. $where .= " and features like '%-$haircap-%'";
  753. }
  754. if ($density) {
  755. $where .= " and features like '%-$density-%'";
  756. }
  757. if ($lacecolor) {
  758. $where .= " and features like '%-$lacecolor-%'";
  759. }
  760. if ($usa) {
  761. if (!$warehouse) {
  762. $where .= " and (warehouse = '5' or warehouse = '8')";
  763. }
  764. }
  765. if ($warehouse) {
  766. $where .= " and warehouse = '$warehouse'";
  767. }
  768. if ($details) {
  769. $where .= " and details = '$details'";
  770. }
  771. if ($purchase) {
  772. $where .= " and purchase = '$purchase'";
  773. }
  774. if ($state) {
  775. $where .= " and state = '$state'";
  776. }
  777. $where_add = '';
  778. if ($cklx) {
  779. $shop = $this->shop->read($cklx);
  780. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  781. }
  782. if ($ktime && $jtime) {
  783. $gj = " and enter > '$ktime' and enter < '$jtime'";
  784. $ck = " and outk > '$ktime' and outk < '$jtime'";
  785. }
  786. //数据排序
  787. $order_str = "id desc";
  788. if (empty($page)) {
  789. $start = 0;
  790. $perpage = 1;
  791. } else {
  792. $start = ($page - 1) * $perpage;
  793. }
  794. if ($sku) {
  795. $sku = trim($sku, ' ');
  796. $sku = trim($sku, ' ');
  797. $where .= " and sku like '%$sku%'";
  798. $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);
  799. } else if ($title) {
  800. $title = trim($title, ' ');
  801. $title = trim($title, ' ');
  802. $where .= " and title like '%$title%'";
  803. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  804. } else {
  805. //$where .= " and time > '$ktime' and time < '$jtime'";
  806. $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);
  807. }
  808. //取得信息列表
  809. $rows = array();
  810. $list = array();
  811. foreach ($info_list as $key => $value) {
  812. $warehouse = $this->warehouse->read($value['warehouse']);
  813. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  814. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  815. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  816. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  817. $ftime = time() - 15 * 24 * 3600;
  818. $info_list[$key]['warehouse'] = $warehouse['title'];
  819. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  820. //$z = count($z);//查看订单号
  821. //$info_list[$key]['zd'] = $z;
  822. $details = array();
  823. $cpid = array();
  824. foreach ($c as $k => $v) {
  825. $details[$v['details']] = $v['details'];
  826. if ($v['cpid'] != 0) {
  827. $cpid[$v['cpid']] = $v['cpid'];
  828. }
  829. }
  830. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  831. if ($value['shop'] != '') {
  832. $shop = explode(',', trim($value['shop'], ','));
  833. $shop = $this->shop->read($shop[0]);
  834. $info_list[$key]['shop'] = $shop['shopname'];
  835. }
  836. }
  837. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  838. $pagenum = ceil($total / $perpage);
  839. $over = $total - ($start + $perpage);
  840. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  841. echo json_encode($rows);
  842. exit;
  843. }
  844. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  845. $this->_Template('whlabel_typedy_ck', $this->data);
  846. }
  847. public function _typeck($arg_array)
  848. {
  849. $prc = array();
  850. $purchase = $this->purchase->find_all();
  851. foreach ($purchase as $k => $v) {
  852. $prc[$v['id']] = $v['title'];
  853. }
  854. $post = $this->input->post(NULL, TRUE);
  855. if (isset($post['page'])) {
  856. $page = $this->input->post('page', true);
  857. $perpage = $this->input->post('perpage', true);
  858. $category = $this->input->post('category', true);
  859. $size = $this->input->post('size', true);
  860. $grade = $this->input->post('grade', true);
  861. $color = $this->input->post('color', true);
  862. $lacecolor = $this->input->post('lacecolor', true);
  863. $lowe = $this->input->post('lowe', true);
  864. $sku = $this->input->post('sku');
  865. $title = $this->input->post('title');
  866. $warehouse = 13;
  867. $usa = $this->input->post('usa', true);
  868. $purchase = $this->input->post('purchase', true);
  869. $lacetype = $this->input->post('lacetype', true);
  870. $haircap = $this->input->post('haircap', true);
  871. $density = $this->input->post('density', true);
  872. $details = $this->input->post('details', true);
  873. $state = $this->input->post('state', true);
  874. $ktime = $this->input->post('ktime', true);
  875. $jtime = $this->input->post('jtime', true);
  876. $ktime = strtotime($ktime);
  877. $jtime = strtotime($jtime);
  878. $where = "1=1";
  879. $gj = "";
  880. $ck = "";
  881. if ($lacetype) {
  882. $where .= " and features like '%-$lacetype-%'";
  883. }
  884. if ($category) {
  885. $where .= " and features like '%-$category-%'";
  886. }
  887. if ($size) {
  888. $where .= " and features like '%-$size-%'";
  889. }
  890. if ($grade) {
  891. $where .= " and features like '%-$grade-%'";
  892. }
  893. if ($color) {
  894. $where .= " and features like '%-$color-%'";
  895. }
  896. if ($lacecolor) {
  897. $where .= " and features like '%-$lacecolor-%'";
  898. }
  899. if ($lowe) {
  900. $where .= " and features like '%-$lowe-%'";
  901. }
  902. if ($haircap) {
  903. $where .= " and features like '%-$haircap-%'";
  904. }
  905. if ($density) {
  906. $where .= " and features like '%-$density-%'";
  907. }
  908. if ($warehouse) {
  909. $where .= " and warehouse = '$warehouse'";
  910. }
  911. if ($details) {
  912. $where .= " and details = '$details'";
  913. }
  914. if ($purchase) {
  915. $where .= " and purchase = '$purchase'";
  916. }
  917. if ($state) {
  918. $where .= " and state = '$state'";
  919. }
  920. if ($ktime && $jtime) {
  921. $gj = " and enter > '$ktime' and enter < '$jtime'";
  922. $ck = " and outk > '$ktime' and outk < '$jtime'";
  923. }
  924. //数据排序
  925. $order_str = "id desc";
  926. if (empty($page)) {
  927. $start = 0;
  928. $perpage = 1;
  929. } else {
  930. $start = ($page - 1) * $perpage;
  931. }
  932. if ($sku) {
  933. $sku = trim($sku, ' ');
  934. $sku = trim($sku, ' ');
  935. $where .= " and sku like '%$sku%'";
  936. } else if ($title) {
  937. $title = trim($title, ' ');
  938. $title = trim($title, ' ');
  939. $where .= " and title like '%$title%'";
  940. }
  941. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  942. //取得信息列表
  943. $t = array();
  944. $typeclass = $this->typeclass->find_all();
  945. foreach ($typeclass as $v) {
  946. $t[$v['id']] = $v;
  947. }
  948. $rows = array();
  949. $list = array();
  950. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  951. foreach ($info_list as $key => $value) {
  952. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  953. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  954. $warehouse = $this->warehouse->read($value['warehouse']);
  955. $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');
  956. $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'] . '"');
  957. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  958. $number = $value['number'];
  959. $ftime = time() - 15 * 24 * 3600;
  960. $z = count($z); //查看订单号
  961. $info_list[$key]['warehouse'] = $warehouse['title'];
  962. $info_list[$key]['features'] = count($c);
  963. $info_list[$key]['number'] = $z;
  964. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  965. $details = array();
  966. $cpid = array();
  967. foreach ($c as $k => $v) {
  968. $details[$v['details']] = $v['details'];
  969. if ($v['cpid'] != 0) {
  970. $cpid[$v['cpid']] = $v['cpid'];
  971. }
  972. }
  973. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  974. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  975. unset($info_list[$key]['pm']);
  976. unset($info_list[$key]['jm']);
  977. unset($info_list[$key]['bm']);
  978. }
  979. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  980. $pagenum = ceil($total / $perpage);
  981. $over = $total - ($start + $perpage);
  982. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  983. echo json_encode($rows);
  984. exit;
  985. }
  986. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  987. $this->_Template('whlabel_typeck', $this->data);
  988. }
  989. //进销存导出
  990. public function _whlabeckdc()
  991. {
  992. $prc = array();
  993. $purchase = $this->purchase->find_all();
  994. foreach ($purchase as $k => $v) {
  995. $prc[$v['id']] = $v['title'];
  996. }
  997. if (isset($_GET['excel'])) {
  998. $where = "sku != 'Preset'";
  999. //数据排序
  1000. $order_str = "id desc";
  1001. if (empty($page)) {
  1002. $start = 0;
  1003. $perpage = 1;
  1004. } else {
  1005. $start = ($page - 1) * $perpage;
  1006. }
  1007. $category = $this->input->get('category', true);
  1008. $color = $this->input->get('color', true);
  1009. $lowe = $this->input->get('lowe', true);
  1010. $lacetype = $this->input->get('lacetype', true);
  1011. $size = $this->input->get('size', true);
  1012. $density = $this->input->get('density', true);
  1013. $haircap = $this->input->get('haircap', true);
  1014. $sku = $this->input->get('sku', true);
  1015. $details = $this->input->get('details', true);
  1016. $warehouse = 13;
  1017. $excelid = $this->input->get('sid', true);
  1018. if ($category) {
  1019. $where .= " and features like '%-$category-%'";
  1020. }
  1021. if ($color) {
  1022. $where .= " and features like '%-$color-%'";
  1023. }
  1024. if ($lowe) {
  1025. $where .= " and features like '%-$lowe-%'";
  1026. }
  1027. if ($lacetype) {
  1028. $where .= " and features like '%-$lacetype-%'";
  1029. }
  1030. if ($size) {
  1031. $where .= " and features like '%-$size-%'";
  1032. }
  1033. if ($density) {
  1034. $where .= " and features like '%-$density-%'";
  1035. }
  1036. if ($haircap) {
  1037. $where .= " and features like '%-$haircap-%'";
  1038. }
  1039. if ($warehouse) {
  1040. $where .= " and warehouse = '$warehouse'";
  1041. }
  1042. if ($sku) {
  1043. $where .= " and sku like '%$sku%'";
  1044. }
  1045. if ($details) {
  1046. $where .= " and details = '$details'";
  1047. }
  1048. $xzid = '';
  1049. if ($excelid) {
  1050. $excelid = explode(',', trim($excelid, ','));
  1051. foreach ($excelid as $key => $value) {
  1052. $xzid .= " id = " . $value . " or";
  1053. }
  1054. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1055. }
  1056. //取得信息列表
  1057. /**
  1058. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1059. $rows = array();$list = array();
  1060. foreach ($info_list as $key=>$value)
  1061. {
  1062. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1063. }
  1064. **/
  1065. $wh = array();
  1066. $w = $this->warehouse->find_all('1=1', 'id,title');
  1067. foreach ($w as $v) {
  1068. $wh[$v['id']] = $v['title'];
  1069. }
  1070. $tc = array();
  1071. $tcdata = array();
  1072. $list = array();
  1073. $classid = $this->classid->sku();
  1074. $tcall = $this->typeclass->find_all();
  1075. $typeclass = array();
  1076. foreach ($tcall as $v)
  1077. {
  1078. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1079. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1080. }
  1081. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1082. foreach ($rows as $key => $value) {
  1083. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1084. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1085. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1086. $rows[$key]['cpbz'] = $u9_info['bm'];
  1087. $rows[$key]['cs'] = $u9_info['jm'];
  1088. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1089. $details = array();
  1090. $cpid = array();
  1091. $cpbz = array();
  1092. $c = 0;
  1093. $g = 0;
  1094. $x = 0;
  1095. $t = 0;
  1096. $s = 0;
  1097. $q = 0;
  1098. foreach ($sd as $k => $v) {
  1099. if ($v['state'] == 0) {
  1100. $c++;
  1101. }
  1102. if ($v['state'] != 9) {
  1103. $g++;
  1104. }
  1105. if ($v['state'] == 1) {
  1106. $x++;
  1107. }
  1108. if ($v['state'] == 2) {
  1109. $t++;
  1110. }
  1111. if ($v['state'] == 8) {
  1112. $s++;
  1113. }
  1114. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1115. $q++;
  1116. }
  1117. $details[$v['details']] = $v['details'];
  1118. if ($v['cpid'] != 0) {
  1119. $cpid[$v['cpid']] = $v['cpid'];
  1120. }
  1121. if ($v['cpbz'] != '') {
  1122. $cpbz[$v['cpbz']] = $v['cpbz'];
  1123. }
  1124. }
  1125. $rows[$key]['details'] = implode("、", $details);
  1126. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1127. $number = $value['number'];
  1128. $ftime = time() - 15 * 24 * 3600;
  1129. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1130. $rows[$key]['number'] = $g;
  1131. $rows[$key]['features'] = $c;
  1132. $rows[$key]['x'] = $x;
  1133. $rows[$key]['t'] = $t;
  1134. $rows[$key]['s'] = $s;
  1135. $rows[$key]['q'] = $q;
  1136. $rows[$key]['wzsl'] = count($details);
  1137. }
  1138. $title = "进销存统计表" . date('Y-m-d', time());
  1139. $titlename = "<table border=1>
  1140. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1141. <tr align='center'>
  1142. <td>仓库</td>
  1143. <td>供应商</td>
  1144. <td>位置</td>
  1145. <td>库存编码</td>
  1146. <td>SKU</td>
  1147. <td>用友编码</td>
  1148. <td>用友料号</td>
  1149. <td>产品英文名</td>
  1150. <td>产品中文名</td>
  1151. <td>入库总量</td>
  1152. <td>库存数量</td>
  1153. <td>销售数量</td>
  1154. <td>退货数量</td>
  1155. <td>删除数量</td>
  1156. <td>其它操作</td>
  1157. <td>位置数量</td>
  1158. </tr>
  1159. </table>";
  1160. $filename = $title . ".xls";
  1161. $tail = "";
  1162. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1163. }
  1164. }
  1165. public function _type()
  1166. {
  1167. $vip = 0;
  1168. if (isset($_SESSION['api'])) {
  1169. $user = $this->user->get_api($_SESSION['api']);
  1170. $fgshop = "";
  1171. $sid = "";
  1172. $usersp = explode('|', trim($user['shop'], '|'));
  1173. foreach ($usersp as $value) {
  1174. $fgshop .= " shop = " . $value . " or";
  1175. $sid .= " id = " . $value . " or";
  1176. }
  1177. if ($user['vip'] == 1) {
  1178. $vip = 1;
  1179. }
  1180. } else {
  1181. header('Location: /');
  1182. exit;
  1183. }
  1184. $prc = array();
  1185. $purchase = $this->purchase->find_all();
  1186. foreach ($purchase as $k => $v) {
  1187. $prc[$v['id']] = $v['title'];
  1188. }
  1189. $company = array();
  1190. $ct = $this->company->find_all();
  1191. foreach ($ct as $k => $v) {
  1192. $company[$v['id']] = $v['title'];
  1193. }
  1194. $sp = array();
  1195. $s = $this->shop->find_all('1=1', 'id,shopname');
  1196. foreach ($s as $v) {
  1197. $sp[$v['id']] = $v['shopname'];
  1198. }
  1199. $wh = array();
  1200. $w = $this->warehouse->find_all('1=1', 'id,title');
  1201. foreach ($w as $v) {
  1202. $wh[$v['id']] = $v['title'];
  1203. }
  1204. $post = $this->input->post(NULL, TRUE);
  1205. if (isset($post['page'])) {
  1206. $page = $this->input->post('page', true);
  1207. $perpage = $this->input->post('perpage', true);
  1208. $category = $this->input->post('category', true);
  1209. $size = $this->input->post('size', true);
  1210. $grade = $this->input->post('grade', true);
  1211. $color = $this->input->post('color', true);
  1212. $lowe = $this->input->post('lowe', true);
  1213. $sku = $this->input->post('sku');
  1214. $title = $this->input->post('title');
  1215. $warehouse = $this->input->post('warehouse', true);
  1216. $usa = $this->input->post('usa', true);
  1217. $purchase = $this->input->post('purchase', true);
  1218. $lacetype = $this->input->post('lacetype', true);
  1219. $haircap = $this->input->post('haircap', true);
  1220. $density = $this->input->post('density', true);
  1221. $details = $this->input->post('details', true);
  1222. $state = $this->input->post('state', true);
  1223. $shop = $this->input->post('shop', true);
  1224. $lacecolor = $this->input->post('lacecolor', true);
  1225. $hairnumber = $this->input->post('hairnumber', true);
  1226. $type = $this->input->post('type', true);
  1227. $ktime = $this->input->post('ktime', true);
  1228. $jtime = $this->input->post('jtime', true);
  1229. $ktime = strtotime($ktime);
  1230. $jtime = strtotime($jtime);
  1231. $cpbz = $this->input->post('cpbz', true);
  1232. $sm = $this->input->post('sm', true);
  1233. $where = "1=1";
  1234. $gj = "";
  1235. $ck = "";
  1236. if ($usa) {
  1237. if (!$warehouse) {
  1238. $where .= " and (warehouse = '5' or warehouse = '8')";
  1239. }
  1240. }
  1241. if ($warehouse) {
  1242. $where .= " and warehouse = '$warehouse'";
  1243. }
  1244. if ($details) {
  1245. $where .= " and details = '$details'";
  1246. }
  1247. if ($purchase) {
  1248. $where .= " and purchase = '$purchase'";
  1249. }
  1250. if ($state) {
  1251. $where .= " and state = '$state'";
  1252. }
  1253. if ($shop) {
  1254. $where .= " and shop like '%$shop%'";
  1255. }
  1256. if ($type) {
  1257. $where .= " and type = '$type'";
  1258. }
  1259. if ($ktime && $jtime) {
  1260. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1261. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1262. }
  1263. if ($cpbz) {
  1264. $where .= " and cpbz like '%$cpbz%' ";
  1265. }
  1266. if ($sm) {
  1267. $where .= " and sm like '%$sm%' ";
  1268. }
  1269. if ($lacecolor) {
  1270. $where .= " and features like '%-$lacecolor-%'";
  1271. }
  1272. if ($lacetype) {
  1273. $where .= " and features like '%-$lacetype-%'";
  1274. }
  1275. if ($category) {
  1276. $where .= " and features like '%-$category-%'";
  1277. }
  1278. if ($size) {
  1279. $where .= " and features like '%-$size-%'";
  1280. }
  1281. if ($grade) {
  1282. $where .= " and features like '%-$grade-%'";
  1283. }
  1284. if ($color) {
  1285. $where .= " and features like '%-$color-%'";
  1286. }
  1287. if ($lowe) {
  1288. $where .= " and features like '%-$lowe-%'";
  1289. }
  1290. if ($haircap) {
  1291. $where .= " and features like '%-$haircap-%'";
  1292. }
  1293. if ($density) {
  1294. $where .= " and features like '%-$density-%'";
  1295. }
  1296. if (!empty($hairnumber)) {
  1297. $where .= " and features like '%-128-%' ";
  1298. if ($hairnumber < 0) {
  1299. $class_list = $this->typeclass->find_all('classid = 43');
  1300. foreach ($class_list as $v) {
  1301. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1302. }
  1303. } else {
  1304. $where .= " and features like '%-$hairnumber-%'";
  1305. }
  1306. }
  1307. //数据排序
  1308. $order_str = "id desc";
  1309. if (empty($page)) {
  1310. $start = 0;
  1311. $perpage = 1;
  1312. } else {
  1313. $start = ($page - 1) * $perpage;
  1314. }
  1315. $fjnr = '';
  1316. if ($sku) {
  1317. $sku = trim($sku, ' ');
  1318. $sku = trim($sku, ' ');
  1319. $fjnr .= " and sku like '%$sku%'";
  1320. }
  1321. if ($title) {
  1322. $title = trim($title, ' ');
  1323. $title = trim($title, ' ');
  1324. $fjnr .= " and title like '%$title%'";
  1325. }
  1326. $wt = array();
  1327. $whlabel_type = $this->whlabel_type->find_all();
  1328. foreach ($whlabel_type as $v) {
  1329. $wt[$v['id']] = $v['title'];
  1330. }
  1331. //$where .= " and time > '$ktime' and time < '$jtime'";
  1332. $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
  1333. //取得信息列表
  1334. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1335. $rows = array();
  1336. $list = array();
  1337. foreach ($info_list as $key => $value) {
  1338. if (isset($wt[$value['type']])) {
  1339. $info_list[$key]['type'] = $wt[$value['type']];
  1340. } else {
  1341. $info_list[$key]['type'] = '未设置';
  1342. }
  1343. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1344. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1345. $ztdata = '';
  1346. if (count($zt) > 0) {
  1347. foreach ($zt as $vv) {
  1348. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1349. }
  1350. }
  1351. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1352. $cdata = array_filter($qbdata, function ($item) {
  1353. return $item['state'] < 1;
  1354. });
  1355. $c = array_sum(array_column($cdata, 'jnum'));
  1356. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1357. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1358. });
  1359. $g = array_sum(array_column($gdata, 'jnum'));
  1360. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1361. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1362. });
  1363. $x = array_sum(array_column($xdata, 'jnum'));
  1364. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1365. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1366. });
  1367. $t = array_sum(array_column($tdata, 'jnum'));
  1368. // $zdata = array_filter($qbdata, function ($item) {
  1369. // return $item['zd'] != "" && $item['state'] < 1;
  1370. // });
  1371. // $z = array_sum(array_column($zdata, 'jnum'));
  1372. $zdata = array_filter($qbdata, function ($item) {
  1373. return $item['zd'] != "" && $item['state'] < 1;
  1374. });
  1375. $z = array_sum(array_column($zdata, 'jnum'));
  1376. //$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');
  1377. //$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'].'"');
  1378. //$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'].'"');
  1379. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1380. //$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'].'"');
  1381. $details = array();
  1382. $cpid = array();
  1383. $od = array();
  1384. $odid = '';
  1385. $companytitle = '';
  1386. $shop_list = [];
  1387. foreach ($qbdata as $v) {
  1388. if ($v['zd'] != "" && $v['state'] < 1) {
  1389. if (!isset($od[$v['zd']])) {
  1390. $od[$v['zd']] = 1; //所有数据sku
  1391. } else {
  1392. $od[$v['zd']] = $od[$v['zd']] + 1;
  1393. }
  1394. }
  1395. if ($v['state'] < 1) {
  1396. $details[$v['details']] = $v['details'];
  1397. if ($v['cpid'] != 0) {
  1398. $cpid[$v['cpid']] = $v['cpid'];
  1399. }
  1400. }
  1401. if($v['state'] == 0){
  1402. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1403. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1404. }
  1405. if ($v['shop'] != '') {
  1406. $shop = explode(',', trim($v['shop'], ','));
  1407. foreach ($shop as $vv) {
  1408. if (!in_array($vv, $shop_list)) {
  1409. $shop_list[] = $vv;
  1410. }
  1411. }
  1412. }
  1413. }
  1414. }
  1415. foreach ($od as $k => $vv) {
  1416. $odid .= $k . '数量' . $vv;
  1417. }
  1418. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1419. $info_list[$key]['label'] = $value['sm'];
  1420. $number = $value['number'];
  1421. $ftime = time() - 15 * 24 * 3600;
  1422. $z = $z . '(' . $odid . ')'; //查看订单号
  1423. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1424. $info_list[$key]['features'] = $c;
  1425. $info_list[$key]['number'] = $ztdata;
  1426. $info_list[$key]['sm'] = $g;
  1427. $info_list[$key]['x'] = $x;
  1428. $info_list[$key]['t'] = $t;
  1429. $info_list[$key]['z'] = $z;
  1430. /**
  1431. foreach ($cdata as $k=>$v)
  1432. {
  1433. $details[$v['details']] = $v['details'];
  1434. if($v['cpid'] != 0)
  1435. {
  1436. $cpid[$v['cpid']] = $v['cpid'];
  1437. }
  1438. }
  1439. **/
  1440. $info_list[$key]['shop'] = '';
  1441. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1442. // if ($value['shop'] != '') {
  1443. // $shop = explode(',', trim($value['shop'], ','));
  1444. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1445. // }
  1446. $shop_list = array_unique($shop_list);
  1447. $shop_str = '';
  1448. foreach ($shop_list as $v) {
  1449. if(isset($sp[$v])){
  1450. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1451. }
  1452. }
  1453. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1454. /**
  1455. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1456. if(isset($companytitle[0]))
  1457. {
  1458. foreach ($companytitle as $k=>$v)
  1459. {
  1460. if($v['companytitle'] != '')
  1461. {
  1462. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1463. }
  1464. }
  1465. }
  1466. **/
  1467. }
  1468. $final_all_list = [];
  1469. foreach ($info_list as $k => $v) {
  1470. $final_all_list[] = [
  1471. 'id' => $v['id'],
  1472. "warehouse" => $v["warehouse"],
  1473. "purchase" => $v["purchase"],
  1474. "sku" => $v["sku"],
  1475. "title" => $v["title"] . "<br/>" . $v["pm"],
  1476. "details" => $v["details"],
  1477. "shop" => $v["shop"],
  1478. "cpbz" => $v["cpbz"],
  1479. 'label' => $v['label'],
  1480. "type" => $v["type"],
  1481. "features" => $v["features"],
  1482. "number" => $v["number"],
  1483. "sm" => $v["sm"],
  1484. "x" => $v["x"],
  1485. "t" => $v["t"],
  1486. "z" => $v["z"]
  1487. ];
  1488. }
  1489. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1490. $pagenum = ceil($total / $perpage);
  1491. $over = $total - ($start + $perpage);
  1492. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1493. echo json_encode($rows);
  1494. exit;
  1495. }
  1496. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1497. $this->data['shop'] = $wlshop;
  1498. $this->data['vip'] = $vip;
  1499. $this->_Template('whlabel_type', $this->data);
  1500. }
  1501. //美仓进销存浏览
  1502. public function _usatype()
  1503. {
  1504. if (isset($_SESSION['api'])) {
  1505. $user = $this->user->get_api($_SESSION['api']);
  1506. $usp = $user;
  1507. $fgshop = "";
  1508. $sid = "";
  1509. $wid = "";
  1510. $wtype = "";
  1511. $userwh = explode('|', trim($user['warehouse'], '|'));
  1512. foreach ($userwh as $value) {
  1513. $wid .= " id = " . $value . " or";
  1514. $wtype .= " type = " . $value . " or";
  1515. }
  1516. }
  1517. $prc = array();
  1518. $purchase = $this->purchase->find_all();
  1519. foreach ($purchase as $k => $v) {
  1520. $prc[$v['id']] = $v['title'];
  1521. }
  1522. $post = $this->input->post(NULL, TRUE);
  1523. if (isset($post['page'])) {
  1524. $page = $this->input->post('page', true);
  1525. $perpage = $this->input->post('perpage', true);
  1526. $category = $this->input->post('category', true);
  1527. $size = $this->input->post('size', true);
  1528. $grade = $this->input->post('grade', true);
  1529. $color = $this->input->post('color', true);
  1530. $lowe = $this->input->post('lowe', true);
  1531. $sku = $this->input->post('sku');
  1532. $title = $this->input->post('title');
  1533. $warehouse = $this->input->post('warehouse', true);
  1534. $usa = $this->input->post('usa', true);
  1535. $purchase = $this->input->post('purchase', true);
  1536. $lacetype = $this->input->post('lacetype', true);
  1537. $haircap = $this->input->post('haircap', true);
  1538. $density = $this->input->post('density', true);
  1539. $details = $this->input->post('details', true);
  1540. $state = $this->input->post('state', true);
  1541. $lacecolor = $this->input->post('lacecolor', true);
  1542. $cklx = $this->input->post('cklx', true);
  1543. $ktime = $this->input->post('ktime', true);
  1544. $jtime = $this->input->post('jtime', true);
  1545. $ktime = strtotime($ktime);
  1546. $jtime = strtotime($jtime);
  1547. $where = "1=1";
  1548. $gj = "";
  1549. $ck = "";
  1550. if ($lacetype) {
  1551. $where .= " and features like '%-$lacetype-%'";
  1552. }
  1553. if ($category) {
  1554. $where .= " and features like '%-$category-%'";
  1555. }
  1556. if ($size) {
  1557. $where .= " and features like '%-$size-%'";
  1558. }
  1559. if ($grade) {
  1560. $where .= " and features like '%-$grade-%'";
  1561. }
  1562. if ($color) {
  1563. $where .= " and features like '%-$color-%'";
  1564. }
  1565. if ($lowe) {
  1566. $where .= " and features like '%-$lowe-%'";
  1567. }
  1568. if ($haircap) {
  1569. $where .= " and features like '%-$haircap-%'";
  1570. }
  1571. if ($density) {
  1572. $where .= " and features like '%-$density-%'";
  1573. }
  1574. if ($lacecolor) {
  1575. $where .= " and features like '%-$lacecolor-%'";
  1576. }
  1577. if ($usa) {
  1578. if (!$warehouse) {
  1579. $where .= " and (warehouse = '5' or warehouse = '8')";
  1580. }
  1581. }
  1582. if ($warehouse) {
  1583. $where .= " and warehouse = '$warehouse'";
  1584. }
  1585. if ($details) {
  1586. $where .= " and details = '$details'";
  1587. }
  1588. if ($purchase) {
  1589. $where .= " and purchase = '$purchase'";
  1590. }
  1591. if ($state) {
  1592. $where .= " and state = '$state'";
  1593. }
  1594. $where_add = '';
  1595. if ($cklx) {
  1596. $shop = $this->shop->read($cklx);
  1597. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1598. }
  1599. if ($ktime && $jtime) {
  1600. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1601. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1602. }
  1603. //数据排序
  1604. $order_str = "id desc";
  1605. if (empty($page)) {
  1606. $start = 0;
  1607. $perpage = 1;
  1608. } else {
  1609. $start = ($page - 1) * $perpage;
  1610. }
  1611. if ($sku) {
  1612. $sku = trim($sku, ' ');
  1613. $sku = trim($sku, ' ');
  1614. $where .= " and sku like '%$sku%'";
  1615. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1616. } else if ($title) {
  1617. $title = trim($title, ' ');
  1618. $title = trim($title, ' ');
  1619. $where .= " and title like '%$title%'";
  1620. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1621. } else {
  1622. //$where .= " and time > '$ktime' and time < '$jtime'";
  1623. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1624. }
  1625. //取得信息列表
  1626. $rows = array();
  1627. $list = array();
  1628. foreach ($info_list as $key => $value) {
  1629. $warehouse = $this->warehouse->read($value['warehouse']);
  1630. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1631. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1632. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1633. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1634. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1635. $od = array();
  1636. $odid = '';
  1637. foreach ($z as $v) {
  1638. if (!isset($od[$v['zd']])) {
  1639. $od[$v['zd']] = 1; //所有数据sku
  1640. } else {
  1641. $od[$v['zd']] = $od[$v['zd']] + 1;
  1642. }
  1643. }
  1644. foreach ($od as $k => $vv) {
  1645. $odid .= $k . '数量' . $vv . ' ';
  1646. }
  1647. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1648. $info_list[$key]['features'] = $c;
  1649. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1650. $ztdata = '';
  1651. if (count($zt) > 0) {
  1652. foreach ($zt as $vv) {
  1653. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1654. }
  1655. }
  1656. $info_list[$key]['warehouse'] = $ztdata;
  1657. $info_list[$key]['g'] = $g;
  1658. $info_list[$key]['x'] = $x;
  1659. $info_list[$key]['t'] = $t;
  1660. $info_list[$key]['z'] = $z;
  1661. }
  1662. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1663. $pagenum = ceil($total / $perpage);
  1664. $over = $total - ($start + $perpage);
  1665. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1666. echo json_encode($rows);
  1667. exit;
  1668. }
  1669. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1670. $this->data['warehouse'] = $warehouse;
  1671. $this->_Template('whlabel_typeusa', $this->data);
  1672. }
  1673. //美仓进销存浏览
  1674. public function _usatypeapp()
  1675. {
  1676. $post = $this->input->post(NULL, TRUE);
  1677. if (isset($post['page'])) {
  1678. $page = $this->input->post('page', true);
  1679. $perpage = $this->input->post('perpage', true);
  1680. $sku = $this->input->post('sku', true);
  1681. $warehouse = 5;
  1682. $title = $this->input->post('title', true);
  1683. $state = $this->input->post('state', true);
  1684. $ktime = $this->input->post('ktime', true);
  1685. $jtime = $this->input->post('jtime', true);
  1686. $ktime = strtotime($ktime);
  1687. $jtime = strtotime($jtime);
  1688. $where = "1=1";
  1689. $gj = "";
  1690. $ck = "";
  1691. if ($title) {
  1692. $st = explode(' ', trim($title, ' '));
  1693. foreach ($st as $v) {
  1694. $where .= " and title like '%$v%'";
  1695. }
  1696. }
  1697. if ($warehouse) {
  1698. $where .= " and warehouse = '$warehouse'";
  1699. }
  1700. if ($state) {
  1701. $where .= " and state = '$state'";
  1702. }
  1703. if ($sku) {
  1704. $where .= " and sku like '%$sku%'";
  1705. }
  1706. if ($ktime && $jtime) {
  1707. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1708. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1709. }
  1710. //数据排序
  1711. $order_str = "id desc";
  1712. if (empty($page)) {
  1713. $start = 0;
  1714. $perpage = 1;
  1715. } else {
  1716. $start = ($page - 1) * $perpage;
  1717. }
  1718. //取得信息列表
  1719. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1720. $rows = array();
  1721. $list = array();
  1722. foreach ($info_list as $key => $value) {
  1723. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1724. }
  1725. $rowsdq = array_slice($rows, $start, $perpage);
  1726. foreach ($rowsdq as $value) {
  1727. $warehouse = $this->warehouse->read($value['warehouse']);
  1728. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1729. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1730. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1731. $od = array();
  1732. $odid = '';
  1733. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1734. }
  1735. $total = count($rows);
  1736. $pagenum = ceil($total / $perpage);
  1737. $over = $total - ($start + $perpage);
  1738. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1739. echo json_encode($rows);
  1740. exit;
  1741. }
  1742. $this->_Template('phone/p_usatypeapp', $this->data);
  1743. }
  1744. //入库操作
  1745. public function _enteradd()
  1746. {
  1747. $dt = 0;
  1748. if (isset($_SESSION['api'])) {
  1749. $user = $this->user->get_api($_SESSION['api']);
  1750. $usp = $user;
  1751. $fgshop = "";
  1752. $sid = "";
  1753. $user = explode('|', trim($user['shop'], '|'));
  1754. foreach ($user as $value) {
  1755. $fgshop .= " shop = " . $value . " or";
  1756. $sid .= " id = " . $value . " or";
  1757. }
  1758. }
  1759. $tc = $this->typeclass->find_all();
  1760. $typeclass = array();
  1761. foreach ($tc as $v) {
  1762. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1763. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1764. }
  1765. $post = $this->input->post(NULL, TRUE);
  1766. if (isset($post['sku'])) {
  1767. $list = array();
  1768. $num = "";
  1769. $title = "";
  1770. $features = "";
  1771. $order = $this->input->post('order', true);
  1772. $shop = $this->input->post('shop', true);
  1773. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1774. $sku = $this->input->post('sku', true);
  1775. $post['sm'] = $this->input->post('sm', true);
  1776. $post['warehouse'] = $this->input->post('warehouse', true);
  1777. $post['purchase'] = $this->input->post('purchase', true);
  1778. $post['retreatwarehouse'] = $post['warehouse'];
  1779. $post['state'] = $this->input->post('state', true);
  1780. $post['rktype'] = $this->input->post('rktype', true);
  1781. $post['text'] = $this->input->post('text', true);
  1782. $category = $this->input->post('category', true);
  1783. $list['category'] = $category;
  1784. $list['hairtype'] = $this->input->post('hairtype', true);
  1785. $list['grade'] = $this->input->post('grade', true);
  1786. $size = $this->input->post('size', true);
  1787. $xzsku = $this->input->post('xzsku', true);
  1788. $list['size'] = rtrim($size, ',');
  1789. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1790. $list['extension'] = $this->input->post('extension', true);
  1791. if ($category == 1297) {
  1792. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1793. }
  1794. if ($category == 1702) {
  1795. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1796. $list['syother'] = $this->input->post('syother', true);
  1797. }
  1798. if ($category == 133) {
  1799. $list['fittype'] = $this->input->post('fittype', true);
  1800. $list['acother'] = $this->input->post('acother', true);
  1801. }
  1802. $list['color'] = $this->input->post('color', true);
  1803. $list['lowe'] = $this->input->post('lowe', true);
  1804. if (!$post['purchase']) {
  1805. $post['purchase'] = 1;
  1806. }
  1807. if ($category == 127) {
  1808. $list['type'] = $this->input->post('type', true);
  1809. $list['headroad'] = $this->input->post('headroad', true);
  1810. $list['density'] = $this->input->post('density', true);
  1811. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1812. $list['lacesize'] = $this->input->post('lacesize', true);
  1813. }
  1814. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1815. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1816. }
  1817. if ($category == 128) {
  1818. $list['lacetype'] = $this->input->post('lacetype', true);
  1819. $list['haircap'] = $this->input->post('haircap', true);
  1820. $list['density'] = $this->input->post('density', true);
  1821. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1822. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1823. $list['wigother'] = $this->input->post('wigother', true);
  1824. $list['wigother1'] = $this->input->post('wigother1', true);
  1825. $list['wigother2'] = $this->input->post('wigother2', true);
  1826. }
  1827. if ($category == 129) {
  1828. $list['wide'] = $this->input->post('wide', true);
  1829. }
  1830. if ($category == 131) {
  1831. $list['gifttype'] = $this->input->post('gifttype', true);
  1832. $list['giftother'] = $this->input->post('giftother', true);
  1833. }
  1834. if ($category == 134) {
  1835. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1836. }
  1837. if ($category == 1297) {
  1838. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1839. $list['sywigother'] = $this->input->post('sywigother', true);
  1840. }
  1841. if ($category == 130 || $category == 133 || $category == 1702) {
  1842. $list['items'] = $this->input->post('items', true);
  1843. $list['weight'] = $this->input->post('weight', true);
  1844. }
  1845. if ($category == 1702) {
  1846. $list['syhairther'] = $this->input->post('syhairther', true);
  1847. }
  1848. $classid = $this->classid->sku();
  1849. $scsku = $classid;
  1850. $pm = $classid;
  1851. foreach ($list as $k => $v) {
  1852. if ($v != 0) {
  1853. $num .= $v;
  1854. $features .= $v . '-';
  1855. $post[$k] = $v;
  1856. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1857. if ($k != 'size') {
  1858. $title .= $typeclass[$v]['title'] . " ";
  1859. }
  1860. if (isset($pm[$typeclass[$v]['classid']])) {
  1861. if ($typeclass[$v]['title'] == '9A') {
  1862. $pm[$typeclass[$v]['classid']] = '9A';
  1863. } else if ($typeclass[$v]['title'] == '10A') {
  1864. $pm[$typeclass[$v]['classid']] = '10A';
  1865. } else {
  1866. $clzh = $typeclass[$v]['zh'];
  1867. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1868. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1869. $clzh = $clzh[0];
  1870. }
  1871. $pm[$typeclass[$v]['classid']] = $clzh;
  1872. }
  1873. }
  1874. }
  1875. }
  1876. $zh = implode(" ", $pm);
  1877. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1878. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1879. if ($list['size']) {
  1880. $typeclass = $this->typeclass->read($list['size']);
  1881. $title .= $typeclass['title'];
  1882. }
  1883. $time = time();
  1884. if ($xzsku) {
  1885. $scsku = implode("-", $scsku);
  1886. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1887. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1888. $post['sku'] = trim($scsku, ' ');
  1889. } else {
  1890. $post['sku'] = $sku;
  1891. }
  1892. //$post['sku'] = trim($sku,' ');
  1893. $post['title'] = rtrim($title, ' ');
  1894. $post['number'] = $num;
  1895. $post['features'] = '-' . $features;
  1896. $post['enter'] = $time;
  1897. $post['time'] = $time; //操作时间
  1898. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1899. if ($yza) {
  1900. if ($post['features'] != $yza[0]['features']) {
  1901. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1902. exit;
  1903. }
  1904. }
  1905. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1906. if ($yzb) {
  1907. if ($post['sku'] != $yzb[0]['sku']) {
  1908. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1909. exit;
  1910. }
  1911. }
  1912. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1913. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1914. exit;
  1915. }
  1916. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1917. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1918. exit;
  1919. }
  1920. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1921. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1922. exit;
  1923. }
  1924. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1925. if (isset($yz[0]['type'])) {
  1926. $post['type'] = $yz[0]['type'];
  1927. }
  1928. if ($post['state'] == 9) //如果选择预设库存
  1929. {
  1930. $this->whlabel->insert($post);
  1931. } else {
  1932. /**
  1933. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1934. if($ljg == 1)
  1935. {
  1936. for($i=0;$i<$order;$i++)
  1937. {
  1938. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1939. $this->whlabel->insert($post);
  1940. }
  1941. }
  1942. **/
  1943. //if($post['warehouse'] == '5')
  1944. //{
  1945. //}
  1946. $yydata = $post;
  1947. $yydata['zh'] = $zh;
  1948. /**
  1949. $wl = $this->apiyy->get_cjlp($yydata);
  1950. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1951. {
  1952. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1953. }
  1954. if($wl['Data'][0]['m_isSucess'] != 1)
  1955. {
  1956. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1957. }
  1958. **/
  1959. for ($i = 0; $i < $order; $i++) {
  1960. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1961. $this->whlabel->insert($post);
  1962. }
  1963. }
  1964. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1965. exit;
  1966. }
  1967. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1968. $this->data['wlshop'] = $wlshop;
  1969. $this->_Template('whlabel_enteradd', $this->data);
  1970. }
  1971. //修改产品
  1972. public function _enteredit($arg_array)
  1973. {
  1974. $dt = 0;
  1975. if (isset($_SESSION['api'])) {
  1976. $user = $this->user->get_api($_SESSION['api']);
  1977. $usp = $user;
  1978. $fgshop = "";
  1979. $sid = "";
  1980. $user = explode('|', trim($user['shop'], '|'));
  1981. foreach ($user as $value) {
  1982. $fgshop .= " shop = " . $value . " or";
  1983. $sid .= " id = " . $value . " or";
  1984. }
  1985. }
  1986. $post = $this->input->post(NULL, TRUE);
  1987. if (isset($post['sku'])) {
  1988. $list = array();
  1989. $num = "";
  1990. $title = "";
  1991. $features = "";
  1992. $id = $this->input->post('id', true);
  1993. $order = $this->input->post('order', true);
  1994. $shop = $this->input->post('shop', true);
  1995. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1996. $post['sku'] = $this->input->post('sku', true);
  1997. $post['sm'] = $this->input->post('sm', true);
  1998. $post['warehouse'] = $this->input->post('warehouse', true);
  1999. $post['purchase'] = $this->input->post('purchase', true);
  2000. $post['retreatwarehouse'] = $post['warehouse'];
  2001. $category = $this->input->post('category', true);
  2002. $list['category'] = $category;
  2003. $list['hairtype'] = $this->input->post('hairtype', true);
  2004. $list['grade'] = $this->input->post('grade', true);
  2005. $size = $this->input->post('size', true);
  2006. $list['size'] = rtrim($size, ',');
  2007. $post['rktype'] = $this->input->post('rktype', true);
  2008. $post['text'] = $this->input->post('text', true);
  2009. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2010. $list['extension'] = $this->input->post('extension', true);
  2011. if ($category == 1297) {
  2012. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2013. }
  2014. if ($category == 1702) {
  2015. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2016. $list['syother'] = $this->input->post('syother', true);
  2017. }
  2018. if ($category == 133) {
  2019. $list['fittype'] = $this->input->post('fittype', true);
  2020. $list['acother'] = $this->input->post('acother', true);
  2021. }
  2022. $list['color'] = $this->input->post('color', true);
  2023. $list['lowe'] = $this->input->post('lowe', true);
  2024. if (!$post['purchase']) {
  2025. $post['purchase'] = 1;
  2026. }
  2027. if ($category == 127) {
  2028. $list['type'] = $this->input->post('type', true);
  2029. $list['headroad'] = $this->input->post('headroad', true);
  2030. $list['density'] = $this->input->post('density', true);
  2031. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2032. $list['lacesize'] = $this->input->post('lacesize', true);
  2033. }
  2034. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2035. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2036. }
  2037. if ($category == 128) {
  2038. $list['lacetype'] = $this->input->post('lacetype', true);
  2039. $list['haircap'] = $this->input->post('haircap', true);
  2040. $list['density'] = $this->input->post('density', true);
  2041. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2042. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2043. $list['wigother'] = $this->input->post('wigother', true);
  2044. $list['wigother1'] = $this->input->post('wigother1', true);
  2045. $list['wigother2'] = $this->input->post('wigother2', true);
  2046. }
  2047. if ($category == 129) {
  2048. $list['wide'] = $this->input->post('wide', true);
  2049. }
  2050. if ($category == 131) {
  2051. $list['gifttype'] = $this->input->post('gifttype', true);
  2052. $list['giftother'] = $this->input->post('giftother', true);
  2053. }
  2054. if ($category == 134) {
  2055. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2056. }
  2057. if ($category == 1297) {
  2058. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2059. $list['sywigother'] = $this->input->post('sywigother', true);
  2060. }
  2061. if ($category == 130 || $category == 133 || $category == 1702) {
  2062. $list['items'] = $this->input->post('items', true);
  2063. $list['weight'] = $this->input->post('weight', true);
  2064. }
  2065. if ($category == 1702) {
  2066. $list['syhairther'] = $this->input->post('syhairther', true);
  2067. }
  2068. foreach ($list as $k => $v) {
  2069. if ($v != 0) {
  2070. $num .= $v;
  2071. $features .= $v . '-';
  2072. $typeclass = $this->typeclass->read($v);
  2073. if ($k != 'size') {
  2074. $title .= $typeclass['title'] . " ";
  2075. }
  2076. }
  2077. }
  2078. $typeclass = $this->typeclass->read($list['size']);
  2079. $title .= $typeclass['title'];
  2080. $time = time();
  2081. $post['title'] = rtrim($title, ' ');
  2082. $post['number'] = $num;
  2083. $post['features'] = '-' . $features;
  2084. $post['time'] = $time; //操作时间
  2085. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2086. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2087. exit;
  2088. }
  2089. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2090. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2091. exit;
  2092. }
  2093. $uid = $this->whlabel->read($id);
  2094. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2095. if ($datanum > 0) {
  2096. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2097. exit;
  2098. }
  2099. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2100. {
  2101. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2102. if ($yza) {
  2103. if ($post['features'] != $yza[0]['features']) {
  2104. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2105. exit;
  2106. }
  2107. }
  2108. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2109. if ($yzb) {
  2110. if ($post['sku'] != $yzb[0]['sku']) {
  2111. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2112. exit;
  2113. }
  2114. }
  2115. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2116. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2117. exit;
  2118. }
  2119. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2120. foreach ($data as $v) {
  2121. $post['id'] = $v['id'];
  2122. $this->whlabel->save($post, $v['id']);
  2123. }
  2124. } else {
  2125. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2126. if ($data > 0) {
  2127. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2128. exit;
  2129. } else {
  2130. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2131. foreach ($data as $v) {
  2132. $post['id'] = $v['id'];
  2133. $this->whlabel->save($post, $v['id']);
  2134. }
  2135. }
  2136. }
  2137. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2138. exit;
  2139. }
  2140. $uid = $this->whlabel->read($arg_array[0]);
  2141. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2142. $this->data['enter'] = $uid;
  2143. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2144. $this->data['wlshop'] = $wlshop;
  2145. $this->_Template('whlabel_enteredit', $this->data);
  2146. }
  2147. //入库浏览
  2148. public function _enter()
  2149. {
  2150. $post = $this->input->post(NULL, TRUE);
  2151. if (isset($post['s'])) {
  2152. $id_arr = $this->input->post('s');
  2153. $id_arr = explode(',', $id_arr);
  2154. if (!$id_arr) {
  2155. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2156. exit;
  2157. }
  2158. //循环删除记录
  2159. foreach ($id_arr as $v) {
  2160. $sid = $this->whlabel->read($v);
  2161. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2162. if ($count > 0) {
  2163. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2164. exit;
  2165. }
  2166. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2167. foreach ($info_list as $va) {
  2168. $this->whlabel->remove($va['id']);
  2169. }
  2170. }
  2171. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2172. exit;
  2173. }
  2174. $sp = array();
  2175. $s = $this->shop->find_all('1=1', 'id,shopname');
  2176. foreach ($s as $v) {
  2177. $sp[$v['id']] = $v['shopname'];
  2178. }
  2179. $wh = array();
  2180. $w = $this->warehouse->find_all('1=1', 'id,title');
  2181. foreach ($w as $v) {
  2182. $wh[$v['id']] = $v['title'];
  2183. }
  2184. if (isset($post['page'])) {
  2185. $page = $this->input->post('page', true);
  2186. $perpage = $this->input->post('perpage', true);
  2187. $category = $this->input->post('category', true);
  2188. $size = $this->input->post('size', true);
  2189. $grade = $this->input->post('grade', true);
  2190. $color = $this->input->post('color', true);
  2191. $lowe = $this->input->post('lowe', true);
  2192. $sku = $this->input->post('sku', true);
  2193. $warehouse = $this->input->post('warehouse', true);
  2194. $purchase = $this->input->post('purchase', true);
  2195. $ktime = $this->input->post('ktime', true);
  2196. $jtime = $this->input->post('jtime', true);
  2197. $ktime = strtotime($ktime);
  2198. $jtime = strtotime($jtime);
  2199. $where = "1=1";
  2200. $gj = "";
  2201. $ck = "";
  2202. if ($category) {
  2203. $where .= " and features like '%-$category-%'";
  2204. }
  2205. if ($size) {
  2206. $where .= " and features like '%-$size-%'";
  2207. }
  2208. if ($grade) {
  2209. $where .= " and features like '%-$grade-%'";
  2210. }
  2211. if ($color) {
  2212. $where .= " and features like '%-$color-%'";
  2213. }
  2214. if ($lowe) {
  2215. $where .= " and features like '%-$lowe-%'";
  2216. }
  2217. if ($warehouse) {
  2218. $where .= " and warehouse = '$warehouse'";
  2219. }
  2220. if ($purchase) {
  2221. $where .= " and purchase = '$purchase'";
  2222. }
  2223. if ($sku) {
  2224. $where .= " and sku like '%$sku%'";
  2225. }
  2226. if ($ktime && $jtime) {
  2227. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2228. }
  2229. //数据排序
  2230. $order_str = "enter desc";
  2231. if (empty($page)) {
  2232. $start = 0;
  2233. $perpage = 1;
  2234. } else {
  2235. $start = ($page - 1) * $perpage;
  2236. }
  2237. //取得信息列表
  2238. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2239. foreach ($info_list as $k => $v) {
  2240. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2241. if ($v['shop'] == '') {
  2242. $s = '通用';
  2243. } else {
  2244. $info_list[$k]['shop'] = '';
  2245. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2246. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2247. }
  2248. }
  2249. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2250. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2251. $info_list[$k]['g'] = $g;
  2252. }
  2253. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2254. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2255. $pagenum = ceil($total / $perpage);
  2256. $over = $total - ($start + $perpage);
  2257. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2258. echo json_encode($rows);
  2259. exit;
  2260. }
  2261. $this->_Template('whlabel_enter', $this->data);
  2262. }
  2263. //出库浏览
  2264. public function _out()
  2265. {
  2266. $post = $this->input->post(NULL, TRUE);
  2267. if (isset($post['page'])) {
  2268. $page = $this->input->post('page', true);
  2269. $perpage = $this->input->post('perpage', true);
  2270. $category = $this->input->post('category', true);
  2271. $size = $this->input->post('size', true);
  2272. $grade = $this->input->post('grade', true);
  2273. $color = $this->input->post('color', true);
  2274. $lowe = $this->input->post('lowe', true);
  2275. $sku = $this->input->post('sku', true);
  2276. $warehouse = $this->input->post('warehouse', true);
  2277. $purchase = $this->input->post('purchase', true);
  2278. $state = $this->input->post('state', true);
  2279. $ktime = $this->input->post('ktime', true);
  2280. $jtime = $this->input->post('jtime', true);
  2281. $ktime = strtotime($ktime);
  2282. $jtime = strtotime($jtime);
  2283. $where = "state=3";
  2284. $gj = "";
  2285. $ck = "";
  2286. if ($category) {
  2287. $where .= " and features like '%-$category-%'";
  2288. }
  2289. if ($size) {
  2290. $where .= " and features like '%-$size-%'";
  2291. }
  2292. if ($grade) {
  2293. $where .= " and features like '%-$grade-%'";
  2294. }
  2295. if ($color) {
  2296. $where .= " and features like '%-$color-%'";
  2297. }
  2298. if ($lowe) {
  2299. $where .= " and features like '%-$lowe-%'";
  2300. }
  2301. if ($state) {
  2302. $where .= " and state = '$state'";
  2303. }
  2304. if ($warehouse) {
  2305. $where .= " and warehouse = '$warehouse'";
  2306. }
  2307. if ($purchase) {
  2308. $where .= " and purchase = '$purchase'";
  2309. }
  2310. if ($sku) {
  2311. $where .= " and sku = '$sku'";
  2312. }
  2313. if ($ktime && $jtime) {
  2314. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2315. }
  2316. //数据排序
  2317. $order_str = "id desc";
  2318. if (empty($page)) {
  2319. $start = 0;
  2320. $perpage = 1;
  2321. } else {
  2322. $start = ($page - 1) * $perpage;
  2323. }
  2324. //取得信息列表
  2325. $info_list = $this->whlabel->find_all($where, 'sku');
  2326. $rows = array();
  2327. $list = array();
  2328. foreach ($info_list as $key => $value) {
  2329. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2330. }
  2331. $rows = array_unique($rows); //删除重复记录
  2332. foreach ($rows as $key => $value) {
  2333. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2334. $ck = $this->warehouse->read($data['warehouse']);
  2335. $warehouse = $ck['title'];
  2336. $gy = $this->purchase->read($data['purchase']);
  2337. $purchase = $gy['purchase'];
  2338. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2339. $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);
  2340. }
  2341. $total = count($list);
  2342. $pagenum = ceil($total / $perpage);
  2343. $over = $total - ($start + $perpage);
  2344. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2345. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2346. echo json_encode($rows);
  2347. exit;
  2348. }
  2349. $this->_Template('whlabel_out', $this->data);
  2350. }
  2351. //出库标签浏览
  2352. public function _label()
  2353. {
  2354. $post = $this->input->post(NULL, TRUE);
  2355. if (isset($post['page'])) {
  2356. $page = $this->input->post('page', true);
  2357. $perpage = $this->input->post('perpage', true);
  2358. $sku = $this->input->post('sku', true);
  2359. $warehouse = $this->input->post('warehouse', true);
  2360. $purchase = $this->input->post('purchase', true);
  2361. $orderinfo = $this->input->post('orderinfo', true);
  2362. $waybill = $this->input->post('waybill', true);
  2363. $category = $this->input->post('category', true);
  2364. $size = $this->input->post('size', true);
  2365. $grade = $this->input->post('grade', true);
  2366. $color = $this->input->post('color', true);
  2367. $lowe = $this->input->post('lowe', true);
  2368. $where = "state=1";
  2369. if ($sku) {
  2370. $where .= " and sku = '$sku'";
  2371. }
  2372. if ($warehouse) {
  2373. $where .= " and warehouse = '$warehouse'";
  2374. }
  2375. if ($purchase) {
  2376. $where .= " and purchase = '$purchase'";
  2377. }
  2378. if ($orderinfo) {
  2379. $where .= " and orderinfo = '$orderinfo'";
  2380. }
  2381. if ($waybill) {
  2382. $where .= " and waybill = '$waybill'";
  2383. }
  2384. if ($category) {
  2385. $where .= " and features like '%-$category-%'";
  2386. }
  2387. if ($size) {
  2388. $where .= " and features like '%-$size-%'";
  2389. }
  2390. if ($grade) {
  2391. $where .= " and features like '%-$grade-%'";
  2392. }
  2393. if ($color) {
  2394. $where .= " and features like '%-$color-%'";
  2395. }
  2396. if ($lowe) {
  2397. $where .= " and features like '%-$lowe-%'";
  2398. }
  2399. //数据排序
  2400. $order_str = "outk desc";
  2401. if (empty($page)) {
  2402. $start = 0;
  2403. $perpage = 1;
  2404. } else {
  2405. $start = ($page - 1) * $perpage;
  2406. }
  2407. //取得信息列表
  2408. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2409. foreach ($info_list as $key => $value) {
  2410. $warehouse = $this->warehouse->read($value['warehouse']);
  2411. $info_list[$key]['warehouse'] = $warehouse['title'];
  2412. $purchase = $this->purchase->read($value['purchase']);
  2413. $info_list[$key]['purchase'] = $purchase['title'];
  2414. if ($value['outk'] != 0) {
  2415. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2416. } else {
  2417. $info_list[$key]['outk'] = "";
  2418. }
  2419. if ($value['orderinfo'] == 0) {
  2420. $info_list[$key]['orderinfo'] = "";
  2421. }
  2422. if ($value['waybill'] == 0) {
  2423. $info_list[$key]['waybill'] = "";
  2424. }
  2425. }
  2426. $total = $this->whlabel->find_count($where);
  2427. $pagenum = ceil($total / $perpage);
  2428. $over = $total - ($start + $perpage);
  2429. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2430. echo json_encode($rows);
  2431. exit;
  2432. }
  2433. $this->_Template('whlabel_label', $this->data);
  2434. }
  2435. //独立站出库订单
  2436. public function _outorder()
  2437. {
  2438. if (isset($_SESSION['api'])) {
  2439. $user = $this->user->get_api($_SESSION['api']);
  2440. $usp = $user;
  2441. $fgshop = "";
  2442. $sid = "";
  2443. $user = explode('|', trim($user['shop'], '|'));
  2444. foreach ($user as $value) {
  2445. $fgshop .= " shop = " . $value . " or";
  2446. $sid .= " id = " . $value . " or";
  2447. }
  2448. } else {
  2449. echo "请重新登录";
  2450. }
  2451. $post = $this->input->post(NULL, TRUE);
  2452. if (isset($post['page'])) {
  2453. $page = $this->input->post('page', true);
  2454. $perpage = $this->input->post('perpage', true);
  2455. $warehouse = $this->input->post('warehouse', true);
  2456. $xztime = $this->input->post('xztime', true);
  2457. $timetk = $this->input->post('timetkk', true);
  2458. $timetj = $this->input->post('timetjj', true);
  2459. $shop = $this->input->post('shop', true);
  2460. $source = $this->input->post('source', true);
  2461. $orderinfo = $this->input->post('orderinfo', true);
  2462. $number = $this->input->post('number', true);
  2463. $sfxh = $this->input->post('sfxh', true);
  2464. $express = $this->input->post('express', true);
  2465. $waybill = $this->input->post('waybill', true);
  2466. $library = $this->input->post('library', true);
  2467. $country = $this->input->post('country', true);
  2468. $so = $this->input->post('so', true);
  2469. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2470. $print = $this->input->post('print', true);
  2471. $state = $this->input->post('state', true);
  2472. $orderurl = $this->input->post('orderurl', true);
  2473. $productid = $this->input->post('productid', true);
  2474. $timetk = strtotime($timetk);
  2475. $timetj = strtotime($timetj);
  2476. /**
  2477. $sj = $this->input->post('sj',true);
  2478. if($sj)
  2479. {
  2480. $sj = $this->input->post('sj',true);
  2481. }
  2482. else
  2483. {
  2484. $sj = "fullorder";
  2485. }
  2486. **/
  2487. $sj = "fullorder";
  2488. $where = "1=1";
  2489. if ($warehouse) {
  2490. $where .= " and type = '$warehouse'";
  2491. }
  2492. if ($timetk && $timetj) {
  2493. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2494. }
  2495. if ($orderinfo) {
  2496. $where .= " and orderinfo = '$orderinfo'";
  2497. }
  2498. if ($number) {
  2499. $where .= " and number = '$number'";
  2500. }
  2501. if ($express) {
  2502. $where .= " and express = '$express'";
  2503. }
  2504. if ($waybill) {
  2505. $where .= " and waybill = '$waybill'";
  2506. }
  2507. if ($library) {
  2508. $where .= " and library = '$library'";
  2509. }
  2510. if ($print) {
  2511. $where .= " and print = '$print'";
  2512. }
  2513. if ($libraryconfirm) {
  2514. $where .= " and libraryconfirm = '$libraryconfirm'";
  2515. }
  2516. if ($state) {
  2517. $where .= " and state = '$state'";
  2518. }
  2519. if ($shop) {
  2520. $where .= " and shop = '$shop'";
  2521. }
  2522. if ($country) {
  2523. $where .= " and country = '$country'";
  2524. }
  2525. if ($sfxh != '') {
  2526. $where .= " and sfxh = '$sfxh'";
  2527. }
  2528. if ($so) {
  2529. $where .= " and shipremarks like '%$so%'";
  2530. }
  2531. if ($source) {
  2532. if ($source == '2d') {
  2533. $where .= " and source >= '2'";
  2534. } else {
  2535. $where .= " and source = '$source'";
  2536. }
  2537. }
  2538. if (isset($_SESSION['api'])) {
  2539. foreach ($user as $value) {
  2540. $fgshop .= " shop = " . $value . " or";
  2541. }
  2542. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2543. }
  2544. if ($orderurl) {
  2545. $url = $this->orderurl->read($orderurl);
  2546. $where .= " and link like '%" . $url['url'] . "%'";
  2547. }
  2548. if($productid){
  2549. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2550. }
  2551. //数据排序
  2552. $order_str = "librarytime desc";
  2553. if (empty($page)) {
  2554. $start = 0;
  2555. $perpage = 1;
  2556. } else {
  2557. $start = ($page - 1) * $perpage;
  2558. }
  2559. //取得信息列表
  2560. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2561. //格式化数据
  2562. foreach ($info_list as $key => $value) {
  2563. $shop = $this->shop->read($value['shop']);
  2564. $info_list[$key]['shop'] = $shop['shopname'];
  2565. $express = $this->express->read($value['express']);
  2566. $info_list[$key]['express'] = $express['servicename'];
  2567. $warehouse = $this->warehouse->read($value['type']);
  2568. $info_list[$key]['type'] = $warehouse['title'];
  2569. if ($value['librarytime'] == '0') {
  2570. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2571. } else {
  2572. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2573. }
  2574. }
  2575. $total = $this->$sj->find_count($where);
  2576. $pagenum = ceil($total / $perpage);
  2577. $over = $total - ($start + $perpage);
  2578. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2579. echo json_encode($rows);
  2580. exit;
  2581. }
  2582. $this->data['express'] = $this->express->find_all();
  2583. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2584. $this->data['wlshop'] = $wlshop;
  2585. $user = $this->user->get_api($_SESSION['api']);
  2586. $powerid = $this->power->read($user['power']);
  2587. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2588. $pid = '';
  2589. foreach ($powertext as $v) {
  2590. $pid .= " id = " . $v . " or";
  2591. }
  2592. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2593. $this->data['fullorderexcel'] = $fullorderexcel;
  2594. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2595. $this->data['orderurl'] = $orderurl;
  2596. $this->_Template('whlabel_outorder', $this->data);
  2597. }
  2598. //tt出库
  2599. public function _toutorder()
  2600. {
  2601. $fgshop = "";
  2602. $sid = "";
  2603. if (isset($_SESSION['api'])) {
  2604. $user = $this->user->get_api($_SESSION['api']);
  2605. $usp = $user;
  2606. $user = explode('|', trim($user['shop'], '|'));
  2607. foreach ($user as $value) {
  2608. $fgshop .= " shop = " . $value . " or";
  2609. $sid .= " id = " . $value . " or";
  2610. }
  2611. } else {
  2612. echo "请重新登录";
  2613. die;
  2614. }
  2615. $post = $this->input->post(NULL, TRUE);
  2616. if (isset($post['page'])) {
  2617. $page = $this->input->post('page', true);
  2618. $perpage = $this->input->post('perpage', true);
  2619. $warehouse = $this->input->post('warehouse', true);
  2620. $xztime = $this->input->post('xztime', true);
  2621. $timetk = $this->input->post('timetkk', true);
  2622. $timetj = $this->input->post('timetjj', true);
  2623. $shop = $this->input->post('shop', true);
  2624. $source = $this->input->post('source', true);
  2625. $orderinfo = $this->input->post('orderinfo', true);
  2626. $number = $this->input->post('number', true);
  2627. $sfxh = $this->input->post('sfxh', true);
  2628. $express = $this->input->post('express', true);
  2629. $waybill = $this->input->post('waybill', true);
  2630. $library = $this->input->post('library', true);
  2631. $country = $this->input->post('country', true);
  2632. $so = $this->input->post('so', true);
  2633. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2634. $print = $this->input->post('print', true);
  2635. $state = $this->input->post('state', true);
  2636. $orderurl = $this->input->post('orderurl', true);
  2637. $timetk = strtotime($timetk);
  2638. $timetj = strtotime($timetj);
  2639. /**
  2640. $sj = $this->input->post('sj',true);
  2641. if($sj)
  2642. {
  2643. $sj = $this->input->post('sj',true);
  2644. }
  2645. else
  2646. {
  2647. $sj = "fullorder";
  2648. }
  2649. **/
  2650. $sj = "fullordertt";
  2651. $where = "1=1";
  2652. if ($warehouse) {
  2653. $where .= " and type = '$warehouse'";
  2654. }
  2655. if ($timetk && $timetj) {
  2656. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2657. }
  2658. if ($orderinfo) {
  2659. $where .= " and orderinfo = '$orderinfo'";
  2660. }
  2661. if ($number) {
  2662. $where .= " and number = '$number'";
  2663. }
  2664. if ($express) {
  2665. $where .= " and express = '$express'";
  2666. }
  2667. if ($waybill) {
  2668. $where .= " and waybill = '$waybill'";
  2669. }
  2670. if ($library) {
  2671. $where .= " and library = '$library'";
  2672. }
  2673. if ($print) {
  2674. $where .= " and print = '$print'";
  2675. }
  2676. if ($libraryconfirm) {
  2677. $where .= " and libraryconfirm = '$libraryconfirm'";
  2678. }
  2679. if ($state) {
  2680. $where .= " and state = '$state'";
  2681. }
  2682. if ($shop) {
  2683. $where .= " and shop = '$shop'";
  2684. }
  2685. if ($country) {
  2686. $where .= " and country = '$country'";
  2687. }
  2688. if ($sfxh != '') {
  2689. $where .= " and sfxh = '$sfxh'";
  2690. }
  2691. if ($so) {
  2692. $where .= " and shipremarks like '%$so%'";
  2693. }
  2694. if ($source) {
  2695. if ($source == '2d') {
  2696. $where .= " and source >= '2'";
  2697. } else {
  2698. $where .= " and source = '$source'";
  2699. }
  2700. }
  2701. if (isset($_SESSION['api'])) {
  2702. foreach ($user as $value) {
  2703. $fgshop .= " shop = " . $value . " or";
  2704. }
  2705. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2706. }
  2707. if ($orderurl) {
  2708. $url = $this->orderurl->read($orderurl);
  2709. $where .= " and link like '%" . $url['url'] . "%'";
  2710. }
  2711. //数据排序
  2712. $order_str = "librarytime desc";
  2713. if (empty($page)) {
  2714. $start = 0;
  2715. $perpage = 1;
  2716. } else {
  2717. $start = ($page - 1) * $perpage;
  2718. }
  2719. //取得信息列表
  2720. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2721. //格式化数据
  2722. foreach ($info_list as $key => $value) {
  2723. $shop = $this->shop->read($value['shop']);
  2724. $info_list[$key]['shop'] = $shop['shopname'];
  2725. $express = $this->express->read($value['express']);
  2726. $info_list[$key]['express'] = $express['servicename'];
  2727. $warehouse = $this->warehouse->read($value['type']);
  2728. $info_list[$key]['type'] = $warehouse['title'];
  2729. if ($value['librarytime'] == '0') {
  2730. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2731. } else {
  2732. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2733. }
  2734. }
  2735. $total = $this->$sj->find_count($where);
  2736. $pagenum = ceil($total / $perpage);
  2737. $over = $total - ($start + $perpage);
  2738. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2739. echo json_encode($rows);
  2740. exit;
  2741. }
  2742. $this->data['express'] = $this->express->find_all();
  2743. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2744. $this->data['wlshop'] = $wlshop;
  2745. $user = $this->user->get_api($_SESSION['api']);
  2746. $powerid = $this->power->read($user['power']);
  2747. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2748. $pid = '';
  2749. foreach ($powertext as $v) {
  2750. $pid .= " id = " . $v . " or";
  2751. }
  2752. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2753. $this->data['fullorderexcel'] = $fullorderexcel;
  2754. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2755. $this->data['orderurl'] = $orderurl;
  2756. $this->_Template('whlabel_toutorder', $this->data);
  2757. }
  2758. //tt出库
  2759. public function _aoutorder()
  2760. {
  2761. if (isset($_SESSION['api'])) {
  2762. $user = $this->user->get_api($_SESSION['api']);
  2763. $usp = $user;
  2764. $fgshop = "";
  2765. $sid = "";
  2766. $user = explode('|', trim($user['shop'], '|'));
  2767. foreach ($user as $value) {
  2768. $fgshop .= " shop = " . $value . " or";
  2769. $sid .= " id = " . $value . " or";
  2770. }
  2771. } else {
  2772. echo "请重新登录";
  2773. }
  2774. $post = $this->input->post(NULL, TRUE);
  2775. if (isset($post['page'])) {
  2776. $page = $this->input->post('page', true);
  2777. $perpage = $this->input->post('perpage', true);
  2778. $warehouse = $this->input->post('warehouse', true);
  2779. $xztime = $this->input->post('xztime', true);
  2780. $timetk = $this->input->post('timetkk', true);
  2781. $timetj = $this->input->post('timetjj', true);
  2782. $shop = $this->input->post('shop', true);
  2783. $source = $this->input->post('source', true);
  2784. $orderinfo = $this->input->post('orderinfo', true);
  2785. $number = $this->input->post('number', true);
  2786. $sfxh = $this->input->post('sfxh', true);
  2787. $express = $this->input->post('express', true);
  2788. $waybill = $this->input->post('waybill', true);
  2789. $library = $this->input->post('library', true);
  2790. $country = $this->input->post('country', true);
  2791. $so = $this->input->post('so', true);
  2792. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2793. $print = $this->input->post('print', true);
  2794. $state = $this->input->post('state', true);
  2795. $orderurl = $this->input->post('orderurl', true);
  2796. $timetk = strtotime($timetk);
  2797. $timetj = strtotime($timetj);
  2798. /**
  2799. $sj = $this->input->post('sj',true);
  2800. if($sj)
  2801. {
  2802. $sj = $this->input->post('sj',true);
  2803. }
  2804. else
  2805. {
  2806. $sj = "fullorder";
  2807. }
  2808. **/
  2809. $sj = "fullorderamz";
  2810. $where = "1=1";
  2811. if ($warehouse) {
  2812. $where .= " and type = '$warehouse'";
  2813. }
  2814. if ($timetk && $timetj) {
  2815. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2816. }
  2817. if ($orderinfo) {
  2818. $where .= " and orderinfo = '$orderinfo'";
  2819. }
  2820. if ($number) {
  2821. $where .= " and number = '$number'";
  2822. }
  2823. if ($express) {
  2824. $where .= " and express = '$express'";
  2825. }
  2826. if ($waybill) {
  2827. $where .= " and waybill = '$waybill'";
  2828. }
  2829. if ($library) {
  2830. $where .= " and library = '$library'";
  2831. }
  2832. if ($print) {
  2833. $where .= " and print = '$print'";
  2834. }
  2835. if ($libraryconfirm) {
  2836. $where .= " and libraryconfirm = '$libraryconfirm'";
  2837. }
  2838. if ($state) {
  2839. $where .= " and state = '$state'";
  2840. }
  2841. if ($shop) {
  2842. $where .= " and shop = '$shop'";
  2843. }
  2844. if ($country) {
  2845. $where .= " and country = '$country'";
  2846. }
  2847. if ($sfxh != '') {
  2848. $where .= " and sfxh = '$sfxh'";
  2849. }
  2850. if ($so) {
  2851. $where .= " and shipremarks like '%$so%'";
  2852. }
  2853. if ($source) {
  2854. if ($source == '2d') {
  2855. $where .= " and source >= '2'";
  2856. } else {
  2857. $where .= " and source = '$source'";
  2858. }
  2859. }
  2860. if (isset($_SESSION['api'])) {
  2861. foreach ($user as $value) {
  2862. $fgshop .= " shop = " . $value . " or";
  2863. }
  2864. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2865. }
  2866. if ($orderurl) {
  2867. $url = $this->orderurl->read($orderurl);
  2868. $where .= " and link like '%" . $url['url'] . "%'";
  2869. }
  2870. //数据排序
  2871. $order_str = "librarytime desc";
  2872. if (empty($page)) {
  2873. $start = 0;
  2874. $perpage = 1;
  2875. } else {
  2876. $start = ($page - 1) * $perpage;
  2877. }
  2878. //取得信息列表
  2879. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2880. //格式化数据
  2881. foreach ($info_list as $key => $value) {
  2882. $shop = $this->shop->read($value['shop']);
  2883. $info_list[$key]['shop'] = $shop['shopname'];
  2884. $express = $this->express->read($value['express']);
  2885. $info_list[$key]['express'] = $express['servicename'];
  2886. $warehouse = $this->warehouse->read($value['type']);
  2887. $info_list[$key]['type'] = $warehouse['title'];
  2888. if ($value['librarytime'] == '0') {
  2889. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2890. } else {
  2891. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2892. }
  2893. }
  2894. $total = $this->$sj->find_count($where);
  2895. $pagenum = ceil($total / $perpage);
  2896. $over = $total - ($start + $perpage);
  2897. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2898. echo json_encode($rows);
  2899. exit;
  2900. }
  2901. $this->data['express'] = $this->express->find_all();
  2902. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2903. $this->data['wlshop'] = $wlshop;
  2904. $user = $this->user->get_api($_SESSION['api']);
  2905. $powerid = $this->power->read($user['power']);
  2906. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2907. $pid = '';
  2908. foreach ($powertext as $v) {
  2909. $pid .= " id = " . $v . " or";
  2910. }
  2911. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2912. $this->data['fullorderexcel'] = $fullorderexcel;
  2913. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2914. $this->data['orderurl'] = $orderurl;
  2915. $this->_Template('whlabel_aoutorder', $this->data);
  2916. }
  2917. //速卖通出库订单
  2918. public function _soutorder()
  2919. {
  2920. if (isset($_SESSION['api'])) {
  2921. $user = $this->user->get_api($_SESSION['api']);
  2922. $usp = $user;
  2923. $fgshop = "";
  2924. $sid = "";
  2925. $user = explode('|', trim($user['shop'], '|'));
  2926. foreach ($user as $value) {
  2927. $sid .= " id = " . $value . " or";
  2928. }
  2929. }
  2930. $post = $this->input->post(NULL, TRUE);
  2931. if (isset($post['page'])) {
  2932. $page = $this->input->post('page', true);
  2933. $perpage = $this->input->post('perpage', true);
  2934. $warehouse = $this->input->post('warehouse', true);
  2935. $xztime = $this->input->post('xztime', true);
  2936. $timetk = $this->input->post('timetkk', true);
  2937. $timetj = $this->input->post('timetjj', true);
  2938. $shop = $this->input->post('shop', true);
  2939. $source = $this->input->post('source', true);
  2940. $orderinfo = $this->input->post('orderinfo', true);
  2941. $number = $this->input->post('number', true);
  2942. $express = $this->input->post('express', true);
  2943. $waybill = $this->input->post('waybill', true);
  2944. $library = $this->input->post('library', true);
  2945. $country = $this->input->post('country', true);
  2946. $sfxh = $this->input->post('sfxh', true);
  2947. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2948. $print = $this->input->post('print', true);
  2949. $state = $this->input->post('state', true);
  2950. $so = $this->input->post('so', true);
  2951. $timetk = strtotime($timetk);
  2952. $timetj = strtotime($timetj);
  2953. /**
  2954. $sj = $this->input->post('sj',true);
  2955. if($sj)
  2956. {
  2957. $sj = $this->input->post('sj',true);
  2958. }
  2959. else
  2960. {
  2961. $sj = "fullorder";
  2962. }
  2963. **/
  2964. $sj = "fullordersmt";
  2965. $where = "1=1";
  2966. if ($warehouse) {
  2967. $where .= " and type = '$warehouse'";
  2968. }
  2969. if ($timetk && $timetj) {
  2970. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2971. }
  2972. if ($orderinfo) {
  2973. $where .= " and orderinfo = '$orderinfo'";
  2974. }
  2975. if ($number) {
  2976. $where .= " and number = '$number'";
  2977. }
  2978. if ($express) {
  2979. $where .= " and express = '$express'";
  2980. }
  2981. if ($waybill) {
  2982. $where .= " and waybill = '$waybill'";
  2983. }
  2984. if ($library) {
  2985. $where .= " and library = '$library'";
  2986. }
  2987. if ($print) {
  2988. $where .= " and print = '$print'";
  2989. }
  2990. if ($libraryconfirm) {
  2991. $where .= " and libraryconfirm = '$libraryconfirm'";
  2992. }
  2993. if ($state) {
  2994. $where .= " and state = '$state'";
  2995. }
  2996. if ($shop) {
  2997. $where .= " and shop = '$shop'";
  2998. }
  2999. if ($sfxh != '') {
  3000. $where .= " and sfxh = '$sfxh'";
  3001. }
  3002. if ($so) {
  3003. $where .= " and shipremarks like '%$so%'";
  3004. }
  3005. if ($source) {
  3006. $where .= " and source = '$source'";
  3007. }
  3008. if ($country) {
  3009. $where .= " and country = '$country'";
  3010. } else {
  3011. if (isset($_SESSION['api'])) {
  3012. foreach ($user as $value) {
  3013. $fgshop .= " shop = " . $value . " or";
  3014. }
  3015. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3016. }
  3017. }
  3018. //数据排序
  3019. $order_str = "librarytime desc";
  3020. if (empty($page)) {
  3021. $start = 0;
  3022. $perpage = 1;
  3023. } else {
  3024. $start = ($page - 1) * $perpage;
  3025. }
  3026. //取得信息列表
  3027. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3028. //格式化数据
  3029. foreach ($info_list as $key => $value) {
  3030. $shop = $this->shop->read($value['shop']);
  3031. $info_list[$key]['shop'] = $shop['shopname'];
  3032. $express = $this->express->read($value['express']);
  3033. $info_list[$key]['express'] = $express['servicename'];
  3034. $warehouse = $this->warehouse->read($value['type']);
  3035. $info_list[$key]['type'] = $warehouse['title'];
  3036. if ($value['librarytime'] == '0') {
  3037. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3038. } else {
  3039. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3040. }
  3041. }
  3042. $total = $this->$sj->find_count($where);
  3043. $pagenum = ceil($total / $perpage);
  3044. $over = $total - ($start + $perpage);
  3045. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3046. echo json_encode($rows);
  3047. exit;
  3048. }
  3049. $this->data['express'] = $this->express->find_all();
  3050. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3051. $this->data['wlshop'] = $wlshop;
  3052. $user = $this->user->get_api($_SESSION['api']);
  3053. $powerid = $this->power->read($user['power']);
  3054. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3055. $pid = '';
  3056. foreach ($powertext as $v) {
  3057. $pid .= " id = " . $v . " or";
  3058. }
  3059. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3060. $this->data['fullorderexcel'] = $fullorderexcel;
  3061. $this->_Template('whlabel_soutorder', $this->data);
  3062. }
  3063. //订单退库
  3064. public function _retreat()
  3065. {
  3066. $post = $this->input->post(NULL, TRUE);
  3067. if (isset($post['page'])) {
  3068. $page = $this->input->post('page', true);
  3069. $perpage = $this->input->post('perpage', true);
  3070. $warehouse = $this->input->post('warehouse', true);
  3071. $timetk = $this->input->post('timetk', true);
  3072. $timetj = $this->input->post('timetj', true);
  3073. $shop = $this->input->post('shop', true);
  3074. $source = $this->input->post('source', true);
  3075. $state = $this->input->post('state', true);
  3076. $review = $this->input->post('review', true);
  3077. $state = $this->input->post('state', true);
  3078. $express = $this->input->post('express', true);
  3079. $orderinfo = $this->input->post('orderinfo', true);
  3080. $user = $this->input->post('user', true);
  3081. $name = $this->input->post('name', true);
  3082. $waybill = $this->input->post('waybill', true);
  3083. $timetk = strtotime($timetk);
  3084. $timetj = strtotime($timetj);
  3085. $where = "(state=206 or state=210) and mergeid = 0";
  3086. if ($warehouse) {
  3087. $where .= " and state = '$warehouse'";
  3088. }
  3089. if ($timetk && $timetj) {
  3090. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3091. }
  3092. if ($shop) {
  3093. $where .= " and shop = '$shop'";
  3094. }
  3095. if ($source) {
  3096. $where .= " and source = '$source'";
  3097. }
  3098. if ($state) {
  3099. $where .= " and state = '$state'";
  3100. }
  3101. if ($review) {
  3102. $where .= " and review = '$review'";
  3103. }
  3104. if ($state) {
  3105. $where .= " and state = '$state'";
  3106. }
  3107. if ($express) {
  3108. $where .= " and express = '$express'";
  3109. }
  3110. if ($orderinfo) {
  3111. $where .= " and orderinfo = '$orderinfo'";
  3112. }
  3113. if ($user) {
  3114. $where .= " and user = '$user'";
  3115. }
  3116. if ($name) {
  3117. $where .= " and name = '$name'";
  3118. }
  3119. if ($waybill) {
  3120. $where .= " and waybill = '$waybill'";
  3121. }
  3122. //数据排序
  3123. $order_str = "id desc";
  3124. if (empty($page)) {
  3125. $start = 0;
  3126. $perpage = 1;
  3127. } else {
  3128. $start = ($page - 1) * $perpage;
  3129. }
  3130. //取得信息列表
  3131. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3132. //格式化数据
  3133. foreach ($info_list as $key => $value) {
  3134. $shop = $this->shop->read($value['shop']);
  3135. $info_list[$key]['shop'] = $shop['shopname'];
  3136. $warehouse = $this->warehouse->read($value['warehouse']);
  3137. $info_list[$key]['warehouse'] = $warehouse['title'];
  3138. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3139. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3140. if ($value['waybill'] == 0) {
  3141. $info_list[$key]['waybill'] = "";
  3142. }
  3143. $express = $this->express->read($value['express']);
  3144. $info_list[$key]['express'] = $express['title'];
  3145. $typeclass = $this->typeclass->read($value['state']);
  3146. $info_list[$key]['state'] = $typeclass['title'];
  3147. }
  3148. $total = $this->fullorder->find_count($where);
  3149. $pagenum = ceil($total / $perpage);
  3150. $over = $total - ($start + $perpage);
  3151. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3152. echo json_encode($rows);
  3153. exit;
  3154. }
  3155. $this->data['express'] = $this->express->find_all();
  3156. $this->_Template('whlabel_retreat', $this->data);
  3157. }
  3158. //退库标签浏览
  3159. public function _retreatlk()
  3160. {
  3161. $post = $this->input->post(NULL, TRUE);
  3162. if (isset($post['page'])) {
  3163. $page = $this->input->post('page', true);
  3164. $perpage = $this->input->post('perpage', true);
  3165. $timetk = $this->input->post('timetk', true);
  3166. $timetj = $this->input->post('timetj', true);
  3167. $sku = $this->input->post('sku', true);
  3168. $warehouse = $this->input->post('warehouse', true);
  3169. $purchase = $this->input->post('purchase', true);
  3170. $orderinfo = $this->input->post('orderinfo', true);
  3171. $waybill = $this->input->post('waybill', true);
  3172. $category = $this->input->post('category', true);
  3173. $size = $this->input->post('size', true);
  3174. $grade = $this->input->post('grade', true);
  3175. $color = $this->input->post('color', true);
  3176. $lowe = $this->input->post('lowe', true);
  3177. $state = $this->input->post('state', true);
  3178. $timetk = strtotime($timetk);
  3179. $timetj = strtotime($timetj);
  3180. $where = "state=2";
  3181. if ($timetk && $timetj) {
  3182. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3183. }
  3184. if ($sku) {
  3185. $where .= " and sku = '$sku'";
  3186. }
  3187. if ($warehouse) {
  3188. $where .= " and warehouse = '$warehouse'";
  3189. }
  3190. if ($purchase) {
  3191. $where .= " and purchase = '$purchase'";
  3192. }
  3193. if ($orderinfo) {
  3194. $where .= " and orderinfo = '$orderinfo'";
  3195. }
  3196. if ($waybill) {
  3197. $where .= " and waybill = '$waybill'";
  3198. }
  3199. if ($category) {
  3200. $where .= " and features like '%-$category-%'";
  3201. }
  3202. if ($size) {
  3203. $where .= " and features like '%-$size-%'";
  3204. }
  3205. if ($grade) {
  3206. $where .= " and features like '%-$grade-%'";
  3207. }
  3208. if ($color) {
  3209. $where .= " and features like '%-$color-%'";
  3210. }
  3211. if ($lowe) {
  3212. $where .= " and features like '%-$lowe-%'";
  3213. }
  3214. //数据排序
  3215. $order_str = "time desc";
  3216. if (empty($page)) {
  3217. $start = 0;
  3218. $perpage = 1;
  3219. } else {
  3220. $start = ($page - 1) * $perpage;
  3221. }
  3222. //取得信息列表
  3223. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3224. foreach ($info_list as $key => $value) {
  3225. $warehouse = $this->warehouse->read($value['warehouse']);
  3226. $info_list[$key]['warehouse'] = $warehouse['title'];
  3227. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3228. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3229. $purchase = $this->purchase->read($value['purchase']);
  3230. $info_list[$key]['purchase'] = $purchase['title'];
  3231. if ($value['outk'] != 0) {
  3232. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3233. } else {
  3234. $info_list[$key]['outk'] = "";
  3235. }
  3236. if ($value['retreat'] != 0) {
  3237. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3238. } else {
  3239. $info_list[$key]['retreat'] = "";
  3240. }
  3241. if ($value['orderinfo'] == 0) {
  3242. $info_list[$key]['orderinfo'] = "";
  3243. }
  3244. if ($value['waybill'] == 0) {
  3245. $info_list[$key]['waybill'] = "";
  3246. }
  3247. }
  3248. $total = $this->whlabel->find_count($where);
  3249. $pagenum = ceil($total / $perpage);
  3250. $over = $total - ($start + $perpage);
  3251. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3252. echo json_encode($rows);
  3253. exit;
  3254. }
  3255. $this->_Template('whlabel_retreatlk', $this->data);
  3256. }
  3257. //更换标签及浏览
  3258. public function _change()
  3259. {
  3260. $post = $this->input->post(NULL, TRUE);
  3261. if (isset($post['page'])) {
  3262. $page = $this->input->post('page', true);
  3263. $perpage = $this->input->post('perpage', true);
  3264. $timetk = $this->input->post('timetk', true);
  3265. $timetj = $this->input->post('timetj', true);
  3266. $label = $this->input->post('label', true);
  3267. $oldlabel = $this->input->post('oldlabel', true);
  3268. $timetk = strtotime($timetk);
  3269. $timetj = strtotime($timetj);
  3270. $where = "state=10 ";
  3271. if ($timetk && $timetj) {
  3272. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3273. }
  3274. if ($label) {
  3275. $where .= " and label = '$label'";
  3276. }
  3277. if ($oldlabel) {
  3278. $where .= " and oldlabel = '$oldlabel'";
  3279. }
  3280. //数据排序
  3281. $order_str = "time asc";
  3282. if (empty($page)) {
  3283. $start = 0;
  3284. $perpage = 1;
  3285. } else {
  3286. $start = ($page - 1) * $perpage;
  3287. }
  3288. //取得信息列表
  3289. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3290. foreach ($info_list as $key => $value) {
  3291. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3292. }
  3293. $total = $this->whlabel->find_count($where);
  3294. $pagenum = ceil($total / $perpage);
  3295. $over = $total - ($start + $perpage);
  3296. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3297. echo json_encode($rows);
  3298. exit;
  3299. }
  3300. $this->_Template('whlabel_change', $this->data);
  3301. }
  3302. //产品标签
  3303. public function _cpbqdc()
  3304. {
  3305. if (isset($_GET['excel'])) {
  3306. $where = "1=1";
  3307. //数据排序
  3308. $order_str = "id desc";
  3309. if (empty($page)) {
  3310. $start = 0;
  3311. $perpage = 1;
  3312. } else {
  3313. $start = ($page - 1) * $perpage;
  3314. }
  3315. $warehouse = $this->input->get('warehouse', true);
  3316. $state = $this->input->get('state', true);
  3317. $timetk = $this->input->get('timetkk', true);
  3318. $timetj = $this->input->get('timetjj', true);
  3319. $timetk = strtotime($timetk);
  3320. $timetj = strtotime($timetj);
  3321. if ($warehouse) {
  3322. $where .= " and warehouse = '$warehouse'";
  3323. }
  3324. if ($state || $state == 0) {
  3325. $where .= " and state = '$state'";
  3326. }
  3327. if ($timetk && $timetj) {
  3328. $where .= " and time > '$timetk' and time < '$timetj'";
  3329. }
  3330. //取得信息列表
  3331. $info_list = $this->whlabel->find_all($where, '*');
  3332. $rows = array();
  3333. $list = array();
  3334. foreach ($info_list as $key => $value) {
  3335. $rows[$value['time']] = $value; //所有数据sku
  3336. }
  3337. foreach ($rows as $value) {
  3338. $warehouse = $this->warehouse->read($value['warehouse']);
  3339. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3340. $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);
  3341. }
  3342. $title = "产品标签统计表";
  3343. $titlename = "<table border=1>
  3344. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3345. <tr align='center'>
  3346. <td>仓库</td>
  3347. <td>SKU</td>
  3348. <td>产品</td>
  3349. <td>入库时间</td>
  3350. <td>操作时间</td>
  3351. <td>备注</td>
  3352. <td>数量</td>
  3353. </tr>
  3354. </table>";
  3355. $filename = $title . ".xls";
  3356. $tail = "";
  3357. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3358. }
  3359. }
  3360. //进销存导出
  3361. public function _exceljxc()
  3362. {
  3363. $classid = $this->classid->sku();
  3364. $pm = $classid;
  3365. $typeclass = array();
  3366. $tc = $this->typeclass->find_all();
  3367. foreach ($tc as $v) {
  3368. $typeclass[$v['id']] = $v;
  3369. }
  3370. $prc = array();
  3371. $purchase = $this->purchase->find_all();
  3372. foreach ($purchase as $k => $v) {
  3373. $prc[$v['id']] = $v['title'];
  3374. }
  3375. if (isset($_GET['excel'])) {
  3376. $where = "sku != 'Preset'";
  3377. //数据排序
  3378. $order_str = "id desc";
  3379. if (empty($page)) {
  3380. $start = 0;
  3381. $perpage = 1;
  3382. } else {
  3383. $start = ($page - 1) * $perpage;
  3384. }
  3385. $category = $this->input->get('category', true);
  3386. $warehouse = $this->input->get('warehouse', true);
  3387. $excelid = $this->input->get('sid', true);
  3388. if ($category) {
  3389. $where .= " and features like '%-$category-%'";
  3390. }
  3391. if ($warehouse) {
  3392. $where .= " and warehouse = '$warehouse'";
  3393. }
  3394. $xzid = '';
  3395. if ($excelid) {
  3396. $excelid = explode(',', trim($excelid, ','));
  3397. foreach ($excelid as $key => $value) {
  3398. $xzid .= " id = " . $value . " or";
  3399. }
  3400. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3401. }
  3402. //取得信息列表
  3403. /**
  3404. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3405. $rows = array();$list = array();
  3406. foreach ($info_list as $key=>$value)
  3407. {
  3408. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3409. }
  3410. **/
  3411. $wt = array();
  3412. $whlabel_type = $this->whlabel_type->find_all();
  3413. foreach ($whlabel_type as $v) {
  3414. $wt[$v['id']] = $v['title'];
  3415. }
  3416. $wh = array();
  3417. $w = $this->warehouse->find_all('1=1', 'id,title');
  3418. foreach ($w as $v) {
  3419. $wh[$v['id']] = $v['title'];
  3420. }
  3421. $list = array();
  3422. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3423. foreach ($rows as $key => $value) {
  3424. if (isset($wt[$value['type']])) {
  3425. $rows[$key]['type'] = $wt[$value['type']];
  3426. } else {
  3427. $rows[$key]['type'] = '未设置';
  3428. }
  3429. $bm = '03';
  3430. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3431. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3432. $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');
  3433. $details = array();
  3434. $cpid = array();
  3435. $cpbz = array();
  3436. $c = 0;
  3437. $g = 0;
  3438. $x = 0;
  3439. $t = 0;
  3440. $s = 0;
  3441. $q = 0;
  3442. foreach ($sd as $k => $v) {
  3443. if ($v['state'] == 0) {
  3444. $c++;
  3445. if ($v['cpid'] != 0) {
  3446. $cpid[$v['cpid']] = $v['cpid'];
  3447. }
  3448. if ($v['cpbz'] != '') {
  3449. $cpbz[$v['cpbz']] = $v['cpbz'];
  3450. }
  3451. }
  3452. if ($v['state'] != 9) {
  3453. $g++;
  3454. }
  3455. if ($v['state'] == 1) {
  3456. $x++;
  3457. }
  3458. if ($v['state'] == 2) {
  3459. $t++;
  3460. }
  3461. if ($v['state'] == 8) {
  3462. $s++;
  3463. }
  3464. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3465. $q++;
  3466. }
  3467. $details[$v['details']] = $v['details'];
  3468. }
  3469. $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'] . '"');
  3470. $rows[$key]['details'] = implode("、", $details);
  3471. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3472. $number = $value['number'];
  3473. $ftime = time() - 15 * 24 * 3600;
  3474. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3475. $rows[$key]['number'] = $g;
  3476. $rows[$key]['c'] = $c;
  3477. $rows[$key]['x'] = $x;
  3478. $rows[$key]['t'] = $t;
  3479. $rows[$key]['s'] = $s;
  3480. $rows[$key]['q'] = $q;
  3481. $rows[$key]['z'] = $z;
  3482. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3483. $features = explode('-', trim($features, '-'));
  3484. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3485. // $pm = $classid;
  3486. // $jm = $classid;
  3487. // foreach($features as $k=>$v)
  3488. // {
  3489. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3490. // {
  3491. // if($typeclass[$v]['bm'] != '')
  3492. // {
  3493. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3494. // }
  3495. // }
  3496. // if($v != 0)
  3497. // {
  3498. // if(!isset($typeclass[$v]))
  3499. // {
  3500. // continue;
  3501. // }
  3502. // if(isset($pm[$typeclass[$v]['classid']]))
  3503. // {
  3504. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3505. // {
  3506. // $tz = explode('|',$typeclass[$v]['zh']);
  3507. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3508. // }
  3509. // else
  3510. // {
  3511. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3512. // }
  3513. // }
  3514. // if(isset($jm[$typeclass[$v]['classid']]))
  3515. // {
  3516. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3517. // }
  3518. // }
  3519. // }
  3520. // $jm = array_filter($jm);
  3521. // $rows[$key]['bs'] = implode("-",$jm);
  3522. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3523. // $zh = implode(" ",$pm);
  3524. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3525. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3526. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3527. // $rows[$key]['features'] = $zh;
  3528. }
  3529. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3530. $final_list = [];
  3531. foreach ($list as $k => $v) {
  3532. if (empty($v['sku'])) {
  3533. continue;
  3534. }
  3535. $final_list[] = [
  3536. "warehouse" => $v["warehouse"],
  3537. "purchase" => $v["purchase"],
  3538. "details" => $v["details"],
  3539. "cpid" => $v["cpid"],
  3540. "dbcontent" => $v["dbcontent"],
  3541. "sku" => $v["sku"],
  3542. "cs" => $v["bm"],
  3543. "bs" => $v["jm"],
  3544. "title" => $v["title"],
  3545. "features" => $v["pm"],
  3546. "cpbz" => $v["cpbz"],
  3547. "sm" => $v["sm"],
  3548. "type" => $v["type"],
  3549. "number" => $v["number"],
  3550. "c" => $v["c"],
  3551. "x" => $v["x"],
  3552. "t" => $v["t"],
  3553. "s" => $v["s"],
  3554. "q" => $v["q"],
  3555. "z" => $v["z"],
  3556. "weight" => $v['weight'],
  3557. ];
  3558. }
  3559. $title = "总进销存统计表";
  3560. $titlename = "<table border=1>
  3561. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3562. <tr align='center'>
  3563. <td>仓库</td>
  3564. <td>供应商</td>
  3565. <td>位置</td>
  3566. <td>库存编码</td>
  3567. <td>类目</td>
  3568. <td>SKU</td>
  3569. <td>用友编码</td>
  3570. <td>用友料号</td>
  3571. <td>商品名称</td>
  3572. <td>商品中文</td>
  3573. <td>产品备注</td>
  3574. <td>说明</td>
  3575. <td>类型</td>
  3576. <td>入库总量</td>
  3577. <td>库存数量</td>
  3578. <td>销售数量</td>
  3579. <td>退货数量</td>
  3580. <td>删除数量</td>
  3581. <td>其它操作</td>
  3582. <td>占单数量</td>
  3583. <td>重量(g)</td>
  3584. </tr>
  3585. </table>";
  3586. $filename = $title . ".xls";
  3587. $tail = "";
  3588. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3589. }
  3590. }
  3591. //入库导出
  3592. public function _excelr()
  3593. {
  3594. if (isset($_GET['excel'])) {
  3595. $category = $this->input->get('category', true);
  3596. $size = $this->input->get('size', true);
  3597. $grade = $this->input->get('grade', true);
  3598. $color = $this->input->get('color', true);
  3599. $lowe = $this->input->get('lowe', true);
  3600. $sku = $this->input->get('sku', true);
  3601. $warehouse = $this->input->get('warehouse', true);
  3602. $purchase = $this->input->get('purchase', true);
  3603. $ktime = $this->input->get('ktime', true);
  3604. $jtime = $this->input->get('jtime', true);
  3605. $ktime = strtotime($ktime);
  3606. $jtime = strtotime($jtime);
  3607. $where = "1=1";
  3608. $gj = "";
  3609. $ck = "";
  3610. if ($category) {
  3611. $where .= " and features like '%-$category-%'";
  3612. }
  3613. if ($size) {
  3614. $where .= " and features like '%-$size-%'";
  3615. }
  3616. if ($grade) {
  3617. $where .= " and features like '%-$grade-%'";
  3618. }
  3619. if ($color) {
  3620. $where .= " and features like '%-$color-%'";
  3621. }
  3622. if ($lowe) {
  3623. $where .= " and features like '%-$lowe-%'";
  3624. }
  3625. if ($warehouse) {
  3626. $where .= " and warehouse = '$warehouse'";
  3627. }
  3628. if ($purchase) {
  3629. $where .= " and purchase = '$purchase'";
  3630. }
  3631. if ($sku) {
  3632. $where .= " and sku = '$sku'";
  3633. }
  3634. if ($ktime && $jtime) {
  3635. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3636. }
  3637. //数据排序
  3638. $order_str = "id desc";
  3639. if (empty($page)) {
  3640. $start = 0;
  3641. $perpage = 1;
  3642. } else {
  3643. $start = ($page - 1) * $perpage;
  3644. }
  3645. $list = array();
  3646. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3647. foreach ($rows as $value) {
  3648. $ck = $this->warehouse->read($value['warehouse']);
  3649. $warehouse = $ck['title'];
  3650. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3651. $retreatwarehouse = $tkck['title'];
  3652. $gy = $this->purchase->read($value['purchase']);
  3653. $purchase = $gy['title'];
  3654. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3655. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3656. }
  3657. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3658. $titlename = "<table border=1>
  3659. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3660. <tr align='center'>
  3661. <td>仓库</td>
  3662. <td>SKU</td>
  3663. <td>产品</td>
  3664. <td>时间</td>
  3665. <td>数量</td>
  3666. </tr>
  3667. </table>";
  3668. $filename = $title . ".xls";
  3669. $tail = "";
  3670. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3671. }
  3672. }
  3673. //出库、退库导出
  3674. public function _excelct()
  3675. {
  3676. $classid = $this->classid->sku();
  3677. $pm = $classid;
  3678. $typeclass = array();
  3679. $tc = $this->typeclass->find_all();
  3680. foreach ($tc as $v) {
  3681. $typeclass[$v['id']] = $v;
  3682. }
  3683. $prc = array();
  3684. $purchase = $this->purchase->find_all();
  3685. foreach ($purchase as $k => $v) {
  3686. $prc[$v['id']] = $v['title'];
  3687. }
  3688. if (isset($_GET['excel'])) {
  3689. $wh = array();
  3690. $w = $this->warehouse->find_all('1=1', 'id,title');
  3691. foreach ($w as $v) {
  3692. $wh[$v['id']] = $v['title'];
  3693. }
  3694. $type = $this->input->get('excel', true);
  3695. $category = $this->input->get('category', true);
  3696. $size = $this->input->get('size', true);
  3697. $grade = $this->input->get('grade', true);
  3698. $color = $this->input->get('color', true);
  3699. $lowe = $this->input->get('lowe', true);
  3700. $sku = $this->input->get('sku', true);
  3701. $title = $this->input->get('title', true);
  3702. $warehouse = $this->input->get('warehouse', true);
  3703. $purchase = $this->input->get('purchase', true);
  3704. $lacetype = $this->input->get('lacetype', true);
  3705. $haircap = $this->input->get('haircap', true);
  3706. $lacecolor = $this->input->get('lacecolor', true);
  3707. $density = $this->input->get('density', true);
  3708. $details = $this->input->get('details', true);
  3709. $state = $this->input->get('state', true);
  3710. $shop = $this->input->get('shop', true);
  3711. $hairnumber = $this->input->get('hairnumber', true);
  3712. $type_leixi = $this->input->get('type', true);
  3713. $cpbz = $this->input->get('cpbz', true);
  3714. $sm = $this->input->get('sm', true);
  3715. $sid = $this->input->get('sid', true);
  3716. $ktime = $this->input->get('ktime', true);
  3717. $jtime = $this->input->get('jtime', true);
  3718. $ktime = strtotime($ktime);
  3719. $jtime = strtotime($jtime);
  3720. //$where = " 1=1 ";
  3721. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3722. $where = " sku != '' ";
  3723. $gj = "";
  3724. $ck = "";
  3725. if ($category) {
  3726. $where .= " and features like '%-$category-%'";
  3727. }
  3728. if ($size) {
  3729. $where .= " and features like '%-$size-%'";
  3730. }
  3731. if ($grade) {
  3732. $where .= " and features like '%-$grade-%'";
  3733. }
  3734. if ($color) {
  3735. $where .= " and features like '%-$color-%'";
  3736. }
  3737. if ($lowe) {
  3738. $where .= " and features like '%-$lowe-%'";
  3739. }
  3740. if ($warehouse) {
  3741. $where .= " and warehouse = '$warehouse'";
  3742. }
  3743. if ($purchase) {
  3744. $where .= " and purchase = '$purchase'";
  3745. }
  3746. if ($state) {
  3747. $where .= " and state = '$state'";
  3748. }
  3749. if ($lacetype) {
  3750. $where .= " and features like '%-$lacetype-%'";
  3751. }
  3752. if ($lacecolor) {
  3753. $where .= " and features like '%-$lacecolor-%'";
  3754. }
  3755. if ($density) {
  3756. $where .= " and features like '%-$density-%'";
  3757. }
  3758. if ($haircap) {
  3759. $where .= " and features like '%-$haircap-%'";
  3760. }
  3761. if ($details) {
  3762. $where .= " and details = '$details'";
  3763. }
  3764. if ($shop) {
  3765. $where .= " and shop like '%$shop%'";
  3766. }
  3767. if ($title) {
  3768. $title = trim($title, ' ');
  3769. $title = trim($title, ' ');
  3770. $where .= " and title like '%$title%'";
  3771. }
  3772. if (!empty($hairnumber)) {
  3773. $where .= " and features like '%-128-%' ";
  3774. if ($hairnumber < 0) {
  3775. $class_list = $this->typeclass->find_all('classid = 43');
  3776. foreach ($class_list as $v) {
  3777. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3778. }
  3779. } else {
  3780. $where .= " and features like '%-$hairnumber-%'";
  3781. }
  3782. }
  3783. if ($type_leixi) {
  3784. $where .= " and type = '$type_leixi'";
  3785. }
  3786. if ($cpbz) {
  3787. $where .= " and cpbz like '%$cpbz%' ";
  3788. }
  3789. if ($sm) {
  3790. $where .= " and sm like '%$sm%' ";
  3791. }
  3792. if ($sku) {
  3793. $sku = trim($sku, ' ');
  3794. $sku = trim($sku, ' ');
  3795. $where .= " and sku like '%$sku%'";
  3796. }
  3797. if ($ktime && $jtime) {
  3798. if ($type == 1) {
  3799. $tl = '出库';
  3800. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3801. } else if ($type == 2) {
  3802. $tl = '退库';
  3803. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3804. } else if ($type == 3) {
  3805. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3806. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3807. } else if ($type == 4) {
  3808. $tl = '出库+零售';
  3809. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3810. } else if ($type == 5) {
  3811. $tl = '零售';
  3812. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3813. }
  3814. }
  3815. $sidwhere = '';
  3816. if ($sid) {
  3817. $sd = "";
  3818. $s = explode(',', trim($sid, ','));
  3819. foreach ($s as $value) {
  3820. $sd .= " id = " . $value . " or";
  3821. }
  3822. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3823. }
  3824. //数据排序
  3825. $order_str = "time desc";
  3826. if (empty($page)) {
  3827. $start = 0;
  3828. $perpage = 1;
  3829. } else {
  3830. $start = ($page - 1) * $perpage;
  3831. }
  3832. //取得信息列表
  3833. if ($type != 3 && $type != 5) {
  3834. if ($type == 1 || $type == 4) {
  3835. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3836. foreach ($info_list as $key => $value) {
  3837. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3838. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3839. $warehouse = $this->warehouse->read($value['warehouse']);
  3840. $info_list[$key]['warehouse'] = $warehouse['title'];
  3841. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3842. $features = explode('-', trim($features, '-'));
  3843. $pm = $classid;
  3844. foreach ($features as $k => $v) {
  3845. if ($v != 0) {
  3846. if (!isset($typeclass[$v])) {
  3847. continue;
  3848. }
  3849. if (isset($pm[$typeclass[$v]['classid']])) {
  3850. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3851. $tz = explode('|', $typeclass[$v]['zh']);
  3852. $pm[$typeclass[$v]['classid']] = $tz[0];
  3853. } else {
  3854. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3855. }
  3856. }
  3857. }
  3858. }
  3859. $zh = implode(" ", $pm);
  3860. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3861. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3862. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3863. $info_list[$key]['features'] = $zh;
  3864. }
  3865. $final_list = [];
  3866. foreach($info_list as $k=>$v){
  3867. $number = "";
  3868. if(!empty($v['orderinfo'])){
  3869. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3870. if(!empty($tmp_info['number'])){
  3871. $number = $tmp_info['number'];
  3872. }
  3873. }
  3874. $final_list[] = [
  3875. 'warehouse'=>$v['warehouse'],
  3876. 'purchase'=>$v['purchase'],
  3877. 'sku'=>$v['sku'],
  3878. 'title'=>$v['title'],
  3879. 'features'=>$v['features'],
  3880. 'label'=>$v['label'],
  3881. 'orderinfo'=>$v['orderinfo'],
  3882. 'number'=>$number,
  3883. 'waybill'=>$v['waybill'],
  3884. 'outk'=>$v['outk'],
  3885. ];
  3886. }
  3887. } else {
  3888. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3889. foreach ($info_list as $key => $value) {
  3890. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3891. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3892. $warehouse = $this->warehouse->read($value['warehouse']);
  3893. $info_list[$key]['warehouse'] = $warehouse['title'];
  3894. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3895. $features = explode('-', trim($features, '-'));
  3896. $pm = $classid;
  3897. foreach ($features as $k => $v) {
  3898. if ($v != 0) {
  3899. if (!isset($typeclass[$v])) {
  3900. continue;
  3901. }
  3902. if (isset($pm[$typeclass[$v]['classid']])) {
  3903. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3904. $tz = explode('|', $typeclass[$v]['zh']);
  3905. $pm[$typeclass[$v]['classid']] = $tz[0];
  3906. } else {
  3907. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3908. }
  3909. }
  3910. }
  3911. }
  3912. $zh = implode(" ", $pm);
  3913. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3914. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3915. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3916. $info_list[$key]['features'] = $zh;
  3917. }
  3918. $final_list = [];
  3919. foreach($info_list as $k=>$v){
  3920. $number = "";
  3921. if(!empty($v['orderinfo'])){
  3922. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3923. if(!empty($tmp_info['number'])){
  3924. $number = $tmp_info['number'];
  3925. }
  3926. }
  3927. $final_list[] = [
  3928. 'warehouse'=>$v['warehouse'],
  3929. 'purchase'=>$v['purchase'],
  3930. 'sku'=>$v['sku'],
  3931. 'title'=>$v['title'],
  3932. 'features'=>$v['features'],
  3933. 'label'=>$v['label'],
  3934. 'orderinfo'=>$v['orderinfo'],
  3935. 'number'=>$number,
  3936. 'waybill'=>$v['waybill'],
  3937. 'retreat'=>$v['retreat'],
  3938. ];
  3939. }
  3940. }
  3941. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3942. $titlename = "<table border=1>
  3943. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3944. <tr align='center'>
  3945. <td>仓库</td>
  3946. <td>供应商</td>
  3947. <td>SKU</td>
  3948. <td>商品名称</td>
  3949. <td>商品中文</td>
  3950. <td>标签</td>
  3951. <td>订单号</td>
  3952. <td>订单编码</td>
  3953. <td>运单号</td>
  3954. <td>" . $tl . "时间(中国时间)</td>
  3955. </tr>
  3956. </table>";
  3957. $filename = $title . ".xls";
  3958. $tail = "";
  3959. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3960. } else if ($type == 5) {
  3961. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3962. foreach ($info_list as $key => $value) {
  3963. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3964. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3965. $warehouse = $this->warehouse->read($value['warehouse']);
  3966. $info_list[$key]['warehouse'] = $warehouse['title'];
  3967. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3968. $features = explode('-', trim($features, '-'));
  3969. $pm = $classid;
  3970. foreach ($features as $k => $v) {
  3971. if ($v != 0) {
  3972. if (!isset($typeclass[$v])) {
  3973. continue;
  3974. }
  3975. if (isset($pm[$typeclass[$v]['classid']])) {
  3976. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3977. $tz = explode('|', $typeclass[$v]['zh']);
  3978. $pm[$typeclass[$v]['classid']] = $tz[0];
  3979. } else {
  3980. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3981. }
  3982. }
  3983. }
  3984. }
  3985. $zh = implode(" ", $pm);
  3986. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3987. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3988. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3989. $info_list[$key]['features'] = $zh;
  3990. }
  3991. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3992. $titlename = "<table border=1>
  3993. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3994. <tr align='center'>
  3995. <td>仓库</td>
  3996. <td>供应商</td>
  3997. <td>SKU</td>
  3998. <td>商品名称</td>
  3999. <td>商品中文</td>
  4000. <td>标签</td>
  4001. <td>" . $tl . "时间(中国时间)</td>
  4002. </tr>
  4003. </table>";
  4004. $filename = $title . ".xls";
  4005. $tail = "";
  4006. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4007. } else {
  4008. /**
  4009. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4010. $rows = array();$list = array();
  4011. foreach ($info_list as $key=>$value)
  4012. {
  4013. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4014. }
  4015. **/
  4016. $wh = array();
  4017. $w = $this->warehouse->find_all('1=1', 'id,title');
  4018. foreach ($w as $v) {
  4019. $wh[$v['id']] = $v['title'];
  4020. }
  4021. $wt = array();
  4022. $whlabel_type = $this->whlabel_type->find_all();
  4023. foreach ($whlabel_type as $v) {
  4024. $wt[$v['id']] = $v['title'];
  4025. }
  4026. $classid = $this->classid->sku();
  4027. $list = array();
  4028. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4029. foreach ($rows as $key => $value) {
  4030. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4031. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4032. $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');
  4033. $details = array();
  4034. $cpid = array();
  4035. $cpbz = array();
  4036. $c = 0;
  4037. $g = 0;
  4038. $x = 0;
  4039. $t = 0;
  4040. $s = 0;
  4041. $q = 0;
  4042. foreach ($sd as $k => $v) {
  4043. if ($v['state'] == 0) {
  4044. $c++;
  4045. }
  4046. if ($v['state'] != 9) {
  4047. $g++;
  4048. }
  4049. if ($v['outk'] > 1) {
  4050. $x++;
  4051. }
  4052. if ($v['retreat'] > 0) {
  4053. $t++;
  4054. }
  4055. if ($v['state'] == 8) {
  4056. $s++;
  4057. }
  4058. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4059. $q++;
  4060. }
  4061. $details[$v['details']] = $v['details'];
  4062. if ($v['cpid'] != 0) {
  4063. $cpid[$v['cpid']] = $v['cpid'];
  4064. }
  4065. if ($v['cpbz'] != '') {
  4066. $cpbz[$v['cpbz']] = $v['cpbz'];
  4067. }
  4068. }
  4069. if (isset($wt[$value['type']])) {
  4070. $rows[$key]['type'] = $wt[$value['type']];
  4071. } else {
  4072. $rows[$key]['type'] = '未设置';
  4073. }
  4074. $rows[$key]['details'] = implode("、", $details);
  4075. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4076. $ftime = time() - 15 * 24 * 3600;
  4077. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4078. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4079. $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);
  4080. $rows[$key]['c'] = $c;
  4081. $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);
  4082. $rows[$key]['t'] = $t;
  4083. $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'] . '"');
  4084. $rows[$key]['z'] = $z;
  4085. // $jm = $classid;
  4086. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4087. $features = explode('-', trim($features, '-'));
  4088. // $pm = $classid;
  4089. // foreach ($features as $k => $v) {
  4090. // if ($v != 0) {
  4091. // if (!isset($typeclass[$v])) {
  4092. // continue;
  4093. // }
  4094. // if (isset($pm[$typeclass[$v]['classid']])) {
  4095. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4096. // $tz = explode('|', $typeclass[$v]['zh']);
  4097. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4098. // } else {
  4099. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4100. // }
  4101. // if (isset($jm[$typeclass[$v]['classid']])) {
  4102. // if ($typeclass[$v]['jm']) {
  4103. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4104. // }
  4105. // }
  4106. // }
  4107. // }
  4108. // }
  4109. // $zh = implode(" ", $pm);
  4110. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4111. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4112. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4113. // $rows[$key]['features'] = $zh;
  4114. // $jm = array_filter($jm); //去除空值
  4115. // $jm = implode("-", $jm);
  4116. // $rows[$key]['jm'] = $jm;
  4117. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4118. }
  4119. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4120. // echo "<pre>";
  4121. // print_r($tmp_list);
  4122. // die;
  4123. $final_list =[];
  4124. foreach($tmp_list as $k=>$v){
  4125. $final_list[] = [
  4126. "warehouse"=>$v['warehouse'],
  4127. "purchase"=>$v['purchase'],
  4128. "details"=>$v['details'],
  4129. "cpid"=>$v['cpid'],
  4130. "sku"=>$v['sku'],
  4131. "title"=>$v['title'],
  4132. "features"=>$v['pm'],
  4133. "cpbz"=>$v['cpbz'],
  4134. "sm"=>$v['sm'],
  4135. "type"=>$v['type'],
  4136. "g"=>$v["g"],
  4137. "c"=>$v["c"],
  4138. "x"=>$v["x"],
  4139. "t"=>$v["t"],
  4140. "z"=>$v["z"],
  4141. "jm"=>$v["jm"],
  4142. "weight"=>$v["weight"],
  4143. "asd"=>$v["asd"],
  4144. ];
  4145. }
  4146. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4147. $titlename = "<table border=1>
  4148. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4149. <tr align='center'>
  4150. <td>仓库</td>
  4151. <td>供应商</td>
  4152. <td>位置</td>
  4153. <td>库存编码</td>
  4154. <td>SKU</td>
  4155. <td>商品名称</td>
  4156. <td>商品中文</td>
  4157. <td>产品备注</td>
  4158. <td>说明</td>
  4159. <td>类型</td>
  4160. <td>入库总量</td>
  4161. <td>库存数量</td>
  4162. <td>销售数量</td>
  4163. <td>退货数量</td>
  4164. <td>占单数量</td>
  4165. <td>料号</td>
  4166. <td>重量</td>
  4167. <td>类目</td>
  4168. </tr>
  4169. </table>";
  4170. $filename = $title . ".xls";
  4171. $tail = "";
  4172. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4173. }
  4174. }
  4175. }
  4176. //出库+入库数据整合
  4177. public function _excelcr()
  4178. {
  4179. if (isset($_GET['excel'])) {
  4180. $type = $this->input->get('excel', true);
  4181. $category = $this->input->get('category', true);
  4182. $size = $this->input->get('size', true);
  4183. $grade = $this->input->get('grade', true);
  4184. $color = $this->input->get('color', true);
  4185. $lowe = $this->input->get('lowe', true);
  4186. $sku = $this->input->get('sku', true);
  4187. $warehouse = $this->input->get('warehouse', true);
  4188. $purchase = $this->input->get('purchase', true);
  4189. $state = $this->input->get('state', true);
  4190. $sid = $this->input->get('sid', true);
  4191. $ktime = $this->input->get('ktime', true);
  4192. $jtime = $this->input->get('jtime', true);
  4193. $ktime = strtotime($ktime);
  4194. $jtime = strtotime($jtime);
  4195. $where = "1=1";
  4196. $gj = "";
  4197. $ck = "";
  4198. if ($category) {
  4199. $where .= " and features like '%-$category-%'";
  4200. }
  4201. if ($size) {
  4202. $where .= " and features like '%-$size-%'";
  4203. }
  4204. if ($grade) {
  4205. $where .= " and features like '%-$grade-%'";
  4206. }
  4207. if ($color) {
  4208. $where .= " and features like '%-$color-%'";
  4209. }
  4210. if ($lowe) {
  4211. $where .= " and features like '%-$lowe-%'";
  4212. }
  4213. if ($warehouse) {
  4214. $where .= " and warehouse = '$warehouse'";
  4215. }
  4216. if ($purchase) {
  4217. $where .= " and purchase = '$purchase'";
  4218. }
  4219. if ($state) {
  4220. $where .= " and state = '$state'";
  4221. }
  4222. if ($sku) {
  4223. $where .= " and sku like '%$sku%'";
  4224. }
  4225. if ($ktime && $jtime) {
  4226. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4227. }
  4228. $sidwhere = '';
  4229. if ($sid) {
  4230. $sd = "";
  4231. $s = explode(',', trim($sid, ','));
  4232. foreach ($s as $value) {
  4233. $sd .= " id = " . $value . " or";
  4234. }
  4235. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4236. }
  4237. //取得信息列表
  4238. $timeread = $ktime;
  4239. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4240. $timelist = array();
  4241. for ($i = 0; $i < $timenum; $i++) {
  4242. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4243. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4244. }
  4245. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4246. //echo "<pre>";
  4247. //print_r($info_list);
  4248. //exit();
  4249. $rows = array();
  4250. $list = array();
  4251. foreach ($info_list as $key => $value) {
  4252. $thistime = $timelist;
  4253. if (isset($rows[strtolower($value['sku'])])) {
  4254. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4255. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4256. }
  4257. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4258. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4259. }
  4260. } else {
  4261. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4262. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4263. }
  4264. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4265. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4266. }
  4267. $rows[strtolower($value['sku'])] = $thistime;
  4268. }
  4269. }
  4270. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4271. <head>
  4272. <!--[if gte mso 9]><xml>
  4273. <x:ExcelWorkbook>
  4274. <x:ExcelWorksheets>
  4275. <x:ExcelWorksheet>
  4276. <x:Name>EXCEL</x:Name>
  4277. <x:WorksheetOptions>
  4278. <x:Print>
  4279. <x:ValidPrinterInfo />
  4280. </x:Print>
  4281. </x:WorksheetOptions>
  4282. </x:ExcelWorksheet>
  4283. </x:ExcelWorksheets>
  4284. </x:ExcelWorkbook>
  4285. </xml>
  4286. <![endif]-->
  4287. </head><body>";
  4288. $str .= "<table border=1><tr><td>SKU</td>";
  4289. foreach ($timelist as $k => $v) {
  4290. $str .= "<td>" . $k . "出库</td>";
  4291. $str .= "<td>" . $k . "入库</td>";
  4292. }
  4293. $str .= "</tr></table>";
  4294. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4295. foreach ($rows as $key => $val) {
  4296. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4297. foreach ($val as $k => $v) {
  4298. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4299. if ($val[$k]['r'] > 0) {
  4300. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4301. } else {
  4302. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4303. }
  4304. }
  4305. $str .= "</tr>";
  4306. }
  4307. $str .= "</table>";
  4308. $str .= "</body></html>";
  4309. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4310. header("Content-type: application/octet-stream");
  4311. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4312. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4313. header("Pragma: no-cache");
  4314. header("Expires: 0");
  4315. exit($str);
  4316. }
  4317. }
  4318. //数量调整模板导出
  4319. public function _presetout()
  4320. {
  4321. if (isset($_GET['excel'])) {
  4322. $where = "sku != 'Preset' and purchase != 0";
  4323. //数据排序
  4324. $order_str = "id desc";
  4325. if (empty($page)) {
  4326. $start = 0;
  4327. $perpage = 1;
  4328. } else {
  4329. $start = ($page - 1) * $perpage;
  4330. }
  4331. //取得信息列表
  4332. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4333. $rows = array();
  4334. $list = array();
  4335. foreach ($info_list as $value) {
  4336. $warehouse = $this->warehouse->read($value['warehouse']);
  4337. $number = $value['number'];
  4338. $ftime = time() - 15 * 24 * 3600;
  4339. $purchase = $this->purchase->read($value['purchase']);
  4340. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4341. }
  4342. $title = "库存模板";
  4343. $titlename = "<table border=1>
  4344. <tr align='center'>
  4345. <td>仓库</td>
  4346. <td>供应商编码</td>
  4347. <td>SKU</td>
  4348. <td>增减数量(正数或负数)</td>
  4349. <td>增减备注</td>
  4350. <td>扣减方式:0减少库存1删除库存</td>
  4351. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4352. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4353. </tr>
  4354. </table>";
  4355. $filename = $title . ".xls";
  4356. $tail = "";
  4357. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4358. }
  4359. }
  4360. //数量调整模板导入
  4361. public function _presetedit()
  4362. {
  4363. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4364. $config['upload_path'] = '.' . $dir;
  4365. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4366. $config['allowed_types'] = 'xls|xlsx|csv';
  4367. $config['max_size'] = 10240;
  4368. $this->load->library('upload', $config);
  4369. $this->upload->initialize($config);
  4370. if ($this->upload->do_upload('userfile')) {
  4371. $full_path = $dir . $this->upload->data('file_name');
  4372. $fileName = '.' . $full_path;
  4373. if (!file_exists($fileName)) {
  4374. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4375. exit;
  4376. } else {
  4377. require_once "./data/excel/PHPExcel/IOFactory.php";
  4378. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4379. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4380. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4381. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4382. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4383. ++$column; //如果列数大于26行
  4384. $list = array();
  4385. for ($i = 2; $i <= $row; $i++) // 行数循环
  4386. {
  4387. $data = array();
  4388. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4389. {
  4390. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4391. }
  4392. $list[] = $data;
  4393. }
  4394. }
  4395. $i = 0;
  4396. $j = 0;
  4397. $ed = array();
  4398. foreach ($list as $key => $value) {
  4399. $time = time();
  4400. if ($value['0'] == "") {
  4401. continue;
  4402. }
  4403. $warehouse = $this->warehouse->get_title($value['0']);
  4404. $purchase = $this->purchase->get_bm($value['1']);
  4405. $sku = $value['2'];
  4406. $num = $value['3']; //调整数量
  4407. $text = $value['4']; //扣减说明
  4408. $type = $value['5']; //调整方式0扣减1删除
  4409. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4410. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4411. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4412. if (!$purchase) //如果没有这个SKU
  4413. {
  4414. $ed[] = array($purchase . '-不存在此供应商编码');
  4415. $j++;
  4416. continue;
  4417. }
  4418. if (!$d) //如果没有这个SKU
  4419. {
  4420. $ed[] = array($sku . '-库存中不存在此SKU');
  4421. $j++;
  4422. continue;
  4423. }
  4424. if (!isset($warehouse['id'])) {
  4425. $ed[] = array($sku . '-仓库名错误!');
  4426. $j++;
  4427. continue;
  4428. }
  4429. if ($type != '0' && $type != '1') {
  4430. $ed[] = array($sku . '-扣减方式填写错误!');
  4431. $j++;
  4432. continue;
  4433. }
  4434. if ($num < 0) //扣减库存
  4435. {
  4436. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4437. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4438. $j++;
  4439. continue;
  4440. }
  4441. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4442. if (count($data) < abs($num)) {
  4443. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4444. $j++;
  4445. continue;
  4446. }
  4447. if ($type == 0) //如果扣减方式为 扣减库存
  4448. {
  4449. for ($i = 0; $i < abs($num); $i++) {
  4450. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4451. }
  4452. } else if ($type == 1) {
  4453. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4454. if (count($zt) > 0) {
  4455. $ed[] = array($sku . '-有在途库存无法删除!');
  4456. $j++;
  4457. continue;
  4458. }
  4459. for ($i = 0; $i < abs($num); $i++) {
  4460. $this->whlabel->remove($data[$i]['id']);
  4461. }
  4462. }
  4463. } else if ($num > 0) //增加库存
  4464. {
  4465. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4466. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4467. $j++;
  4468. continue;
  4469. }
  4470. $post['sku'] = $d['sku'];
  4471. $post['shop'] = $d['shop'];
  4472. $post['warehouse'] = $warehouse['id'];
  4473. $post['purchase'] = $purchase['id'];
  4474. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4475. $post['state'] = 0;
  4476. $post['title'] = $d['title'];
  4477. $post['number'] = $d['number'];
  4478. $post['features'] = $d['features'];
  4479. $post['enter'] = $time;
  4480. $post['time'] = $time; //操作时间
  4481. $post['rktype'] = $rktype;
  4482. for ($i = 0; $i < $num; $i++) {
  4483. $post['label'] = time() . rand(100, 999) . $i;
  4484. $this->whlabel->insert($post);
  4485. }
  4486. }
  4487. sleep(1); //防止入库时间一样,需要延迟1秒
  4488. }
  4489. if ($j > 0) {
  4490. $tt = date('Ymd', time());
  4491. $title = '库存导入错误信息-' . $tt;
  4492. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4493. $tail = "\n";
  4494. $filename = $title . ".xls";
  4495. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4496. $dir = '/data/excel/' . $time . '/';
  4497. $file_name = 'error_' . $time . rand(1000, 9999);
  4498. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4499. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4500. fwrite($myfile, $ecl);
  4501. fclose($myfile);
  4502. $error = $dir . $file_name . '.xls';
  4503. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4504. exit;
  4505. } else {
  4506. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4507. exit;
  4508. }
  4509. }
  4510. }
  4511. public function _presetedittwo(){
  4512. $data = $this->input->post(NULL, TRUE);
  4513. if(empty($list)){
  4514. $raw_data = $this->input->raw_input_stream;
  4515. // 解码 JSON
  4516. $data = json_decode($raw_data, true);
  4517. }
  4518. if(empty($data)){
  4519. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4520. }
  4521. $list = [];
  4522. if(isset($data['list'])){
  4523. $list = $data['list'];
  4524. }
  4525. $i = 0;
  4526. $j = 0;
  4527. $ed = array();
  4528. foreach ($list as $key => $value) {
  4529. $time = time();
  4530. if ($value['0'] == "") {
  4531. continue;
  4532. }
  4533. $warehouse = $this->warehouse->get_title($value['0']);
  4534. $purchase = $this->purchase->get_bm($value['1']);
  4535. $sku = $value['2'];
  4536. $num = $value['3']; //调整数量
  4537. $text = $value['4']; //扣减说明
  4538. $type = $value['5']; //调整方式0扣减1删除
  4539. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4540. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4541. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4542. if (!$purchase) //如果没有这个SKU
  4543. {
  4544. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4545. $j++;
  4546. continue;
  4547. }
  4548. if (!$d) //如果没有这个SKU
  4549. {
  4550. $ed[] = array($sku . '-库存中不存在此SKU');
  4551. $j++;
  4552. continue;
  4553. }
  4554. if (!isset($warehouse['id'])) {
  4555. $ed[] = array($sku . '-仓库名错误!');
  4556. $j++;
  4557. continue;
  4558. }
  4559. if ($type != '0' && $type != '1') {
  4560. $ed[] = array($sku . '-扣减方式填写错误!');
  4561. $j++;
  4562. continue;
  4563. }
  4564. if ($num < 0) //扣减库存
  4565. {
  4566. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4567. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4568. $j++;
  4569. continue;
  4570. }
  4571. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4572. if (count($data) < abs($num)) {
  4573. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4574. $j++;
  4575. continue;
  4576. }
  4577. if ($type == 0) //如果扣减方式为 扣减库存
  4578. {
  4579. for ($i = 0; $i < abs($num); $i++) {
  4580. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4581. }
  4582. } else if ($type == 1) {
  4583. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4584. if (count($zt) > 0) {
  4585. $ed[] = array($sku . '-有在途库存无法删除!');
  4586. $j++;
  4587. continue;
  4588. }
  4589. for ($i = 0; $i < abs($num); $i++) {
  4590. $this->whlabel->remove($data[$i]['id']);
  4591. }
  4592. }
  4593. } else if ($num > 0) //增加库存
  4594. {
  4595. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4596. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4597. $j++;
  4598. continue;
  4599. }
  4600. $post['sku'] = $d['sku'];
  4601. $post['shop'] = $d['shop'];
  4602. $post['warehouse'] = $warehouse['id'];
  4603. $post['purchase'] = $purchase['id'];
  4604. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4605. $post['state'] = 0;
  4606. $post['title'] = $d['title'];
  4607. $post['number'] = $d['number'];
  4608. $post['features'] = $d['features'];
  4609. $post['enter'] = $time;
  4610. $post['time'] = $time; //操作时间
  4611. $post['rktype'] = $rktype;
  4612. $post['sku_master_id'] = $d['sku_master_id'];
  4613. $post['sku_shop_id'] = $d['sku_shop_id'];
  4614. for ($i = 0; $i < $num; $i++) {
  4615. $post['label'] = time() . rand(100, 999) . $i;
  4616. $this->whlabel->insert($post);
  4617. }
  4618. }
  4619. sleep(1); //防止入库时间一样,需要延迟1秒
  4620. }
  4621. if ($j > 0) {
  4622. $tt = date('Ymd', time());
  4623. $title = '库存导入错误信息-' . $tt;
  4624. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4625. $tail = "\n";
  4626. $filename = $title . ".xls";
  4627. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4628. $dir = '/data/excel/' . $time . '/';
  4629. $file_name = 'error_' . $time . rand(1000, 9999);
  4630. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4631. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4632. fwrite($myfile, $ecl);
  4633. fclose($myfile);
  4634. $error = $dir . $file_name . '.xls';
  4635. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4636. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4637. exit;
  4638. } else {
  4639. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4640. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4641. exit;
  4642. }
  4643. }
  4644. //笛卡儿积
  4645. function cp($ps, $sets, $list)
  4646. {
  4647. $result = array();
  4648. $j = 0;
  4649. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4650. if ($i == 0) {
  4651. $result = $sets[$i];
  4652. }
  4653. $tmp = array();
  4654. foreach ($result as $res) {
  4655. foreach ($sets[$i + 1] as $set) {
  4656. $tmp[] = $res . ',' . $set;
  4657. }
  4658. }
  4659. $result = $tmp;
  4660. }
  4661. $this->db->trans_begin();
  4662. foreach ($result as $v) {
  4663. $post = array();
  4664. $title = "";
  4665. $num = "";
  4666. $data = explode(',', $v);
  4667. for ($i = 0; $i < count($list); $i++) {
  4668. $post[$list[$i]] = $data[$i];
  4669. $typeclass = $this->typeclass->read($data[$i]);
  4670. $title = $title . $typeclass['title'] . " ";
  4671. if ($data[$i] != 0) {
  4672. $num .= $data[$i]; //所有数据ID拼接
  4673. }
  4674. }
  4675. foreach ($ps as $kp => $vp) {
  4676. $post[$kp] = $vp;
  4677. }
  4678. $post['number'] = $num;
  4679. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4680. if ($info_list) {
  4681. $j++;
  4682. } else {
  4683. $skunum = $this->whlabel->find_count();
  4684. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4685. $post['title'] = rtrim($title, ' ');
  4686. $this->whlabel->insert($post);
  4687. }
  4688. }
  4689. if ($this->db->trans_status() === FALSE) {
  4690. $this->db->trans_commit();
  4691. return NULL;
  4692. } else {
  4693. $this->db->trans_commit();
  4694. return $j;
  4695. }
  4696. }
  4697. public function _kj($arg_array)
  4698. {
  4699. if (isset($_POST['sku'])) {
  4700. $time = time();
  4701. $sku = $this->input->post('sku', true);
  4702. $warehouse = $this->input->post('warehouse', true);
  4703. $num = $this->input->post('num', true);
  4704. $text = $this->input->post('text', true);
  4705. $purchase = $this->input->post('purchase', true);
  4706. $cktype = $this->input->post('cktype', true);
  4707. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4708. if ($cktype != 1 && $text == '') {
  4709. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4710. exit;
  4711. }
  4712. if ($num > count($order)) {
  4713. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4714. exit;
  4715. } else {
  4716. for ($i = 0; $i < $num; $i++) {
  4717. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4718. }
  4719. }
  4720. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4721. exit;
  4722. }
  4723. $uid = $this->whlabel->read($arg_array[0]);
  4724. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4725. $this->data['data'] = $uid;
  4726. $this->_Template('whlabel_kj', $this->data);
  4727. }
  4728. public function _summary($arg_array)
  4729. {
  4730. $prc = array();
  4731. $purchase = $this->purchase->find_all();
  4732. foreach ($purchase as $k => $v) {
  4733. $prc[$v['id']] = $v['title'];
  4734. }
  4735. if (isset($_GET['excel'])) {
  4736. $ktime = $this->input->get('ktime', true);
  4737. $jtime = $this->input->get('jtime', true);
  4738. $ktime = strtotime($ktime);
  4739. $jtime = strtotime($jtime);
  4740. $where = "1=1";
  4741. if ($ktime && $jtime) {
  4742. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4743. }
  4744. //数据排序
  4745. $order_str = "time desc";
  4746. if (empty($page)) {
  4747. $start = 0;
  4748. $perpage = 1;
  4749. } else {
  4750. $start = ($page - 1) * $perpage;
  4751. }
  4752. //取得信息列表
  4753. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4754. foreach ($info_list as $key => $value) {
  4755. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4756. $warehouse = $this->warehouse->read($value['warehouse']);
  4757. $info_list[$key]['warehouse'] = $warehouse['title'];
  4758. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4759. $details = array();
  4760. $cpid = array();
  4761. foreach ($x as $k => $v) {
  4762. if ($v['details'] != '') {
  4763. $details[$v['details']] = $v['details'];
  4764. }
  4765. if ($v['cpid'] != 0) {
  4766. $cpid[$v['cpid']] = $v['cpid'];
  4767. }
  4768. }
  4769. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4770. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4771. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4772. $info_list[$key]['s'] = $s;
  4773. $info_list[$key]['x'] = count($x);
  4774. }
  4775. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4776. $titlename = "<table border=1>
  4777. <tr align='center'>
  4778. <td>仓库</td>
  4779. <td>供应商</td>
  4780. <td>出库位置</td>
  4781. <td>出库编码</td>
  4782. <td>SKU</td>
  4783. <td>产品名</td>
  4784. <td>总剩余库存</td>
  4785. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4786. </tr>
  4787. </table>";
  4788. $filename = $title . ".xls";
  4789. $tail = "";
  4790. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4791. }
  4792. }
  4793. //usps发货清单
  4794. public function _manifest()
  4795. {
  4796. if (isset($_POST['manifest'])) {
  4797. $wltext = $this->input->post('wltext', true);
  4798. $time = time() - 16 * 3600;
  4799. $ptime = strtotime(date('Y-m-d', $time));
  4800. $waybill = array();
  4801. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4802. foreach ($fullorder as $v) {
  4803. $waybill[$v['waybill']] = $v['waybill'];
  4804. }
  4805. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4806. foreach ($fullordersmt as $v) {
  4807. $waybill[$v['waybill']] = $v['waybill'];
  4808. }
  4809. $wltext = explode(';', $wltext);
  4810. foreach ($wltext as $v) {
  4811. if (isset($waybill[$v])) {
  4812. unset($waybill[$v]);
  4813. }
  4814. }
  4815. $data = $this->usps->get_manifest($waybill);
  4816. if (isset($data['Description'])) {
  4817. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4818. exit;
  4819. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4820. $bctime = date('Ymd', time());
  4821. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4822. echo json_encode(array('msg' => $pdf, 'success' => true));
  4823. exit;
  4824. } else {
  4825. echo json_encode(array('msg' => $data, 'success' => false));
  4826. exit;
  4827. }
  4828. }
  4829. }
  4830. public function _pdf($pdf, $title, $bctime)
  4831. {
  4832. $pdf_path = './data/pdf/' . $bctime . '/';
  4833. $file_base64 = $pdf;
  4834. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4835. $file_base64 = base64_decode($file_base64);
  4836. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4837. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4838. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4839. }
  4840. /**
  4841. *
  4842. *
  4843. *
  4844. 进销存占单异常索引
  4845. *
  4846. *
  4847. *
  4848. **/
  4849. public function _abnormal()
  4850. {
  4851. $post = $this->input->post(NULL, TRUE);
  4852. if (isset($post['page'])) {
  4853. $page = $this->input->post('page', true);
  4854. $perpage = $this->input->post('perpage', true);
  4855. $sku = $this->input->post('sku', true);
  4856. $where = "1=1";
  4857. //数据排序
  4858. $order_str = "id desc";
  4859. if (empty($page)) {
  4860. $start = 0;
  4861. $perpage = 1;
  4862. } else {
  4863. $start = ($page - 1) * $perpage;
  4864. }
  4865. //取得信息列表
  4866. $info_list = $this->whlabel->find_all($where, '*');
  4867. $rows = array();
  4868. $list = array();
  4869. foreach ($info_list as $key => $value) {
  4870. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4871. }
  4872. foreach ($rows as $value) {
  4873. $warehouse = $this->warehouse->read($value['warehouse']);
  4874. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4875. $number = $value['number'];
  4876. $ftime = time() - 15 * 24 * 3600;
  4877. if ($value['shop'] != '') {
  4878. $shop = $value['shop'];
  4879. $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');
  4880. $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');
  4881. $order = array_merge($orderdlz, $ordersmt);
  4882. $od = 0;
  4883. $a = '';
  4884. $orid = '';
  4885. foreach ($order as $v) {
  4886. $or = explode('|', ltrim($v['whlabel'], '|'));
  4887. for ($i = 0; $i < count($or); $i++) {
  4888. $orod = explode('-', $or[$i]);
  4889. if ($orod[0] == $number) {
  4890. $od += $orod[1];
  4891. }
  4892. }
  4893. $orid .= $v['number'] . '-';
  4894. }
  4895. } else {
  4896. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4897. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4898. $order = array_merge($orderdlz, $ordersmt);
  4899. $od = 0;
  4900. $a = '';
  4901. $orid = '';
  4902. $qt = array();
  4903. foreach ($order as $v) {
  4904. $or = explode('|', ltrim($v['whlabel'], '|'));
  4905. for ($i = 0; $i < count($or); $i++) {
  4906. $orod = explode('-', $or[$i]);
  4907. if ($orod[0] == $number) {
  4908. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4909. if ($czzs > 0) {
  4910. if (isset($qt[$v['shop']])) {
  4911. if ($qt[$v['shop']] < $orod[1]) {
  4912. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4913. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4914. } else {
  4915. $qt[$v['shop']] -= $orod[1];
  4916. }
  4917. } else {
  4918. $qt[$v['shop']] = $czzs;
  4919. }
  4920. } else {
  4921. $od += $orod[1];
  4922. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4923. }
  4924. }
  4925. }
  4926. }
  4927. }
  4928. $z = $od . '(' . $orid . ')'; //查看订单号
  4929. //$z = $od;
  4930. if ($od > $c) {
  4931. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4932. }
  4933. }
  4934. $listdata = array_slice($list, $start, $perpage);
  4935. $total = count($list);
  4936. $pagenum = ceil($total / $perpage);
  4937. $over = $total - ($start + $perpage);
  4938. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4939. echo json_encode($rows);
  4940. exit;
  4941. }
  4942. $this->_Template('whlabel_abnormal', $this->data);
  4943. }
  4944. /**
  4945. *
  4946. *
  4947. *
  4948. 进销存占单异常索引
  4949. *
  4950. *
  4951. *
  4952. **/
  4953. public function _error()
  4954. {
  4955. $post = $this->input->post(NULL, TRUE);
  4956. if (isset($post['page'])) {
  4957. $page = $this->input->post('page', true);
  4958. $perpage = $this->input->post('perpage', true);
  4959. $sku = $this->input->post('sku', true);
  4960. $warehouse = $this->input->post('warehouse', true);
  4961. $ktime = $this->input->post('ktime', true);
  4962. $jtime = $this->input->post('jtime', true);
  4963. $ktime = strtotime($ktime);
  4964. $jtime = strtotime($jtime);
  4965. $where = "sku != 'Preset'";
  4966. $gj = '';
  4967. if ($sku) {
  4968. $where .= " and sku like '%$sku%'";
  4969. } else {
  4970. if ($ktime && $jtime) {
  4971. $gj = " and time > '$ktime' and time < '$jtime'";
  4972. }
  4973. }
  4974. if ($warehouse) {
  4975. $where .= " and warehouse = '$warehouse'";
  4976. }
  4977. //数据排序
  4978. $order_str = "id desc";
  4979. if (empty($page)) {
  4980. $start = 0;
  4981. $perpage = 1;
  4982. } else {
  4983. $start = ($page - 1) * $perpage;
  4984. }
  4985. //取得信息列表
  4986. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4987. $rows = array();
  4988. $list = array();
  4989. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4990. // foreach ($info_list as $value)
  4991. // {
  4992. // $warehouse = $this->warehouse->read($value['warehouse']);
  4993. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4994. // $number = $value['number'];$ftime = time()-15*24*3600;
  4995. // if($c < 1)
  4996. // {
  4997. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4998. // }
  4999. // }
  5000. $warehouse_list = $this->warehouse->find_all();
  5001. $warehouse_list = array_column($warehouse_list, null, 'id');
  5002. foreach ($info_list as $value) {
  5003. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5004. 'title' => "",
  5005. ];
  5006. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5007. $number = $value['number'];
  5008. $ftime = time() - 15 * 24 * 3600;
  5009. if ($c < 1) {
  5010. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5011. }
  5012. }
  5013. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5014. // $query = $this->db->query($sql);
  5015. // $info_list = $query->result_array();
  5016. // $sql_two = "select title,id from crowd_warehouse";
  5017. // $query_two = $this->db->query($sql_two);
  5018. // $warehouse_list = $query_two->result_array();
  5019. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5020. // foreach ($info_list as $value)
  5021. // {
  5022. // if(isset($warehouse_arr[$value['warehouse']])){
  5023. // $warehouse = $warehouse_arr[$value['warehouse']];
  5024. // }else{
  5025. // $warehouse = [
  5026. // 'id'=>0,
  5027. // 'title'=>"异常",
  5028. // ];
  5029. // }
  5030. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5031. // $number = $value['number'];$ftime = time()-15*24*3600;
  5032. // if($c < 1)
  5033. // {
  5034. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5035. // }
  5036. // }
  5037. $listdata = array_slice($list, $start, $perpage);
  5038. $total = count($list);
  5039. $pagenum = ceil($total / $perpage);
  5040. $over = $total - ($start + $perpage);
  5041. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5042. echo json_encode($rows);
  5043. exit;
  5044. }
  5045. if (isset($post['s'])) {
  5046. $id_arr = $this->input->post('s');
  5047. $id_arr = explode(',', trim($id_arr, ','));
  5048. if (!$id_arr) {
  5049. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5050. exit;
  5051. }
  5052. //循环删除记录
  5053. foreach ($id_arr as $v) {
  5054. $dd = $this->whlabel->read($v);
  5055. if (!isset($dd['id'])) {
  5056. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5057. exit;
  5058. }
  5059. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5060. if (isset($zt[0])) {
  5061. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5062. exit;
  5063. }
  5064. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5065. foreach ($deldd as $vv) {
  5066. $this->whlabel->remove($vv['id']);
  5067. }
  5068. }
  5069. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5070. exit;
  5071. }
  5072. $this->_Template('whlabel_error', $this->data);
  5073. }
  5074. public function _errorexcel()
  5075. {
  5076. $post = $this->input->post(NULL, TRUE);
  5077. if (isset($_GET['page'])) {
  5078. $page = $this->input->get('page', true);
  5079. $perpage = $this->input->get('perpage', true);
  5080. $sku = $this->input->get('sku', true);
  5081. $warehouse = $this->input->get('warehouse', true);
  5082. $ktime = $this->input->get('ktime', true);
  5083. $jtime = $this->input->get('jtime', true);
  5084. $ktime = strtotime($ktime);
  5085. $jtime = strtotime($jtime);
  5086. $where = "sku != 'Preset'";
  5087. $gj = '';
  5088. if ($sku) {
  5089. $where .= " and sku like '%$sku%'";
  5090. } else {
  5091. if ($ktime && $jtime) {
  5092. $gj = " and time > '$ktime' and time < '$jtime'";
  5093. }
  5094. }
  5095. if ($warehouse) {
  5096. $where .= " and warehouse = '$warehouse'";
  5097. }
  5098. //数据排序
  5099. $order_str = "id desc";
  5100. if (empty($page)) {
  5101. $start = 0;
  5102. $perpage = 1;
  5103. } else {
  5104. $start = ($page - 1) * $perpage;
  5105. }
  5106. //取得信息列表
  5107. $rows = array();
  5108. $list = array();
  5109. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5110. foreach ($info_list as $value) {
  5111. $warehouse = $this->warehouse->read($value['warehouse']);
  5112. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5113. $number = $value['number'];
  5114. $ftime = time() - 15 * 24 * 3600;
  5115. if ($c < 1) {
  5116. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5117. }
  5118. }
  5119. $title = "0库存汇总";
  5120. $titlename = "<table border=1>
  5121. <tr align='center'>
  5122. <td>仓库</td>
  5123. <td>SKU</td>
  5124. <td>产品</td>
  5125. <td>当前库存</td>
  5126. </tr>
  5127. </table>";
  5128. $filename = $title . ".xls";
  5129. $tail = "";
  5130. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5131. }
  5132. }
  5133. /**
  5134. *
  5135. *
  5136. * 占单
  5137. *
  5138. *
  5139. **/
  5140. public function _kcyz()
  5141. {
  5142. $post = $this->input->post(NULL, TRUE);
  5143. if (isset($post['warehouse'])) {
  5144. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5145. exit; //不再使用
  5146. $warehouse = $this->input->post('warehouse', true);
  5147. $whlabel = $this->input->post('whlabel', true);
  5148. $id = $this->input->post('id', true);
  5149. $shop = $this->input->post('shop', true);
  5150. $number = $this->input->post('number', true);
  5151. if (!$whlabel || $whlabel == '|') {
  5152. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5153. exit;
  5154. }
  5155. $pp = explode('|', trim($whlabel, '|'));
  5156. $x = 0;
  5157. $save = array();
  5158. foreach ($pp as $va) {
  5159. $num = explode('-', $va);
  5160. if ($number) {
  5161. $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 = '')"); //通用
  5162. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5163. } else {
  5164. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5165. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5166. }
  5167. $x++;
  5168. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5169. $save[] = $x - 1;
  5170. continue; //提前先加X不然出错,所以要减1
  5171. }
  5172. }
  5173. if (isset($save[0])) {
  5174. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5175. exit;
  5176. } else {
  5177. echo json_encode(array('success' => true));
  5178. exit;
  5179. }
  5180. }
  5181. }
  5182. public function _db()
  5183. {
  5184. $post = $this->input->post(NULL, TRUE);
  5185. if (isset($post['page'])) {
  5186. $page = $this->input->post('page', true);
  5187. $perpage = $this->input->post('perpage', true);
  5188. $sku = $this->input->post('sku', true);
  5189. $number = $this->input->post('number', true);
  5190. $warehouse = $this->input->post('warehouse', true);
  5191. $purchase = $this->input->post('purchase', true);
  5192. $orderinfo = $this->input->post('orderinfo', true);
  5193. $waybill = $this->input->post('waybill', true);
  5194. $category = $this->input->post('category', true);
  5195. $size = $this->input->post('size', true);
  5196. $grade = $this->input->post('grade', true);
  5197. $color = $this->input->post('color', true);
  5198. $lowe = $this->input->post('lowe', true);
  5199. $state = $this->input->post('state', true);
  5200. $label = $this->input->post('label', true);
  5201. $timetk = $this->input->post('timetkk', true);
  5202. $timetj = $this->input->post('timetjj', true);
  5203. $timetk = strtotime($timetk);
  5204. $timetj = strtotime($timetj);
  5205. $where = "dbtime > 0";
  5206. if ($timetk && $timetj) {
  5207. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5208. }
  5209. if ($sku) {
  5210. $where .= " and sku = '$sku'";
  5211. }
  5212. if ($warehouse) {
  5213. $where .= " and warehouse = '$warehouse'";
  5214. if ($warehouse == 12) {
  5215. $w = 'specialstock';
  5216. } else {
  5217. $w = 'whlabel';
  5218. }
  5219. }
  5220. if ($purchase) {
  5221. $where .= " and purchase = '$purchase'";
  5222. }
  5223. if ($category) {
  5224. $where .= " and features like '%-$category-%'";
  5225. }
  5226. if ($size) {
  5227. $where .= " and features like '%-$size-%'";
  5228. }
  5229. if ($grade) {
  5230. $where .= " and features like '%-$grade-%'";
  5231. }
  5232. if ($color) {
  5233. $where .= " and features like '%-$color-%'";
  5234. }
  5235. if ($lowe) {
  5236. $where .= " and features like '%-$lowe-%'";
  5237. }
  5238. if ($state != '') {
  5239. $where .= " and state = '$state'";
  5240. }
  5241. //数据排序
  5242. $order_str = "dbtime desc";
  5243. if (empty($page)) {
  5244. $start = 0;
  5245. $perpage = 1;
  5246. } else {
  5247. $start = ($page - 1) * $perpage;
  5248. }
  5249. //取得信息列表
  5250. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5251. foreach ($info_list as $key => $value) {
  5252. $warehouse = $this->$w->read($value['warehouse']);
  5253. $info_list[$key]['warehouse'] = $warehouse['title'];
  5254. $purchase = $this->purchase->read($value['purchase']);
  5255. $info_list[$key]['purchase'] = $purchase['title'];
  5256. if ($value['enter'] != 0) {
  5257. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5258. } else {
  5259. $info_list[$key]['enter'] = "";
  5260. }
  5261. if ($value['dbtime'] != 0) {
  5262. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5263. } else {
  5264. $info_list[$key]['dbtime'] = "";
  5265. }
  5266. if ($value['state'] == 0) {
  5267. $info_list[$key]['state'] = "在库";
  5268. } else if ($value['state'] == 1) {
  5269. $info_list[$key]['state'] = "出库";
  5270. } else if ($value['state'] == 2) {
  5271. $info_list[$key]['state'] = "退库";
  5272. } else if ($value['state'] == 3) {
  5273. $info_list[$key]['state'] = "调拨中";
  5274. } else if ($value['state'] == 4) {
  5275. $info_list[$key]['state'] = "再加工";
  5276. } else if ($value['state'] == 5) {
  5277. $info_list[$key]['state'] = "维修中";
  5278. } else if ($value['state'] == 6) {
  5279. $info_list[$key]['state'] = "盘亏";
  5280. } else if ($value['state'] == 7) {
  5281. $info_list[$key]['state'] = "更换标签";
  5282. } else if ($value['state'] == 8) {
  5283. $info_list[$key]['state'] = "其它";
  5284. } else if ($value['state'] == 9) {
  5285. $info_list[$key]['state'] = "预设";
  5286. }
  5287. }
  5288. $total = $this->whlabel->find_count($where);
  5289. $pagenum = ceil($total / $perpage);
  5290. $over = $total - ($start + $perpage);
  5291. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5292. echo json_encode($rows);
  5293. exit;
  5294. }
  5295. if (isset($post['outsku'])) {
  5296. $time = time();
  5297. $cz = $this->input->post('cz', true);
  5298. $label = $this->input->post('outsku', true);
  5299. $sl = $this->input->post('sl', true);
  5300. $num = $this->input->post('num', true);
  5301. //$warehouse = $this->input->post('warehouse',true);
  5302. if (!$sl) {
  5303. $sl = 1;
  5304. }
  5305. if (!$warehouse) {
  5306. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5307. exit;
  5308. }
  5309. $dblabel = $this->whlabellabel->get_label($label);
  5310. if ($dblabel) {
  5311. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5312. if (count($data) < 1) {
  5313. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5314. exit;
  5315. }
  5316. if (count($data) < $num) {
  5317. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5318. exit;
  5319. }
  5320. for ($i = 0; $i < $sl; $i++) {
  5321. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5322. }
  5323. echo json_encode(array('success' => true));
  5324. exit;
  5325. } else {
  5326. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5327. exit;
  5328. }
  5329. }
  5330. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5331. $this->_Template('whlabel_db', $this->data);
  5332. }
  5333. public function _dbrk()
  5334. {
  5335. $post = $this->input->post(NULL, TRUE);
  5336. if (isset($post['page'])) {
  5337. $page = $this->input->post('page', true);
  5338. $perpage = $this->input->post('perpage', true);
  5339. $sku = $this->input->post('sku', true);
  5340. $number = $this->input->post('number', true);
  5341. $warehouse = $this->input->post('warehouse', true);
  5342. $purchase = $this->input->post('purchase', true);
  5343. $orderinfo = $this->input->post('orderinfo', true);
  5344. $waybill = $this->input->post('waybill', true);
  5345. $category = $this->input->post('category', true);
  5346. $size = $this->input->post('size', true);
  5347. $grade = $this->input->post('grade', true);
  5348. $color = $this->input->post('color', true);
  5349. $lowe = $this->input->post('lowe', true);
  5350. $state = $this->input->post('state', true);
  5351. $label = $this->input->post('label', true);
  5352. $ctime = $this->input->post('ctime', true);
  5353. $timetk = $this->input->post('timetkk', true);
  5354. $timetj = $this->input->post('timetjj', true);
  5355. $timetk = strtotime($timetk);
  5356. $timetj = strtotime($timetj);
  5357. $where = "dbtime > 0";
  5358. if ($timetk && $timetj) {
  5359. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5360. }
  5361. if ($sku) {
  5362. $where .= " and sku = '$sku'";
  5363. }
  5364. if ($warehouse) {
  5365. $where .= " and warehouse = '$warehouse'";
  5366. }
  5367. if ($purchase) {
  5368. $where .= " and purchase = '$purchase'";
  5369. }
  5370. if ($category) {
  5371. $where .= " and features like '%-$category-%'";
  5372. }
  5373. if ($size) {
  5374. $where .= " and features like '%-$size-%'";
  5375. }
  5376. if ($grade) {
  5377. $where .= " and features like '%-$grade-%'";
  5378. }
  5379. if ($color) {
  5380. $where .= " and features like '%-$color-%'";
  5381. }
  5382. if ($lowe) {
  5383. $where .= " and features like '%-$lowe-%'";
  5384. }
  5385. if ($state != '') {
  5386. $where .= " and state = '$state'";
  5387. }
  5388. //数据排序
  5389. $order_str = "dbtime desc";
  5390. if (empty($page)) {
  5391. $start = 0;
  5392. $perpage = 1;
  5393. } else {
  5394. $start = ($page - 1) * $perpage;
  5395. }
  5396. //取得信息列表
  5397. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5398. foreach ($info_list as $key => $value) {
  5399. $warehouse = $this->warehouse->read($value['warehouse']);
  5400. $info_list[$key]['warehouse'] = $warehouse['title'];
  5401. $purchase = $this->purchase->read($value['purchase']);
  5402. $info_list[$key]['purchase'] = $purchase['title'];
  5403. if ($value['enter'] != 0) {
  5404. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5405. } else {
  5406. $info_list[$key]['enter'] = "";
  5407. }
  5408. if ($value['dbtime'] != 0) {
  5409. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5410. } else {
  5411. $info_list[$key]['dbtime'] = "";
  5412. }
  5413. if ($value['state'] == 0) {
  5414. $info_list[$key]['state'] = "在库";
  5415. } else if ($value['state'] == 1) {
  5416. $info_list[$key]['state'] = "出库";
  5417. } else if ($value['state'] == 2) {
  5418. $info_list[$key]['state'] = "退库";
  5419. } else if ($value['state'] == 3) {
  5420. $info_list[$key]['state'] = "调拨中";
  5421. } else if ($value['state'] == 4) {
  5422. $info_list[$key]['state'] = "再加工";
  5423. } else if ($value['state'] == 5) {
  5424. $info_list[$key]['state'] = "维修中";
  5425. } else if ($value['state'] == 6) {
  5426. $info_list[$key]['state'] = "盘亏";
  5427. } else if ($value['state'] == 7) {
  5428. $info_list[$key]['state'] = "更换标签";
  5429. } else if ($value['state'] == 8) {
  5430. $info_list[$key]['state'] = "其它";
  5431. } else if ($value['state'] == 9) {
  5432. $info_list[$key]['state'] = "预设";
  5433. }
  5434. }
  5435. $total = $this->whlabel->find_count($where);
  5436. $pagenum = ceil($total / $perpage);
  5437. $over = $total - ($start + $perpage);
  5438. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5439. echo json_encode($rows);
  5440. exit;
  5441. }
  5442. if (isset($post['rsku'])) {
  5443. $cz = $this->input->post('cz', true);
  5444. $label = $this->input->post('rsku', true);
  5445. $sl = $this->input->post('sl', true);
  5446. $warehouse = $this->input->post('warehouse', true);
  5447. if (!$sl) {
  5448. $sl = 1;
  5449. }
  5450. if (!$warehouse) {
  5451. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5452. exit;
  5453. }
  5454. $dblabel = $this->whlabellabel->get_label($label);
  5455. if ($dblabel) {
  5456. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5457. if (count($data) < 1) {
  5458. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5459. exit;
  5460. }
  5461. if ($sl > count($data)) {
  5462. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5463. exit;
  5464. }
  5465. $time = time();
  5466. for ($i = 0; $i < $sl; $i++) {
  5467. $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']);
  5468. }
  5469. echo json_encode(array('success' => true));
  5470. exit;
  5471. } else {
  5472. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5473. exit;
  5474. }
  5475. }
  5476. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5477. $this->_Template('whlabel_dbrk', $this->data);
  5478. }
  5479. public function _whlabelczdc()
  5480. {
  5481. if (isset($_GET['excel'])) {
  5482. //数据排序
  5483. $order_str = "id desc";
  5484. if (empty($page)) {
  5485. $start = 0;
  5486. $perpage = 1;
  5487. } else {
  5488. $start = ($page - 1) * $perpage;
  5489. }
  5490. $state = $this->input->get('state', true);
  5491. $sku = $this->input->get('sku', true);
  5492. $ctime = $this->input->get('ctime', true);
  5493. $category = $this->input->get('category', true);
  5494. $size = $this->input->get('size', true);
  5495. $grade = $this->input->get('grade', true);
  5496. $color = $this->input->get('color', true);
  5497. $lowe = $this->input->get('lowe', true);
  5498. $timetk = $this->input->get('timetkk', true);
  5499. $timetj = $this->input->get('timetjj', true);
  5500. $timetk = strtotime($timetk);
  5501. $timetj = strtotime($timetj);
  5502. $where = "dbtime > 0";
  5503. if ($timetk && $timetj) {
  5504. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5505. }
  5506. if ($category) {
  5507. $where .= " and features like '%-$category-%'";
  5508. }
  5509. if ($size) {
  5510. $where .= " and features like '%-$size-%'";
  5511. }
  5512. if ($grade) {
  5513. $where .= " and features like '%-$grade-%'";
  5514. }
  5515. if ($color) {
  5516. $where .= " and features like '%-$color-%'";
  5517. }
  5518. if ($lowe) {
  5519. $where .= " and features like '%-$lowe-%'";
  5520. }
  5521. //取得信息列表
  5522. $info_list = $this->whlabel->find_all($where, '*');
  5523. $rows = array();
  5524. $list = array();
  5525. foreach ($info_list as $key => $value) {
  5526. $rows[$value['sku']] = $value; //所有数据sku
  5527. }
  5528. foreach ($rows as $value) {
  5529. $warehouse = $this->warehouse->read($value['warehouse']);
  5530. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5531. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5532. if ($value['orderinfo'] == 0) {
  5533. $info_list[$key]['orderinfo'] = "";
  5534. }
  5535. if ($value['waybill'] == 0) {
  5536. $info_list[$key]['waybill'] = "";
  5537. }
  5538. if ($value['state'] == 0) {
  5539. $value['state'] = "在库";
  5540. } else if ($value['state'] == 3) {
  5541. $value['state'] = "调拨中";
  5542. }
  5543. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5544. }
  5545. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5546. $titlename = "<table border=1>
  5547. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5548. <tr align='center'>
  5549. <td>SKU</td>
  5550. <td>产品</td>
  5551. <td>调拨数量</td>
  5552. <td>入库数量</td>
  5553. </tr>
  5554. </table>";
  5555. $filename = $title . ".xls";
  5556. $tail = "";
  5557. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5558. }
  5559. }
  5560. public function _print($arg_array)
  5561. {
  5562. if (isset($_SESSION['api'])) {
  5563. $user = $this->user->get_api($_SESSION['api']);
  5564. $usp = $user;
  5565. $fgshop = "";
  5566. $sid = "";
  5567. $wid = "";
  5568. $wtype = "";
  5569. $usersp = explode('|', trim($user['shop'], '|'));
  5570. $userwh = explode('|', trim($user['warehouse'], '|'));
  5571. foreach ($usersp as $value) {
  5572. $fgshop .= " shop = " . $value . " or";
  5573. $sid .= " id = " . $value . " or";
  5574. }
  5575. foreach ($userwh as $value) {
  5576. $wid .= " id = " . $value . " or";
  5577. $wtype .= " type = " . $value . " or";
  5578. }
  5579. }
  5580. $post = $this->input->post(NULL, TRUE);
  5581. if (isset($post['tmsku'])) {
  5582. $tmsku = $this->input->post('tmsku', true);
  5583. if (is_numeric($tmsku)) {
  5584. $yyh = $this->whlabellabel->get_label($tmsku);
  5585. } else {
  5586. $yyh = $this->whlabellabel->get_sku($tmsku);
  5587. if(empty($yyh)){
  5588. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5589. if($r['code'] == -1 ){
  5590. echo json_encode(array('success' => false));
  5591. exit;
  5592. }else{
  5593. echo json_encode(array('features' => $r['data'], 'success' => true));
  5594. exit;
  5595. }
  5596. }
  5597. }
  5598. if ($yyh) {
  5599. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5600. exit;
  5601. } else {
  5602. echo json_encode(array('success' => false));
  5603. exit;
  5604. }
  5605. }
  5606. $classid = $this->classid->sku();
  5607. $pm = $classid;
  5608. $scsku = $classid;
  5609. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5610. if (isset($post['warehouse'])) {
  5611. if ($post['warehouse']) {
  5612. $list = array();
  5613. $num = "";
  5614. $title = "";
  5615. $features = "";
  5616. $order = 0;
  5617. $post['shop'] = '';
  5618. $brand = $this->input->post('brand', true);
  5619. if ($brand != '0,') {
  5620. $b = $this->brand->read(rtrim($brand, ','));
  5621. if ($b) {
  5622. $post['shop'] = str_replace('|', ',', $b['shop']);
  5623. }
  5624. }
  5625. $post['details'] = $this->input->post('details', true); //打印数量
  5626. $xbqnum = $this->input->post('xbqnum', true);
  5627. $post['purchase'] = $this->input->post('purchase', true);
  5628. $post['warehouse'] = $this->input->post('warehouse', true);
  5629. $post['purchase'] = $this->input->post('purchase', true);
  5630. $post['retreatwarehouse'] = $post['warehouse'];
  5631. $post['cpbz'] = $this->input->post('cpbz', true);
  5632. $post['state'] = 9;
  5633. $category = $this->input->post('category', true);
  5634. $list['category'] = $category;
  5635. $list['hairtype'] = $this->input->post('hairtype', true);
  5636. $list['grade'] = $this->input->post('grade', true);
  5637. $size = $this->input->post('size', true);
  5638. $list['size'] = rtrim($size, ',');
  5639. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5640. $list['extension'] = $this->input->post('extension', true);
  5641. if ($category == 1297) {
  5642. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5643. }
  5644. if ($category == 1702) {
  5645. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5646. $list['syother'] = $this->input->post('syother', true);
  5647. }
  5648. if ($category == 133) {
  5649. $list['fittype'] = $this->input->post('fittype', true);
  5650. $list['acother'] = $this->input->post('acother', true);
  5651. }
  5652. $list['color'] = $this->input->post('color', true);
  5653. $list['lowe'] = $this->input->post('lowe', true);
  5654. if ($category == 127) {
  5655. $list['type'] = $this->input->post('type', true);
  5656. $list['headroad'] = $this->input->post('headroad', true);
  5657. $list['density'] = $this->input->post('density', true);
  5658. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5659. $list['lacesize'] = $this->input->post('lacesize', true);
  5660. }
  5661. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5662. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5663. }
  5664. if ($category == 128) {
  5665. $list['lacetype'] = $this->input->post('lacetype', true);
  5666. $list['haircap'] = $this->input->post('haircap', true);
  5667. $list['density'] = $this->input->post('density', true);
  5668. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5669. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5670. $list['wigother'] = $this->input->post('wigother', true);
  5671. $list['wigother1'] = $this->input->post('wigother1', true);
  5672. $list['wigother2'] = $this->input->post('wigother2', true);
  5673. }
  5674. if ($category == 129) {
  5675. $list['wide'] = $this->input->post('wide', true);
  5676. }
  5677. if ($category == 131) {
  5678. $list['gifttype'] = $this->input->post('gifttype', true);
  5679. $list['giftother'] = $this->input->post('giftother', true);
  5680. }
  5681. if ($category == 134) {
  5682. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5683. }
  5684. if ($category == 1297) {
  5685. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5686. $list['sywigother'] = $this->input->post('sywigother', true);
  5687. }
  5688. if ($category == 130 || $category == 133 || $category == 1702) {
  5689. $list['items'] = $this->input->post('items', true);
  5690. $list['weight'] = $this->input->post('weight', true);
  5691. }
  5692. if ($category == 1702) {
  5693. $list['syhairther'] = $this->input->post('syhairther', true);
  5694. }
  5695. foreach ($list as $k => $v) {
  5696. if ($v != 0) {
  5697. $num .= $v;
  5698. $features .= $v . '-';
  5699. $post[$k] = $v;
  5700. $typeclass = $this->typeclass->read($v);
  5701. if (isset($pm[$typeclass['classid']])) {
  5702. if (stripos($typeclass['zh'], '|') !== false) {
  5703. $exzh = explode('|', $typeclass['zh']);
  5704. $pm[$typeclass['classid']] = $exzh[0];
  5705. } else {
  5706. $pm[$typeclass['classid']] = $typeclass['zh'];
  5707. }
  5708. }
  5709. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5710. if ($k != 'size') {
  5711. $title .= $typeclass['title'] . " ";
  5712. }
  5713. }
  5714. }
  5715. $typeclass = $this->typeclass->read($list['size']);
  5716. $title .= $typeclass['title'];
  5717. $time = time();
  5718. $post['title'] = rtrim($title, ' ');
  5719. $post['number'] = $num;
  5720. $post['features'] = '-' . $features;
  5721. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5722. $featurespp = explode('-', trim($featurespp, '-'));
  5723. if (isset($featurespp[5])) {
  5724. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5725. } else {
  5726. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5727. }
  5728. $post['enter'] = $time;
  5729. $post['time'] = $time; //操作时间
  5730. $scsku = implode("-", $scsku);
  5731. $zh = implode(" ", $pm);
  5732. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5733. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5734. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5735. $post['sku'] = $bqsku;
  5736. $label = time() . rand(0, 9);
  5737. $post['label'] = $label;
  5738. $cpid = $this->whlabellabel->find_count();
  5739. $post['cpid'] = $cpid + 1;
  5740. $cpid = $post['cpid'];
  5741. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5742. //if($whlabelbarcode)
  5743. //{
  5744. //$post['label'] = $whlabelbarcode['label'];
  5745. //if(!$this->whlabellabel->insert($post))
  5746. //{
  5747. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5748. //}
  5749. //}
  5750. //else
  5751. //{
  5752. $this->db->trans_begin();
  5753. $this->whlabellabel->insert($post);
  5754. //$this->whlabelbarcode->insert($post);
  5755. if ($this->db->trans_status() === TRUE) {
  5756. $this->db->trans_commit();
  5757. } else {
  5758. $this->db->trans_rollback();
  5759. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5760. exit;
  5761. }
  5762. //}
  5763. $warehouse_name = "";
  5764. $warehouse = $post['warehouse'];
  5765. if($warehouse == 12){
  5766. $warehouse_name = "特殊库存库";
  5767. }
  5768. // if($warehouse == 13){
  5769. // $warehouse_name = "许昌仓";
  5770. // }
  5771. // if($warehouse == 5){
  5772. // $warehouse_name = "美国店";
  5773. // }
  5774. // if($warehouse == 16){
  5775. // $warehouse_name = "定制头套仓";
  5776. // }
  5777. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5778. if(!empty($warehouse_name)){
  5779. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5780. }
  5781. $purchase = $this->purchase->read($post['purchase']);
  5782. 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));
  5783. exit; //特殊仓目前不需要仓库选项
  5784. }
  5785. }
  5786. if (isset($_SESSION['api'])) {
  5787. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5788. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5789. $this->data['wlshop'] = $wlshop;
  5790. $this->data['warehouse'] = $warehouse;
  5791. }
  5792. $whlabelwz = $this->whlabelwz->find_all();
  5793. $this->data['whlabelwz'] = $whlabelwz;
  5794. $this->_Template('whlabel_print', $this->data);
  5795. }
  5796. public function _usaprint($arg_array)
  5797. {
  5798. if (isset($_SESSION['api'])) {
  5799. $user = $this->user->get_api($_SESSION['api']);
  5800. $usp = $user;
  5801. $fgshop = "";
  5802. $sid = "";
  5803. $wid = "";
  5804. $wtype = "";
  5805. $usersp = explode('|', trim($user['shop'], '|'));
  5806. $userwh = explode('|', trim($user['warehouse'], '|'));
  5807. foreach ($usersp as $value) {
  5808. $fgshop .= " shop = " . $value . " or";
  5809. $sid .= " id = " . $value . " or";
  5810. }
  5811. foreach ($userwh as $value) {
  5812. $wid .= " id = " . $value . " or";
  5813. $wtype .= " type = " . $value . " or";
  5814. }
  5815. }
  5816. $post = $this->input->post(NULL, TRUE);
  5817. if (isset($post['tmsku'])) {
  5818. $tmsku = $this->input->post('tmsku', true);
  5819. if (is_numeric($tmsku)) {
  5820. $yyh = $this->whlabellabel->get_label($tmsku);
  5821. } else {
  5822. $yyh = $this->whlabellabel->get_sku($tmsku);
  5823. }
  5824. if ($yyh) {
  5825. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5826. exit;
  5827. } else {
  5828. echo json_encode(array('success' => false));
  5829. exit;
  5830. }
  5831. }
  5832. $classid = $this->classid->sku();
  5833. $pm = $classid;
  5834. $scsku = $classid;
  5835. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5836. if (isset($post['warehouse'])) {
  5837. if ($post['warehouse']) {
  5838. $list = array();
  5839. $num = "";
  5840. $title = "";
  5841. $features = "";
  5842. $order = 0;
  5843. $post['shop'] = '';
  5844. $brand = $this->input->post('brand', true);
  5845. if ($brand != '0,') {
  5846. $b = $this->brand->read(rtrim($brand, ','));
  5847. if ($b) {
  5848. $post['shop'] = str_replace('|', ',', $b['shop']);
  5849. }
  5850. }
  5851. $post['details'] = $this->input->post('details', true); //打印数量
  5852. $xbqnum = $this->input->post('xbqnum', true);
  5853. $post['purchase'] = $this->input->post('purchase', true);
  5854. $post['warehouse'] = $this->input->post('warehouse', true);
  5855. $post['purchase'] = $this->input->post('purchase', true);
  5856. $post['retreatwarehouse'] = $post['warehouse'];
  5857. $post['cpbz'] = $this->input->post('cpbz', true);
  5858. $post['state'] = 9;
  5859. $category = $this->input->post('category', true);
  5860. $list['category'] = $category;
  5861. $list['hairtype'] = $this->input->post('hairtype', true);
  5862. $list['grade'] = $this->input->post('grade', true);
  5863. $size = $this->input->post('size', true);
  5864. $list['size'] = rtrim($size, ',');
  5865. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5866. $list['extension'] = $this->input->post('extension', true);
  5867. if ($category == 1297) {
  5868. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5869. }
  5870. if ($category == 1702) {
  5871. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5872. $list['syother'] = $this->input->post('syother', true);
  5873. }
  5874. if ($category == 133) {
  5875. $list['fittype'] = $this->input->post('fittype', true);
  5876. $list['acother'] = $this->input->post('acother', true);
  5877. }
  5878. $list['color'] = $this->input->post('color', true);
  5879. $list['lowe'] = $this->input->post('lowe', true);
  5880. if ($category == 127) {
  5881. $list['type'] = $this->input->post('type', true);
  5882. $list['headroad'] = $this->input->post('headroad', true);
  5883. $list['density'] = $this->input->post('density', true);
  5884. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5885. $list['lacesize'] = $this->input->post('lacesize', true);
  5886. }
  5887. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5888. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5889. }
  5890. if ($category == 128) {
  5891. $list['lacetype'] = $this->input->post('lacetype', true);
  5892. $list['haircap'] = $this->input->post('haircap', true);
  5893. $list['density'] = $this->input->post('density', true);
  5894. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5895. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5896. $list['wigother'] = $this->input->post('wigother', true);
  5897. $list['wigother1'] = $this->input->post('wigother1', true);
  5898. $list['wigother2'] = $this->input->post('wigother2', true);
  5899. }
  5900. if ($category == 129) {
  5901. $list['wide'] = $this->input->post('wide', true);
  5902. }
  5903. if ($category == 131) {
  5904. $list['gifttype'] = $this->input->post('gifttype', true);
  5905. $list['giftother'] = $this->input->post('giftother', true);
  5906. }
  5907. if ($category == 134) {
  5908. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5909. }
  5910. if ($category == 1297) {
  5911. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5912. $list['sywigother'] = $this->input->post('sywigother', true);
  5913. }
  5914. if ($category == 130 || $category == 133 || $category == 1702) {
  5915. $list['items'] = $this->input->post('items', true);
  5916. $list['weight'] = $this->input->post('weight', true);
  5917. }
  5918. if ($category == 1702) {
  5919. $list['syhairther'] = $this->input->post('syhairther', true);
  5920. }
  5921. foreach ($list as $k => $v) {
  5922. if ($v != 0) {
  5923. $num .= $v;
  5924. $features .= $v . '-';
  5925. $post[$k] = $v;
  5926. $typeclass = $this->typeclass->read($v);
  5927. if (isset($pm[$typeclass['classid']])) {
  5928. if (stripos($typeclass['zh'], '|') !== false) {
  5929. $exzh = explode('|', $typeclass['zh']);
  5930. $pm[$typeclass['classid']] = $exzh[0];
  5931. } else {
  5932. $pm[$typeclass['classid']] = $typeclass['zh'];
  5933. }
  5934. }
  5935. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5936. if ($k != 'size') {
  5937. $title .= $typeclass['title'] . " ";
  5938. }
  5939. }
  5940. }
  5941. $typeclass = $this->typeclass->read($list['size']);
  5942. $title .= $typeclass['title'];
  5943. $time = time();
  5944. $post['title'] = rtrim($title, ' ');
  5945. $post['number'] = $num;
  5946. $post['features'] = '-' . $features;
  5947. $fp = $this->whlabel->get_features($post['features']);
  5948. if (!$fp) {
  5949. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5950. exit;
  5951. }
  5952. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5953. $featurespp = explode('-', trim($featurespp, '-'));
  5954. if (isset($featurespp[5])) {
  5955. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5956. } else {
  5957. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5958. }
  5959. $post['enter'] = $time;
  5960. $post['time'] = $time; //操作时间
  5961. $scsku = implode("-", $scsku);
  5962. $zh = implode(" ", $pm);
  5963. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5964. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5965. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5966. $post['sku'] = $fp['sku'];
  5967. $post['label'] = $fp['sku'];
  5968. $cpid = $this->whlabellabel->find_count();
  5969. $post['cpid'] = $cpid + 1;
  5970. $cpid = $post['cpid'];
  5971. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5972. //if($whlabelbarcode)
  5973. //{
  5974. //$post['label'] = $whlabelbarcode['label'];
  5975. //if(!$this->whlabellabel->insert($post))
  5976. //{
  5977. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5978. //}
  5979. //}
  5980. //else
  5981. //{
  5982. $this->db->trans_begin();
  5983. $this->whlabellabel->insert($post);
  5984. //$this->whlabelbarcode->insert($post);
  5985. if ($this->db->trans_status() === TRUE) {
  5986. $this->db->trans_commit();
  5987. } else {
  5988. $this->db->trans_rollback();
  5989. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5990. exit;
  5991. }
  5992. //}
  5993. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5994. $purchase = $this->purchase->read($post['purchase']);
  5995. 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));
  5996. exit; //特殊仓目前不需要仓库选项
  5997. }
  5998. }
  5999. if (isset($_SESSION['api'])) {
  6000. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6001. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6002. $this->data['wlshop'] = $wlshop;
  6003. $this->data['warehouse'] = $warehouse;
  6004. }
  6005. $whlabelwz = $this->whlabelwz->find_all();
  6006. $this->data['whlabelwz'] = $whlabelwz;
  6007. $this->_Template('whlabel_usaprint', $this->data);
  6008. }
  6009. public function _printrk($arg_array)
  6010. {
  6011. $prc = array();
  6012. $purchase = $this->purchase->find_all();
  6013. foreach ($purchase as $k => $v) {
  6014. $prc[$v['id']] = $v['title'];
  6015. }
  6016. $post = $this->input->post(NULL, TRUE);
  6017. if (isset($post['page'])) {
  6018. $page = $this->input->post('page', true);
  6019. $perpage = $this->input->post('perpage', true);
  6020. $sku = $this->input->post('sku', true);
  6021. $bs = $this->input->post('bs', true);
  6022. $number = $this->input->post('number', true);
  6023. $warehouse = $this->input->post('warehouse', true);
  6024. $purchase = $this->input->post('purchase', true);
  6025. $orderinfo = $this->input->post('orderinfo', true);
  6026. $waybill = $this->input->post('waybill', true);
  6027. $category = $this->input->post('category', true);
  6028. $size = $this->input->post('size', true);
  6029. $grade = $this->input->post('grade', true);
  6030. $color = $this->input->post('color', true);
  6031. $lowe = $this->input->post('lowe', true);
  6032. $state = $this->input->post('state', true);
  6033. $label = $this->input->post('label', true);
  6034. $timetk = $this->input->post('ktime', true);
  6035. $timetj = $this->input->post('jtime', true);
  6036. $timetk = strtotime($timetk);
  6037. $timetj = strtotime($timetj);
  6038. $where = "1=1 ";
  6039. if ($timetk && $timetj) {
  6040. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6041. }
  6042. if ($sku) {
  6043. $where .= " and sku = '$sku'";
  6044. }
  6045. if ($bs != '') {
  6046. $where .= " and bs = '$bs'";
  6047. }
  6048. if ($number) {
  6049. $where .= " and number = '$number'";
  6050. }
  6051. if ($warehouse) {
  6052. $where .= " and warehouse = '$warehouse'";
  6053. }
  6054. if ($purchase) {
  6055. $where .= " and purchase = '$purchase'";
  6056. }
  6057. if ($orderinfo) {
  6058. $where .= " and orderinfo = '$orderinfo'";
  6059. }
  6060. if ($waybill) {
  6061. $where .= " and waybill = '$waybill'";
  6062. }
  6063. if ($category) {
  6064. $where .= " and features like '%-$category-%'";
  6065. }
  6066. if ($size) {
  6067. $where .= " and features like '%-$size-%'";
  6068. }
  6069. if ($grade) {
  6070. $where .= " and features like '%-$grade-%'";
  6071. }
  6072. if ($color) {
  6073. $where .= " and features like '%-$color-%'";
  6074. }
  6075. if ($lowe) {
  6076. $where .= " and features like '%-$lowe-%'";
  6077. }
  6078. if ($label) {
  6079. $where .= " and label = '$label'";
  6080. }
  6081. if ($state || $state == 0) {
  6082. $where .= " and state = '$state'";
  6083. }
  6084. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6085. //数据排序
  6086. $order_str = "enter desc";
  6087. if (empty($page)) {
  6088. $start = 0;
  6089. $perpage = 1;
  6090. } else {
  6091. $start = ($page - 1) * $perpage;
  6092. }
  6093. //取得信息列表
  6094. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6095. foreach ($info_list as $key => $value) {
  6096. $warehouse = $this->warehouse->read($value['warehouse']);
  6097. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6098. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6099. if ($value['state'] == 0) {
  6100. $info_list[$key]['state'] = "在库";
  6101. } else if ($value['state'] == 1) {
  6102. $info_list[$key]['state'] = "出库";
  6103. } else if ($value['state'] == 2) {
  6104. $info_list[$key]['state'] = "退库";
  6105. } else if ($value['state'] == 3) {
  6106. $info_list[$key]['state'] = "调拨中";
  6107. } else if ($value['state'] == 4) {
  6108. $info_list[$key]['state'] = "再加工";
  6109. } else if ($value['state'] == 5) {
  6110. $info_list[$key]['state'] = "维修中";
  6111. } else if ($value['state'] == 6) {
  6112. $info_list[$key]['state'] = "盘亏";
  6113. } else if ($value['state'] == 7) {
  6114. $info_list[$key]['state'] = "更换标签";
  6115. } else if ($value['state'] == 8) {
  6116. $info_list[$key]['state'] = "其它";
  6117. } else if ($value['state'] == 9) {
  6118. $info_list[$key]['state'] = "预设";
  6119. } else if ($value['state'] == 10) {
  6120. $info_list[$key]['state'] = "美店零售";
  6121. }
  6122. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6123. }
  6124. $total = $this->$ck->find_count($where);
  6125. $pagenum = ceil($total / $perpage);
  6126. $over = $total - ($start + $perpage);
  6127. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6128. echo json_encode($rows);
  6129. exit;
  6130. }
  6131. if (isset($post['tmsku'])) {
  6132. $time = time();
  6133. $tmsku = $this->input->post('tmsku', true);
  6134. //$post['shop'] = $this->input->post('shop',true);
  6135. $num = $this->input->post('num', true);
  6136. $rktype = $this->input->post('rktype', true);
  6137. if ($num > 200) {
  6138. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6139. exit;
  6140. }
  6141. if (!$rktype) {
  6142. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6143. }
  6144. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6145. /**
  6146. $wz = array();
  6147. foreach ($rk as $key=>$value)
  6148. {
  6149. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6150. }
  6151. if(count($wz) > 1)
  6152. {
  6153. $wz = array_values($wz);
  6154. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6155. }
  6156. **/
  6157. if (isset($rk[0]['purchase'])) {
  6158. $rk = $rk[0];
  6159. $j = 0;
  6160. $post['purchase'] = $rk['purchase'];
  6161. $post['warehouse'] = $rk['warehouse'];
  6162. $post['retreatwarehouse'] = $rk['warehouse'];
  6163. $post['sku'] = $rk['sku'];
  6164. $post['number'] = $rk['number'];
  6165. $post['features'] = $rk['features'];
  6166. $post['title'] = $rk['title'];
  6167. $post['enter'] = $time;
  6168. $post['time'] = $time;
  6169. $post['bs'] = 1;
  6170. $post['shop'] = $rk['shop'];
  6171. $post['details'] = $rk['details'];
  6172. $post['cpid'] = $rk['cpid'];
  6173. $post['cpbz'] = $rk['cpbz'];
  6174. //$post['rktype'] = $rktype;
  6175. $warehouse = $this->warehouse->read($rk['warehouse']);
  6176. if ($warehouse['bdck'] == '') {
  6177. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6178. exit;
  6179. } else {
  6180. $bdck = $warehouse['bdck'];
  6181. }
  6182. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6183. if (isset($pdwz['details'])) {
  6184. if ($pdwz['details'] != $post['details']) {
  6185. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6186. exit;
  6187. }
  6188. }
  6189. $post['featurespp'] = $rk['featurespp'];
  6190. if ($post['warehouse'] == '5') {
  6191. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6192. if ($yza) {
  6193. if ($post['features'] != $yza[0]['features']) {
  6194. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6195. exit;
  6196. }
  6197. }
  6198. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6199. if ($yzb) {
  6200. if ($post['sku'] != $yzb[0]['sku']) {
  6201. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6202. exit;
  6203. }
  6204. }
  6205. }
  6206. for ($i = 0; $i < $num; $i++) {
  6207. $post['label'] = time() . rand(100, 999) . $i;
  6208. if ($this->$bdck->insert($post)) {
  6209. $j++;
  6210. }
  6211. }
  6212. /**
  6213. if($post['warehouse'] != 12)
  6214. {
  6215. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6216. }
  6217. **/
  6218. if ($j == $num) {
  6219. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6220. exit;
  6221. } else {
  6222. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6223. exit;
  6224. }
  6225. } else {
  6226. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6227. exit;
  6228. }
  6229. }
  6230. $this->_Template('whlabel_printrk', $this->data);
  6231. }
  6232. public function _printxzrk($arg_array)
  6233. {
  6234. $post = $this->input->post(NULL, TRUE);
  6235. if (isset($post['wzid'])) {
  6236. $time = time();
  6237. $id = $this->input->post('wzid', true);
  6238. //$post['shop'] = $this->input->post('shop',true);
  6239. $num = 1;
  6240. $rk = $this->whlabellabel->read($id);
  6241. if (isset($rk['purchase'])) {
  6242. $x = 0;
  6243. $post['purchase'] = $rk['purchase'];
  6244. $post['warehouse'] = $rk['warehouse'];
  6245. $post['retreatwarehouse'] = $rk['warehouse'];
  6246. $post['sku'] = $rk['sku'];
  6247. $post['number'] = $rk['number'];
  6248. $post['features'] = $rk['features'];
  6249. $post['title'] = $rk['title'];
  6250. $post['enter'] = $time;
  6251. $post['time'] = $time;
  6252. $post['bs'] = 1;
  6253. $post['shop'] = $rk['shop'];
  6254. $post['details'] = $rk['details'];
  6255. $post['cpid'] = $rk['cpid'];
  6256. $post['cpbz'] = $rk['cpbz'];
  6257. $warehouse = $this->warehouse->read($rk['warehouse']);
  6258. if ($warehouse['bdck'] == '') {
  6259. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6260. exit;
  6261. } else {
  6262. $bdck = $warehouse['bdck'];
  6263. }
  6264. $post['featurespp'] = $rk['featurespp'];
  6265. $this->db->trans_begin();
  6266. for ($i = 0; $i < $num; $i++) {
  6267. $post['label'] = time() . rand(100, 999) . $i;
  6268. $this->$bdck->insert($post);
  6269. }
  6270. /**
  6271. if($post['warehouse'] != 12)
  6272. {
  6273. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6274. }
  6275. **/
  6276. if ($this->db->trans_status() === TRUE) {
  6277. $this->db->trans_commit();
  6278. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6279. exit;
  6280. } else {
  6281. $this->db->trans_rollback();
  6282. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6283. exit;
  6284. }
  6285. } else {
  6286. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6287. exit;
  6288. }
  6289. }
  6290. }
  6291. public function _printck($arg_array)
  6292. {
  6293. $prc = array();
  6294. $purchase = $this->purchase->find_all();
  6295. foreach ($purchase as $k => $v) {
  6296. $prc[$v['id']] = $v['title'];
  6297. }
  6298. $post = $this->input->post(NULL, TRUE);
  6299. if (isset($post['page'])) {
  6300. $page = $this->input->post('page', true);
  6301. $perpage = $this->input->post('perpage', true);
  6302. $sku = $this->input->post('sku', true);
  6303. $bs = $this->input->post('bs', true);
  6304. $number = $this->input->post('number', true);
  6305. $warehouse = $this->input->post('warehouse', true);
  6306. $purchase = $this->input->post('purchase', true);
  6307. $orderinfo = $this->input->post('orderinfo', true);
  6308. $waybill = $this->input->post('waybill', true);
  6309. $category = $this->input->post('category', true);
  6310. $size = $this->input->post('size', true);
  6311. $grade = $this->input->post('grade', true);
  6312. $color = $this->input->post('color', true);
  6313. $lowe = $this->input->post('lowe', true);
  6314. $state = $this->input->post('state', true);
  6315. $label = $this->input->post('label', true);
  6316. $timetk = $this->input->post('ktime', true);
  6317. $timetj = $this->input->post('jtime', true);
  6318. $timetk = strtotime($timetk);
  6319. $timetj = strtotime($timetj);
  6320. $where = "state=1 ";
  6321. if ($timetk && $timetj) {
  6322. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6323. }
  6324. if ($sku) {
  6325. $where .= " and sku = '$sku'";
  6326. }
  6327. if ($bs != '') {
  6328. $where .= " and bs = '$bs'";
  6329. }
  6330. if ($number) {
  6331. $where .= " and number = '$number'";
  6332. }
  6333. if ($warehouse) {
  6334. $where .= " and warehouse = '$warehouse'";
  6335. }
  6336. if ($purchase) {
  6337. $where .= " and purchase = '$purchase'";
  6338. }
  6339. if ($orderinfo) {
  6340. $where .= " and orderinfo = '$orderinfo'";
  6341. }
  6342. if ($waybill) {
  6343. $where .= " and waybill = '$waybill'";
  6344. }
  6345. if ($category) {
  6346. $where .= " and features like '%-$category-%'";
  6347. }
  6348. if ($size) {
  6349. $where .= " and features like '%-$size-%'";
  6350. }
  6351. if ($grade) {
  6352. $where .= " and features like '%-$grade-%'";
  6353. }
  6354. if ($color) {
  6355. $where .= " and features like '%-$color-%'";
  6356. }
  6357. if ($lowe) {
  6358. $where .= " and features like '%-$lowe-%'";
  6359. }
  6360. if ($label) {
  6361. $where .= " and label = '$label'";
  6362. }
  6363. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6364. //数据排序
  6365. $order_str = "outk desc";
  6366. if (empty($page)) {
  6367. $start = 0;
  6368. $perpage = 1;
  6369. } else {
  6370. $start = ($page - 1) * $perpage;
  6371. }
  6372. //取得信息列表
  6373. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6374. foreach ($info_list as $key => $value) {
  6375. $warehouse = $this->warehouse->read($value['warehouse']);
  6376. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6377. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6378. if ($value['state'] == 0) {
  6379. $info_list[$key]['state'] = "在库";
  6380. } else if ($value['state'] == 1) {
  6381. $info_list[$key]['state'] = "出库";
  6382. } else if ($value['state'] == 2) {
  6383. $info_list[$key]['state'] = "退库";
  6384. } else if ($value['state'] == 3) {
  6385. $info_list[$key]['state'] = "调拨中";
  6386. } else if ($value['state'] == 4) {
  6387. $info_list[$key]['state'] = "再加工";
  6388. } else if ($value['state'] == 5) {
  6389. $info_list[$key]['state'] = "维修中";
  6390. } else if ($value['state'] == 6) {
  6391. $info_list[$key]['state'] = "盘亏";
  6392. } else if ($value['state'] == 7) {
  6393. $info_list[$key]['state'] = "更换标签";
  6394. } else if ($value['state'] == 8) {
  6395. $info_list[$key]['state'] = "其它";
  6396. } else if ($value['state'] == 9) {
  6397. $info_list[$key]['state'] = "预设";
  6398. } else if ($value['state'] == 10) {
  6399. $info_list[$key]['state'] = "美店零售";
  6400. }
  6401. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6402. }
  6403. $total = $this->$ck->find_count($where);
  6404. $pagenum = ceil($total / $perpage);
  6405. $over = $total - ($start + $perpage);
  6406. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6407. echo json_encode($rows);
  6408. exit;
  6409. }
  6410. if (isset($post['tmsku'])) {
  6411. $time = time();
  6412. $tmsku = $this->input->post('tmsku', true);
  6413. //$post['shop'] = $this->input->post('shop',true);
  6414. $num = $this->input->post('num', true);
  6415. $cktype = $this->input->post('cktype', true);
  6416. $label = $this->whlabellabel->get_label($tmsku);
  6417. if (!$cktype) {
  6418. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6419. }
  6420. if (!isset($label['warehouse'])) {
  6421. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6422. exit;
  6423. }
  6424. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6425. if (stripos($label['features'], '-126-') !== false) {
  6426. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6427. } else {
  6428. $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 = ''");
  6429. }
  6430. $j = 0;
  6431. if (count($ck) >= $num) {
  6432. for ($i = 0; $i < $num; $i++) {
  6433. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6434. {
  6435. $j++;
  6436. }
  6437. }
  6438. if ($j == $num) {
  6439. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6440. exit;
  6441. } else {
  6442. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6443. exit;
  6444. }
  6445. } else {
  6446. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6447. exit;
  6448. }
  6449. }
  6450. if(isset($_SESSION['api']))
  6451. {
  6452. $user = $this->user->get_api($_SESSION['api']);
  6453. if(in_array($user['power'],[1,27])){
  6454. $vip = 1;
  6455. }
  6456. }
  6457. else
  6458. {
  6459. $vip = 0;
  6460. header('Location: /');exit;
  6461. }
  6462. $this->data['vip'] = $vip;
  6463. $this->_Template('whlabel_printck', $this->data);
  6464. }
  6465. public function _printexcel()
  6466. {
  6467. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6468. $config['upload_path'] = '.' . $dir;
  6469. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6470. $config['allowed_types'] = 'xls|xlsx|csv';
  6471. $config['max_size'] = 10240;
  6472. $this->load->library('upload', $config);
  6473. $this->upload->initialize($config);
  6474. if ($this->upload->do_upload('userfile')) {
  6475. $full_path = $dir . $this->upload->data('file_name');
  6476. $fileName = '.' . $full_path;
  6477. if (!file_exists($fileName)) {
  6478. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6479. exit;
  6480. } else {
  6481. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6482. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6483. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6484. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6485. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6486. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6487. ++$column; //如果列数大于26行
  6488. $list = array();
  6489. for ($i = 2; $i <= $row; $i++) // 行数循环
  6490. {
  6491. $data = array();
  6492. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6493. {
  6494. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6495. }
  6496. $list[] = $data;
  6497. }
  6498. }
  6499. $ed = array();
  6500. $i = 0;
  6501. $j = 0;
  6502. $dcdata = array();
  6503. $yc = '';
  6504. $cmf_arr = array_column($list, '1');
  6505. array_multisort($cmf_arr, SORT_ASC, $list);
  6506. foreach ($list as $key => $value) {
  6507. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6508. if ($typeclass) {
  6509. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6510. } else {
  6511. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6512. $i++;
  6513. continue;
  6514. }
  6515. }
  6516. if ($i > 0) {
  6517. $yc = $i . '条异常';
  6518. }
  6519. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6520. exit;
  6521. }
  6522. }
  6523. public function _uck()
  6524. {
  6525. if (isset($_GET['excel'])) {
  6526. $tc = array();
  6527. $typeclass = $this->typeclass->find_all();
  6528. foreach ($typeclass as $v) {
  6529. $tc[$v['id']] = $v['zh'];
  6530. }
  6531. $data = array();
  6532. $t = array();
  6533. $rq = '';
  6534. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6535. $ts = $ts / (24 * 3600);
  6536. for ($i = 0; $i < $ts; $i++) {
  6537. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6538. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6539. }
  6540. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6541. foreach ($info_list as $k => $v) {
  6542. $features = explode('-', trim($v['features'], '-'));
  6543. if (!isset($features[3]) || !isset($features[4])) {
  6544. continue;
  6545. }
  6546. $data[$k][0] = $tc[$features[0]]; //类型
  6547. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6548. $data[$k][2] = $tc[$features[4]]; //曲度
  6549. $data[$k][3] = '';
  6550. if (isset($data[$k][1])) {
  6551. $data[$k][3] .= $data[$k][1];
  6552. }
  6553. if (isset($data[$k][2])) {
  6554. $data[$k][3] .= $data[$k][2];
  6555. }
  6556. if (isset($features[5])) {
  6557. $data[$k][3] .= $tc[$features[5]];
  6558. }
  6559. if (isset($features[2])) {
  6560. $data[$k][3] .= $tc[$features[2]];
  6561. }
  6562. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6563. $data[$k][4] = $v['sku'];
  6564. $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())) . '))'); //月初库存
  6565. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6566. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6567. $ztrq = '';
  6568. $ztsl = '';
  6569. if (count($zt) > 0) {
  6570. foreach ($zt as $vv) {
  6571. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6572. $ztsl .= $vv['num'] . '<br>';
  6573. }
  6574. }
  6575. $data[$k][] = trim($ztsl, '<br>');
  6576. $data[$k][] = trim($ztrq, '<br>');
  6577. $byck = 0;
  6578. foreach ($t as $vv) {
  6579. $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));
  6580. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6581. $byck += $sl;
  6582. }
  6583. $data[$k][] = ($byck > 0) ? $byck : '';
  6584. }
  6585. $title = "详情 " . date("Y-m-d", time());
  6586. $titlename = "<table border=1>
  6587. <tr align='center'>
  6588. <td>类别</td>
  6589. <td>颜色</td>
  6590. <td>曲度</td>
  6591. <td>名称</td>
  6592. <td>SKU</td>
  6593. <td>月初库存</td>
  6594. <td>剩余库存</td>
  6595. <td>在途数量</td>
  6596. <td>预达日期</td>" .
  6597. $rq
  6598. . "<td>本月出库</td></tr>
  6599. </table>";
  6600. $filename = $title . ".xls";
  6601. $tail = "";
  6602. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6603. }
  6604. }
  6605. public function _whlabelexcelzh()
  6606. {
  6607. if (isset($_GET['excel'])) {
  6608. $where = "sku != 'Preset'";
  6609. //数据排序
  6610. $order_str = "id desc";
  6611. if (empty($page)) {
  6612. $start = 0;
  6613. $perpage = 1;
  6614. } else {
  6615. $start = ($page - 1) * $perpage;
  6616. }
  6617. $category = $this->input->get('category', true);
  6618. $warehouse = $this->input->get('warehouse', true);
  6619. $excelid = $this->input->get('sid', true);
  6620. if ($category) {
  6621. $where .= " and features like '%-$category-%'";
  6622. }
  6623. if ($warehouse) {
  6624. $where .= " and warehouse = '$warehouse'";
  6625. }
  6626. $xzid = '';
  6627. if ($excelid) {
  6628. $excelid = explode(',', trim($excelid, ','));
  6629. foreach ($excelid as $key => $value) {
  6630. $xzid .= " id = " . $value . " or";
  6631. }
  6632. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6633. }
  6634. //取得信息列表
  6635. /**
  6636. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6637. $rows = array();$list = array();
  6638. foreach ($info_list as $key=>$value)
  6639. {
  6640. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6641. }
  6642. **/
  6643. $list = array();
  6644. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6645. foreach ($rows as $key => $value) {
  6646. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6647. $zh = '';
  6648. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6649. foreach ($zt as $v) {
  6650. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6651. }
  6652. $zt = array_sum(array_column($zt, 'num'));
  6653. $number = $value['number'];
  6654. $ftime = time() - 15 * 24 * 3600;
  6655. $warehouse = $this->warehouse->read($value['warehouse']);
  6656. $rows[$key]['warehouse'] = $warehouse['title'];
  6657. $rows[$key]['number'] = $c;
  6658. $rows[$key]['features'] = $zh;
  6659. $rows[$key]['hb'] = $c + $zt;
  6660. }
  6661. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6662. $titlename = "<table border=1>
  6663. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6664. <tr align='center'>
  6665. <td>仓库</td>
  6666. <td>SKU</td>
  6667. <td>产品</td>
  6668. <td>库存数量</td>
  6669. <td>在途数量及预达日期</td>
  6670. <td>在途+库存数量</td>
  6671. </tr>
  6672. </table>";
  6673. $filename = $title . ".xls";
  6674. $tail = "";
  6675. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6676. }
  6677. if (isset($_GET['excel'])) {
  6678. $warehouse = $this->input->get('warehouse', true);
  6679. $sku = $this->input->get('sku', true);
  6680. $cz = $this->input->get('cz', true);
  6681. $text = $this->input->post('text', true);
  6682. $xztime = $this->input->get('xztime', true);
  6683. $timetk = $this->input->get('timetk', true);
  6684. $timetj = $this->input->get('timetj', true);
  6685. $timetk = strtotime($timetk);
  6686. $timetj = strtotime($timetj);
  6687. $where = "time = '0' ";
  6688. if ($warehouse) {
  6689. $where .= " and warehouse = '$warehouse'";
  6690. }
  6691. if ($sku) {
  6692. $where .= " and sku = '$sku'";
  6693. }
  6694. if ($text) {
  6695. $where .= " and text like '%$text%'";
  6696. }
  6697. if ($cz != '') {
  6698. $where .= " and cz = '$cz'";
  6699. }
  6700. if ($timetk && $timetj) {
  6701. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6702. }
  6703. //数据排序
  6704. $order_str = $xztime . " desc";
  6705. //取得信息列表
  6706. $zh = array();
  6707. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6708. foreach ($info_list as $v) {
  6709. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6710. $warehouse = $this->warehouse->read($v['warehouse']);
  6711. $v['warehouse'] = $warehouse['title'];
  6712. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6713. $v['stime'] = date('Y-m-d', $v['stime']);
  6714. if (isset($zh[$v['features']])) {
  6715. $zh[$v['features']]['num'] += $v['num'];
  6716. } else {
  6717. $zh[$v['features']] = $v;
  6718. }
  6719. $zh[$v['features']]['features'] = $c;
  6720. }
  6721. $title = "在途数据" . date('Y-m-d', time());
  6722. $titlename = "<table border=1>
  6723. <tr align='center'>
  6724. <td>仓库</td>
  6725. <td>SKU</td>
  6726. <td>名称</td>
  6727. <td>在途数量</td>
  6728. <td>库存数量</td>
  6729. <td>添加在途日期</td>
  6730. <td>预达日期</td>
  6731. <td>备注</td>
  6732. </tr>
  6733. </table>";
  6734. $filename = $title . ".xls";
  6735. $tail = "";
  6736. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6737. }
  6738. }
  6739. public function _fc()
  6740. {
  6741. $vip = 0;
  6742. if (isset($_SESSION['api'])) {
  6743. $user = $this->user->get_api($_SESSION['api']);
  6744. if ($user['vip'] == 1) {
  6745. $vip = 1;
  6746. }
  6747. } else {
  6748. header('Location: /');
  6749. exit;
  6750. }
  6751. $post = $this->input->post(NULL, TRUE);
  6752. if (isset($post['page'])) {
  6753. $page = $this->input->post('page', true);
  6754. $perpage = $this->input->post('perpage', true);
  6755. $category = $this->input->post('category', true);
  6756. $size = $this->input->post('size', true);
  6757. $grade = $this->input->post('grade', true);
  6758. $color = $this->input->post('color', true);
  6759. $lowe = $this->input->post('lowe', true);
  6760. $sku = $this->input->post('sku');
  6761. $title = $this->input->post('title');
  6762. $warehouse = $this->input->post('warehouse', true);
  6763. $usa = $this->input->post('usa', true);
  6764. $purchase = $this->input->post('purchase', true);
  6765. $lacetype = $this->input->post('lacetype', true);
  6766. $haircap = $this->input->post('haircap', true);
  6767. $density = $this->input->post('density', true);
  6768. $details = $this->input->post('details', true);
  6769. $state = $this->input->post('state', true);
  6770. $ktime = $this->input->post('ktime', true);
  6771. $jtime = $this->input->post('jtime', true);
  6772. $ktime = strtotime($ktime);
  6773. $jtime = strtotime($jtime);
  6774. $where = "state = '11'";
  6775. $gj = "";
  6776. $ck = "";
  6777. if ($lacetype) {
  6778. $where .= " and features like '%-$lacetype-%'";
  6779. }
  6780. if ($category) {
  6781. $where .= " and features like '%-$category-%'";
  6782. }
  6783. if ($size) {
  6784. $where .= " and features like '%-$size-%'";
  6785. }
  6786. if ($grade) {
  6787. $where .= " and features like '%-$grade-%'";
  6788. }
  6789. if ($color) {
  6790. $where .= " and features like '%-$color-%'";
  6791. }
  6792. if ($lowe) {
  6793. $where .= " and features like '%-$lowe-%'";
  6794. }
  6795. if ($haircap) {
  6796. $where .= " and features like '%-$haircap-%'";
  6797. }
  6798. if ($density) {
  6799. $where .= " and features like '%-$density-%'";
  6800. }
  6801. if ($usa) {
  6802. if (!$warehouse) {
  6803. $where .= " and (warehouse = '5' or warehouse = '8')";
  6804. }
  6805. }
  6806. if ($warehouse) {
  6807. $where .= " and warehouse = '$warehouse'";
  6808. }
  6809. if ($details) {
  6810. $where .= " and details = '$details'";
  6811. }
  6812. if ($purchase) {
  6813. $where .= " and purchase = '$purchase'";
  6814. }
  6815. if ($state) {
  6816. $where .= " and state = '$state'";
  6817. }
  6818. if ($ktime && $jtime) {
  6819. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6820. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6821. }
  6822. //数据排序
  6823. $order_str = "id desc";
  6824. if (empty($page)) {
  6825. $start = 0;
  6826. $perpage = 1;
  6827. } else {
  6828. $start = ($page - 1) * $perpage;
  6829. }
  6830. if ($sku) {
  6831. $sku = trim($sku, ' ');
  6832. $sku = trim($sku, ' ');
  6833. $where .= " and sku like '%$sku%'";
  6834. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6835. } else if ($title) {
  6836. $title = trim($title, ' ');
  6837. $title = trim($title, ' ');
  6838. $where .= " and title like '%$title%'";
  6839. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6840. } else {
  6841. //$where .= " and time > '$ktime' and time < '$jtime'";
  6842. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6843. }
  6844. //取得信息列表
  6845. $rows = array();
  6846. $list = array();
  6847. foreach ($info_list as $key => $value) {
  6848. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  6849. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6850. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6851. $warehouse = $this->warehouse->read($value['warehouse']);
  6852. $info_list[$key]['warehouse'] = $warehouse['title'];
  6853. $info_list[$key]['number'] = $g;
  6854. $info_list[$key]['features'] = $x;
  6855. $info_list[$key]['x'] = $s;
  6856. }
  6857. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6858. $pagenum = ceil($total / $perpage);
  6859. $over = $total - ($start + $perpage);
  6860. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6861. echo json_encode($rows);
  6862. exit;
  6863. }
  6864. $this->data['vip'] = $vip;
  6865. $this->_Template('whlabel_fc', $this->data);
  6866. }
  6867. public function _fcmb()
  6868. {
  6869. $where = "sku != 'Preset'";
  6870. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6871. foreach ($rows as $k => $v) {
  6872. $warehouse = $this->warehouse->read($v['warehouse']);
  6873. $rows[$k]['warehouse'] = $warehouse['title'];
  6874. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6875. $rows[$k]['t'] = '';
  6876. $rows[$k]['n'] = '';
  6877. }
  6878. $title = "封货产品数据导入模板";
  6879. $titlename = "<table border=1>
  6880. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6881. <tr align='center'>
  6882. <td>仓库</td>
  6883. <td>SKU</td>
  6884. <td>产品</td>
  6885. <td>封存产品总数量</td>
  6886. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6887. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6888. </tr>
  6889. </table>";
  6890. $filename = $title . ".xls";
  6891. $tail = "";
  6892. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6893. }
  6894. public function _fcexcel()
  6895. {
  6896. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6897. $config['upload_path'] = '.' . $dir;
  6898. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6899. $config['allowed_types'] = 'xls|xlsx|csv';
  6900. $config['max_size'] = 10240;
  6901. $this->load->library('upload', $config);
  6902. $this->upload->initialize($config);
  6903. if ($this->upload->do_upload('userfile')) {
  6904. $full_path = $dir . $this->upload->data('file_name');
  6905. $fileName = '.' . $full_path;
  6906. if (!file_exists($fileName)) {
  6907. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6908. exit;
  6909. } else {
  6910. libxml_use_internal_errors(true);
  6911. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6912. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6913. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6914. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6915. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6916. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6917. ++$column; //如果列数大于26行
  6918. $list = array();
  6919. for ($i = 2; $i <= $row; $i++) // 行数循环
  6920. {
  6921. $data = array();
  6922. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6923. {
  6924. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6925. }
  6926. $list[] = $data;
  6927. }
  6928. }
  6929. $i = 0;
  6930. $j = 0;
  6931. $ed = array();
  6932. foreach ($list as $key => $value) {
  6933. $time = time();
  6934. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6935. continue;
  6936. }
  6937. $warehouse = $this->warehouse->get_title($value['0']);
  6938. $sku = $value['1'];
  6939. $type = $value['4']; //调整方式0扣减1删除
  6940. $num = $value['5']; //调整数量
  6941. //$text = $value['4'];//扣减说明
  6942. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6943. if (!$d) //如果没有这个SKU
  6944. {
  6945. $ed[] = array($sku . '-库存中不存在此SKU');
  6946. $j++;
  6947. continue;
  6948. }
  6949. if (!isset($warehouse['id'])) {
  6950. $ed[] = array($sku . '-仓库名错误!');
  6951. $j++;
  6952. continue;
  6953. }
  6954. if ($type == 1 || $type == 2) //扣减库存
  6955. {
  6956. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6957. if (count($data) < abs($num)) {
  6958. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6959. $j++;
  6960. continue;
  6961. }
  6962. if ($type == 1) //转入库存
  6963. {
  6964. for ($i = 0; $i < abs($num); $i++) {
  6965. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6966. }
  6967. } else if ($type == 2) //删除
  6968. {
  6969. for ($i = 0; $i < abs($num); $i++) {
  6970. $this->whlabel->remove($data[$i]['id']);
  6971. }
  6972. }
  6973. } else if ($type == 0) //增加库存
  6974. {
  6975. $post['sku'] = $d['sku'];
  6976. $post['shop'] = '';
  6977. $post['warehouse'] = $warehouse['id'];
  6978. $post['purchase'] = $d['purchase'];
  6979. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6980. $post['state'] = 11;
  6981. $post['title'] = $d['title'];
  6982. $post['number'] = $d['number'];
  6983. $post['features'] = $d['features'];
  6984. $post['enter'] = $time;
  6985. $post['time'] = $time; //操作时间
  6986. for ($i = 0; $i < $num; $i++) {
  6987. $post['label'] = time() . rand(100, 999) . $i;
  6988. $this->whlabel->insert($post);
  6989. }
  6990. }
  6991. sleep(1); //防止入库时间一样,需要延迟1秒
  6992. }
  6993. if ($j > 0) {
  6994. $tt = date('Ymd', time());
  6995. $title = '库存导入错误信息-' . $tt;
  6996. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6997. $tail = "\n";
  6998. $filename = $title . ".xls";
  6999. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7000. $dir = '/data/excel/' . $time . '/';
  7001. $file_name = 'error_' . $time . rand(1000, 9999);
  7002. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7003. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7004. fwrite($myfile, $ecl);
  7005. fclose($myfile);
  7006. $error = $dir . $file_name . '.xls';
  7007. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7008. exit;
  7009. } else {
  7010. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7011. exit;
  7012. }
  7013. }
  7014. }
  7015. public function _fcjxc($arg_array)
  7016. {
  7017. if (isset($_GET['excel'])) {
  7018. $category = $this->input->get('category', true);
  7019. $size = $this->input->get('size', true);
  7020. $grade = $this->input->get('grade', true);
  7021. $color = $this->input->get('color', true);
  7022. $lowe = $this->input->get('lowe', true);
  7023. $sku = $this->input->get('sku');
  7024. $title = $this->input->get('title');
  7025. $warehouse = $arg_array[0];
  7026. $usa = $this->input->get('usa', true);
  7027. $purchase = $this->input->get('purchase', true);
  7028. $lacetype = $this->input->get('lacetype', true);
  7029. $haircap = $this->input->get('haircap', true);
  7030. $density = $this->input->get('density', true);
  7031. $title = $this->input->get('title', true);
  7032. $state = $this->input->get('state', true);
  7033. $ktime = $this->input->get('ktime', true);
  7034. $jtime = $this->input->get('jtime', true);
  7035. $where = "state=11";
  7036. $gj = "";
  7037. $ck = "";
  7038. if ($lacetype) {
  7039. $where .= " and features like '%-$lacetype-%'";
  7040. }
  7041. if ($category) {
  7042. $where .= " and features like '%-$category-%'";
  7043. }
  7044. if ($size) {
  7045. $where .= " and features like '%-$size-%'";
  7046. }
  7047. if ($grade) {
  7048. $where .= " and features like '%-$grade-%'";
  7049. }
  7050. if ($color) {
  7051. $where .= " and features like '%-$color-%'";
  7052. }
  7053. if ($lowe) {
  7054. $where .= " and features like '%-$lowe-%'";
  7055. }
  7056. if ($haircap) {
  7057. $where .= " and features like '%-$haircap-%'";
  7058. }
  7059. if ($density) {
  7060. $where .= " and features like '%-$density-%'";
  7061. }
  7062. if ($usa) {
  7063. if (!$warehouse) {
  7064. $where .= " and (warehouse = '5' or warehouse = '8')";
  7065. }
  7066. }
  7067. if ($warehouse) {
  7068. $where .= " and warehouse = '$warehouse'";
  7069. }
  7070. if ($purchase) {
  7071. $where .= " and purchase = '$purchase'";
  7072. }
  7073. if ($state) {
  7074. $where .= " and state = '$state'";
  7075. }
  7076. $order_str = "id desc";
  7077. if ($sku) {
  7078. $sku = trim($sku, ' ');
  7079. $sku = trim($sku, ' ');
  7080. $where .= " and sku like '%$sku%'";
  7081. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7082. } else if ($title) {
  7083. $title = trim($title, ' ');
  7084. $title = trim($title, ' ');
  7085. $where .= " and title like '%$title%'";
  7086. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7087. } else {
  7088. //$where .= " and time > '$ktime' and time < '$jtime'";
  7089. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7090. }
  7091. //取得信息列表
  7092. $rows = array();
  7093. $list = array();
  7094. foreach ($info_list as $key => $value) {
  7095. $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'] . '"');
  7096. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7097. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7098. $rows[$key] = $value;
  7099. $warehouse = $this->warehouse->read($value['warehouse']);
  7100. $rows[$key]['warehouse'] = $warehouse['title'];
  7101. $rows[$key]['features'] = $g;
  7102. $rows[$key]['a'] = $x;
  7103. $rows[$key]['b'] = $s;
  7104. }
  7105. $title = "总统计表";
  7106. $titlename = "<table border=1>
  7107. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7108. <tr align='center'>
  7109. <td>仓库</td>
  7110. <td>SKU</td>
  7111. <td>产品名称</td>
  7112. <td>录入总量</td>
  7113. <td>取出总量</td>
  7114. <td>剩余总量</td>
  7115. </tr>
  7116. </table>";
  7117. $filename = $title . ".xls";
  7118. $tail = "";
  7119. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7120. }
  7121. $vip = 0;
  7122. if (isset($_SESSION['api'])) {
  7123. $user = $this->user->get_api($_SESSION['api']);
  7124. if ($user['vip'] == 1) {
  7125. $vip = 1;
  7126. }
  7127. } else {
  7128. header('Location: /');
  7129. exit;
  7130. }
  7131. $post = $this->input->post(NULL, TRUE);
  7132. if (isset($post['page'])) {
  7133. $page = $this->input->post('page', true);
  7134. $perpage = $this->input->post('perpage', true);
  7135. $category = $this->input->post('category', true);
  7136. $size = $this->input->post('size', true);
  7137. $grade = $this->input->post('grade', true);
  7138. $color = $this->input->post('color', true);
  7139. $lowe = $this->input->post('lowe', true);
  7140. $sku = $this->input->post('sku');
  7141. $title = $this->input->post('title');
  7142. $warehouse = $arg_array[0];
  7143. $usa = $this->input->post('usa', true);
  7144. $purchase = $this->input->post('purchase', true);
  7145. $lacetype = $this->input->post('lacetype', true);
  7146. $haircap = $this->input->post('haircap', true);
  7147. $density = $this->input->post('density', true);
  7148. $title = $this->input->post('title', true);
  7149. $state = $this->input->post('state', true);
  7150. $ktime = $this->input->post('ktime', true);
  7151. $jtime = $this->input->post('jtime', true);
  7152. $ktime = strtotime($ktime);
  7153. $jtime = strtotime($jtime);
  7154. $where = "state=11";
  7155. $gj = "";
  7156. $ck = "";
  7157. if ($lacetype) {
  7158. $where .= " and features like '%-$lacetype-%'";
  7159. }
  7160. if ($category) {
  7161. $where .= " and features like '%-$category-%'";
  7162. }
  7163. if ($size) {
  7164. $where .= " and features like '%-$size-%'";
  7165. }
  7166. if ($grade) {
  7167. $where .= " and features like '%-$grade-%'";
  7168. }
  7169. if ($color) {
  7170. $where .= " and features like '%-$color-%'";
  7171. }
  7172. if ($lowe) {
  7173. $where .= " and features like '%-$lowe-%'";
  7174. }
  7175. if ($haircap) {
  7176. $where .= " and features like '%-$haircap-%'";
  7177. }
  7178. if ($density) {
  7179. $where .= " and features like '%-$density-%'";
  7180. }
  7181. if ($usa) {
  7182. if (!$warehouse) {
  7183. $where .= " and (warehouse = '5' or warehouse = '8')";
  7184. }
  7185. }
  7186. if ($warehouse) {
  7187. $where .= " and warehouse = '$warehouse'";
  7188. }
  7189. if ($purchase) {
  7190. $where .= " and purchase = '$purchase'";
  7191. }
  7192. if ($state) {
  7193. $where .= " and state = '$state'";
  7194. }
  7195. if ($ktime && $jtime) {
  7196. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7197. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7198. }
  7199. //数据排序
  7200. $order_str = "id desc";
  7201. $xs = 0;
  7202. $rows = array();
  7203. $list = array();
  7204. if (empty($page)) {
  7205. $start = 0;
  7206. $perpage = 1;
  7207. } else {
  7208. $start = ($page - 1) * $perpage;
  7209. }
  7210. if ($sku || $title) {
  7211. if ($title) {
  7212. $title = trim($title, ' ');
  7213. $title = trim($title, ' ');
  7214. $where .= " and title like '%$title%'";
  7215. } else {
  7216. $sku = trim($sku, ' ');
  7217. $sku = trim($sku, ' ');
  7218. $where .= " and sku like '%$sku%'";
  7219. }
  7220. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7221. foreach ($info_list as $key => $value) {
  7222. $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'] . '"');
  7223. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7224. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7225. $rows[$key] = $value;
  7226. $warehouse = $this->warehouse->read($value['warehouse']);
  7227. $rows[$key]['warehouse'] = $warehouse['title'];
  7228. $rows[$key]['features'] = $g;
  7229. $rows[$key]['a'] = $x;
  7230. $rows[$key]['b'] = $s;
  7231. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7232. $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天销量
  7233. $yj = $c / ($xl / 30);
  7234. if ($yj < 7) {
  7235. $rows[$key]['y'] = round($yj) . '天销量';
  7236. } else {
  7237. $rows[$key]['y'] = '正常';
  7238. }
  7239. }
  7240. } else {
  7241. //$where .= " and time > '$ktime' and time < '$jtime'";
  7242. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7243. foreach ($info_list as $key => $value) {
  7244. $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'] . '"');
  7245. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7246. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7247. $zs[$key] = $value;
  7248. $warehouse = $this->warehouse->read($value['warehouse']);
  7249. $zs[$key]['warehouse'] = $warehouse['title'];
  7250. $zs[$key]['features'] = $g;
  7251. $zs[$key]['a'] = $x;
  7252. $zs[$key]['b'] = $s;
  7253. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7254. $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天销量
  7255. $yj = $c / ($xl / 30);
  7256. if ($yj < 7) {
  7257. $zs[$key]['y'] = round($yj) . '天销量';
  7258. $rows[$key] = $zs[$key];
  7259. }
  7260. }
  7261. }
  7262. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7263. $pagenum = ceil($total / $perpage);
  7264. $over = $total - ($start + $perpage);
  7265. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7266. echo json_encode($rows);
  7267. exit;
  7268. }
  7269. $this->data['arg_array'] = $arg_array[0];
  7270. $this->_Template('whlabel_fcjxc', $this->data);
  7271. }
  7272. public function _0kcdel()
  7273. {
  7274. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7275. $config['upload_path'] = '.' . $dir;
  7276. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7277. $config['allowed_types'] = 'xls|xlsx|csv';
  7278. $config['max_size'] = 10240;
  7279. $this->load->library('upload', $config);
  7280. $this->upload->initialize($config);
  7281. if ($this->upload->do_upload('userfile')) {
  7282. $full_path = $dir . $this->upload->data('file_name');
  7283. $fileName = '.' . $full_path;
  7284. if (!file_exists($fileName)) {
  7285. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7286. exit;
  7287. } else {
  7288. require_once "./data/excel/PHPExcel/IOFactory.php";
  7289. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7290. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7291. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7292. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7293. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7294. ++$column; //如果列数大于26行
  7295. $list = array();
  7296. for ($i = 2; $i <= $row; $i++) // 行数循环
  7297. {
  7298. $data = array();
  7299. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7300. {
  7301. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7302. }
  7303. $list[] = $data;
  7304. }
  7305. }
  7306. $i = 0;
  7307. $j = 0;
  7308. $ed = array();
  7309. foreach ($list as $key => $value) {
  7310. $time = time();
  7311. if ($value['0'] == "" || $value['1'] == "") {
  7312. continue;
  7313. }
  7314. $warehouse = $this->warehouse->get_title($value['0']);
  7315. $sku = $value['1'];
  7316. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7317. if (!$d) //如果没有这个SKU
  7318. {
  7319. $ed[] = array($sku . '-库存中不存在此SKU');
  7320. $j++;
  7321. continue;
  7322. }
  7323. if (!isset($warehouse['id'])) {
  7324. $ed[] = array($sku . '-仓库名错误!');
  7325. $j++;
  7326. continue;
  7327. }
  7328. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7329. if ($z < 1) {
  7330. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7331. foreach ($z as $v) {
  7332. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7333. if (count($zt) > 0) {
  7334. $ed[] = array($sku . '-有在途库存无法删除!');
  7335. $j++;
  7336. continue;
  7337. }
  7338. $this->whlabel->remove($v['id']);
  7339. }
  7340. } else {
  7341. $ed[] = array($sku . '-非0库存!');
  7342. $j++;
  7343. continue;
  7344. }
  7345. }
  7346. if ($j > 0) {
  7347. $tt = date('Ymd', time());
  7348. $title = '删除0库存错误信息-' . $tt;
  7349. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7350. $tail = "\n";
  7351. $filename = $title . ".xls";
  7352. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7353. $dir = '/data/excel/' . $time . '/';
  7354. $file_name = 'error_' . $time . rand(1000, 9999);
  7355. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7356. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7357. fwrite($myfile, $ecl);
  7358. fclose($myfile);
  7359. $error = $dir . $file_name . '.xls';
  7360. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7361. exit;
  7362. } else {
  7363. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7364. exit;
  7365. }
  7366. }
  7367. }
  7368. public function _gbhtype()
  7369. {
  7370. $post = $this->input->post(NULL, TRUE);
  7371. if (isset($post['s'])) {
  7372. $n = $this->input->post('n');
  7373. $d = $this->input->post('s');
  7374. if (!$d) {
  7375. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7376. exit;
  7377. }
  7378. $d = explode(',', trim($d, ','));
  7379. $t = $this->whlabel_type->read($n);
  7380. //循环删除记录
  7381. foreach ($d as $v) {
  7382. $u = $this->whlabel->read($v);
  7383. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7384. foreach ($data as $val) {
  7385. $this->whlabel->save(array('type' => $n), $val['id']);
  7386. }
  7387. }
  7388. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7389. }
  7390. }
  7391. //出库、退库导出
  7392. public function _dccrtype()
  7393. {
  7394. $classid = $this->classid->sku();
  7395. $pm = $classid;
  7396. $typeclass = array();
  7397. $tc = $this->typeclass->find_all();
  7398. foreach ($tc as $v) {
  7399. $typeclass[$v['id']] = $v;
  7400. }
  7401. $prc = array();
  7402. $purchase = $this->purchase->find_all();
  7403. foreach ($purchase as $k => $v) {
  7404. $prc[$v['id']] = $v['title'];
  7405. }
  7406. if (isset($_GET['sid'])) {
  7407. $wh = array();
  7408. $w = $this->warehouse->find_all('1=1', 'id,title');
  7409. foreach ($w as $v) {
  7410. $wh[$v['id']] = $v['title'];
  7411. }
  7412. $type = $this->input->get('excel', true);
  7413. $category = $this->input->get('category', true);
  7414. $size = $this->input->get('size', true);
  7415. $grade = $this->input->get('grade', true);
  7416. $color = $this->input->get('color', true);
  7417. $lowe = $this->input->get('lowe', true);
  7418. $sku = $this->input->get('sku', true);
  7419. $warehouse = $this->input->get('warehouse', true);
  7420. $lacetype = $this->input->get('lacetype', true);
  7421. $lacecolor = $this->input->get('lacecolor', true);
  7422. $density = $this->input->get('density', true);
  7423. $haircap = $this->input->get('haircap', true);
  7424. $purchase = $this->input->get('purchase', true);
  7425. $title = $this->input->get('title', true);
  7426. $state = $this->input->get('state', true);
  7427. $sid = $this->input->get('sid', true);
  7428. $ktime = $this->input->get('ktime', true);
  7429. $jtime = $this->input->get('jtime', true);
  7430. $ktime = strtotime($ktime);
  7431. $jtime = strtotime($jtime);
  7432. $where = "1=1";
  7433. $gj = "";
  7434. $ck = "";
  7435. if ($category) {
  7436. $where .= " and features like '%-$category-%'";
  7437. }
  7438. if ($size) {
  7439. $where .= " and features like '%-$size-%'";
  7440. }
  7441. if ($grade) {
  7442. $where .= " and features like '%-$grade-%'";
  7443. }
  7444. if ($color) {
  7445. $where .= " and features like '%-$color-%'";
  7446. }
  7447. if ($lowe) {
  7448. $where .= " and features like '%-$lowe-%'";
  7449. }
  7450. if ($warehouse) {
  7451. $where .= " and warehouse = '$warehouse'";
  7452. }
  7453. if ($purchase) {
  7454. $where .= " and purchase = '$purchase'";
  7455. }
  7456. if ($state) {
  7457. $where .= " and state = '$state'";
  7458. }
  7459. if ($lacetype) {
  7460. $where .= " and features like '%-$lacetype-%'";
  7461. }
  7462. if ($lacecolor) {
  7463. $where .= " and features like '%-$lacecolor-%'";
  7464. }
  7465. if ($density) {
  7466. $where .= " and features like '%-$density-%'";
  7467. }
  7468. if ($haircap) {
  7469. $where .= " and features like '%-$haircap-%'";
  7470. }
  7471. if ($title) {
  7472. $title = trim($title, ' ');
  7473. $title = trim($title, ' ');
  7474. $where .= " and title like '%$title%'";
  7475. }
  7476. if ($sku) {
  7477. $sku = trim($sku, ' ');
  7478. $sku = trim($sku, ' ');
  7479. $where .= " and sku like '%$sku%'";
  7480. }
  7481. if ($ktime && $jtime) {
  7482. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7483. }
  7484. $sidwhere = '';
  7485. if ($sid) {
  7486. $sd = "";
  7487. $s = explode(',', trim($sid, ','));
  7488. foreach ($s as $value) {
  7489. $sd .= " id = " . $value . " or";
  7490. }
  7491. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7492. }
  7493. //数据排序
  7494. $order_str = "time desc";
  7495. if (empty($page)) {
  7496. $start = 0;
  7497. $perpage = 1;
  7498. } else {
  7499. $start = ($page - 1) * $perpage;
  7500. }
  7501. $wh = array();
  7502. $w = $this->warehouse->find_all('1=1', 'id,title');
  7503. foreach ($w as $v) {
  7504. $wh[$v['id']] = $v['title'];
  7505. }
  7506. $wt = array();
  7507. $whlabel_type = $this->whlabel_type->find_all();
  7508. foreach ($whlabel_type as $v) {
  7509. $wt[$v['id']] = $v['title'];
  7510. }
  7511. $classid = $this->classid->sku();
  7512. $list = array();
  7513. $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');
  7514. foreach ($rows_r as $key => $value) {
  7515. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7516. $pm = $classid;
  7517. $jm = $classid;
  7518. $rows_r[$key]['enter'] = '入库';
  7519. $rows_r[$key]['time'] = $value['enter'];
  7520. if ($value['rktype'] == 1) {
  7521. $rows_r[$key]['rktype'] = '采购入库';
  7522. } else if ($value['rktype'] == 2) {
  7523. $rows_r[$key]['rktype'] = '盘盈调整';
  7524. } else if ($value['rktype'] == 3) {
  7525. $rows_r[$key]['rktype'] = '其他调整入库';
  7526. } else if ($value['rktype'] == 4) {
  7527. $rows_r[$key]['rktype'] = '其他调整入库';
  7528. } else if ($value['rktype'] == 5) {
  7529. $rows_r[$key]['rktype'] = '退库入库';
  7530. } else if ($value['rktype'] == 6) {
  7531. $rows_r[$key]['rktype'] = '退货可用入库';
  7532. } else if ($value['rktype'] == 7) {
  7533. $rows_r[$key]['rktype'] = '形态转换入库';
  7534. } else {
  7535. $rows_r[$key]['rktype'] = '';
  7536. }
  7537. $features = explode('-', trim($value['features'], '-'));
  7538. foreach ($features as $v) {
  7539. if (isset($typeclass[$v])) {
  7540. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7541. $pm[$typeclass[$v]['classid']] = $zh[0];
  7542. }
  7543. if (isset($typeclass[$v])) {
  7544. if (isset($jm[$typeclass[$v]['classid']])) {
  7545. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7546. }
  7547. }
  7548. }
  7549. $zh = implode(" ", $pm);
  7550. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7551. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7552. $rows_r[$key]['zh'] = $zh;
  7553. $jm = array_filter($jm);
  7554. $rows_r[$key]['features'] = implode("-", $jm);
  7555. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7556. }
  7557. $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');
  7558. foreach ($rows_c as $key => $value) {
  7559. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7560. $pm = $classid;
  7561. $jm = $classid;
  7562. $rows_c[$key]['time'] = $value['outk'];
  7563. $rows_c[$key]['outk'] = '出库';
  7564. if ($value['cktype'] == 1) {
  7565. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7566. } else if ($value['cktype'] == 2) {
  7567. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7568. } else if ($value['cktype'] == 3) {
  7569. $rows_c[$key]['cktype'] = '盘亏调整';
  7570. } else if ($value['cktype'] == 4) {
  7571. $rows_c[$key]['cktype'] = '其他调整出库';
  7572. } else if ($value['cktype'] == 5) {
  7573. $rows_c[$key]['cktype'] = '形态转换出库';
  7574. } else {
  7575. $rows_c[$key]['cktype'] = '';
  7576. }
  7577. unset($rows_c[$key]['state']);
  7578. $features = explode('-', trim($value['features'], '-'));
  7579. foreach ($features as $v) {
  7580. if (isset($typeclass[$v])) {
  7581. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7582. $pm[$typeclass[$v]['classid']] = $zh[0];
  7583. }
  7584. if (isset($typeclass[$v])) {
  7585. if (isset($jm[$typeclass[$v]['classid']])) {
  7586. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7587. }
  7588. }
  7589. }
  7590. $zh = implode(" ", $pm);
  7591. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7592. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7593. $rows_c[$key]['zh'] = $zh;
  7594. $jm = array_filter($jm);
  7595. $rows_c[$key]['features'] = implode("-", $jm);
  7596. $rows_c[$key]['number'] = 1;
  7597. }
  7598. $merged = $rows_r;
  7599. foreach ($rows_c as $key => $value) {
  7600. if (isset($merged[$key])) {
  7601. $merged[] = $value;
  7602. } else {
  7603. $merged[$key] = $value;
  7604. }
  7605. }
  7606. usort($merged, function ($a, $b) {
  7607. return $a['time'] - $b['time'];
  7608. });
  7609. foreach ($merged as $key => $value) {
  7610. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7611. }
  7612. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7613. $titlename = "<table border=1>
  7614. <tr align='center'>
  7615. <td>仓库</td>
  7616. <td>SKU</td>
  7617. <td>商品名称</td>
  7618. <td>仓库品名</td>
  7619. <td>料号</td>
  7620. <td>时间</td>
  7621. <td>操作</td>
  7622. <td>类型</td>
  7623. <td>数量</td>
  7624. <td>备注</td>
  7625. </tr>
  7626. </table>";
  7627. $filename = $title . ".xlsx";
  7628. $tail = "";
  7629. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7630. }
  7631. }
  7632. /*************************************处理exceljs导出****************************************************/
  7633. public function _excelrjs(){
  7634. if (isset($_GET['excel'])) {
  7635. $category = $this->input->get('category', true);
  7636. $size = $this->input->get('size', true);
  7637. $grade = $this->input->get('grade', true);
  7638. $color = $this->input->get('color', true);
  7639. $lowe = $this->input->get('lowe', true);
  7640. $sku = $this->input->get('sku', true);
  7641. $warehouse = $this->input->get('warehouse', true);
  7642. $purchase = $this->input->get('purchase', true);
  7643. $ktime = $this->input->get('ktime', true);
  7644. $jtime = $this->input->get('jtime', true);
  7645. $ktime = strtotime($ktime);
  7646. $jtime = strtotime($jtime);
  7647. $where = "1=1";
  7648. $gj = "";
  7649. $ck = "";
  7650. if ($category) {
  7651. $where .= " and features like '%-$category-%'";
  7652. }
  7653. if ($size) {
  7654. $where .= " and features like '%-$size-%'";
  7655. }
  7656. if ($grade) {
  7657. $where .= " and features like '%-$grade-%'";
  7658. }
  7659. if ($color) {
  7660. $where .= " and features like '%-$color-%'";
  7661. }
  7662. if ($lowe) {
  7663. $where .= " and features like '%-$lowe-%'";
  7664. }
  7665. if ($warehouse) {
  7666. $where .= " and warehouse = '$warehouse'";
  7667. }
  7668. if ($purchase) {
  7669. $where .= " and purchase = '$purchase'";
  7670. }
  7671. if ($sku) {
  7672. $where .= " and sku = '$sku'";
  7673. }
  7674. if ($ktime && $jtime) {
  7675. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7676. }
  7677. //数据排序
  7678. $order_str = "id desc";
  7679. if (empty($page)) {
  7680. $start = 0;
  7681. $perpage = 1;
  7682. } else {
  7683. $start = ($page - 1) * $perpage;
  7684. }
  7685. $list = array();
  7686. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7687. foreach ($rows as $value) {
  7688. $ck = $this->warehouse->read($value['warehouse']);
  7689. $warehouse = $ck['title'];
  7690. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7691. $retreatwarehouse = $tkck['title'];
  7692. $gy = $this->purchase->read($value['purchase']);
  7693. $purchase = $gy['title'];
  7694. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7695. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7696. }
  7697. if(empty($list)){
  7698. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7699. }else{
  7700. $final_list = [];
  7701. foreach($list as $v){
  7702. $final_list[] = array_values($v);
  7703. }
  7704. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7705. array_unshift($final_list,[
  7706. "仓库","SKU","商品名称","时间","数量"
  7707. ]);
  7708. array_unshift($final_list,[
  7709. $title,"","","",""
  7710. ]);
  7711. $merges = [
  7712. [
  7713. "s"=>["r"=>0,"c"=>0],
  7714. "e"=>["r"=>0,"c"=>4]
  7715. ]
  7716. ];
  7717. $cols = [
  7718. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7719. ];
  7720. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7721. }
  7722. }
  7723. }
  7724. //出库、退库导出
  7725. public function _excelctjs()
  7726. {
  7727. $classid = $this->classid->sku();
  7728. $pm = $classid;
  7729. $typeclass = array();
  7730. $tc = $this->typeclass->find_all();
  7731. foreach ($tc as $v) {
  7732. $typeclass[$v['id']] = $v;
  7733. }
  7734. $prc = array();
  7735. $purchase = $this->purchase->find_all();
  7736. foreach ($purchase as $k => $v) {
  7737. $prc[$v['id']] = $v['title'];
  7738. }
  7739. if (isset($_GET['excel'])) {
  7740. $wh = array();
  7741. $w = $this->warehouse->find_all('1=1', 'id,title');
  7742. foreach ($w as $v) {
  7743. $wh[$v['id']] = $v['title'];
  7744. }
  7745. $type = $this->input->get('excel', true);
  7746. $category = $this->input->get('category', true);
  7747. $size = $this->input->get('size', true);
  7748. $grade = $this->input->get('grade', true);
  7749. $color = $this->input->get('color', true);
  7750. $lowe = $this->input->get('lowe', true);
  7751. $sku = $this->input->get('sku', true);
  7752. $title = $this->input->get('title', true);
  7753. $warehouse = $this->input->get('warehouse', true);
  7754. $purchase = $this->input->get('purchase', true);
  7755. $lacetype = $this->input->get('lacetype', true);
  7756. $haircap = $this->input->get('haircap', true);
  7757. $lacecolor = $this->input->get('lacecolor', true);
  7758. $density = $this->input->get('density', true);
  7759. $details = $this->input->get('details', true);
  7760. $state = $this->input->get('state', true);
  7761. $shop = $this->input->get('shop', true);
  7762. $hairnumber = $this->input->get('hairnumber', true);
  7763. $type_leixi = $this->input->get('type', true);
  7764. $cpbz = $this->input->get('cpbz', true);
  7765. $sm = $this->input->get('sm', true);
  7766. $sid = $this->input->get('sid', true);
  7767. $ktime = $this->input->get('ktime', true);
  7768. $jtime = $this->input->get('jtime', true);
  7769. $ktime = strtotime($ktime);
  7770. $jtime = strtotime($jtime);
  7771. //$where = " 1=1 ";
  7772. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7773. $where = " sku != '' ";
  7774. $gj = "";
  7775. $ck = "";
  7776. if ($category) {
  7777. $where .= " and features like '%-$category-%'";
  7778. }
  7779. if ($size) {
  7780. $where .= " and features like '%-$size-%'";
  7781. }
  7782. if ($grade) {
  7783. $where .= " and features like '%-$grade-%'";
  7784. }
  7785. if ($color) {
  7786. $where .= " and features like '%-$color-%'";
  7787. }
  7788. if ($lowe) {
  7789. $where .= " and features like '%-$lowe-%'";
  7790. }
  7791. if ($warehouse) {
  7792. $where .= " and warehouse = '$warehouse'";
  7793. }
  7794. if ($purchase) {
  7795. $where .= " and purchase = '$purchase'";
  7796. }
  7797. if ($state) {
  7798. $where .= " and state = '$state'";
  7799. }
  7800. if ($lacetype) {
  7801. $where .= " and features like '%-$lacetype-%'";
  7802. }
  7803. if ($lacecolor) {
  7804. $where .= " and features like '%-$lacecolor-%'";
  7805. }
  7806. if ($density) {
  7807. $where .= " and features like '%-$density-%'";
  7808. }
  7809. if ($haircap) {
  7810. $where .= " and features like '%-$haircap-%'";
  7811. }
  7812. if ($details) {
  7813. $where .= " and details = '$details'";
  7814. }
  7815. if ($shop) {
  7816. $where .= " and shop like '%$shop%'";
  7817. }
  7818. if ($title) {
  7819. $title = trim($title, ' ');
  7820. $title = trim($title, ' ');
  7821. $where .= " and title like '%$title%'";
  7822. }
  7823. if (!empty($hairnumber)) {
  7824. $where .= " and features like '%-128-%' ";
  7825. if ($hairnumber < 0) {
  7826. $class_list = $this->typeclass->find_all('classid = 43');
  7827. foreach ($class_list as $v) {
  7828. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7829. }
  7830. } else {
  7831. $where .= " and features like '%-$hairnumber-%'";
  7832. }
  7833. }
  7834. if ($type_leixi) {
  7835. $where .= " and type = '$type_leixi'";
  7836. }
  7837. if ($cpbz) {
  7838. $where .= " and cpbz like '%$cpbz%' ";
  7839. }
  7840. if ($sm) {
  7841. $where .= " and sm like '%$sm%' ";
  7842. }
  7843. if ($sku) {
  7844. $sku = trim($sku, ' ');
  7845. $sku = trim($sku, ' ');
  7846. $where .= " and sku like '%$sku%'";
  7847. }
  7848. if ($ktime && $jtime) {
  7849. if ($type == 1) {
  7850. $tl = '出库';
  7851. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7852. } else if ($type == 2) {
  7853. $tl = '退库';
  7854. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7855. } else if ($type == 3) {
  7856. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7857. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7858. } else if ($type == 4) {
  7859. $tl = '出库+零售';
  7860. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7861. } else if ($type == 5) {
  7862. $tl = '零售';
  7863. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7864. }
  7865. }
  7866. $sidwhere = '';
  7867. if ($sid) {
  7868. $sd = "";
  7869. $s = explode(',', trim($sid, ','));
  7870. foreach ($s as $value) {
  7871. $sd .= " id = " . $value . " or";
  7872. }
  7873. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7874. }
  7875. //数据排序
  7876. $order_str = "time desc";
  7877. if (empty($page)) {
  7878. $start = 0;
  7879. $perpage = 1;
  7880. } else {
  7881. $start = ($page - 1) * $perpage;
  7882. }
  7883. //取得信息列表
  7884. if ($type != 3 && $type != 5) {
  7885. if ($type == 1 || $type == 4) {
  7886. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7887. foreach ($info_list as $key => $value) {
  7888. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7889. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7890. $warehouse = $this->warehouse->read($value['warehouse']);
  7891. $info_list[$key]['warehouse'] = $warehouse['title'];
  7892. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7893. $features = explode('-', trim($features, '-'));
  7894. $pm = $classid;
  7895. foreach ($features as $k => $v) {
  7896. if ($v != 0) {
  7897. if (!isset($typeclass[$v])) {
  7898. continue;
  7899. }
  7900. if (isset($pm[$typeclass[$v]['classid']])) {
  7901. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7902. $tz = explode('|', $typeclass[$v]['zh']);
  7903. $pm[$typeclass[$v]['classid']] = $tz[0];
  7904. } else {
  7905. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7906. }
  7907. }
  7908. }
  7909. }
  7910. $zh = implode(" ", $pm);
  7911. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7912. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7913. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7914. $info_list[$key]['features'] = $zh;
  7915. }
  7916. $final_list = [];
  7917. foreach($info_list as $k=>$v){
  7918. $number = "";
  7919. if(!empty($v['orderinfo'])){
  7920. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7921. if(!empty($tmp_info['number'])){
  7922. $number = $tmp_info['number'];
  7923. }
  7924. }
  7925. $final_list[] = [
  7926. 'warehouse'=>$v['warehouse'],
  7927. 'purchase'=>$v['purchase'],
  7928. 'sku'=>$v['sku'],
  7929. 'title'=>$v['title'],
  7930. 'features'=>$v['features'],
  7931. 'label'=>$v['label'],
  7932. 'orderinfo'=>$v['orderinfo'],
  7933. 'number'=>$number,
  7934. 'waybill'=>$v['waybill'],
  7935. 'outk'=>$v['outk'],
  7936. ];
  7937. }
  7938. } else {
  7939. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7940. foreach ($info_list as $key => $value) {
  7941. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7942. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7943. $warehouse = $this->warehouse->read($value['warehouse']);
  7944. $info_list[$key]['warehouse'] = $warehouse['title'];
  7945. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7946. $features = explode('-', trim($features, '-'));
  7947. $pm = $classid;
  7948. foreach ($features as $k => $v) {
  7949. if ($v != 0) {
  7950. if (!isset($typeclass[$v])) {
  7951. continue;
  7952. }
  7953. if (isset($pm[$typeclass[$v]['classid']])) {
  7954. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7955. $tz = explode('|', $typeclass[$v]['zh']);
  7956. $pm[$typeclass[$v]['classid']] = $tz[0];
  7957. } else {
  7958. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7959. }
  7960. }
  7961. }
  7962. }
  7963. $zh = implode(" ", $pm);
  7964. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7965. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7966. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7967. $info_list[$key]['features'] = $zh;
  7968. }
  7969. $final_list = [];
  7970. foreach($info_list as $k=>$v){
  7971. $number = "";
  7972. if(!empty($v['orderinfo'])){
  7973. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7974. if(!empty($tmp_info['number'])){
  7975. $number = $tmp_info['number'];
  7976. }
  7977. }
  7978. $final_list[] = [
  7979. 'warehouse'=>$v['warehouse'],
  7980. 'purchase'=>$v['purchase'],
  7981. 'sku'=>$v['sku'],
  7982. 'title'=>$v['title'],
  7983. 'features'=>$v['features'],
  7984. 'label'=>$v['label'],
  7985. 'orderinfo'=>$v['orderinfo'],
  7986. 'number'=>$number,
  7987. 'waybill'=>$v['waybill'],
  7988. 'retreat'=>$v['retreat'],
  7989. ];
  7990. }
  7991. }
  7992. if(empty($final_list)){
  7993. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7994. }else{
  7995. $end_list = [];
  7996. foreach($final_list as $v){
  7997. $end_list[] = array_values($v);
  7998. }
  7999. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8000. array_unshift($end_list,[
  8001. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8002. ]);
  8003. array_unshift($end_list,[
  8004. $title,"","","","","","","","",""
  8005. ]);
  8006. $merges = [
  8007. [
  8008. "s"=>["r"=>0,"c"=>0],
  8009. "e"=>["r"=>0,"c"=>9]
  8010. ]
  8011. ];
  8012. $cols = [
  8013. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8014. ];
  8015. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8016. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8017. ] )));
  8018. }
  8019. } else if ($type == 5) {
  8020. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8021. foreach ($info_list as $key => $value) {
  8022. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8023. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8024. $warehouse = $this->warehouse->read($value['warehouse']);
  8025. $info_list[$key]['warehouse'] = $warehouse['title'];
  8026. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8027. $features = explode('-', trim($features, '-'));
  8028. $pm = $classid;
  8029. foreach ($features as $k => $v) {
  8030. if ($v != 0) {
  8031. if (!isset($typeclass[$v])) {
  8032. continue;
  8033. }
  8034. if (isset($pm[$typeclass[$v]['classid']])) {
  8035. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8036. $tz = explode('|', $typeclass[$v]['zh']);
  8037. $pm[$typeclass[$v]['classid']] = $tz[0];
  8038. } else {
  8039. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8040. }
  8041. }
  8042. }
  8043. }
  8044. $zh = implode(" ", $pm);
  8045. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8046. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8047. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8048. $info_list[$key]['features'] = $zh;
  8049. }
  8050. if(empty($info_list)){
  8051. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8052. }else{
  8053. $final_list = [];
  8054. foreach($info_list as $v){
  8055. $final_list[] = array_values($v);
  8056. }
  8057. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8058. array_unshift($final_list,[
  8059. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8060. ]);
  8061. array_unshift($final_list,[
  8062. $title,"","","","","","",
  8063. ]);
  8064. $merges = [
  8065. [
  8066. "s"=>["r"=>0,"c"=>0],
  8067. "e"=>["r"=>0,"c"=>6]
  8068. ]
  8069. ];
  8070. $cols = [
  8071. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8072. ];
  8073. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8074. }
  8075. } else {
  8076. $wh = array();
  8077. $w = $this->warehouse->find_all('1=1', 'id,title');
  8078. foreach ($w as $v) {
  8079. $wh[$v['id']] = $v['title'];
  8080. }
  8081. $wt = array();
  8082. $whlabel_type = $this->whlabel_type->find_all();
  8083. foreach ($whlabel_type as $v) {
  8084. $wt[$v['id']] = $v['title'];
  8085. }
  8086. $classid = $this->classid->sku();
  8087. $list = array();
  8088. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8089. foreach ($rows as $key => $value) {
  8090. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8091. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8092. $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');
  8093. $details = array();
  8094. $cpid = array();
  8095. $cpbz = array();
  8096. $c = 0;
  8097. $g = 0;
  8098. $x = 0;
  8099. $t = 0;
  8100. $s = 0;
  8101. $q = 0;
  8102. foreach ($sd as $k => $v) {
  8103. if ($v['state'] == 0) {
  8104. $c++;
  8105. }
  8106. if ($v['state'] != 9) {
  8107. $g++;
  8108. }
  8109. if ($v['outk'] > 1) {
  8110. $x++;
  8111. }
  8112. if ($v['retreat'] > 0) {
  8113. $t++;
  8114. }
  8115. if ($v['state'] == 8) {
  8116. $s++;
  8117. }
  8118. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8119. $q++;
  8120. }
  8121. $details[$v['details']] = $v['details'];
  8122. if ($v['cpid'] != 0) {
  8123. $cpid[$v['cpid']] = $v['cpid'];
  8124. }
  8125. if ($v['cpbz'] != '') {
  8126. $cpbz[$v['cpbz']] = $v['cpbz'];
  8127. }
  8128. }
  8129. if (isset($wt[$value['type']])) {
  8130. $rows[$key]['type'] = $wt[$value['type']];
  8131. } else {
  8132. $rows[$key]['type'] = '未设置';
  8133. }
  8134. $rows[$key]['details'] = implode("、", $details);
  8135. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8136. $ftime = time() - 15 * 24 * 3600;
  8137. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8138. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8139. $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);
  8140. $rows[$key]['c'] = $c;
  8141. $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);
  8142. $rows[$key]['t'] = $t;
  8143. $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'] . '"');
  8144. $rows[$key]['z'] = $z;
  8145. // $jm = $classid;
  8146. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8147. $features = explode('-', trim($features, '-'));
  8148. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8149. }
  8150. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8151. $final_list =[];
  8152. foreach($tmp_list as $k=>$v){
  8153. $final_list[] = [
  8154. "warehouse"=>$v['warehouse'],
  8155. "purchase"=>$v['purchase'],
  8156. "details"=>$v['details'],
  8157. "cpid"=>$v['cpid'],
  8158. "sku"=>$v['sku'],
  8159. "title"=>$v['title'],
  8160. "features"=>$v['pm'],
  8161. "cpbz"=>$v['cpbz'],
  8162. "sm"=>$v['sm'],
  8163. "type"=>$v['type'],
  8164. "g"=>$v["g"],
  8165. "c"=>$v["c"],
  8166. "x"=>$v["x"],
  8167. "t"=>$v["t"],
  8168. "z"=>$v["z"],
  8169. "jm"=>$v["jm"],
  8170. "weight"=>$v["weight"],
  8171. "asd"=>$v["asd"],
  8172. ];
  8173. }
  8174. if(empty($final_list)){
  8175. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8176. }else{
  8177. $end_list = [];
  8178. foreach($final_list as $v){
  8179. $end_list[] = array_values($v);
  8180. }
  8181. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8182. array_unshift($end_list,[
  8183. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8184. ]);
  8185. array_unshift($end_list,[
  8186. $title,"","","","","","","","","","","","","","","","","",""
  8187. ]);
  8188. $merges = [
  8189. [
  8190. "s"=>["r"=>0,"c"=>0],
  8191. "e"=>["r"=>0,"c"=>6]
  8192. ]
  8193. ];
  8194. $cols = [
  8195. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8196. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8197. ];
  8198. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8199. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8200. ])));
  8201. }
  8202. }
  8203. }
  8204. }
  8205. public function _exceljxcjs(){
  8206. $classid = $this->classid->sku();
  8207. $pm = $classid;
  8208. $typeclass = array();
  8209. $tc = $this->typeclass->find_all();
  8210. foreach ($tc as $v) {
  8211. $typeclass[$v['id']] = $v;
  8212. }
  8213. $prc = array();
  8214. $purchase = $this->purchase->find_all();
  8215. foreach ($purchase as $k => $v) {
  8216. $prc[$v['id']] = $v['title'];
  8217. }
  8218. if(!isset($_GET['excel'])){
  8219. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8220. }
  8221. $where = "sku != 'Preset'";
  8222. //数据排序
  8223. $order_str = "id desc";
  8224. if (empty($page)) {
  8225. $start = 0;
  8226. $perpage = 1;
  8227. } else {
  8228. $start = ($page - 1) * $perpage;
  8229. }
  8230. $category = $this->input->get('category', true);
  8231. $warehouse = $this->input->get('warehouse', true);
  8232. $excelid = $this->input->get('sid', true);
  8233. if ($category) {
  8234. $where .= " and features like '%-$category-%'";
  8235. }
  8236. if ($warehouse) {
  8237. $where .= " and warehouse = '$warehouse'";
  8238. }
  8239. $xzid = '';
  8240. if ($excelid) {
  8241. $excelid = explode(',', trim($excelid, ','));
  8242. foreach ($excelid as $key => $value) {
  8243. $xzid .= " id = " . $value . " or";
  8244. }
  8245. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8246. }
  8247. $wt = array();
  8248. $whlabel_type = $this->whlabel_type->find_all();
  8249. foreach ($whlabel_type as $v) {
  8250. $wt[$v['id']] = $v['title'];
  8251. }
  8252. $wh = array();
  8253. $w = $this->warehouse->find_all('1=1', 'id,title');
  8254. foreach ($w as $v) {
  8255. $wh[$v['id']] = $v['title'];
  8256. }
  8257. $list = array();
  8258. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8259. foreach ($rows as $key => $value) {
  8260. if (isset($wt[$value['type']])) {
  8261. $rows[$key]['type'] = $wt[$value['type']];
  8262. } else {
  8263. $rows[$key]['type'] = '未设置';
  8264. }
  8265. $bm = '03';
  8266. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8267. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8268. $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');
  8269. $details = array();
  8270. $cpid = array();
  8271. $cpbz = array();
  8272. $c = 0;
  8273. $g = 0;
  8274. $x = 0;
  8275. $t = 0;
  8276. $s = 0;
  8277. $q = 0;
  8278. foreach ($sd as $k => $v) {
  8279. if ($v['state'] == 0) {
  8280. $c++;
  8281. if ($v['cpid'] != 0) {
  8282. $cpid[$v['cpid']] = $v['cpid'];
  8283. }
  8284. if ($v['cpbz'] != '') {
  8285. $cpbz[$v['cpbz']] = $v['cpbz'];
  8286. }
  8287. }
  8288. if ($v['state'] != 9) {
  8289. $g++;
  8290. }
  8291. if ($v['state'] == 1) {
  8292. $x++;
  8293. }
  8294. if ($v['state'] == 2) {
  8295. $t++;
  8296. }
  8297. if ($v['state'] == 8) {
  8298. $s++;
  8299. }
  8300. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8301. $q++;
  8302. }
  8303. $details[$v['details']] = $v['details'];
  8304. }
  8305. $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'] . '"');
  8306. $rows[$key]['details'] = implode("、", $details);
  8307. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8308. $number = $value['number'];
  8309. $ftime = time() - 15 * 24 * 3600;
  8310. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8311. $rows[$key]['number'] = $g;
  8312. $rows[$key]['c'] = $c;
  8313. $rows[$key]['x'] = $x;
  8314. $rows[$key]['t'] = $t;
  8315. $rows[$key]['s'] = $s;
  8316. $rows[$key]['q'] = $q;
  8317. $rows[$key]['z'] = $z;
  8318. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8319. $features = explode('-', trim($features, '-'));
  8320. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8321. }
  8322. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8323. $final_list = [];
  8324. foreach ($list as $k => $v) {
  8325. if (empty($v['sku'])) {
  8326. continue;
  8327. }
  8328. $final_list[] = [
  8329. $v["warehouse"],
  8330. $v["purchase"],
  8331. $v["details"],
  8332. $v["cpid"],
  8333. $v["dbcontent"],
  8334. $v["sku"],
  8335. $v["bm"],
  8336. $v["jm"],
  8337. $v["title"],
  8338. $v["pm"],
  8339. $v["cpbz"],
  8340. $v["sm"],
  8341. $v["type"],
  8342. $v["number"],
  8343. $v["c"],
  8344. $v["x"],
  8345. $v["t"],
  8346. $v["s"],
  8347. $v["q"],
  8348. $v["z"],
  8349. $v['weight'],
  8350. ];
  8351. }
  8352. if(empty($final_list)){
  8353. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8354. }
  8355. $title = "总进销存统计表";
  8356. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8357. $merges = [
  8358. [
  8359. "s"=>["r"=>0,"c"=>0],
  8360. "e"=>["r"=>0,"c"=>21]
  8361. ]
  8362. ];
  8363. $cols = [
  8364. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8365. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8366. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8367. ];
  8368. array_unshift($final_list, $first_row);
  8369. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8370. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8371. }
  8372. public function _summaryjs($arg_array)
  8373. {
  8374. $prc = array();
  8375. $purchase = $this->purchase->find_all();
  8376. foreach ($purchase as $k => $v) {
  8377. $prc[$v['id']] = $v['title'];
  8378. }
  8379. if (isset($_GET['excel'])) {
  8380. $ktime = $this->input->get('ktime', true);
  8381. $jtime = $this->input->get('jtime', true);
  8382. $ktime = strtotime($ktime);
  8383. $jtime = strtotime($jtime);
  8384. $where = "1=1";
  8385. if ($ktime && $jtime) {
  8386. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8387. }
  8388. //数据排序
  8389. $order_str = "time desc";
  8390. if (empty($page)) {
  8391. $start = 0;
  8392. $perpage = 1;
  8393. } else {
  8394. $start = ($page - 1) * $perpage;
  8395. }
  8396. //取得信息列表
  8397. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8398. foreach ($info_list as $key => $value) {
  8399. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8400. $warehouse = $this->warehouse->read($value['warehouse']);
  8401. $info_list[$key]['warehouse'] = $warehouse['title'];
  8402. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8403. $details = array();
  8404. $cpid = array();
  8405. foreach ($x as $k => $v) {
  8406. if ($v['details'] != '') {
  8407. $details[$v['details']] = $v['details'];
  8408. }
  8409. if ($v['cpid'] != 0) {
  8410. $cpid[$v['cpid']] = $v['cpid'];
  8411. }
  8412. }
  8413. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8414. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8415. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8416. $info_list[$key]['s'] = $s;
  8417. $info_list[$key]['x'] = count($x);
  8418. }
  8419. if(empty($info_list)){
  8420. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8421. }
  8422. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8423. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8424. $merges = [
  8425. [
  8426. "s"=>["r"=>0,"c"=>0],
  8427. "e"=>["r"=>0,"c"=>7]
  8428. ]
  8429. ];
  8430. $cols = [
  8431. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8432. ];
  8433. $final_list = [];
  8434. foreach($info_list as $k => $v){
  8435. $final_list[] = array_values($v);
  8436. }
  8437. array_unshift($final_list, $first_row);
  8438. array_unshift($final_list,[
  8439. $title,"","","","","","","","",
  8440. ]);
  8441. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8442. $titlename = "<table border=1>
  8443. <tr align='center'>
  8444. <td>仓库</td>
  8445. <td>供应商</td>
  8446. <td>出库位置</td>
  8447. <td>出库编码</td>
  8448. <td>SKU</td>
  8449. <td>产品名</td>
  8450. <td>总剩余库存</td>
  8451. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8452. </tr>
  8453. </table>";
  8454. $filename = $title . ".xls";
  8455. $tail = "";
  8456. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8457. }
  8458. }
  8459. public function _uckjs()
  8460. {
  8461. if (isset($_GET['excel'])) {
  8462. $tc = array();
  8463. $typeclass = $this->typeclass->find_all();
  8464. foreach ($typeclass as $v) {
  8465. $tc[$v['id']] = $v['zh'];
  8466. }
  8467. $first_row = [
  8468. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8469. ];
  8470. $t = array();
  8471. $rq = '';
  8472. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8473. $ts = $ts / (24 * 3600);
  8474. for ($i = 0; $i < $ts; $i++) {
  8475. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8476. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8477. }
  8478. $day_len = count($t);
  8479. $first_row[] = "本月出库";
  8480. $merges = [
  8481. ];
  8482. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8483. $excel_key = 1;
  8484. $final_list = [];
  8485. foreach ($info_list as $k => $v) {
  8486. $features = explode('-', trim($v['features'], '-'));
  8487. if (!isset($features[3]) || !isset($features[4])) {
  8488. continue;
  8489. }
  8490. $tmp = [];
  8491. $tmp[0] = $tc[$features[0]]; //类型
  8492. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8493. $tmp[2] = $tc[$features[4]]; //曲度
  8494. $tmp[3] = '';
  8495. if (isset($data[$k][1])) {
  8496. $tmp[3] .=$tmp[1];
  8497. }
  8498. if (isset($data[$k][2])) {
  8499. $tmp[3] .= $tmp[2];
  8500. }
  8501. if (isset($features[5])) {
  8502. $tmp[3] .= $tc[$features[5]];
  8503. }
  8504. if (isset($features[2])) {
  8505. $tmp[3] .= $tc[$features[2]];
  8506. }
  8507. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8508. $tmp[4] = $v['sku'];
  8509. $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())) . '))'); //月初库存
  8510. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8511. $tmp[7] ="";
  8512. $tmp[8] ="";
  8513. $byck = 0;
  8514. foreach ($t as $vv) {
  8515. $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));
  8516. $tmp[] = ($sl > 0) ? $sl : '';
  8517. $byck += $sl;
  8518. }
  8519. $tmp[] = ($byck > 0) ? $byck : '';
  8520. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8521. // $ztrq = '';
  8522. // $ztsl = '';
  8523. // if (count($zt) > 0) {
  8524. // foreach ($zt as $vv) {
  8525. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8526. // $ztsl .= $vv['num'] . '<br>';
  8527. // }
  8528. // }
  8529. if(empty($zt)){
  8530. $final_list[] = $tmp;
  8531. $excel_key = $excel_key + 1;
  8532. }else{
  8533. $len = count($zt);
  8534. if($len == 1){
  8535. $tmp[7] = $zt[0]['num'] ;
  8536. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8537. $final_list[] = $tmp;
  8538. $excel_key = $excel_key + 1;
  8539. }else{
  8540. foreach($zt as $vv){
  8541. $tmp[7] = "";
  8542. $tmp[8] = "";
  8543. $tmp[7] = $vv['num'];
  8544. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8545. $final_list[] = $tmp;
  8546. }
  8547. $merges[] = [
  8548. "s"=>["r"=>$excel_key,"c"=>0],
  8549. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8550. ];
  8551. $merges[] = [
  8552. "s"=>["r"=>$excel_key,"c"=>1],
  8553. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8554. ];
  8555. $merges[] = [
  8556. "s"=>["r"=>$excel_key,"c"=>2],
  8557. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8558. ];
  8559. $merges[] = [
  8560. "s"=>["r"=>$excel_key,"c"=>3],
  8561. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8562. ];
  8563. $merges[] = [
  8564. "s"=>["r"=>$excel_key,"c"=>4],
  8565. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8566. ];
  8567. $merges[] = [
  8568. "s"=>["r"=>$excel_key,"c"=>5],
  8569. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8570. ];
  8571. $merges[] = [
  8572. "s"=>["r"=>$excel_key,"c"=>6],
  8573. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8574. ];
  8575. for($i=1;$i<=$day_len;$i++){
  8576. $merges[] = [
  8577. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8578. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8579. ];
  8580. }
  8581. $merges[] = [
  8582. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8583. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8584. ];
  8585. $excel_key = $excel_key + $len;
  8586. }
  8587. }
  8588. }
  8589. $title = "详情 " . date("Y-m-d", time());
  8590. if(empty($final_list)){
  8591. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8592. }
  8593. $cols = [
  8594. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8595. ];
  8596. array_unshift($final_list, $first_row);
  8597. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8598. }
  8599. }
  8600. public function _whlabelexcelzhjs(){
  8601. if(empty($_GET['excel'])){
  8602. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8603. }
  8604. $where = "sku != 'Preset' and sku != '' ";
  8605. //数据排序
  8606. $order_str = "id desc";
  8607. if (empty($page)) {
  8608. $start = 0;
  8609. $perpage = 1;
  8610. } else {
  8611. $start = ($page - 1) * $perpage;
  8612. }
  8613. $category = $this->input->get('category', true);
  8614. $warehouse = $this->input->get('warehouse', true);
  8615. $excelid = $this->input->get('sid', true);
  8616. if ($category) {
  8617. $where .= " and features like '%-$category-%'";
  8618. }
  8619. if ($warehouse) {
  8620. $where .= " and warehouse = '$warehouse'";
  8621. }
  8622. $xzid = '';
  8623. if ($excelid) {
  8624. $excelid = explode(',', trim($excelid, ','));
  8625. foreach ($excelid as $key => $value) {
  8626. $xzid .= " id = " . $value . " or";
  8627. }
  8628. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8629. }
  8630. $merges = [
  8631. [
  8632. "s"=>["r"=>0,"c"=>0],
  8633. "e"=>["r"=>0,"c"=>6]
  8634. ]
  8635. ];
  8636. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8637. $excel_index = 2;
  8638. $final_list = [];
  8639. foreach ($rows as $key => $value) {
  8640. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8641. $zh = '';
  8642. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8643. // foreach ($zt_list as $v) {
  8644. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8645. // }
  8646. $zt = array_sum(array_column($zt_list, 'num'));
  8647. $number = $value['number'];
  8648. $ftime = time() - 15 * 24 * 3600;
  8649. $warehouse = $this->warehouse->read($value['warehouse']);
  8650. // $rows[$key]['warehouse'] = $warehouse['title'];
  8651. // $rows[$key]['number'] = $c;
  8652. // $rows[$key]['features'] = $zh;
  8653. //$rows[$key]['hb'] = $c + $zt;
  8654. $tmp = [];
  8655. $tmp[0] = $warehouse['title'];
  8656. $tmp[1] = $value['sku'];
  8657. $tmp[2] = $value['title'];
  8658. $tmp[3] = $c;
  8659. $tmp[4] = "";
  8660. $tmp[5] = $c + $zt;
  8661. if(empty($zt_list)){
  8662. $tmp[4] = "";
  8663. $final_list[] = $tmp;
  8664. $excel_index = $excel_index + 1;
  8665. }else{
  8666. if(count($zt_list) == 1){
  8667. $tmp[4] = "";
  8668. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8669. $final_list[] = $tmp;
  8670. $excel_index = $excel_index + 1;
  8671. }else{
  8672. $len = count($zt_list);
  8673. foreach ($zt_list as $v){
  8674. $tmp[4] = "";
  8675. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8676. $final_list[] = $tmp;
  8677. }
  8678. $merges[] = [
  8679. "s"=>["r"=>$excel_index,"c"=>0],
  8680. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8681. ];
  8682. $merges[] = [
  8683. "s"=>["r"=>$excel_index,"c"=>1],
  8684. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8685. ];
  8686. $merges[] = [
  8687. "s"=>["r"=>$excel_index,"c"=>2],
  8688. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8689. ];
  8690. $merges[] = [
  8691. "s"=>["r"=>$excel_index,"c"=>3],
  8692. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8693. ];
  8694. $merges[] = [
  8695. "s"=>["r"=>$excel_index,"c"=>5],
  8696. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8697. ];
  8698. $excel_index = $excel_index + $len;
  8699. }
  8700. }
  8701. }
  8702. $first_row = [
  8703. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8704. ];
  8705. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8706. if(empty($final_list)){
  8707. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8708. }
  8709. $cols = [
  8710. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8711. ];
  8712. array_unshift($final_list, $first_row);
  8713. array_unshift($final_list, [
  8714. $title,"","","","",""
  8715. ]);
  8716. $end_list = [];
  8717. foreach ($final_list as $key => $value) {
  8718. $end_list[] = array_values($value);
  8719. }
  8720. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8721. }
  8722. //出库、退库导出
  8723. public function _dccrtypejs()
  8724. {
  8725. $classid = $this->classid->sku();
  8726. $pm = $classid;
  8727. $typeclass = array();
  8728. $tc = $this->typeclass->find_all();
  8729. foreach ($tc as $v) {
  8730. $typeclass[$v['id']] = $v;
  8731. }
  8732. $prc = array();
  8733. $purchase = $this->purchase->find_all();
  8734. foreach ($purchase as $k => $v) {
  8735. $prc[$v['id']] = $v['title'];
  8736. }
  8737. if (isset($_GET['sid'])) {
  8738. $wh = array();
  8739. $w = $this->warehouse->find_all('1=1', 'id,title');
  8740. foreach ($w as $v) {
  8741. $wh[$v['id']] = $v['title'];
  8742. }
  8743. $type = $this->input->get('excel', true);
  8744. $category = $this->input->get('category', true);
  8745. $size = $this->input->get('size', true);
  8746. $grade = $this->input->get('grade', true);
  8747. $color = $this->input->get('color', true);
  8748. $lowe = $this->input->get('lowe', true);
  8749. $sku = $this->input->get('sku', true);
  8750. $warehouse = $this->input->get('warehouse', true);
  8751. $lacetype = $this->input->get('lacetype', true);
  8752. $lacecolor = $this->input->get('lacecolor', true);
  8753. $density = $this->input->get('density', true);
  8754. $haircap = $this->input->get('haircap', true);
  8755. $purchase = $this->input->get('purchase', true);
  8756. $title = $this->input->get('title', true);
  8757. $state = $this->input->get('state', true);
  8758. $sid = $this->input->get('sid', true);
  8759. $ktime = $this->input->get('ktime', true);
  8760. $jtime = $this->input->get('jtime', true);
  8761. $ktime = strtotime($ktime);
  8762. $jtime = strtotime($jtime);
  8763. $where = "1=1";
  8764. $gj = "";
  8765. $ck = "";
  8766. if ($category) {
  8767. $where .= " and features like '%-$category-%'";
  8768. }
  8769. if ($size) {
  8770. $where .= " and features like '%-$size-%'";
  8771. }
  8772. if ($grade) {
  8773. $where .= " and features like '%-$grade-%'";
  8774. }
  8775. if ($color) {
  8776. $where .= " and features like '%-$color-%'";
  8777. }
  8778. if ($lowe) {
  8779. $where .= " and features like '%-$lowe-%'";
  8780. }
  8781. if ($warehouse) {
  8782. $where .= " and warehouse = '$warehouse'";
  8783. }
  8784. if ($purchase) {
  8785. $where .= " and purchase = '$purchase'";
  8786. }
  8787. if ($state) {
  8788. $where .= " and state = '$state'";
  8789. }
  8790. if ($lacetype) {
  8791. $where .= " and features like '%-$lacetype-%'";
  8792. }
  8793. if ($lacecolor) {
  8794. $where .= " and features like '%-$lacecolor-%'";
  8795. }
  8796. if ($density) {
  8797. $where .= " and features like '%-$density-%'";
  8798. }
  8799. if ($haircap) {
  8800. $where .= " and features like '%-$haircap-%'";
  8801. }
  8802. if ($title) {
  8803. $title = trim($title, ' ');
  8804. $title = trim($title, ' ');
  8805. $where .= " and title like '%$title%'";
  8806. }
  8807. if ($sku) {
  8808. $sku = trim($sku, ' ');
  8809. $sku = trim($sku, ' ');
  8810. $where .= " and sku like '%$sku%'";
  8811. }
  8812. if ($ktime && $jtime) {
  8813. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8814. }
  8815. $sidwhere = '';
  8816. if ($sid) {
  8817. $sd = "";
  8818. $s = explode(',', trim($sid, ','));
  8819. foreach ($s as $value) {
  8820. $sd .= " id = " . $value . " or";
  8821. }
  8822. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8823. }
  8824. //数据排序
  8825. $order_str = "time desc";
  8826. if (empty($page)) {
  8827. $start = 0;
  8828. $perpage = 1;
  8829. } else {
  8830. $start = ($page - 1) * $perpage;
  8831. }
  8832. $wh = array();
  8833. $w = $this->warehouse->find_all('1=1', 'id,title');
  8834. foreach ($w as $v) {
  8835. $wh[$v['id']] = $v['title'];
  8836. }
  8837. $wt = array();
  8838. $whlabel_type = $this->whlabel_type->find_all();
  8839. foreach ($whlabel_type as $v) {
  8840. $wt[$v['id']] = $v['title'];
  8841. }
  8842. $classid = $this->classid->sku();
  8843. $list = array();
  8844. $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');
  8845. foreach ($rows_r as $key => $value) {
  8846. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8847. $pm = $classid;
  8848. $jm = $classid;
  8849. $rows_r[$key]['enter'] = '入库';
  8850. $rows_r[$key]['time'] = $value['enter'];
  8851. if ($value['rktype'] == 1) {
  8852. $rows_r[$key]['rktype'] = '采购入库';
  8853. } else if ($value['rktype'] == 2) {
  8854. $rows_r[$key]['rktype'] = '盘盈调整';
  8855. } else if ($value['rktype'] == 3) {
  8856. $rows_r[$key]['rktype'] = '其他调整入库';
  8857. } else if ($value['rktype'] == 4) {
  8858. $rows_r[$key]['rktype'] = '其他调整入库';
  8859. } else if ($value['rktype'] == 5) {
  8860. $rows_r[$key]['rktype'] = '退库入库';
  8861. } else if ($value['rktype'] == 6) {
  8862. $rows_r[$key]['rktype'] = '退货可用入库';
  8863. } else if ($value['rktype'] == 7) {
  8864. $rows_r[$key]['rktype'] = '形态转换入库';
  8865. } else {
  8866. $rows_r[$key]['rktype'] = '';
  8867. }
  8868. $features = explode('-', trim($value['features'], '-'));
  8869. foreach ($features as $v) {
  8870. if (isset($typeclass[$v])) {
  8871. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8872. $pm[$typeclass[$v]['classid']] = $zh[0];
  8873. }
  8874. if (isset($typeclass[$v])) {
  8875. if (isset($jm[$typeclass[$v]['classid']])) {
  8876. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8877. }
  8878. }
  8879. }
  8880. $zh = implode(" ", $pm);
  8881. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8882. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8883. $rows_r[$key]['zh'] = $zh;
  8884. $jm = array_filter($jm);
  8885. $rows_r[$key]['features'] = implode("-", $jm);
  8886. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8887. }
  8888. $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');
  8889. foreach ($rows_c as $key => $value) {
  8890. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8891. $pm = $classid;
  8892. $jm = $classid;
  8893. $rows_c[$key]['time'] = $value['outk'];
  8894. $rows_c[$key]['outk'] = '出库';
  8895. if ($value['cktype'] == 1) {
  8896. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8897. } else if ($value['cktype'] == 2) {
  8898. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8899. } else if ($value['cktype'] == 3) {
  8900. $rows_c[$key]['cktype'] = '盘亏调整';
  8901. } else if ($value['cktype'] == 4) {
  8902. $rows_c[$key]['cktype'] = '其他调整出库';
  8903. } else if ($value['cktype'] == 5) {
  8904. $rows_c[$key]['cktype'] = '形态转换出库';
  8905. } else {
  8906. $rows_c[$key]['cktype'] = '';
  8907. }
  8908. unset($rows_c[$key]['state']);
  8909. $features = explode('-', trim($value['features'], '-'));
  8910. foreach ($features as $v) {
  8911. if (isset($typeclass[$v])) {
  8912. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8913. $pm[$typeclass[$v]['classid']] = $zh[0];
  8914. }
  8915. if (isset($typeclass[$v])) {
  8916. if (isset($jm[$typeclass[$v]['classid']])) {
  8917. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8918. }
  8919. }
  8920. }
  8921. $zh = implode(" ", $pm);
  8922. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8923. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8924. $rows_c[$key]['zh'] = $zh;
  8925. $jm = array_filter($jm);
  8926. $rows_c[$key]['features'] = implode("-", $jm);
  8927. $rows_c[$key]['number'] = 1;
  8928. }
  8929. $merged = $rows_r;
  8930. foreach ($rows_c as $key => $value) {
  8931. if (isset($merged[$key])) {
  8932. $merged[] = $value;
  8933. } else {
  8934. $merged[$key] = $value;
  8935. }
  8936. }
  8937. usort($merged, function ($a, $b) {
  8938. return $a['time'] - $b['time'];
  8939. });
  8940. foreach ($merged as $key => $value) {
  8941. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8942. }
  8943. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8944. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8945. $cols = [
  8946. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8947. ];
  8948. $final_list= [];
  8949. foreach($merged as $key => $value){
  8950. $final_list[] = array_values($value) ;
  8951. }
  8952. if(empty($merged)){
  8953. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8954. }
  8955. array_unshift($final_list, $first_row);
  8956. $end_list = [];
  8957. foreach ($final_list as $key => $value) {
  8958. $end_list[] = array_values($value);
  8959. }
  8960. $merges = [];
  8961. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8962. }
  8963. }
  8964. public function _errorexceljs()
  8965. {
  8966. $post = $this->input->post(NULL, TRUE);
  8967. if (isset($_GET['page'])) {
  8968. $page = $this->input->get('page', true);
  8969. $perpage = $this->input->get('perpage', true);
  8970. $sku = $this->input->get('sku', true);
  8971. $warehouse = $this->input->get('warehouse', true);
  8972. $ktime = $this->input->get('ktime', true);
  8973. $jtime = $this->input->get('jtime', true);
  8974. $ktime = strtotime($ktime);
  8975. $jtime = strtotime($jtime);
  8976. $where = "sku != 'Preset'";
  8977. $gj = '';
  8978. if ($sku) {
  8979. $where .= " and sku like '%$sku%'";
  8980. } else {
  8981. if ($ktime && $jtime) {
  8982. $gj = " and time > '$ktime' and time < '$jtime'";
  8983. }
  8984. }
  8985. if ($warehouse) {
  8986. $where .= " and warehouse = '$warehouse'";
  8987. }
  8988. //数据排序
  8989. $order_str = "id desc";
  8990. if (empty($page)) {
  8991. $start = 0;
  8992. $perpage = 1;
  8993. } else {
  8994. $start = ($page - 1) * $perpage;
  8995. }
  8996. //取得信息列表
  8997. $rows = array();
  8998. $list = array();
  8999. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9000. foreach ($info_list as $value) {
  9001. $warehouse = $this->warehouse->read($value['warehouse']);
  9002. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9003. $number = $value['number'];
  9004. $ftime = time() - 15 * 24 * 3600;
  9005. if ($c < 1) {
  9006. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9007. }
  9008. }
  9009. $title = "0库存汇总";
  9010. $first_row = ["仓库","SKU","产品","当前库存"];
  9011. $cols = [
  9012. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9013. ];
  9014. $final_list= [];
  9015. foreach($list as $key => $value){
  9016. $final_list[] = array_values($value) ;
  9017. }
  9018. if(empty($final_list)){
  9019. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9020. }
  9021. array_unshift($final_list, $first_row);
  9022. $merges = [];
  9023. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9024. }
  9025. }
  9026. }