Whlabel.php 316 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322
  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. $details[$v['details']] = $v['details'];
  1396. if ($v['state'] < 1) {
  1397. //$details[$v['details']] = $v['details'];
  1398. if ($v['cpid'] != 0) {
  1399. $cpid[$v['cpid']] = $v['cpid'];
  1400. }
  1401. }
  1402. if($v['state'] == 0){
  1403. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1404. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1405. }
  1406. if ($v['shop'] != '') {
  1407. $shop = explode(',', trim($v['shop'], ','));
  1408. foreach ($shop as $vv) {
  1409. if (!in_array($vv, $shop_list)) {
  1410. $shop_list[] = $vv;
  1411. }
  1412. }
  1413. }
  1414. }
  1415. }
  1416. foreach ($od as $k => $vv) {
  1417. $odid .= $k . '数量' . $vv;
  1418. }
  1419. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1420. $info_list[$key]['label'] = $value['sm'];
  1421. $number = $value['number'];
  1422. $ftime = time() - 15 * 24 * 3600;
  1423. $z = $z . '(' . $odid . ')'; //查看订单号
  1424. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1425. $info_list[$key]['features'] = $c;
  1426. $info_list[$key]['number'] = $ztdata;
  1427. $info_list[$key]['sm'] = $g;
  1428. $info_list[$key]['x'] = $x;
  1429. $info_list[$key]['t'] = $t;
  1430. $info_list[$key]['z'] = $z;
  1431. /**
  1432. foreach ($cdata as $k=>$v)
  1433. {
  1434. $details[$v['details']] = $v['details'];
  1435. if($v['cpid'] != 0)
  1436. {
  1437. $cpid[$v['cpid']] = $v['cpid'];
  1438. }
  1439. }
  1440. **/
  1441. $info_list[$key]['shop'] = '';
  1442. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1443. // if ($value['shop'] != '') {
  1444. // $shop = explode(',', trim($value['shop'], ','));
  1445. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1446. // }
  1447. $shop_list = array_unique($shop_list);
  1448. $shop_str = '';
  1449. foreach ($shop_list as $v) {
  1450. if(isset($sp[$v])){
  1451. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1452. }
  1453. }
  1454. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1455. /**
  1456. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1457. if(isset($companytitle[0]))
  1458. {
  1459. foreach ($companytitle as $k=>$v)
  1460. {
  1461. if($v['companytitle'] != '')
  1462. {
  1463. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1464. }
  1465. }
  1466. }
  1467. **/
  1468. }
  1469. $final_all_list = [];
  1470. foreach ($info_list as $k => $v) {
  1471. $final_all_list[] = [
  1472. 'id' => $v['id'],
  1473. "warehouse" => $v["warehouse"],
  1474. "purchase" => $v["purchase"],
  1475. "sku" => $v["sku"],
  1476. "title" => $v["title"] . "<br/>" . $v["pm"],
  1477. "details" => $v["details"],
  1478. "shop" => $v["shop"],
  1479. "cpbz" => $v["cpbz"],
  1480. 'label' => $v['label'],
  1481. "type" => $v["type"],
  1482. "features" => $v["features"],
  1483. "number" => $v["number"],
  1484. "sm" => $v["sm"],
  1485. "x" => $v["x"],
  1486. "t" => $v["t"],
  1487. "z" => $v["z"]
  1488. ];
  1489. }
  1490. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1491. $pagenum = ceil($total / $perpage);
  1492. $over = $total - ($start + $perpage);
  1493. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1494. echo json_encode($rows);
  1495. exit;
  1496. }
  1497. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1498. $this->data['shop'] = $wlshop;
  1499. $this->data['vip'] = $vip;
  1500. $this->_Template('whlabel_type', $this->data);
  1501. }
  1502. //美仓进销存浏览
  1503. public function _usatype()
  1504. {
  1505. if (isset($_SESSION['api'])) {
  1506. $user = $this->user->get_api($_SESSION['api']);
  1507. $usp = $user;
  1508. $fgshop = "";
  1509. $sid = "";
  1510. $wid = "";
  1511. $wtype = "";
  1512. $userwh = explode('|', trim($user['warehouse'], '|'));
  1513. foreach ($userwh as $value) {
  1514. $wid .= " id = " . $value . " or";
  1515. $wtype .= " type = " . $value . " or";
  1516. }
  1517. }
  1518. $prc = array();
  1519. $purchase = $this->purchase->find_all();
  1520. foreach ($purchase as $k => $v) {
  1521. $prc[$v['id']] = $v['title'];
  1522. }
  1523. $post = $this->input->post(NULL, TRUE);
  1524. if (isset($post['page'])) {
  1525. $page = $this->input->post('page', true);
  1526. $perpage = $this->input->post('perpage', true);
  1527. $category = $this->input->post('category', true);
  1528. $size = $this->input->post('size', true);
  1529. $grade = $this->input->post('grade', true);
  1530. $color = $this->input->post('color', true);
  1531. $lowe = $this->input->post('lowe', true);
  1532. $sku = $this->input->post('sku');
  1533. $title = $this->input->post('title');
  1534. $warehouse = $this->input->post('warehouse', true);
  1535. $usa = $this->input->post('usa', true);
  1536. $purchase = $this->input->post('purchase', true);
  1537. $lacetype = $this->input->post('lacetype', true);
  1538. $haircap = $this->input->post('haircap', true);
  1539. $density = $this->input->post('density', true);
  1540. $details = $this->input->post('details', true);
  1541. $state = $this->input->post('state', true);
  1542. $lacecolor = $this->input->post('lacecolor', true);
  1543. $cklx = $this->input->post('cklx', true);
  1544. $ktime = $this->input->post('ktime', true);
  1545. $jtime = $this->input->post('jtime', true);
  1546. $ktime = strtotime($ktime);
  1547. $jtime = strtotime($jtime);
  1548. $where = "1=1";
  1549. $gj = "";
  1550. $ck = "";
  1551. if ($lacetype) {
  1552. $where .= " and features like '%-$lacetype-%'";
  1553. }
  1554. if ($category) {
  1555. $where .= " and features like '%-$category-%'";
  1556. }
  1557. if ($size) {
  1558. $where .= " and features like '%-$size-%'";
  1559. }
  1560. if ($grade) {
  1561. $where .= " and features like '%-$grade-%'";
  1562. }
  1563. if ($color) {
  1564. $where .= " and features like '%-$color-%'";
  1565. }
  1566. if ($lowe) {
  1567. $where .= " and features like '%-$lowe-%'";
  1568. }
  1569. if ($haircap) {
  1570. $where .= " and features like '%-$haircap-%'";
  1571. }
  1572. if ($density) {
  1573. $where .= " and features like '%-$density-%'";
  1574. }
  1575. if ($lacecolor) {
  1576. $where .= " and features like '%-$lacecolor-%'";
  1577. }
  1578. if ($usa) {
  1579. if (!$warehouse) {
  1580. $where .= " and (warehouse = '5' or warehouse = '8')";
  1581. }
  1582. }
  1583. if ($warehouse) {
  1584. $where .= " and warehouse = '$warehouse'";
  1585. }
  1586. if ($details) {
  1587. $where .= " and details = '$details'";
  1588. }
  1589. if ($purchase) {
  1590. $where .= " and purchase = '$purchase'";
  1591. }
  1592. if ($state) {
  1593. $where .= " and state = '$state'";
  1594. }
  1595. $where_add = '';
  1596. if ($cklx) {
  1597. $shop = $this->shop->read($cklx);
  1598. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1599. }
  1600. if ($ktime && $jtime) {
  1601. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1602. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1603. }
  1604. //数据排序
  1605. $order_str = "id desc";
  1606. if (empty($page)) {
  1607. $start = 0;
  1608. $perpage = 1;
  1609. } else {
  1610. $start = ($page - 1) * $perpage;
  1611. }
  1612. if ($sku) {
  1613. $sku = trim($sku, ' ');
  1614. $sku = trim($sku, ' ');
  1615. $where .= " and sku like '%$sku%'";
  1616. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1617. } else if ($title) {
  1618. $title = trim($title, ' ');
  1619. $title = trim($title, ' ');
  1620. $where .= " and title like '%$title%'";
  1621. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1622. } else {
  1623. //$where .= " and time > '$ktime' and time < '$jtime'";
  1624. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1625. }
  1626. //取得信息列表
  1627. $rows = array();
  1628. $list = array();
  1629. foreach ($info_list as $key => $value) {
  1630. $warehouse = $this->warehouse->read($value['warehouse']);
  1631. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1632. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1633. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1635. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1636. $od = array();
  1637. $odid = '';
  1638. foreach ($z as $v) {
  1639. if (!isset($od[$v['zd']])) {
  1640. $od[$v['zd']] = 1; //所有数据sku
  1641. } else {
  1642. $od[$v['zd']] = $od[$v['zd']] + 1;
  1643. }
  1644. }
  1645. foreach ($od as $k => $vv) {
  1646. $odid .= $k . '数量' . $vv . ' ';
  1647. }
  1648. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1649. $info_list[$key]['features'] = $c;
  1650. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1651. $ztdata = '';
  1652. if (count($zt) > 0) {
  1653. foreach ($zt as $vv) {
  1654. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1655. }
  1656. }
  1657. $info_list[$key]['warehouse'] = $ztdata;
  1658. $info_list[$key]['g'] = $g;
  1659. $info_list[$key]['x'] = $x;
  1660. $info_list[$key]['t'] = $t;
  1661. $info_list[$key]['z'] = $z;
  1662. }
  1663. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1664. $pagenum = ceil($total / $perpage);
  1665. $over = $total - ($start + $perpage);
  1666. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1667. echo json_encode($rows);
  1668. exit;
  1669. }
  1670. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1671. $this->data['warehouse'] = $warehouse;
  1672. $this->_Template('whlabel_typeusa', $this->data);
  1673. }
  1674. //美仓进销存浏览
  1675. public function _usatypeapp()
  1676. {
  1677. $post = $this->input->post(NULL, TRUE);
  1678. if (isset($post['page'])) {
  1679. $page = $this->input->post('page', true);
  1680. $perpage = $this->input->post('perpage', true);
  1681. $sku = $this->input->post('sku', true);
  1682. $warehouse = 5;
  1683. $title = $this->input->post('title', true);
  1684. $state = $this->input->post('state', true);
  1685. $ktime = $this->input->post('ktime', true);
  1686. $jtime = $this->input->post('jtime', true);
  1687. $ktime = strtotime($ktime);
  1688. $jtime = strtotime($jtime);
  1689. $where = "1=1";
  1690. $gj = "";
  1691. $ck = "";
  1692. if ($title) {
  1693. $st = explode(' ', trim($title, ' '));
  1694. foreach ($st as $v) {
  1695. $where .= " and title like '%$v%'";
  1696. }
  1697. }
  1698. if ($warehouse) {
  1699. $where .= " and warehouse = '$warehouse'";
  1700. }
  1701. if ($state) {
  1702. $where .= " and state = '$state'";
  1703. }
  1704. if ($sku) {
  1705. $where .= " and sku like '%$sku%'";
  1706. }
  1707. if ($ktime && $jtime) {
  1708. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1709. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1710. }
  1711. //数据排序
  1712. $order_str = "id desc";
  1713. if (empty($page)) {
  1714. $start = 0;
  1715. $perpage = 1;
  1716. } else {
  1717. $start = ($page - 1) * $perpage;
  1718. }
  1719. //取得信息列表
  1720. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1721. $rows = array();
  1722. $list = array();
  1723. foreach ($info_list as $key => $value) {
  1724. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1725. }
  1726. $rowsdq = array_slice($rows, $start, $perpage);
  1727. foreach ($rowsdq as $value) {
  1728. $warehouse = $this->warehouse->read($value['warehouse']);
  1729. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1730. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1731. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1732. $od = array();
  1733. $odid = '';
  1734. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1735. }
  1736. $total = count($rows);
  1737. $pagenum = ceil($total / $perpage);
  1738. $over = $total - ($start + $perpage);
  1739. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1740. echo json_encode($rows);
  1741. exit;
  1742. }
  1743. $this->_Template('phone/p_usatypeapp', $this->data);
  1744. }
  1745. //入库操作
  1746. public function _enteradd()
  1747. {
  1748. $dt = 0;
  1749. if (isset($_SESSION['api'])) {
  1750. $user = $this->user->get_api($_SESSION['api']);
  1751. $usp = $user;
  1752. $fgshop = "";
  1753. $sid = "";
  1754. $user = explode('|', trim($user['shop'], '|'));
  1755. foreach ($user as $value) {
  1756. $fgshop .= " shop = " . $value . " or";
  1757. $sid .= " id = " . $value . " or";
  1758. }
  1759. }
  1760. $tc = $this->typeclass->find_all();
  1761. $typeclass = array();
  1762. foreach ($tc as $v) {
  1763. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1764. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1765. }
  1766. $post = $this->input->post(NULL, TRUE);
  1767. if (isset($post['sku'])) {
  1768. $list = array();
  1769. $num = "";
  1770. $title = "";
  1771. $features = "";
  1772. $order = $this->input->post('order', true);
  1773. $shop = $this->input->post('shop', true);
  1774. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1775. $sku = $this->input->post('sku', true);
  1776. $post['sm'] = $this->input->post('sm', true);
  1777. $post['warehouse'] = $this->input->post('warehouse', true);
  1778. $post['purchase'] = $this->input->post('purchase', true);
  1779. $post['retreatwarehouse'] = $post['warehouse'];
  1780. $post['state'] = $this->input->post('state', true);
  1781. $post['rktype'] = $this->input->post('rktype', true);
  1782. $post['text'] = $this->input->post('text', true);
  1783. $category = $this->input->post('category', true);
  1784. $list['category'] = $category;
  1785. $list['hairtype'] = $this->input->post('hairtype', true);
  1786. $list['grade'] = $this->input->post('grade', true);
  1787. $size = $this->input->post('size', true);
  1788. $xzsku = $this->input->post('xzsku', true);
  1789. $list['size'] = rtrim($size, ',');
  1790. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1791. $list['extension'] = $this->input->post('extension', true);
  1792. if ($category == 1297) {
  1793. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1794. }
  1795. if ($category == 1702) {
  1796. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1797. $list['syother'] = $this->input->post('syother', true);
  1798. }
  1799. if ($category == 133) {
  1800. $list['fittype'] = $this->input->post('fittype', true);
  1801. $list['acother'] = $this->input->post('acother', true);
  1802. }
  1803. $list['color'] = $this->input->post('color', true);
  1804. $list['lowe'] = $this->input->post('lowe', true);
  1805. if (!$post['purchase']) {
  1806. $post['purchase'] = 1;
  1807. }
  1808. if ($category == 127) {
  1809. $list['type'] = $this->input->post('type', true);
  1810. $list['headroad'] = $this->input->post('headroad', true);
  1811. $list['density'] = $this->input->post('density', true);
  1812. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1813. $list['lacesize'] = $this->input->post('lacesize', true);
  1814. }
  1815. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1816. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1817. }
  1818. if ($category == 128) {
  1819. $list['lacetype'] = $this->input->post('lacetype', true);
  1820. $list['haircap'] = $this->input->post('haircap', true);
  1821. $list['density'] = $this->input->post('density', true);
  1822. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1823. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1824. $list['wigother'] = $this->input->post('wigother', true);
  1825. $list['wigother1'] = $this->input->post('wigother1', true);
  1826. $list['wigother2'] = $this->input->post('wigother2', true);
  1827. }
  1828. if ($category == 129) {
  1829. $list['wide'] = $this->input->post('wide', true);
  1830. }
  1831. if ($category == 131) {
  1832. $list['gifttype'] = $this->input->post('gifttype', true);
  1833. $list['giftother'] = $this->input->post('giftother', true);
  1834. }
  1835. if ($category == 134) {
  1836. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1837. }
  1838. if ($category == 1297) {
  1839. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1840. $list['sywigother'] = $this->input->post('sywigother', true);
  1841. }
  1842. if ($category == 130 || $category == 133 || $category == 1702) {
  1843. $list['items'] = $this->input->post('items', true);
  1844. $list['weight'] = $this->input->post('weight', true);
  1845. }
  1846. if($category == 130){
  1847. $list['jfother'] = $this->input->post('jfother', true);
  1848. }
  1849. if ($category == 1702) {
  1850. $list['syhairther'] = $this->input->post('syhairther', true);
  1851. }
  1852. $classid = $this->classid->sku();
  1853. $scsku = $classid;
  1854. $pm = $classid;
  1855. foreach ($list as $k => $v) {
  1856. if ($v != 0) {
  1857. $num .= $v;
  1858. $features .= $v . '-';
  1859. $post[$k] = $v;
  1860. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1861. if ($k != 'size') {
  1862. $title .= $typeclass[$v]['title'] . " ";
  1863. }
  1864. if (isset($pm[$typeclass[$v]['classid']])) {
  1865. if ($typeclass[$v]['title'] == '9A') {
  1866. $pm[$typeclass[$v]['classid']] = '9A';
  1867. } else if ($typeclass[$v]['title'] == '10A') {
  1868. $pm[$typeclass[$v]['classid']] = '10A';
  1869. } else {
  1870. $clzh = $typeclass[$v]['zh'];
  1871. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1872. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1873. $clzh = $clzh[0];
  1874. }
  1875. $pm[$typeclass[$v]['classid']] = $clzh;
  1876. }
  1877. }
  1878. }
  1879. }
  1880. $zh = implode(" ", $pm);
  1881. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1882. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1883. if ($list['size']) {
  1884. $typeclass = $this->typeclass->read($list['size']);
  1885. $title .= $typeclass['title'];
  1886. }
  1887. $time = time();
  1888. if ($xzsku) {
  1889. $scsku = implode("-", $scsku);
  1890. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1891. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1892. $post['sku'] = trim($scsku, ' ');
  1893. } else {
  1894. $post['sku'] = $sku;
  1895. }
  1896. //$post['sku'] = trim($sku,' ');
  1897. $post['title'] = rtrim($title, ' ');
  1898. $post['number'] = $num;
  1899. $post['features'] = '-' . $features;
  1900. $post['enter'] = $time;
  1901. $post['time'] = $time; //操作时间
  1902. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1903. if ($yza) {
  1904. if ($post['features'] != $yza[0]['features']) {
  1905. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1906. exit;
  1907. }
  1908. }
  1909. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1910. if ($yzb) {
  1911. if ($post['sku'] != $yzb[0]['sku']) {
  1912. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1913. exit;
  1914. }
  1915. }
  1916. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1917. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1918. exit;
  1919. }
  1920. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1921. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1922. exit;
  1923. }
  1924. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1925. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1926. exit;
  1927. }
  1928. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1929. if (isset($yz[0]['type'])) {
  1930. $post['type'] = $yz[0]['type'];
  1931. }
  1932. if ($post['state'] == 9) //如果选择预设库存
  1933. {
  1934. $this->whlabel->insert($post);
  1935. } else {
  1936. /**
  1937. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1938. if($ljg == 1)
  1939. {
  1940. for($i=0;$i<$order;$i++)
  1941. {
  1942. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1943. $this->whlabel->insert($post);
  1944. }
  1945. }
  1946. **/
  1947. //if($post['warehouse'] == '5')
  1948. //{
  1949. //}
  1950. $yydata = $post;
  1951. $yydata['zh'] = $zh;
  1952. /**
  1953. $wl = $this->apiyy->get_cjlp($yydata);
  1954. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1955. {
  1956. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1957. }
  1958. if($wl['Data'][0]['m_isSucess'] != 1)
  1959. {
  1960. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1961. }
  1962. **/
  1963. for ($i = 0; $i < $order; $i++) {
  1964. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1965. $this->whlabel->insert($post);
  1966. }
  1967. }
  1968. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1969. exit;
  1970. }
  1971. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1972. $this->data['wlshop'] = $wlshop;
  1973. $this->_Template('whlabel_enteradd', $this->data);
  1974. }
  1975. //修改产品
  1976. public function _enteredit($arg_array)
  1977. {
  1978. $dt = 0;
  1979. if (isset($_SESSION['api'])) {
  1980. $user = $this->user->get_api($_SESSION['api']);
  1981. $usp = $user;
  1982. $fgshop = "";
  1983. $sid = "";
  1984. $user = explode('|', trim($user['shop'], '|'));
  1985. foreach ($user as $value) {
  1986. $fgshop .= " shop = " . $value . " or";
  1987. $sid .= " id = " . $value . " or";
  1988. }
  1989. }
  1990. $post = $this->input->post(NULL, TRUE);
  1991. if (isset($post['sku'])) {
  1992. $list = array();
  1993. $num = "";
  1994. $title = "";
  1995. $features = "";
  1996. $id = $this->input->post('id', true);
  1997. $order = $this->input->post('order', true);
  1998. $shop = $this->input->post('shop', true);
  1999. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2000. $post['sku'] = $this->input->post('sku', true);
  2001. $post['sm'] = $this->input->post('sm', true);
  2002. $post['warehouse'] = $this->input->post('warehouse', true);
  2003. $post['purchase'] = $this->input->post('purchase', true);
  2004. $post['retreatwarehouse'] = $post['warehouse'];
  2005. $category = $this->input->post('category', true);
  2006. $list['category'] = $category;
  2007. $list['hairtype'] = $this->input->post('hairtype', true);
  2008. $list['grade'] = $this->input->post('grade', true);
  2009. $size = $this->input->post('size', true);
  2010. $list['size'] = rtrim($size, ',');
  2011. $post['rktype'] = $this->input->post('rktype', true);
  2012. $post['text'] = $this->input->post('text', true);
  2013. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2014. $list['extension'] = $this->input->post('extension', true);
  2015. if ($category == 1297) {
  2016. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2017. }
  2018. if ($category == 1702) {
  2019. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2020. $list['syother'] = $this->input->post('syother', true);
  2021. }
  2022. if ($category == 133) {
  2023. $list['fittype'] = $this->input->post('fittype', true);
  2024. $list['acother'] = $this->input->post('acother', true);
  2025. }
  2026. $list['color'] = $this->input->post('color', true);
  2027. $list['lowe'] = $this->input->post('lowe', true);
  2028. if (!$post['purchase']) {
  2029. $post['purchase'] = 1;
  2030. }
  2031. if ($category == 127) {
  2032. $list['type'] = $this->input->post('type', true);
  2033. $list['headroad'] = $this->input->post('headroad', true);
  2034. $list['density'] = $this->input->post('density', true);
  2035. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2036. $list['lacesize'] = $this->input->post('lacesize', true);
  2037. }
  2038. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2039. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2040. }
  2041. if ($category == 128) {
  2042. $list['lacetype'] = $this->input->post('lacetype', true);
  2043. $list['haircap'] = $this->input->post('haircap', true);
  2044. $list['density'] = $this->input->post('density', true);
  2045. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2046. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2047. $list['wigother'] = $this->input->post('wigother', true);
  2048. $list['wigother1'] = $this->input->post('wigother1', true);
  2049. $list['wigother2'] = $this->input->post('wigother2', true);
  2050. }
  2051. if ($category == 129) {
  2052. $list['wide'] = $this->input->post('wide', true);
  2053. }
  2054. if ($category == 131) {
  2055. $list['gifttype'] = $this->input->post('gifttype', true);
  2056. $list['giftother'] = $this->input->post('giftother', true);
  2057. }
  2058. if ($category == 134) {
  2059. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2060. }
  2061. if ($category == 1297) {
  2062. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2063. $list['sywigother'] = $this->input->post('sywigother', true);
  2064. }
  2065. if ($category == 130 || $category == 133 || $category == 1702) {
  2066. $list['items'] = $this->input->post('items', true);
  2067. $list['weight'] = $this->input->post('weight', true);
  2068. }
  2069. if($category == 130){
  2070. $list['jfother'] = $this->input->post('jfother', true);
  2071. }
  2072. if ($category == 1702) {
  2073. $list['syhairther'] = $this->input->post('syhairther', true);
  2074. }
  2075. foreach ($list as $k => $v) {
  2076. if ($v != 0) {
  2077. $num .= $v;
  2078. $features .= $v . '-';
  2079. $typeclass = $this->typeclass->read($v);
  2080. if ($k != 'size') {
  2081. $title .= $typeclass['title'] . " ";
  2082. }
  2083. }
  2084. }
  2085. $typeclass = $this->typeclass->read($list['size']);
  2086. $title .= $typeclass['title'];
  2087. $time = time();
  2088. $post['title'] = rtrim($title, ' ');
  2089. $post['number'] = $num;
  2090. $post['features'] = '-' . $features;
  2091. $post['time'] = $time; //操作时间
  2092. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2093. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2094. exit;
  2095. }
  2096. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2097. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2098. exit;
  2099. }
  2100. $uid = $this->whlabel->read($id);
  2101. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2102. if ($datanum > 0) {
  2103. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2104. exit;
  2105. }
  2106. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2107. {
  2108. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2109. if ($yza) {
  2110. if ($post['features'] != $yza[0]['features']) {
  2111. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2112. exit;
  2113. }
  2114. }
  2115. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2116. if ($yzb) {
  2117. if ($post['sku'] != $yzb[0]['sku']) {
  2118. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2119. exit;
  2120. }
  2121. }
  2122. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2123. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2124. exit;
  2125. }
  2126. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2127. foreach ($data as $v) {
  2128. $post['id'] = $v['id'];
  2129. $this->whlabel->save($post, $v['id']);
  2130. }
  2131. } else {
  2132. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2133. if ($data > 0) {
  2134. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2135. exit;
  2136. } else {
  2137. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2138. foreach ($data as $v) {
  2139. $post['id'] = $v['id'];
  2140. $this->whlabel->save($post, $v['id']);
  2141. }
  2142. }
  2143. }
  2144. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2145. exit;
  2146. }
  2147. $uid = $this->whlabel->read($arg_array[0]);
  2148. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2149. $this->data['enter'] = $uid;
  2150. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2151. $this->data['wlshop'] = $wlshop;
  2152. $this->_Template('whlabel_enteredit', $this->data);
  2153. }
  2154. //入库浏览
  2155. public function _enter()
  2156. {
  2157. $post = $this->input->post(NULL, TRUE);
  2158. if (isset($post['s'])) {
  2159. $id_arr = $this->input->post('s');
  2160. $id_arr = explode(',', $id_arr);
  2161. if (!$id_arr) {
  2162. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2163. exit;
  2164. }
  2165. //循环删除记录
  2166. foreach ($id_arr as $v) {
  2167. $sid = $this->whlabel->read($v);
  2168. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2169. if ($count > 0) {
  2170. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2171. exit;
  2172. }
  2173. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2174. foreach ($info_list as $va) {
  2175. $this->whlabel->remove($va['id']);
  2176. }
  2177. }
  2178. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2179. exit;
  2180. }
  2181. $sp = array();
  2182. $s = $this->shop->find_all('1=1', 'id,shopname');
  2183. foreach ($s as $v) {
  2184. $sp[$v['id']] = $v['shopname'];
  2185. }
  2186. $wh = array();
  2187. $w = $this->warehouse->find_all('1=1', 'id,title');
  2188. foreach ($w as $v) {
  2189. $wh[$v['id']] = $v['title'];
  2190. }
  2191. if (isset($post['page'])) {
  2192. $page = $this->input->post('page', true);
  2193. $perpage = $this->input->post('perpage', true);
  2194. $category = $this->input->post('category', true);
  2195. $size = $this->input->post('size', true);
  2196. $grade = $this->input->post('grade', true);
  2197. $color = $this->input->post('color', true);
  2198. $lowe = $this->input->post('lowe', true);
  2199. $sku = $this->input->post('sku', true);
  2200. $warehouse = $this->input->post('warehouse', true);
  2201. $purchase = $this->input->post('purchase', true);
  2202. $ktime = $this->input->post('ktime', true);
  2203. $jtime = $this->input->post('jtime', true);
  2204. $ktime = strtotime($ktime);
  2205. $jtime = strtotime($jtime);
  2206. $where = "1=1";
  2207. $gj = "";
  2208. $ck = "";
  2209. if ($category) {
  2210. $where .= " and features like '%-$category-%'";
  2211. }
  2212. if ($size) {
  2213. $where .= " and features like '%-$size-%'";
  2214. }
  2215. if ($grade) {
  2216. $where .= " and features like '%-$grade-%'";
  2217. }
  2218. if ($color) {
  2219. $where .= " and features like '%-$color-%'";
  2220. }
  2221. if ($lowe) {
  2222. $where .= " and features like '%-$lowe-%'";
  2223. }
  2224. if ($warehouse) {
  2225. $where .= " and warehouse = '$warehouse'";
  2226. }
  2227. if ($purchase) {
  2228. $where .= " and purchase = '$purchase'";
  2229. }
  2230. if ($sku) {
  2231. $where .= " and sku like '%$sku%'";
  2232. }
  2233. if ($ktime && $jtime) {
  2234. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2235. }
  2236. //数据排序
  2237. $order_str = "enter desc";
  2238. if (empty($page)) {
  2239. $start = 0;
  2240. $perpage = 1;
  2241. } else {
  2242. $start = ($page - 1) * $perpage;
  2243. }
  2244. //取得信息列表
  2245. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2246. foreach ($info_list as $k => $v) {
  2247. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2248. if ($v['shop'] == '') {
  2249. $s = '通用';
  2250. } else {
  2251. $info_list[$k]['shop'] = '';
  2252. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2253. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2254. }
  2255. }
  2256. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2257. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2258. $info_list[$k]['g'] = $g;
  2259. }
  2260. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2261. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2262. $pagenum = ceil($total / $perpage);
  2263. $over = $total - ($start + $perpage);
  2264. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2265. echo json_encode($rows);
  2266. exit;
  2267. }
  2268. $this->_Template('whlabel_enter', $this->data);
  2269. }
  2270. //出库浏览
  2271. public function _out()
  2272. {
  2273. $post = $this->input->post(NULL, TRUE);
  2274. if (isset($post['page'])) {
  2275. $page = $this->input->post('page', true);
  2276. $perpage = $this->input->post('perpage', true);
  2277. $category = $this->input->post('category', true);
  2278. $size = $this->input->post('size', true);
  2279. $grade = $this->input->post('grade', true);
  2280. $color = $this->input->post('color', true);
  2281. $lowe = $this->input->post('lowe', true);
  2282. $sku = $this->input->post('sku', true);
  2283. $warehouse = $this->input->post('warehouse', true);
  2284. $purchase = $this->input->post('purchase', true);
  2285. $state = $this->input->post('state', true);
  2286. $ktime = $this->input->post('ktime', true);
  2287. $jtime = $this->input->post('jtime', true);
  2288. $ktime = strtotime($ktime);
  2289. $jtime = strtotime($jtime);
  2290. $where = "state=3";
  2291. $gj = "";
  2292. $ck = "";
  2293. if ($category) {
  2294. $where .= " and features like '%-$category-%'";
  2295. }
  2296. if ($size) {
  2297. $where .= " and features like '%-$size-%'";
  2298. }
  2299. if ($grade) {
  2300. $where .= " and features like '%-$grade-%'";
  2301. }
  2302. if ($color) {
  2303. $where .= " and features like '%-$color-%'";
  2304. }
  2305. if ($lowe) {
  2306. $where .= " and features like '%-$lowe-%'";
  2307. }
  2308. if ($state) {
  2309. $where .= " and state = '$state'";
  2310. }
  2311. if ($warehouse) {
  2312. $where .= " and warehouse = '$warehouse'";
  2313. }
  2314. if ($purchase) {
  2315. $where .= " and purchase = '$purchase'";
  2316. }
  2317. if ($sku) {
  2318. $where .= " and sku = '$sku'";
  2319. }
  2320. if ($ktime && $jtime) {
  2321. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2322. }
  2323. //数据排序
  2324. $order_str = "id desc";
  2325. if (empty($page)) {
  2326. $start = 0;
  2327. $perpage = 1;
  2328. } else {
  2329. $start = ($page - 1) * $perpage;
  2330. }
  2331. //取得信息列表
  2332. $info_list = $this->whlabel->find_all($where, 'sku');
  2333. $rows = array();
  2334. $list = array();
  2335. foreach ($info_list as $key => $value) {
  2336. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2337. }
  2338. $rows = array_unique($rows); //删除重复记录
  2339. foreach ($rows as $key => $value) {
  2340. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2341. $ck = $this->warehouse->read($data['warehouse']);
  2342. $warehouse = $ck['title'];
  2343. $gy = $this->purchase->read($data['purchase']);
  2344. $purchase = $gy['purchase'];
  2345. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2346. $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);
  2347. }
  2348. $total = count($list);
  2349. $pagenum = ceil($total / $perpage);
  2350. $over = $total - ($start + $perpage);
  2351. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2352. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2353. echo json_encode($rows);
  2354. exit;
  2355. }
  2356. $this->_Template('whlabel_out', $this->data);
  2357. }
  2358. //出库标签浏览
  2359. public function _label()
  2360. {
  2361. $post = $this->input->post(NULL, TRUE);
  2362. if (isset($post['page'])) {
  2363. $page = $this->input->post('page', true);
  2364. $perpage = $this->input->post('perpage', true);
  2365. $sku = $this->input->post('sku', true);
  2366. $warehouse = $this->input->post('warehouse', true);
  2367. $purchase = $this->input->post('purchase', true);
  2368. $orderinfo = $this->input->post('orderinfo', true);
  2369. $waybill = $this->input->post('waybill', true);
  2370. $category = $this->input->post('category', true);
  2371. $size = $this->input->post('size', true);
  2372. $grade = $this->input->post('grade', true);
  2373. $color = $this->input->post('color', true);
  2374. $lowe = $this->input->post('lowe', true);
  2375. $where = "state=1";
  2376. if ($sku) {
  2377. $where .= " and sku = '$sku'";
  2378. }
  2379. if ($warehouse) {
  2380. $where .= " and warehouse = '$warehouse'";
  2381. }
  2382. if ($purchase) {
  2383. $where .= " and purchase = '$purchase'";
  2384. }
  2385. if ($orderinfo) {
  2386. $where .= " and orderinfo = '$orderinfo'";
  2387. }
  2388. if ($waybill) {
  2389. $where .= " and waybill = '$waybill'";
  2390. }
  2391. if ($category) {
  2392. $where .= " and features like '%-$category-%'";
  2393. }
  2394. if ($size) {
  2395. $where .= " and features like '%-$size-%'";
  2396. }
  2397. if ($grade) {
  2398. $where .= " and features like '%-$grade-%'";
  2399. }
  2400. if ($color) {
  2401. $where .= " and features like '%-$color-%'";
  2402. }
  2403. if ($lowe) {
  2404. $where .= " and features like '%-$lowe-%'";
  2405. }
  2406. //数据排序
  2407. $order_str = "outk desc";
  2408. if (empty($page)) {
  2409. $start = 0;
  2410. $perpage = 1;
  2411. } else {
  2412. $start = ($page - 1) * $perpage;
  2413. }
  2414. //取得信息列表
  2415. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2416. foreach ($info_list as $key => $value) {
  2417. $warehouse = $this->warehouse->read($value['warehouse']);
  2418. $info_list[$key]['warehouse'] = $warehouse['title'];
  2419. $purchase = $this->purchase->read($value['purchase']);
  2420. $info_list[$key]['purchase'] = $purchase['title'];
  2421. if ($value['outk'] != 0) {
  2422. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2423. } else {
  2424. $info_list[$key]['outk'] = "";
  2425. }
  2426. if ($value['orderinfo'] == 0) {
  2427. $info_list[$key]['orderinfo'] = "";
  2428. }
  2429. if ($value['waybill'] == 0) {
  2430. $info_list[$key]['waybill'] = "";
  2431. }
  2432. }
  2433. $total = $this->whlabel->find_count($where);
  2434. $pagenum = ceil($total / $perpage);
  2435. $over = $total - ($start + $perpage);
  2436. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2437. echo json_encode($rows);
  2438. exit;
  2439. }
  2440. $this->_Template('whlabel_label', $this->data);
  2441. }
  2442. //独立站出库订单
  2443. public function _outorder()
  2444. {
  2445. if (isset($_SESSION['api'])) {
  2446. $user = $this->user->get_api($_SESSION['api']);
  2447. $usp = $user;
  2448. $fgshop = "";
  2449. $sid = "";
  2450. $user = explode('|', trim($user['shop'], '|'));
  2451. foreach ($user as $value) {
  2452. $fgshop .= " shop = " . $value . " or";
  2453. $sid .= " id = " . $value . " or";
  2454. }
  2455. } else {
  2456. echo "请重新登录";
  2457. }
  2458. $post = $this->input->post(NULL, TRUE);
  2459. if (isset($post['page'])) {
  2460. $page = $this->input->post('page', true);
  2461. $perpage = $this->input->post('perpage', true);
  2462. $warehouse = $this->input->post('warehouse', true);
  2463. $xztime = $this->input->post('xztime', true);
  2464. $timetk = $this->input->post('timetkk', true);
  2465. $timetj = $this->input->post('timetjj', true);
  2466. $shop = $this->input->post('shop', true);
  2467. $source = $this->input->post('source', true);
  2468. $orderinfo = $this->input->post('orderinfo', true);
  2469. $number = $this->input->post('number', true);
  2470. $sfxh = $this->input->post('sfxh', true);
  2471. $express = $this->input->post('express', true);
  2472. $waybill = $this->input->post('waybill', true);
  2473. $library = $this->input->post('library', true);
  2474. $country = $this->input->post('country', true);
  2475. $so = $this->input->post('so', true);
  2476. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2477. $print = $this->input->post('print', true);
  2478. $state = $this->input->post('state', true);
  2479. $orderurl = $this->input->post('orderurl', true);
  2480. $productid = $this->input->post('productid', true);
  2481. $timetk = strtotime($timetk);
  2482. $timetj = strtotime($timetj);
  2483. /**
  2484. $sj = $this->input->post('sj',true);
  2485. if($sj)
  2486. {
  2487. $sj = $this->input->post('sj',true);
  2488. }
  2489. else
  2490. {
  2491. $sj = "fullorder";
  2492. }
  2493. **/
  2494. $sj = "fullorder";
  2495. $where = "1=1";
  2496. if ($warehouse) {
  2497. $where .= " and type = '$warehouse'";
  2498. }
  2499. if ($timetk && $timetj) {
  2500. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2501. }
  2502. if ($orderinfo) {
  2503. $where .= " and orderinfo = '$orderinfo'";
  2504. }
  2505. if ($number) {
  2506. $where .= " and number = '$number'";
  2507. }
  2508. if ($express) {
  2509. $where .= " and express = '$express'";
  2510. }
  2511. if ($waybill) {
  2512. $where .= " and waybill = '$waybill'";
  2513. }
  2514. if ($library) {
  2515. $where .= " and library = '$library'";
  2516. }
  2517. if ($print) {
  2518. $where .= " and print = '$print'";
  2519. }
  2520. if ($libraryconfirm) {
  2521. $where .= " and libraryconfirm = '$libraryconfirm'";
  2522. }
  2523. if ($state) {
  2524. $where .= " and state = '$state'";
  2525. }
  2526. if ($shop) {
  2527. $where .= " and shop = '$shop'";
  2528. }
  2529. if ($country) {
  2530. $where .= " and country = '$country'";
  2531. }
  2532. if ($sfxh != '') {
  2533. $where .= " and sfxh = '$sfxh'";
  2534. }
  2535. if ($so) {
  2536. $where .= " and shipremarks like '%$so%'";
  2537. }
  2538. if ($source) {
  2539. if ($source == '2d') {
  2540. $where .= " and source >= '2'";
  2541. } else {
  2542. $where .= " and source = '$source'";
  2543. }
  2544. }
  2545. if (isset($_SESSION['api'])) {
  2546. foreach ($user as $value) {
  2547. $fgshop .= " shop = " . $value . " or";
  2548. }
  2549. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2550. }
  2551. if ($orderurl) {
  2552. $url = $this->orderurl->read($orderurl);
  2553. $where .= " and link like '%" . $url['url'] . "%'";
  2554. }
  2555. if($productid){
  2556. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2557. }
  2558. //数据排序
  2559. $order_str = "librarytime desc";
  2560. if (empty($page)) {
  2561. $start = 0;
  2562. $perpage = 1;
  2563. } else {
  2564. $start = ($page - 1) * $perpage;
  2565. }
  2566. //取得信息列表
  2567. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2568. //格式化数据
  2569. foreach ($info_list as $key => $value) {
  2570. $shop = $this->shop->read($value['shop']);
  2571. $info_list[$key]['shop'] = $shop['shopname'];
  2572. $express = $this->express->read($value['express']);
  2573. $info_list[$key]['express'] = $express['servicename'];
  2574. $warehouse = $this->warehouse->read($value['type']);
  2575. $info_list[$key]['type'] = $warehouse['title'];
  2576. if ($value['librarytime'] == '0') {
  2577. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2578. } else {
  2579. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2580. }
  2581. }
  2582. $total = $this->$sj->find_count($where);
  2583. $pagenum = ceil($total / $perpage);
  2584. $over = $total - ($start + $perpage);
  2585. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2586. echo json_encode($rows);
  2587. exit;
  2588. }
  2589. $this->data['express'] = $this->express->find_all();
  2590. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2591. $this->data['wlshop'] = $wlshop;
  2592. $user = $this->user->get_api($_SESSION['api']);
  2593. $powerid = $this->power->read($user['power']);
  2594. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2595. $pid = '';
  2596. foreach ($powertext as $v) {
  2597. $pid .= " id = " . $v . " or";
  2598. }
  2599. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2600. $this->data['fullorderexcel'] = $fullorderexcel;
  2601. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2602. $this->data['orderurl'] = $orderurl;
  2603. $this->_Template('whlabel_outorder', $this->data);
  2604. }
  2605. //tt出库
  2606. public function _toutorder()
  2607. {
  2608. $fgshop = "";
  2609. $sid = "";
  2610. if (isset($_SESSION['api'])) {
  2611. $user = $this->user->get_api($_SESSION['api']);
  2612. $usp = $user;
  2613. $user = explode('|', trim($user['shop'], '|'));
  2614. foreach ($user as $value) {
  2615. $fgshop .= " shop = " . $value . " or";
  2616. $sid .= " id = " . $value . " or";
  2617. }
  2618. } else {
  2619. echo "请重新登录";
  2620. die;
  2621. }
  2622. $post = $this->input->post(NULL, TRUE);
  2623. if (isset($post['page'])) {
  2624. $page = $this->input->post('page', true);
  2625. $perpage = $this->input->post('perpage', true);
  2626. $warehouse = $this->input->post('warehouse', true);
  2627. $xztime = $this->input->post('xztime', true);
  2628. $timetk = $this->input->post('timetkk', true);
  2629. $timetj = $this->input->post('timetjj', true);
  2630. $shop = $this->input->post('shop', true);
  2631. $source = $this->input->post('source', true);
  2632. $orderinfo = $this->input->post('orderinfo', true);
  2633. $number = $this->input->post('number', true);
  2634. $sfxh = $this->input->post('sfxh', true);
  2635. $express = $this->input->post('express', true);
  2636. $waybill = $this->input->post('waybill', true);
  2637. $library = $this->input->post('library', true);
  2638. $country = $this->input->post('country', true);
  2639. $so = $this->input->post('so', true);
  2640. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2641. $print = $this->input->post('print', true);
  2642. $state = $this->input->post('state', true);
  2643. $orderurl = $this->input->post('orderurl', true);
  2644. $timetk = strtotime($timetk);
  2645. $timetj = strtotime($timetj);
  2646. /**
  2647. $sj = $this->input->post('sj',true);
  2648. if($sj)
  2649. {
  2650. $sj = $this->input->post('sj',true);
  2651. }
  2652. else
  2653. {
  2654. $sj = "fullorder";
  2655. }
  2656. **/
  2657. $sj = "fullordertt";
  2658. $where = "1=1";
  2659. if ($warehouse) {
  2660. $where .= " and type = '$warehouse'";
  2661. }
  2662. if ($timetk && $timetj) {
  2663. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2664. }
  2665. if ($orderinfo) {
  2666. $where .= " and orderinfo = '$orderinfo'";
  2667. }
  2668. if ($number) {
  2669. $where .= " and number = '$number'";
  2670. }
  2671. if ($express) {
  2672. $where .= " and express = '$express'";
  2673. }
  2674. if ($waybill) {
  2675. $where .= " and waybill = '$waybill'";
  2676. }
  2677. if ($library) {
  2678. $where .= " and library = '$library'";
  2679. }
  2680. if ($print) {
  2681. $where .= " and print = '$print'";
  2682. }
  2683. if ($libraryconfirm) {
  2684. $where .= " and libraryconfirm = '$libraryconfirm'";
  2685. }
  2686. if ($state) {
  2687. $where .= " and state = '$state'";
  2688. }
  2689. if ($shop) {
  2690. $where .= " and shop = '$shop'";
  2691. }
  2692. if ($country) {
  2693. $where .= " and country = '$country'";
  2694. }
  2695. if ($sfxh != '') {
  2696. $where .= " and sfxh = '$sfxh'";
  2697. }
  2698. if ($so) {
  2699. $where .= " and shipremarks like '%$so%'";
  2700. }
  2701. if ($source) {
  2702. if ($source == '2d') {
  2703. $where .= " and source >= '2'";
  2704. } else {
  2705. $where .= " and source = '$source'";
  2706. }
  2707. }
  2708. if (isset($_SESSION['api'])) {
  2709. foreach ($user as $value) {
  2710. $fgshop .= " shop = " . $value . " or";
  2711. }
  2712. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2713. }
  2714. if ($orderurl) {
  2715. $url = $this->orderurl->read($orderurl);
  2716. $where .= " and link like '%" . $url['url'] . "%'";
  2717. }
  2718. //数据排序
  2719. $order_str = "librarytime desc";
  2720. if (empty($page)) {
  2721. $start = 0;
  2722. $perpage = 1;
  2723. } else {
  2724. $start = ($page - 1) * $perpage;
  2725. }
  2726. //取得信息列表
  2727. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2728. //格式化数据
  2729. foreach ($info_list as $key => $value) {
  2730. $shop = $this->shop->read($value['shop']);
  2731. $info_list[$key]['shop'] = $shop['shopname'];
  2732. $express = $this->express->read($value['express']);
  2733. $info_list[$key]['express'] = $express['servicename'];
  2734. $warehouse = $this->warehouse->read($value['type']);
  2735. $info_list[$key]['type'] = $warehouse['title'];
  2736. if ($value['librarytime'] == '0') {
  2737. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2738. } else {
  2739. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2740. }
  2741. }
  2742. $total = $this->$sj->find_count($where);
  2743. $pagenum = ceil($total / $perpage);
  2744. $over = $total - ($start + $perpage);
  2745. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2746. echo json_encode($rows);
  2747. exit;
  2748. }
  2749. $this->data['express'] = $this->express->find_all();
  2750. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2751. $this->data['wlshop'] = $wlshop;
  2752. $user = $this->user->get_api($_SESSION['api']);
  2753. $powerid = $this->power->read($user['power']);
  2754. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2755. $pid = '';
  2756. foreach ($powertext as $v) {
  2757. $pid .= " id = " . $v . " or";
  2758. }
  2759. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2760. $this->data['fullorderexcel'] = $fullorderexcel;
  2761. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2762. $this->data['orderurl'] = $orderurl;
  2763. $this->_Template('whlabel_toutorder', $this->data);
  2764. }
  2765. //tt出库
  2766. public function _aoutorder()
  2767. {
  2768. if (isset($_SESSION['api'])) {
  2769. $user = $this->user->get_api($_SESSION['api']);
  2770. $usp = $user;
  2771. $fgshop = "";
  2772. $sid = "";
  2773. $user = explode('|', trim($user['shop'], '|'));
  2774. foreach ($user as $value) {
  2775. $fgshop .= " shop = " . $value . " or";
  2776. $sid .= " id = " . $value . " or";
  2777. }
  2778. } else {
  2779. echo "请重新登录";
  2780. }
  2781. $post = $this->input->post(NULL, TRUE);
  2782. if (isset($post['page'])) {
  2783. $page = $this->input->post('page', true);
  2784. $perpage = $this->input->post('perpage', true);
  2785. $warehouse = $this->input->post('warehouse', true);
  2786. $xztime = $this->input->post('xztime', true);
  2787. $timetk = $this->input->post('timetkk', true);
  2788. $timetj = $this->input->post('timetjj', true);
  2789. $shop = $this->input->post('shop', true);
  2790. $source = $this->input->post('source', true);
  2791. $orderinfo = $this->input->post('orderinfo', true);
  2792. $number = $this->input->post('number', true);
  2793. $sfxh = $this->input->post('sfxh', true);
  2794. $express = $this->input->post('express', true);
  2795. $waybill = $this->input->post('waybill', true);
  2796. $library = $this->input->post('library', true);
  2797. $country = $this->input->post('country', true);
  2798. $so = $this->input->post('so', true);
  2799. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2800. $print = $this->input->post('print', true);
  2801. $state = $this->input->post('state', true);
  2802. $orderurl = $this->input->post('orderurl', true);
  2803. $timetk = strtotime($timetk);
  2804. $timetj = strtotime($timetj);
  2805. /**
  2806. $sj = $this->input->post('sj',true);
  2807. if($sj)
  2808. {
  2809. $sj = $this->input->post('sj',true);
  2810. }
  2811. else
  2812. {
  2813. $sj = "fullorder";
  2814. }
  2815. **/
  2816. $sj = "fullorderamz";
  2817. $where = "1=1";
  2818. if ($warehouse) {
  2819. $where .= " and type = '$warehouse'";
  2820. }
  2821. if ($timetk && $timetj) {
  2822. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2823. }
  2824. if ($orderinfo) {
  2825. $where .= " and orderinfo = '$orderinfo'";
  2826. }
  2827. if ($number) {
  2828. $where .= " and number = '$number'";
  2829. }
  2830. if ($express) {
  2831. $where .= " and express = '$express'";
  2832. }
  2833. if ($waybill) {
  2834. $where .= " and waybill = '$waybill'";
  2835. }
  2836. if ($library) {
  2837. $where .= " and library = '$library'";
  2838. }
  2839. if ($print) {
  2840. $where .= " and print = '$print'";
  2841. }
  2842. if ($libraryconfirm) {
  2843. $where .= " and libraryconfirm = '$libraryconfirm'";
  2844. }
  2845. if ($state) {
  2846. $where .= " and state = '$state'";
  2847. }
  2848. if ($shop) {
  2849. $where .= " and shop = '$shop'";
  2850. }
  2851. if ($country) {
  2852. $where .= " and country = '$country'";
  2853. }
  2854. if ($sfxh != '') {
  2855. $where .= " and sfxh = '$sfxh'";
  2856. }
  2857. if ($so) {
  2858. $where .= " and shipremarks like '%$so%'";
  2859. }
  2860. if ($source) {
  2861. if ($source == '2d') {
  2862. $where .= " and source >= '2'";
  2863. } else {
  2864. $where .= " and source = '$source'";
  2865. }
  2866. }
  2867. if (isset($_SESSION['api'])) {
  2868. foreach ($user as $value) {
  2869. $fgshop .= " shop = " . $value . " or";
  2870. }
  2871. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2872. }
  2873. if ($orderurl) {
  2874. $url = $this->orderurl->read($orderurl);
  2875. $where .= " and link like '%" . $url['url'] . "%'";
  2876. }
  2877. //数据排序
  2878. $order_str = "librarytime desc";
  2879. if (empty($page)) {
  2880. $start = 0;
  2881. $perpage = 1;
  2882. } else {
  2883. $start = ($page - 1) * $perpage;
  2884. }
  2885. //取得信息列表
  2886. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2887. //格式化数据
  2888. foreach ($info_list as $key => $value) {
  2889. $shop = $this->shop->read($value['shop']);
  2890. $info_list[$key]['shop'] = $shop['shopname'];
  2891. $express = $this->express->read($value['express']);
  2892. $info_list[$key]['express'] = $express['servicename'];
  2893. $warehouse = $this->warehouse->read($value['type']);
  2894. $info_list[$key]['type'] = $warehouse['title'];
  2895. if ($value['librarytime'] == '0') {
  2896. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2897. } else {
  2898. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2899. }
  2900. }
  2901. $total = $this->$sj->find_count($where);
  2902. $pagenum = ceil($total / $perpage);
  2903. $over = $total - ($start + $perpage);
  2904. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2905. echo json_encode($rows);
  2906. exit;
  2907. }
  2908. $this->data['express'] = $this->express->find_all();
  2909. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2910. $this->data['wlshop'] = $wlshop;
  2911. $user = $this->user->get_api($_SESSION['api']);
  2912. $powerid = $this->power->read($user['power']);
  2913. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2914. $pid = '';
  2915. foreach ($powertext as $v) {
  2916. $pid .= " id = " . $v . " or";
  2917. }
  2918. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2919. $this->data['fullorderexcel'] = $fullorderexcel;
  2920. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2921. $this->data['orderurl'] = $orderurl;
  2922. $this->_Template('whlabel_aoutorder', $this->data);
  2923. }
  2924. //速卖通出库订单
  2925. public function _soutorder()
  2926. {
  2927. if (isset($_SESSION['api'])) {
  2928. $user = $this->user->get_api($_SESSION['api']);
  2929. $usp = $user;
  2930. $fgshop = "";
  2931. $sid = "";
  2932. $user = explode('|', trim($user['shop'], '|'));
  2933. foreach ($user as $value) {
  2934. $sid .= " id = " . $value . " or";
  2935. }
  2936. }
  2937. $post = $this->input->post(NULL, TRUE);
  2938. if (isset($post['page'])) {
  2939. $page = $this->input->post('page', true);
  2940. $perpage = $this->input->post('perpage', true);
  2941. $warehouse = $this->input->post('warehouse', true);
  2942. $xztime = $this->input->post('xztime', true);
  2943. $timetk = $this->input->post('timetkk', true);
  2944. $timetj = $this->input->post('timetjj', true);
  2945. $shop = $this->input->post('shop', true);
  2946. $source = $this->input->post('source', true);
  2947. $orderinfo = $this->input->post('orderinfo', true);
  2948. $number = $this->input->post('number', true);
  2949. $express = $this->input->post('express', true);
  2950. $waybill = $this->input->post('waybill', true);
  2951. $library = $this->input->post('library', true);
  2952. $country = $this->input->post('country', true);
  2953. $sfxh = $this->input->post('sfxh', true);
  2954. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2955. $print = $this->input->post('print', true);
  2956. $state = $this->input->post('state', true);
  2957. $so = $this->input->post('so', true);
  2958. $timetk = strtotime($timetk);
  2959. $timetj = strtotime($timetj);
  2960. /**
  2961. $sj = $this->input->post('sj',true);
  2962. if($sj)
  2963. {
  2964. $sj = $this->input->post('sj',true);
  2965. }
  2966. else
  2967. {
  2968. $sj = "fullorder";
  2969. }
  2970. **/
  2971. $sj = "fullordersmt";
  2972. $where = "1=1";
  2973. if ($warehouse) {
  2974. $where .= " and type = '$warehouse'";
  2975. }
  2976. if ($timetk && $timetj) {
  2977. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2978. }
  2979. if ($orderinfo) {
  2980. $where .= " and orderinfo = '$orderinfo'";
  2981. }
  2982. if ($number) {
  2983. $where .= " and number = '$number'";
  2984. }
  2985. if ($express) {
  2986. $where .= " and express = '$express'";
  2987. }
  2988. if ($waybill) {
  2989. $where .= " and waybill = '$waybill'";
  2990. }
  2991. if ($library) {
  2992. $where .= " and library = '$library'";
  2993. }
  2994. if ($print) {
  2995. $where .= " and print = '$print'";
  2996. }
  2997. if ($libraryconfirm) {
  2998. $where .= " and libraryconfirm = '$libraryconfirm'";
  2999. }
  3000. if ($state) {
  3001. $where .= " and state = '$state'";
  3002. }
  3003. if ($shop) {
  3004. $where .= " and shop = '$shop'";
  3005. }
  3006. if ($sfxh != '') {
  3007. $where .= " and sfxh = '$sfxh'";
  3008. }
  3009. if ($so) {
  3010. $where .= " and shipremarks like '%$so%'";
  3011. }
  3012. if ($source) {
  3013. $where .= " and source = '$source'";
  3014. }
  3015. if ($country) {
  3016. $where .= " and country = '$country'";
  3017. } else {
  3018. if (isset($_SESSION['api'])) {
  3019. foreach ($user as $value) {
  3020. $fgshop .= " shop = " . $value . " or";
  3021. }
  3022. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3023. }
  3024. }
  3025. //数据排序
  3026. $order_str = "librarytime desc";
  3027. if (empty($page)) {
  3028. $start = 0;
  3029. $perpage = 1;
  3030. } else {
  3031. $start = ($page - 1) * $perpage;
  3032. }
  3033. //取得信息列表
  3034. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3035. //格式化数据
  3036. foreach ($info_list as $key => $value) {
  3037. $shop = $this->shop->read($value['shop']);
  3038. $info_list[$key]['shop'] = $shop['shopname'];
  3039. $express = $this->express->read($value['express']);
  3040. $info_list[$key]['express'] = $express['servicename'];
  3041. $warehouse = $this->warehouse->read($value['type']);
  3042. $info_list[$key]['type'] = $warehouse['title'];
  3043. if ($value['librarytime'] == '0') {
  3044. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3045. } else {
  3046. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3047. }
  3048. }
  3049. $total = $this->$sj->find_count($where);
  3050. $pagenum = ceil($total / $perpage);
  3051. $over = $total - ($start + $perpage);
  3052. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3053. echo json_encode($rows);
  3054. exit;
  3055. }
  3056. $this->data['express'] = $this->express->find_all();
  3057. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3058. $this->data['wlshop'] = $wlshop;
  3059. $user = $this->user->get_api($_SESSION['api']);
  3060. $powerid = $this->power->read($user['power']);
  3061. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3062. $pid = '';
  3063. foreach ($powertext as $v) {
  3064. $pid .= " id = " . $v . " or";
  3065. }
  3066. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3067. $this->data['fullorderexcel'] = $fullorderexcel;
  3068. $this->_Template('whlabel_soutorder', $this->data);
  3069. }
  3070. //订单退库
  3071. public function _retreat()
  3072. {
  3073. $post = $this->input->post(NULL, TRUE);
  3074. if (isset($post['page'])) {
  3075. $page = $this->input->post('page', true);
  3076. $perpage = $this->input->post('perpage', true);
  3077. $warehouse = $this->input->post('warehouse', true);
  3078. $timetk = $this->input->post('timetk', true);
  3079. $timetj = $this->input->post('timetj', true);
  3080. $shop = $this->input->post('shop', true);
  3081. $source = $this->input->post('source', true);
  3082. $state = $this->input->post('state', true);
  3083. $review = $this->input->post('review', true);
  3084. $state = $this->input->post('state', true);
  3085. $express = $this->input->post('express', true);
  3086. $orderinfo = $this->input->post('orderinfo', true);
  3087. $user = $this->input->post('user', true);
  3088. $name = $this->input->post('name', true);
  3089. $waybill = $this->input->post('waybill', true);
  3090. $timetk = strtotime($timetk);
  3091. $timetj = strtotime($timetj);
  3092. $where = "(state=206 or state=210) and mergeid = 0";
  3093. if ($warehouse) {
  3094. $where .= " and state = '$warehouse'";
  3095. }
  3096. if ($timetk && $timetj) {
  3097. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3098. }
  3099. if ($shop) {
  3100. $where .= " and shop = '$shop'";
  3101. }
  3102. if ($source) {
  3103. $where .= " and source = '$source'";
  3104. }
  3105. if ($state) {
  3106. $where .= " and state = '$state'";
  3107. }
  3108. if ($review) {
  3109. $where .= " and review = '$review'";
  3110. }
  3111. if ($state) {
  3112. $where .= " and state = '$state'";
  3113. }
  3114. if ($express) {
  3115. $where .= " and express = '$express'";
  3116. }
  3117. if ($orderinfo) {
  3118. $where .= " and orderinfo = '$orderinfo'";
  3119. }
  3120. if ($user) {
  3121. $where .= " and user = '$user'";
  3122. }
  3123. if ($name) {
  3124. $where .= " and name = '$name'";
  3125. }
  3126. if ($waybill) {
  3127. $where .= " and waybill = '$waybill'";
  3128. }
  3129. //数据排序
  3130. $order_str = "id desc";
  3131. if (empty($page)) {
  3132. $start = 0;
  3133. $perpage = 1;
  3134. } else {
  3135. $start = ($page - 1) * $perpage;
  3136. }
  3137. //取得信息列表
  3138. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3139. //格式化数据
  3140. foreach ($info_list as $key => $value) {
  3141. $shop = $this->shop->read($value['shop']);
  3142. $info_list[$key]['shop'] = $shop['shopname'];
  3143. $warehouse = $this->warehouse->read($value['warehouse']);
  3144. $info_list[$key]['warehouse'] = $warehouse['title'];
  3145. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3146. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3147. if ($value['waybill'] == 0) {
  3148. $info_list[$key]['waybill'] = "";
  3149. }
  3150. $express = $this->express->read($value['express']);
  3151. $info_list[$key]['express'] = $express['title'];
  3152. $typeclass = $this->typeclass->read($value['state']);
  3153. $info_list[$key]['state'] = $typeclass['title'];
  3154. }
  3155. $total = $this->fullorder->find_count($where);
  3156. $pagenum = ceil($total / $perpage);
  3157. $over = $total - ($start + $perpage);
  3158. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3159. echo json_encode($rows);
  3160. exit;
  3161. }
  3162. $this->data['express'] = $this->express->find_all();
  3163. $this->_Template('whlabel_retreat', $this->data);
  3164. }
  3165. //退库标签浏览
  3166. public function _retreatlk()
  3167. {
  3168. $post = $this->input->post(NULL, TRUE);
  3169. if (isset($post['page'])) {
  3170. $page = $this->input->post('page', true);
  3171. $perpage = $this->input->post('perpage', true);
  3172. $timetk = $this->input->post('timetk', true);
  3173. $timetj = $this->input->post('timetj', true);
  3174. $sku = $this->input->post('sku', true);
  3175. $warehouse = $this->input->post('warehouse', true);
  3176. $purchase = $this->input->post('purchase', true);
  3177. $orderinfo = $this->input->post('orderinfo', true);
  3178. $waybill = $this->input->post('waybill', true);
  3179. $category = $this->input->post('category', true);
  3180. $size = $this->input->post('size', true);
  3181. $grade = $this->input->post('grade', true);
  3182. $color = $this->input->post('color', true);
  3183. $lowe = $this->input->post('lowe', true);
  3184. $state = $this->input->post('state', true);
  3185. $timetk = strtotime($timetk);
  3186. $timetj = strtotime($timetj);
  3187. $where = "state=2";
  3188. if ($timetk && $timetj) {
  3189. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3190. }
  3191. if ($sku) {
  3192. $where .= " and sku = '$sku'";
  3193. }
  3194. if ($warehouse) {
  3195. $where .= " and warehouse = '$warehouse'";
  3196. }
  3197. if ($purchase) {
  3198. $where .= " and purchase = '$purchase'";
  3199. }
  3200. if ($orderinfo) {
  3201. $where .= " and orderinfo = '$orderinfo'";
  3202. }
  3203. if ($waybill) {
  3204. $where .= " and waybill = '$waybill'";
  3205. }
  3206. if ($category) {
  3207. $where .= " and features like '%-$category-%'";
  3208. }
  3209. if ($size) {
  3210. $where .= " and features like '%-$size-%'";
  3211. }
  3212. if ($grade) {
  3213. $where .= " and features like '%-$grade-%'";
  3214. }
  3215. if ($color) {
  3216. $where .= " and features like '%-$color-%'";
  3217. }
  3218. if ($lowe) {
  3219. $where .= " and features like '%-$lowe-%'";
  3220. }
  3221. //数据排序
  3222. $order_str = "time desc";
  3223. if (empty($page)) {
  3224. $start = 0;
  3225. $perpage = 1;
  3226. } else {
  3227. $start = ($page - 1) * $perpage;
  3228. }
  3229. //取得信息列表
  3230. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3231. foreach ($info_list as $key => $value) {
  3232. $warehouse = $this->warehouse->read($value['warehouse']);
  3233. $info_list[$key]['warehouse'] = $warehouse['title'];
  3234. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3235. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3236. $purchase = $this->purchase->read($value['purchase']);
  3237. $info_list[$key]['purchase'] = $purchase['title'];
  3238. if ($value['outk'] != 0) {
  3239. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3240. } else {
  3241. $info_list[$key]['outk'] = "";
  3242. }
  3243. if ($value['retreat'] != 0) {
  3244. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3245. } else {
  3246. $info_list[$key]['retreat'] = "";
  3247. }
  3248. if ($value['orderinfo'] == 0) {
  3249. $info_list[$key]['orderinfo'] = "";
  3250. }
  3251. if ($value['waybill'] == 0) {
  3252. $info_list[$key]['waybill'] = "";
  3253. }
  3254. }
  3255. $total = $this->whlabel->find_count($where);
  3256. $pagenum = ceil($total / $perpage);
  3257. $over = $total - ($start + $perpage);
  3258. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3259. echo json_encode($rows);
  3260. exit;
  3261. }
  3262. $this->_Template('whlabel_retreatlk', $this->data);
  3263. }
  3264. //更换标签及浏览
  3265. public function _change()
  3266. {
  3267. $post = $this->input->post(NULL, TRUE);
  3268. if (isset($post['page'])) {
  3269. $page = $this->input->post('page', true);
  3270. $perpage = $this->input->post('perpage', true);
  3271. $timetk = $this->input->post('timetk', true);
  3272. $timetj = $this->input->post('timetj', true);
  3273. $label = $this->input->post('label', true);
  3274. $oldlabel = $this->input->post('oldlabel', true);
  3275. $timetk = strtotime($timetk);
  3276. $timetj = strtotime($timetj);
  3277. $where = "state=10 ";
  3278. if ($timetk && $timetj) {
  3279. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3280. }
  3281. if ($label) {
  3282. $where .= " and label = '$label'";
  3283. }
  3284. if ($oldlabel) {
  3285. $where .= " and oldlabel = '$oldlabel'";
  3286. }
  3287. //数据排序
  3288. $order_str = "time asc";
  3289. if (empty($page)) {
  3290. $start = 0;
  3291. $perpage = 1;
  3292. } else {
  3293. $start = ($page - 1) * $perpage;
  3294. }
  3295. //取得信息列表
  3296. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3297. foreach ($info_list as $key => $value) {
  3298. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3299. }
  3300. $total = $this->whlabel->find_count($where);
  3301. $pagenum = ceil($total / $perpage);
  3302. $over = $total - ($start + $perpage);
  3303. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3304. echo json_encode($rows);
  3305. exit;
  3306. }
  3307. $this->_Template('whlabel_change', $this->data);
  3308. }
  3309. //产品标签
  3310. public function _cpbqdc()
  3311. {
  3312. if (isset($_GET['excel'])) {
  3313. $where = "1=1";
  3314. //数据排序
  3315. $order_str = "id desc";
  3316. if (empty($page)) {
  3317. $start = 0;
  3318. $perpage = 1;
  3319. } else {
  3320. $start = ($page - 1) * $perpage;
  3321. }
  3322. $warehouse = $this->input->get('warehouse', true);
  3323. $state = $this->input->get('state', true);
  3324. $timetk = $this->input->get('timetkk', true);
  3325. $timetj = $this->input->get('timetjj', true);
  3326. $timetk = strtotime($timetk);
  3327. $timetj = strtotime($timetj);
  3328. if ($warehouse) {
  3329. $where .= " and warehouse = '$warehouse'";
  3330. }
  3331. if ($state || $state == 0) {
  3332. $where .= " and state = '$state'";
  3333. }
  3334. if ($timetk && $timetj) {
  3335. $where .= " and time > '$timetk' and time < '$timetj'";
  3336. }
  3337. //取得信息列表
  3338. $info_list = $this->whlabel->find_all($where, '*');
  3339. $rows = array();
  3340. $list = array();
  3341. foreach ($info_list as $key => $value) {
  3342. $rows[$value['time']] = $value; //所有数据sku
  3343. }
  3344. foreach ($rows as $value) {
  3345. $warehouse = $this->warehouse->read($value['warehouse']);
  3346. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3347. $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);
  3348. }
  3349. $title = "产品标签统计表";
  3350. $titlename = "<table border=1>
  3351. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3352. <tr align='center'>
  3353. <td>仓库</td>
  3354. <td>SKU</td>
  3355. <td>产品</td>
  3356. <td>入库时间</td>
  3357. <td>操作时间</td>
  3358. <td>备注</td>
  3359. <td>数量</td>
  3360. </tr>
  3361. </table>";
  3362. $filename = $title . ".xls";
  3363. $tail = "";
  3364. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3365. }
  3366. }
  3367. //进销存导出
  3368. public function _exceljxc()
  3369. {
  3370. $classid = $this->classid->sku();
  3371. $pm = $classid;
  3372. $typeclass = array();
  3373. $tc = $this->typeclass->find_all();
  3374. foreach ($tc as $v) {
  3375. $typeclass[$v['id']] = $v;
  3376. }
  3377. $prc = array();
  3378. $purchase = $this->purchase->find_all();
  3379. foreach ($purchase as $k => $v) {
  3380. $prc[$v['id']] = $v['title'];
  3381. }
  3382. if (isset($_GET['excel'])) {
  3383. $where = "sku != 'Preset'";
  3384. //数据排序
  3385. $order_str = "id desc";
  3386. if (empty($page)) {
  3387. $start = 0;
  3388. $perpage = 1;
  3389. } else {
  3390. $start = ($page - 1) * $perpage;
  3391. }
  3392. $category = $this->input->get('category', true);
  3393. $warehouse = $this->input->get('warehouse', true);
  3394. $excelid = $this->input->get('sid', true);
  3395. if ($category) {
  3396. $where .= " and features like '%-$category-%'";
  3397. }
  3398. if ($warehouse) {
  3399. $where .= " and warehouse = '$warehouse'";
  3400. }
  3401. $xzid = '';
  3402. if ($excelid) {
  3403. $excelid = explode(',', trim($excelid, ','));
  3404. foreach ($excelid as $key => $value) {
  3405. $xzid .= " id = " . $value . " or";
  3406. }
  3407. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3408. }
  3409. //取得信息列表
  3410. /**
  3411. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3412. $rows = array();$list = array();
  3413. foreach ($info_list as $key=>$value)
  3414. {
  3415. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3416. }
  3417. **/
  3418. $wt = array();
  3419. $whlabel_type = $this->whlabel_type->find_all();
  3420. foreach ($whlabel_type as $v) {
  3421. $wt[$v['id']] = $v['title'];
  3422. }
  3423. $wh = array();
  3424. $w = $this->warehouse->find_all('1=1', 'id,title');
  3425. foreach ($w as $v) {
  3426. $wh[$v['id']] = $v['title'];
  3427. }
  3428. $list = array();
  3429. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3430. foreach ($rows as $key => $value) {
  3431. if (isset($wt[$value['type']])) {
  3432. $rows[$key]['type'] = $wt[$value['type']];
  3433. } else {
  3434. $rows[$key]['type'] = '未设置';
  3435. }
  3436. $bm = '03';
  3437. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3438. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3439. $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');
  3440. $details = array();
  3441. $cpid = array();
  3442. $cpbz = array();
  3443. $c = 0;
  3444. $g = 0;
  3445. $x = 0;
  3446. $t = 0;
  3447. $s = 0;
  3448. $q = 0;
  3449. foreach ($sd as $k => $v) {
  3450. if ($v['state'] == 0) {
  3451. $c++;
  3452. if ($v['cpid'] != 0) {
  3453. $cpid[$v['cpid']] = $v['cpid'];
  3454. }
  3455. if ($v['cpbz'] != '') {
  3456. $cpbz[$v['cpbz']] = $v['cpbz'];
  3457. }
  3458. }
  3459. if ($v['state'] != 9) {
  3460. $g++;
  3461. }
  3462. if ($v['state'] == 1) {
  3463. $x++;
  3464. }
  3465. if ($v['state'] == 2) {
  3466. $t++;
  3467. }
  3468. if ($v['state'] == 8) {
  3469. $s++;
  3470. }
  3471. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3472. $q++;
  3473. }
  3474. $details[$v['details']] = $v['details'];
  3475. }
  3476. $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'] . '"');
  3477. $rows[$key]['details'] = implode("、", $details);
  3478. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3479. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3480. $number = $value['number'];
  3481. $ftime = time() - 15 * 24 * 3600;
  3482. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3483. $rows[$key]['number'] = $g;
  3484. $rows[$key]['c'] = $c;
  3485. $rows[$key]['x'] = $x;
  3486. $rows[$key]['t'] = $t;
  3487. $rows[$key]['s'] = $s;
  3488. $rows[$key]['q'] = $q;
  3489. $rows[$key]['z'] = $z;
  3490. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3491. $features = explode('-', trim($features, '-'));
  3492. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3493. // $pm = $classid;
  3494. // $jm = $classid;
  3495. // foreach($features as $k=>$v)
  3496. // {
  3497. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3498. // {
  3499. // if($typeclass[$v]['bm'] != '')
  3500. // {
  3501. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3502. // }
  3503. // }
  3504. // if($v != 0)
  3505. // {
  3506. // if(!isset($typeclass[$v]))
  3507. // {
  3508. // continue;
  3509. // }
  3510. // if(isset($pm[$typeclass[$v]['classid']]))
  3511. // {
  3512. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3513. // {
  3514. // $tz = explode('|',$typeclass[$v]['zh']);
  3515. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3516. // }
  3517. // else
  3518. // {
  3519. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3520. // }
  3521. // }
  3522. // if(isset($jm[$typeclass[$v]['classid']]))
  3523. // {
  3524. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3525. // }
  3526. // }
  3527. // }
  3528. // $jm = array_filter($jm);
  3529. // $rows[$key]['bs'] = implode("-",$jm);
  3530. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3531. // $zh = implode(" ",$pm);
  3532. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3533. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3534. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3535. // $rows[$key]['features'] = $zh;
  3536. }
  3537. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3538. $final_list = [];
  3539. foreach ($list as $k => $v) {
  3540. if (empty($v['sku'])) {
  3541. continue;
  3542. }
  3543. $final_list[] = [
  3544. "warehouse" => $v["warehouse"],
  3545. "purchase" => $v["purchase"],
  3546. "details" => $v["details"],
  3547. "cpid" => $v["cpid"],
  3548. "dbcontent" => $v["dbcontent"],
  3549. "sku" => $v["sku"],
  3550. "cs" => $v["bm"],
  3551. "bs" => $v["jm"],
  3552. "title" => $v["title"],
  3553. "features" => $v["pm"],
  3554. "cpbz" => $v["cpbz"],
  3555. "sm" => $v["sm"],
  3556. "type" => $v["type"],
  3557. "number" => $v["number"],
  3558. "c" => $v["c"],
  3559. "x" => $v["x"],
  3560. "t" => $v["t"],
  3561. "s" => $v["s"],
  3562. "q" => $v["q"],
  3563. "z" => $v["z"],
  3564. "weight" => $v['weight'],
  3565. ];
  3566. }
  3567. $title = "总进销存统计表";
  3568. $titlename = "<table border=1>
  3569. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3570. <tr align='center'>
  3571. <td>仓库</td>
  3572. <td>供应商</td>
  3573. <td>位置</td>
  3574. <td>库存编码</td>
  3575. <td>类目</td>
  3576. <td>SKU</td>
  3577. <td>用友编码</td>
  3578. <td>用友料号</td>
  3579. <td>商品名称</td>
  3580. <td>商品中文</td>
  3581. <td>产品备注</td>
  3582. <td>库位负责人</td>
  3583. <td>类型</td>
  3584. <td>入库总量</td>
  3585. <td>库存数量</td>
  3586. <td>销售数量</td>
  3587. <td>退货数量</td>
  3588. <td>删除数量</td>
  3589. <td>其它操作</td>
  3590. <td>占单数量</td>
  3591. <td>重量(g)</td>
  3592. </tr>
  3593. </table>";
  3594. $filename = $title . ".xls";
  3595. $tail = "";
  3596. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3597. }
  3598. }
  3599. //入库导出
  3600. public function _excelr()
  3601. {
  3602. if (isset($_GET['excel'])) {
  3603. $category = $this->input->get('category', true);
  3604. $size = $this->input->get('size', true);
  3605. $grade = $this->input->get('grade', true);
  3606. $color = $this->input->get('color', true);
  3607. $lowe = $this->input->get('lowe', true);
  3608. $sku = $this->input->get('sku', true);
  3609. $warehouse = $this->input->get('warehouse', true);
  3610. $purchase = $this->input->get('purchase', true);
  3611. $ktime = $this->input->get('ktime', true);
  3612. $jtime = $this->input->get('jtime', true);
  3613. $ktime = strtotime($ktime);
  3614. $jtime = strtotime($jtime);
  3615. $where = "1=1";
  3616. $gj = "";
  3617. $ck = "";
  3618. if ($category) {
  3619. $where .= " and features like '%-$category-%'";
  3620. }
  3621. if ($size) {
  3622. $where .= " and features like '%-$size-%'";
  3623. }
  3624. if ($grade) {
  3625. $where .= " and features like '%-$grade-%'";
  3626. }
  3627. if ($color) {
  3628. $where .= " and features like '%-$color-%'";
  3629. }
  3630. if ($lowe) {
  3631. $where .= " and features like '%-$lowe-%'";
  3632. }
  3633. if ($warehouse) {
  3634. $where .= " and warehouse = '$warehouse'";
  3635. }
  3636. if ($purchase) {
  3637. $where .= " and purchase = '$purchase'";
  3638. }
  3639. if ($sku) {
  3640. $where .= " and sku = '$sku'";
  3641. }
  3642. if ($ktime && $jtime) {
  3643. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3644. }
  3645. //数据排序
  3646. $order_str = "id desc";
  3647. if (empty($page)) {
  3648. $start = 0;
  3649. $perpage = 1;
  3650. } else {
  3651. $start = ($page - 1) * $perpage;
  3652. }
  3653. $list = array();
  3654. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3655. foreach ($rows as $value) {
  3656. $ck = $this->warehouse->read($value['warehouse']);
  3657. $warehouse = $ck['title'];
  3658. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3659. $retreatwarehouse = $tkck['title'];
  3660. $gy = $this->purchase->read($value['purchase']);
  3661. $purchase = $gy['title'];
  3662. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3663. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3664. }
  3665. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3666. $titlename = "<table border=1>
  3667. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3668. <tr align='center'>
  3669. <td>仓库</td>
  3670. <td>SKU</td>
  3671. <td>产品</td>
  3672. <td>时间</td>
  3673. <td>数量</td>
  3674. </tr>
  3675. </table>";
  3676. $filename = $title . ".xls";
  3677. $tail = "";
  3678. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3679. }
  3680. }
  3681. //出库、退库导出
  3682. public function _excelct()
  3683. {
  3684. $classid = $this->classid->sku();
  3685. $pm = $classid;
  3686. $typeclass = array();
  3687. $tc = $this->typeclass->find_all();
  3688. foreach ($tc as $v) {
  3689. $typeclass[$v['id']] = $v;
  3690. }
  3691. $prc = array();
  3692. $purchase = $this->purchase->find_all();
  3693. foreach ($purchase as $k => $v) {
  3694. $prc[$v['id']] = $v['title'];
  3695. }
  3696. if (isset($_GET['excel'])) {
  3697. $wh = array();
  3698. $w = $this->warehouse->find_all('1=1', 'id,title');
  3699. foreach ($w as $v) {
  3700. $wh[$v['id']] = $v['title'];
  3701. }
  3702. $type = $this->input->get('excel', true);
  3703. $category = $this->input->get('category', true);
  3704. $size = $this->input->get('size', true);
  3705. $grade = $this->input->get('grade', true);
  3706. $color = $this->input->get('color', true);
  3707. $lowe = $this->input->get('lowe', true);
  3708. $sku = $this->input->get('sku', true);
  3709. $title = $this->input->get('title', true);
  3710. $warehouse = $this->input->get('warehouse', true);
  3711. $purchase = $this->input->get('purchase', true);
  3712. $lacetype = $this->input->get('lacetype', true);
  3713. $haircap = $this->input->get('haircap', true);
  3714. $lacecolor = $this->input->get('lacecolor', true);
  3715. $density = $this->input->get('density', true);
  3716. $details = $this->input->get('details', true);
  3717. $state = $this->input->get('state', true);
  3718. $shop = $this->input->get('shop', true);
  3719. $hairnumber = $this->input->get('hairnumber', true);
  3720. $type_leixi = $this->input->get('type', true);
  3721. $cpbz = $this->input->get('cpbz', true);
  3722. $sm = $this->input->get('sm', true);
  3723. $sid = $this->input->get('sid', true);
  3724. $ktime = $this->input->get('ktime', true);
  3725. $jtime = $this->input->get('jtime', true);
  3726. $ktime = strtotime($ktime);
  3727. $jtime = strtotime($jtime);
  3728. //$where = " 1=1 ";
  3729. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3730. $where = " sku != '' ";
  3731. $gj = "";
  3732. $ck = "";
  3733. if ($category) {
  3734. $where .= " and features like '%-$category-%'";
  3735. }
  3736. if ($size) {
  3737. $where .= " and features like '%-$size-%'";
  3738. }
  3739. if ($grade) {
  3740. $where .= " and features like '%-$grade-%'";
  3741. }
  3742. if ($color) {
  3743. $where .= " and features like '%-$color-%'";
  3744. }
  3745. if ($lowe) {
  3746. $where .= " and features like '%-$lowe-%'";
  3747. }
  3748. if ($warehouse) {
  3749. $where .= " and warehouse = '$warehouse'";
  3750. }
  3751. if ($purchase) {
  3752. $where .= " and purchase = '$purchase'";
  3753. }
  3754. if ($state) {
  3755. $where .= " and state = '$state'";
  3756. }
  3757. if ($lacetype) {
  3758. $where .= " and features like '%-$lacetype-%'";
  3759. }
  3760. if ($lacecolor) {
  3761. $where .= " and features like '%-$lacecolor-%'";
  3762. }
  3763. if ($density) {
  3764. $where .= " and features like '%-$density-%'";
  3765. }
  3766. if ($haircap) {
  3767. $where .= " and features like '%-$haircap-%'";
  3768. }
  3769. if ($details) {
  3770. $where .= " and details = '$details'";
  3771. }
  3772. if ($shop) {
  3773. $where .= " and shop like '%$shop%'";
  3774. }
  3775. if ($title) {
  3776. $title = trim($title, ' ');
  3777. $title = trim($title, ' ');
  3778. $where .= " and title like '%$title%'";
  3779. }
  3780. if (!empty($hairnumber)) {
  3781. $where .= " and features like '%-128-%' ";
  3782. if ($hairnumber < 0) {
  3783. $class_list = $this->typeclass->find_all('classid = 43');
  3784. foreach ($class_list as $v) {
  3785. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3786. }
  3787. } else {
  3788. $where .= " and features like '%-$hairnumber-%'";
  3789. }
  3790. }
  3791. if ($type_leixi) {
  3792. $where .= " and type = '$type_leixi'";
  3793. }
  3794. if ($cpbz) {
  3795. $where .= " and cpbz like '%$cpbz%' ";
  3796. }
  3797. if ($sm) {
  3798. $where .= " and sm like '%$sm%' ";
  3799. }
  3800. if ($sku) {
  3801. $sku = trim($sku, ' ');
  3802. $sku = trim($sku, ' ');
  3803. $where .= " and sku like '%$sku%'";
  3804. }
  3805. if ($ktime && $jtime) {
  3806. if ($type == 1) {
  3807. $tl = '出库';
  3808. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3809. } else if ($type == 2) {
  3810. $tl = '退库';
  3811. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3812. } else if ($type == 3) {
  3813. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3814. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3815. } else if ($type == 4) {
  3816. $tl = '出库+零售';
  3817. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3818. } else if ($type == 5) {
  3819. $tl = '零售';
  3820. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3821. }
  3822. }
  3823. $sidwhere = '';
  3824. if ($sid) {
  3825. $sd = "";
  3826. $s = explode(',', trim($sid, ','));
  3827. foreach ($s as $value) {
  3828. $sd .= " id = " . $value . " or";
  3829. }
  3830. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3831. }
  3832. //数据排序
  3833. $order_str = "time desc";
  3834. if (empty($page)) {
  3835. $start = 0;
  3836. $perpage = 1;
  3837. } else {
  3838. $start = ($page - 1) * $perpage;
  3839. }
  3840. //取得信息列表
  3841. if ($type != 3 && $type != 5) {
  3842. if ($type == 1 || $type == 4) {
  3843. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3844. foreach ($info_list as $key => $value) {
  3845. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3846. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3847. $warehouse = $this->warehouse->read($value['warehouse']);
  3848. $info_list[$key]['warehouse'] = $warehouse['title'];
  3849. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3850. $features = explode('-', trim($features, '-'));
  3851. $pm = $classid;
  3852. foreach ($features as $k => $v) {
  3853. if ($v != 0) {
  3854. if (!isset($typeclass[$v])) {
  3855. continue;
  3856. }
  3857. if (isset($pm[$typeclass[$v]['classid']])) {
  3858. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3859. $tz = explode('|', $typeclass[$v]['zh']);
  3860. $pm[$typeclass[$v]['classid']] = $tz[0];
  3861. } else {
  3862. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3863. }
  3864. }
  3865. }
  3866. }
  3867. $zh = implode(" ", $pm);
  3868. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3869. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3870. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3871. $info_list[$key]['features'] = $zh;
  3872. }
  3873. $final_list = [];
  3874. foreach($info_list as $k=>$v){
  3875. $number = "";
  3876. if(!empty($v['orderinfo'])){
  3877. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3878. if(!empty($tmp_info['number'])){
  3879. $number = $tmp_info['number'];
  3880. }
  3881. }
  3882. $final_list[] = [
  3883. 'warehouse'=>$v['warehouse'],
  3884. 'purchase'=>$v['purchase'],
  3885. 'sku'=>$v['sku'],
  3886. 'title'=>$v['title'],
  3887. 'features'=>$v['features'],
  3888. 'label'=>$v['label'],
  3889. 'orderinfo'=>$v['orderinfo'],
  3890. 'number'=>$number,
  3891. 'waybill'=>$v['waybill'],
  3892. 'outk'=>$v['outk'],
  3893. ];
  3894. }
  3895. } else {
  3896. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3897. foreach ($info_list as $key => $value) {
  3898. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3899. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3900. $warehouse = $this->warehouse->read($value['warehouse']);
  3901. $info_list[$key]['warehouse'] = $warehouse['title'];
  3902. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3903. $features = explode('-', trim($features, '-'));
  3904. $pm = $classid;
  3905. foreach ($features as $k => $v) {
  3906. if ($v != 0) {
  3907. if (!isset($typeclass[$v])) {
  3908. continue;
  3909. }
  3910. if (isset($pm[$typeclass[$v]['classid']])) {
  3911. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3912. $tz = explode('|', $typeclass[$v]['zh']);
  3913. $pm[$typeclass[$v]['classid']] = $tz[0];
  3914. } else {
  3915. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3916. }
  3917. }
  3918. }
  3919. }
  3920. $zh = implode(" ", $pm);
  3921. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3922. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3923. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3924. $info_list[$key]['features'] = $zh;
  3925. }
  3926. $final_list = [];
  3927. foreach($info_list as $k=>$v){
  3928. $number = "";
  3929. if(!empty($v['orderinfo'])){
  3930. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3931. if(!empty($tmp_info['number'])){
  3932. $number = $tmp_info['number'];
  3933. }
  3934. }
  3935. $final_list[] = [
  3936. 'warehouse'=>$v['warehouse'],
  3937. 'purchase'=>$v['purchase'],
  3938. 'sku'=>$v['sku'],
  3939. 'title'=>$v['title'],
  3940. 'features'=>$v['features'],
  3941. 'label'=>$v['label'],
  3942. 'orderinfo'=>$v['orderinfo'],
  3943. 'number'=>$number,
  3944. 'waybill'=>$v['waybill'],
  3945. 'retreat'=>$v['retreat'],
  3946. ];
  3947. }
  3948. }
  3949. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3950. $titlename = "<table border=1>
  3951. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3952. <tr align='center'>
  3953. <td>仓库</td>
  3954. <td>供应商</td>
  3955. <td>SKU</td>
  3956. <td>商品名称</td>
  3957. <td>商品中文</td>
  3958. <td>标签</td>
  3959. <td>订单号</td>
  3960. <td>订单编码</td>
  3961. <td>运单号</td>
  3962. <td>" . $tl . "时间(中国时间)</td>
  3963. </tr>
  3964. </table>";
  3965. $filename = $title . ".xls";
  3966. $tail = "";
  3967. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3968. } else if ($type == 5) {
  3969. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3970. foreach ($info_list as $key => $value) {
  3971. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3972. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3973. $warehouse = $this->warehouse->read($value['warehouse']);
  3974. $info_list[$key]['warehouse'] = $warehouse['title'];
  3975. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3976. $features = explode('-', trim($features, '-'));
  3977. $pm = $classid;
  3978. foreach ($features as $k => $v) {
  3979. if ($v != 0) {
  3980. if (!isset($typeclass[$v])) {
  3981. continue;
  3982. }
  3983. if (isset($pm[$typeclass[$v]['classid']])) {
  3984. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3985. $tz = explode('|', $typeclass[$v]['zh']);
  3986. $pm[$typeclass[$v]['classid']] = $tz[0];
  3987. } else {
  3988. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3989. }
  3990. }
  3991. }
  3992. }
  3993. $zh = implode(" ", $pm);
  3994. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3995. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3996. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3997. $info_list[$key]['features'] = $zh;
  3998. }
  3999. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4000. $titlename = "<table border=1>
  4001. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4002. <tr align='center'>
  4003. <td>仓库</td>
  4004. <td>供应商</td>
  4005. <td>SKU</td>
  4006. <td>商品名称</td>
  4007. <td>商品中文</td>
  4008. <td>标签</td>
  4009. <td>" . $tl . "时间(中国时间)</td>
  4010. </tr>
  4011. </table>";
  4012. $filename = $title . ".xls";
  4013. $tail = "";
  4014. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4015. } else {
  4016. /**
  4017. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4018. $rows = array();$list = array();
  4019. foreach ($info_list as $key=>$value)
  4020. {
  4021. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4022. }
  4023. **/
  4024. $wh = array();
  4025. $w = $this->warehouse->find_all('1=1', 'id,title');
  4026. foreach ($w as $v) {
  4027. $wh[$v['id']] = $v['title'];
  4028. }
  4029. $wt = array();
  4030. $whlabel_type = $this->whlabel_type->find_all();
  4031. foreach ($whlabel_type as $v) {
  4032. $wt[$v['id']] = $v['title'];
  4033. }
  4034. $classid = $this->classid->sku();
  4035. $list = array();
  4036. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4037. foreach ($rows as $key => $value) {
  4038. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4039. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4040. $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');
  4041. $details = array();
  4042. $cpid = array();
  4043. $cpbz = array();
  4044. $c = 0;
  4045. $g = 0;
  4046. $x = 0;
  4047. $t = 0;
  4048. $s = 0;
  4049. $q = 0;
  4050. foreach ($sd as $k => $v) {
  4051. if ($v['state'] == 0) {
  4052. $c++;
  4053. }
  4054. if ($v['state'] != 9) {
  4055. $g++;
  4056. }
  4057. if ($v['outk'] > 1) {
  4058. $x++;
  4059. }
  4060. if ($v['retreat'] > 0) {
  4061. $t++;
  4062. }
  4063. if ($v['state'] == 8) {
  4064. $s++;
  4065. }
  4066. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4067. $q++;
  4068. }
  4069. $details[$v['details']] = $v['details'];
  4070. if ($v['cpid'] != 0) {
  4071. $cpid[$v['cpid']] = $v['cpid'];
  4072. }
  4073. if ($v['cpbz'] != '') {
  4074. $cpbz[$v['cpbz']] = $v['cpbz'];
  4075. }
  4076. }
  4077. if (isset($wt[$value['type']])) {
  4078. $rows[$key]['type'] = $wt[$value['type']];
  4079. } else {
  4080. $rows[$key]['type'] = '未设置';
  4081. }
  4082. $rows[$key]['details'] = implode("、", $details);
  4083. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4084. $ftime = time() - 15 * 24 * 3600;
  4085. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4086. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4087. $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);
  4088. $rows[$key]['c'] = $c;
  4089. $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);
  4090. $rows[$key]['t'] = $t;
  4091. $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'] . '"');
  4092. $rows[$key]['z'] = $z;
  4093. // $jm = $classid;
  4094. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4095. $features = explode('-', trim($features, '-'));
  4096. // $pm = $classid;
  4097. // foreach ($features as $k => $v) {
  4098. // if ($v != 0) {
  4099. // if (!isset($typeclass[$v])) {
  4100. // continue;
  4101. // }
  4102. // if (isset($pm[$typeclass[$v]['classid']])) {
  4103. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4104. // $tz = explode('|', $typeclass[$v]['zh']);
  4105. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4106. // } else {
  4107. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4108. // }
  4109. // if (isset($jm[$typeclass[$v]['classid']])) {
  4110. // if ($typeclass[$v]['jm']) {
  4111. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4112. // }
  4113. // }
  4114. // }
  4115. // }
  4116. // }
  4117. // $zh = implode(" ", $pm);
  4118. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4119. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4120. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4121. // $rows[$key]['features'] = $zh;
  4122. // $jm = array_filter($jm); //去除空值
  4123. // $jm = implode("-", $jm);
  4124. // $rows[$key]['jm'] = $jm;
  4125. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4126. }
  4127. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4128. // echo "<pre>";
  4129. // print_r($tmp_list);
  4130. // die;
  4131. $final_list =[];
  4132. foreach($tmp_list as $k=>$v){
  4133. $final_list[] = [
  4134. "warehouse"=>$v['warehouse'],
  4135. "purchase"=>$v['purchase'],
  4136. "details"=>trim($v['details'],'、'),
  4137. "cpid"=>$v['cpid'],
  4138. "sku"=>$v['sku'],
  4139. "title"=>$v['title'],
  4140. "features"=>$v['pm'],
  4141. "cpbz"=>$v['cpbz'],
  4142. "sm"=>$v['sm'],
  4143. "type"=>$v['type'],
  4144. "g"=>$v["g"],
  4145. "c"=>$v["c"],
  4146. "x"=>$v["x"],
  4147. "t"=>$v["t"],
  4148. "z"=>$v["z"],
  4149. "jm"=>$v["jm"],
  4150. "weight"=>$v["weight"],
  4151. "asd"=>$v["asd"],
  4152. ];
  4153. }
  4154. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4155. $titlename = "<table border=1>
  4156. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4157. <tr align='center'>
  4158. <td>仓库</td>
  4159. <td>供应商</td>
  4160. <td>位置</td>
  4161. <td>库存编码</td>
  4162. <td>SKU</td>
  4163. <td>商品名称</td>
  4164. <td>商品中文</td>
  4165. <td>产品备注</td>
  4166. <td>说明</td>
  4167. <td>类型</td>
  4168. <td>入库总量</td>
  4169. <td>库存数量</td>
  4170. <td>销售数量</td>
  4171. <td>退货数量</td>
  4172. <td>占单数量</td>
  4173. <td>料号</td>
  4174. <td>重量</td>
  4175. <td>类目</td>
  4176. </tr>
  4177. </table>";
  4178. $filename = $title . ".xls";
  4179. $tail = "";
  4180. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4181. }
  4182. }
  4183. }
  4184. //出库+入库数据整合
  4185. public function _excelcr()
  4186. {
  4187. if (isset($_GET['excel'])) {
  4188. $type = $this->input->get('excel', true);
  4189. $category = $this->input->get('category', true);
  4190. $size = $this->input->get('size', true);
  4191. $grade = $this->input->get('grade', true);
  4192. $color = $this->input->get('color', true);
  4193. $lowe = $this->input->get('lowe', true);
  4194. $sku = $this->input->get('sku', true);
  4195. $warehouse = $this->input->get('warehouse', true);
  4196. $purchase = $this->input->get('purchase', true);
  4197. $state = $this->input->get('state', true);
  4198. $sid = $this->input->get('sid', true);
  4199. $ktime = $this->input->get('ktime', true);
  4200. $jtime = $this->input->get('jtime', true);
  4201. $ktime = strtotime($ktime);
  4202. $jtime = strtotime($jtime);
  4203. $where = "1=1";
  4204. $gj = "";
  4205. $ck = "";
  4206. if ($category) {
  4207. $where .= " and features like '%-$category-%'";
  4208. }
  4209. if ($size) {
  4210. $where .= " and features like '%-$size-%'";
  4211. }
  4212. if ($grade) {
  4213. $where .= " and features like '%-$grade-%'";
  4214. }
  4215. if ($color) {
  4216. $where .= " and features like '%-$color-%'";
  4217. }
  4218. if ($lowe) {
  4219. $where .= " and features like '%-$lowe-%'";
  4220. }
  4221. if ($warehouse) {
  4222. $where .= " and warehouse = '$warehouse'";
  4223. }
  4224. if ($purchase) {
  4225. $where .= " and purchase = '$purchase'";
  4226. }
  4227. if ($state) {
  4228. $where .= " and state = '$state'";
  4229. }
  4230. if ($sku) {
  4231. $where .= " and sku like '%$sku%'";
  4232. }
  4233. if ($ktime && $jtime) {
  4234. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4235. }
  4236. $sidwhere = '';
  4237. if ($sid) {
  4238. $sd = "";
  4239. $s = explode(',', trim($sid, ','));
  4240. foreach ($s as $value) {
  4241. $sd .= " id = " . $value . " or";
  4242. }
  4243. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4244. }
  4245. //取得信息列表
  4246. $timeread = $ktime;
  4247. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4248. $timelist = array();
  4249. for ($i = 0; $i < $timenum; $i++) {
  4250. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4251. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4252. }
  4253. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4254. //echo "<pre>";
  4255. //print_r($info_list);
  4256. //exit();
  4257. $rows = array();
  4258. $list = array();
  4259. foreach ($info_list as $key => $value) {
  4260. $thistime = $timelist;
  4261. if (isset($rows[strtolower($value['sku'])])) {
  4262. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4263. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4264. }
  4265. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4266. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4267. }
  4268. } else {
  4269. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4270. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4271. }
  4272. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4273. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4274. }
  4275. $rows[strtolower($value['sku'])] = $thistime;
  4276. }
  4277. }
  4278. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4279. <head>
  4280. <!--[if gte mso 9]><xml>
  4281. <x:ExcelWorkbook>
  4282. <x:ExcelWorksheets>
  4283. <x:ExcelWorksheet>
  4284. <x:Name>EXCEL</x:Name>
  4285. <x:WorksheetOptions>
  4286. <x:Print>
  4287. <x:ValidPrinterInfo />
  4288. </x:Print>
  4289. </x:WorksheetOptions>
  4290. </x:ExcelWorksheet>
  4291. </x:ExcelWorksheets>
  4292. </x:ExcelWorkbook>
  4293. </xml>
  4294. <![endif]-->
  4295. </head><body>";
  4296. $str .= "<table border=1><tr><td>SKU</td>";
  4297. foreach ($timelist as $k => $v) {
  4298. $str .= "<td>" . $k . "出库</td>";
  4299. $str .= "<td>" . $k . "入库</td>";
  4300. }
  4301. $str .= "</tr></table>";
  4302. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4303. foreach ($rows as $key => $val) {
  4304. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4305. foreach ($val as $k => $v) {
  4306. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4307. if ($val[$k]['r'] > 0) {
  4308. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4309. } else {
  4310. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4311. }
  4312. }
  4313. $str .= "</tr>";
  4314. }
  4315. $str .= "</table>";
  4316. $str .= "</body></html>";
  4317. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4318. header("Content-type: application/octet-stream");
  4319. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4320. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4321. header("Pragma: no-cache");
  4322. header("Expires: 0");
  4323. exit($str);
  4324. }
  4325. }
  4326. //数量调整模板导出
  4327. public function _presetout()
  4328. {
  4329. if (isset($_GET['excel'])) {
  4330. $where = "sku != 'Preset' and purchase != 0";
  4331. //数据排序
  4332. $order_str = "id desc";
  4333. if (empty($page)) {
  4334. $start = 0;
  4335. $perpage = 1;
  4336. } else {
  4337. $start = ($page - 1) * $perpage;
  4338. }
  4339. //取得信息列表
  4340. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4341. $rows = array();
  4342. $list = array();
  4343. foreach ($info_list as $value) {
  4344. $warehouse = $this->warehouse->read($value['warehouse']);
  4345. $number = $value['number'];
  4346. $ftime = time() - 15 * 24 * 3600;
  4347. $purchase = $this->purchase->read($value['purchase']);
  4348. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4349. }
  4350. $title = "库存模板";
  4351. $titlename = "<table border=1>
  4352. <tr align='center'>
  4353. <td>仓库</td>
  4354. <td>供应商编码</td>
  4355. <td>SKU</td>
  4356. <td>增减数量(正数或负数)</td>
  4357. <td>增减备注</td>
  4358. <td>扣减方式:0减少库存1删除库存</td>
  4359. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4360. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4361. </tr>
  4362. </table>";
  4363. $filename = $title . ".xls";
  4364. $tail = "";
  4365. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4366. }
  4367. }
  4368. //数量调整模板导入
  4369. public function _presetedit()
  4370. {
  4371. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4372. $config['upload_path'] = '.' . $dir;
  4373. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4374. $config['allowed_types'] = 'xls|xlsx|csv';
  4375. $config['max_size'] = 10240;
  4376. $this->load->library('upload', $config);
  4377. $this->upload->initialize($config);
  4378. if ($this->upload->do_upload('userfile')) {
  4379. $full_path = $dir . $this->upload->data('file_name');
  4380. $fileName = '.' . $full_path;
  4381. if (!file_exists($fileName)) {
  4382. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4383. exit;
  4384. } else {
  4385. require_once "./data/excel/PHPExcel/IOFactory.php";
  4386. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4387. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4388. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4389. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4390. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4391. ++$column; //如果列数大于26行
  4392. $list = array();
  4393. for ($i = 2; $i <= $row; $i++) // 行数循环
  4394. {
  4395. $data = array();
  4396. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4397. {
  4398. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4399. }
  4400. $list[] = $data;
  4401. }
  4402. }
  4403. $i = 0;
  4404. $j = 0;
  4405. $ed = array();
  4406. foreach ($list as $key => $value) {
  4407. $time = time();
  4408. if ($value['0'] == "") {
  4409. continue;
  4410. }
  4411. $warehouse = $this->warehouse->get_title($value['0']);
  4412. $purchase = $this->purchase->get_bm($value['1']);
  4413. $sku = $value['2'];
  4414. $num = $value['3']; //调整数量
  4415. $text = $value['4']; //扣减说明
  4416. $type = $value['5']; //调整方式0扣减1删除
  4417. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4418. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4419. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4420. if (!$purchase) //如果没有这个SKU
  4421. {
  4422. $ed[] = array($purchase . '-不存在此供应商编码');
  4423. $j++;
  4424. continue;
  4425. }
  4426. if (!$d) //如果没有这个SKU
  4427. {
  4428. $ed[] = array($sku . '-库存中不存在此SKU');
  4429. $j++;
  4430. continue;
  4431. }
  4432. if (!isset($warehouse['id'])) {
  4433. $ed[] = array($sku . '-仓库名错误!');
  4434. $j++;
  4435. continue;
  4436. }
  4437. if ($type != '0' && $type != '1') {
  4438. $ed[] = array($sku . '-扣减方式填写错误!');
  4439. $j++;
  4440. continue;
  4441. }
  4442. if ($num < 0) //扣减库存
  4443. {
  4444. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4445. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4446. $j++;
  4447. continue;
  4448. }
  4449. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4450. if (count($data) < abs($num)) {
  4451. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4452. $j++;
  4453. continue;
  4454. }
  4455. if ($type == 0) //如果扣减方式为 扣减库存
  4456. {
  4457. for ($i = 0; $i < abs($num); $i++) {
  4458. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4459. }
  4460. } else if ($type == 1) {
  4461. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4462. if (count($zt) > 0) {
  4463. $ed[] = array($sku . '-有在途库存无法删除!');
  4464. $j++;
  4465. continue;
  4466. }
  4467. for ($i = 0; $i < abs($num); $i++) {
  4468. $this->whlabel->remove($data[$i]['id']);
  4469. }
  4470. }
  4471. } else if ($num > 0) //增加库存
  4472. {
  4473. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4474. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4475. $j++;
  4476. continue;
  4477. }
  4478. $post['sku'] = $d['sku'];
  4479. $post['shop'] = $d['shop'];
  4480. $post['warehouse'] = $warehouse['id'];
  4481. $post['purchase'] = $purchase['id'];
  4482. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4483. $post['state'] = 0;
  4484. $post['title'] = $d['title'];
  4485. $post['number'] = $d['number'];
  4486. $post['features'] = $d['features'];
  4487. $post['enter'] = $time;
  4488. $post['time'] = $time; //操作时间
  4489. $post['rktype'] = $rktype;
  4490. for ($i = 0; $i < $num; $i++) {
  4491. $post['label'] = time() . rand(100, 999) . $i;
  4492. $this->whlabel->insert($post);
  4493. }
  4494. }
  4495. sleep(1); //防止入库时间一样,需要延迟1秒
  4496. }
  4497. if ($j > 0) {
  4498. $tt = date('Ymd', time());
  4499. $title = '库存导入错误信息-' . $tt;
  4500. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4501. $tail = "\n";
  4502. $filename = $title . ".xls";
  4503. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4504. $dir = '/data/excel/' . $time . '/';
  4505. $file_name = 'error_' . $time . rand(1000, 9999);
  4506. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4507. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4508. fwrite($myfile, $ecl);
  4509. fclose($myfile);
  4510. $error = $dir . $file_name . '.xls';
  4511. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4512. exit;
  4513. } else {
  4514. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4515. exit;
  4516. }
  4517. }
  4518. }
  4519. public function _presetedittwo(){
  4520. $data = $this->input->post(NULL, TRUE);
  4521. if(empty($list)){
  4522. $raw_data = $this->input->raw_input_stream;
  4523. // 解码 JSON
  4524. $data = json_decode($raw_data, true);
  4525. }
  4526. if(empty($data)){
  4527. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4528. }
  4529. $list = [];
  4530. if(isset($data['list'])){
  4531. $list = $data['list'];
  4532. }
  4533. $i = 0;
  4534. $j = 0;
  4535. $ed = array();
  4536. foreach ($list as $key => $value) {
  4537. $time = time();
  4538. if ($value['0'] == "") {
  4539. continue;
  4540. }
  4541. $warehouse = $this->warehouse->get_title($value['0']);
  4542. $purchase = $this->purchase->get_bm($value['1']);
  4543. $sku = $value['2'];
  4544. $num = $value['3']; //调整数量
  4545. $text = $value['4']; //扣减说明
  4546. $type = $value['5']; //调整方式0扣减1删除
  4547. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4548. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4549. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4550. if (!$purchase) //如果没有这个SKU
  4551. {
  4552. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4553. $j++;
  4554. continue;
  4555. }
  4556. if (!$d) //如果没有这个SKU
  4557. {
  4558. $ed[] = array($sku . '-库存中不存在此SKU');
  4559. $j++;
  4560. continue;
  4561. }
  4562. if (!isset($warehouse['id'])) {
  4563. $ed[] = array($sku . '-仓库名错误!');
  4564. $j++;
  4565. continue;
  4566. }
  4567. if ($type != '0' && $type != '1') {
  4568. $ed[] = array($sku . '-扣减方式填写错误!');
  4569. $j++;
  4570. continue;
  4571. }
  4572. if ($num < 0) //扣减库存
  4573. {
  4574. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4575. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4576. $j++;
  4577. continue;
  4578. }
  4579. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4580. if (count($data) < abs($num)) {
  4581. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4582. $j++;
  4583. continue;
  4584. }
  4585. if ($type == 0) //如果扣减方式为 扣减库存
  4586. {
  4587. for ($i = 0; $i < abs($num); $i++) {
  4588. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4589. }
  4590. } else if ($type == 1) {
  4591. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4592. if (count($zt) > 0) {
  4593. $ed[] = array($sku . '-有在途库存无法删除!');
  4594. $j++;
  4595. continue;
  4596. }
  4597. for ($i = 0; $i < abs($num); $i++) {
  4598. $this->whlabel->remove($data[$i]['id']);
  4599. }
  4600. }
  4601. } else if ($num > 0) //增加库存
  4602. {
  4603. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4604. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4605. $j++;
  4606. continue;
  4607. }
  4608. $post['sku'] = $d['sku'];
  4609. $post['shop'] = $d['shop'];
  4610. $post['warehouse'] = $warehouse['id'];
  4611. $post['purchase'] = $purchase['id'];
  4612. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4613. $post['state'] = 0;
  4614. $post['title'] = $d['title'];
  4615. $post['number'] = $d['number'];
  4616. $post['features'] = $d['features'];
  4617. $post['enter'] = $time;
  4618. $post['time'] = $time; //操作时间
  4619. $post['rktype'] = $rktype;
  4620. $post['sku_master_id'] = $d['sku_master_id'];
  4621. $post['sku_shop_id'] = $d['sku_shop_id'];
  4622. for ($i = 0; $i < $num; $i++) {
  4623. $post['label'] = time() . rand(100, 999) . $i;
  4624. $this->whlabel->insert($post);
  4625. }
  4626. }
  4627. sleep(1); //防止入库时间一样,需要延迟1秒
  4628. }
  4629. if ($j > 0) {
  4630. $tt = date('Ymd', time());
  4631. $title = '库存导入错误信息-' . $tt;
  4632. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4633. $tail = "\n";
  4634. $filename = $title . ".xls";
  4635. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4636. $dir = '/data/excel/' . $time . '/';
  4637. $file_name = 'error_' . $time . rand(1000, 9999);
  4638. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4639. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4640. fwrite($myfile, $ecl);
  4641. fclose($myfile);
  4642. $error = $dir . $file_name . '.xls';
  4643. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4644. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4645. exit;
  4646. } else {
  4647. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4648. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4649. exit;
  4650. }
  4651. }
  4652. //笛卡儿积
  4653. function cp($ps, $sets, $list)
  4654. {
  4655. $result = array();
  4656. $j = 0;
  4657. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4658. if ($i == 0) {
  4659. $result = $sets[$i];
  4660. }
  4661. $tmp = array();
  4662. foreach ($result as $res) {
  4663. foreach ($sets[$i + 1] as $set) {
  4664. $tmp[] = $res . ',' . $set;
  4665. }
  4666. }
  4667. $result = $tmp;
  4668. }
  4669. $this->db->trans_begin();
  4670. foreach ($result as $v) {
  4671. $post = array();
  4672. $title = "";
  4673. $num = "";
  4674. $data = explode(',', $v);
  4675. for ($i = 0; $i < count($list); $i++) {
  4676. $post[$list[$i]] = $data[$i];
  4677. $typeclass = $this->typeclass->read($data[$i]);
  4678. $title = $title . $typeclass['title'] . " ";
  4679. if ($data[$i] != 0) {
  4680. $num .= $data[$i]; //所有数据ID拼接
  4681. }
  4682. }
  4683. foreach ($ps as $kp => $vp) {
  4684. $post[$kp] = $vp;
  4685. }
  4686. $post['number'] = $num;
  4687. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4688. if ($info_list) {
  4689. $j++;
  4690. } else {
  4691. $skunum = $this->whlabel->find_count();
  4692. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4693. $post['title'] = rtrim($title, ' ');
  4694. $this->whlabel->insert($post);
  4695. }
  4696. }
  4697. if ($this->db->trans_status() === FALSE) {
  4698. $this->db->trans_commit();
  4699. return NULL;
  4700. } else {
  4701. $this->db->trans_commit();
  4702. return $j;
  4703. }
  4704. }
  4705. public function _kj($arg_array)
  4706. {
  4707. if (isset($_POST['sku'])) {
  4708. $time = time();
  4709. $sku = $this->input->post('sku', true);
  4710. $warehouse = $this->input->post('warehouse', true);
  4711. $num = $this->input->post('num', true);
  4712. $text = $this->input->post('text', true);
  4713. $purchase = $this->input->post('purchase', true);
  4714. $cktype = $this->input->post('cktype', true);
  4715. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4716. if ($cktype != 1 && $text == '') {
  4717. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4718. exit;
  4719. }
  4720. if ($num > count($order)) {
  4721. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4722. exit;
  4723. } else {
  4724. for ($i = 0; $i < $num; $i++) {
  4725. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4726. }
  4727. }
  4728. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4729. exit;
  4730. }
  4731. $uid = $this->whlabel->read($arg_array[0]);
  4732. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4733. $this->data['data'] = $uid;
  4734. $this->_Template('whlabel_kj', $this->data);
  4735. }
  4736. public function _summary($arg_array)
  4737. {
  4738. $prc = array();
  4739. $purchase = $this->purchase->find_all();
  4740. foreach ($purchase as $k => $v) {
  4741. $prc[$v['id']] = $v['title'];
  4742. }
  4743. if (isset($_GET['excel'])) {
  4744. $ktime = $this->input->get('ktime', true);
  4745. $jtime = $this->input->get('jtime', true);
  4746. $ktime = strtotime($ktime);
  4747. $jtime = strtotime($jtime);
  4748. $where = "1=1";
  4749. if ($ktime && $jtime) {
  4750. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4751. }
  4752. //数据排序
  4753. $order_str = "time desc";
  4754. if (empty($page)) {
  4755. $start = 0;
  4756. $perpage = 1;
  4757. } else {
  4758. $start = ($page - 1) * $perpage;
  4759. }
  4760. //取得信息列表
  4761. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4762. foreach ($info_list as $key => $value) {
  4763. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4764. $warehouse = $this->warehouse->read($value['warehouse']);
  4765. $info_list[$key]['warehouse'] = $warehouse['title'];
  4766. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4767. $details = array();
  4768. $cpid = array();
  4769. foreach ($x as $k => $v) {
  4770. if ($v['details'] != '') {
  4771. $details[$v['details']] = $v['details'];
  4772. }
  4773. if ($v['cpid'] != 0) {
  4774. $cpid[$v['cpid']] = $v['cpid'];
  4775. }
  4776. }
  4777. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4778. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4779. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4780. $info_list[$key]['s'] = $s;
  4781. $info_list[$key]['x'] = count($x);
  4782. }
  4783. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4784. $titlename = "<table border=1>
  4785. <tr align='center'>
  4786. <td>仓库</td>
  4787. <td>供应商</td>
  4788. <td>出库位置</td>
  4789. <td>出库编码</td>
  4790. <td>SKU</td>
  4791. <td>产品名</td>
  4792. <td>总剩余库存</td>
  4793. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4794. </tr>
  4795. </table>";
  4796. $filename = $title . ".xls";
  4797. $tail = "";
  4798. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4799. }
  4800. }
  4801. //usps发货清单
  4802. public function _manifest()
  4803. {
  4804. if (isset($_POST['manifest'])) {
  4805. $wltext = $this->input->post('wltext', true);
  4806. $time = time() - 16 * 3600;
  4807. $ptime = strtotime(date('Y-m-d', $time));
  4808. $waybill = array();
  4809. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4810. foreach ($fullorder as $v) {
  4811. $waybill[$v['waybill']] = $v['waybill'];
  4812. }
  4813. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4814. foreach ($fullordersmt as $v) {
  4815. $waybill[$v['waybill']] = $v['waybill'];
  4816. }
  4817. $wltext = explode(';', $wltext);
  4818. foreach ($wltext as $v) {
  4819. if (isset($waybill[$v])) {
  4820. unset($waybill[$v]);
  4821. }
  4822. }
  4823. $data = $this->usps->get_manifest($waybill);
  4824. if (isset($data['Description'])) {
  4825. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4826. exit;
  4827. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4828. $bctime = date('Ymd', time());
  4829. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4830. echo json_encode(array('msg' => $pdf, 'success' => true));
  4831. exit;
  4832. } else {
  4833. echo json_encode(array('msg' => $data, 'success' => false));
  4834. exit;
  4835. }
  4836. }
  4837. }
  4838. public function _pdf($pdf, $title, $bctime)
  4839. {
  4840. $pdf_path = './data/pdf/' . $bctime . '/';
  4841. $file_base64 = $pdf;
  4842. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4843. $file_base64 = base64_decode($file_base64);
  4844. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4845. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4846. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4847. }
  4848. /**
  4849. *
  4850. *
  4851. *
  4852. 进销存占单异常索引
  4853. *
  4854. *
  4855. *
  4856. **/
  4857. public function _abnormal()
  4858. {
  4859. $post = $this->input->post(NULL, TRUE);
  4860. if (isset($post['page'])) {
  4861. $page = $this->input->post('page', true);
  4862. $perpage = $this->input->post('perpage', true);
  4863. $sku = $this->input->post('sku', true);
  4864. $where = "1=1";
  4865. //数据排序
  4866. $order_str = "id desc";
  4867. if (empty($page)) {
  4868. $start = 0;
  4869. $perpage = 1;
  4870. } else {
  4871. $start = ($page - 1) * $perpage;
  4872. }
  4873. //取得信息列表
  4874. $info_list = $this->whlabel->find_all($where, '*');
  4875. $rows = array();
  4876. $list = array();
  4877. foreach ($info_list as $key => $value) {
  4878. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4879. }
  4880. foreach ($rows as $value) {
  4881. $warehouse = $this->warehouse->read($value['warehouse']);
  4882. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4883. $number = $value['number'];
  4884. $ftime = time() - 15 * 24 * 3600;
  4885. if ($value['shop'] != '') {
  4886. $shop = $value['shop'];
  4887. $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');
  4888. $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');
  4889. $order = array_merge($orderdlz, $ordersmt);
  4890. $od = 0;
  4891. $a = '';
  4892. $orid = '';
  4893. foreach ($order as $v) {
  4894. $or = explode('|', ltrim($v['whlabel'], '|'));
  4895. for ($i = 0; $i < count($or); $i++) {
  4896. $orod = explode('-', $or[$i]);
  4897. if ($orod[0] == $number) {
  4898. $od += $orod[1];
  4899. }
  4900. }
  4901. $orid .= $v['number'] . '-';
  4902. }
  4903. } else {
  4904. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4905. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4906. $order = array_merge($orderdlz, $ordersmt);
  4907. $od = 0;
  4908. $a = '';
  4909. $orid = '';
  4910. $qt = array();
  4911. foreach ($order as $v) {
  4912. $or = explode('|', ltrim($v['whlabel'], '|'));
  4913. for ($i = 0; $i < count($or); $i++) {
  4914. $orod = explode('-', $or[$i]);
  4915. if ($orod[0] == $number) {
  4916. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4917. if ($czzs > 0) {
  4918. if (isset($qt[$v['shop']])) {
  4919. if ($qt[$v['shop']] < $orod[1]) {
  4920. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4921. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4922. } else {
  4923. $qt[$v['shop']] -= $orod[1];
  4924. }
  4925. } else {
  4926. $qt[$v['shop']] = $czzs;
  4927. }
  4928. } else {
  4929. $od += $orod[1];
  4930. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4931. }
  4932. }
  4933. }
  4934. }
  4935. }
  4936. $z = $od . '(' . $orid . ')'; //查看订单号
  4937. //$z = $od;
  4938. if ($od > $c) {
  4939. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4940. }
  4941. }
  4942. $listdata = array_slice($list, $start, $perpage);
  4943. $total = count($list);
  4944. $pagenum = ceil($total / $perpage);
  4945. $over = $total - ($start + $perpage);
  4946. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4947. echo json_encode($rows);
  4948. exit;
  4949. }
  4950. $this->_Template('whlabel_abnormal', $this->data);
  4951. }
  4952. /**
  4953. *
  4954. *
  4955. *
  4956. 进销存占单异常索引
  4957. *
  4958. *
  4959. *
  4960. **/
  4961. public function _error()
  4962. {
  4963. $post = $this->input->post(NULL, TRUE);
  4964. if (isset($post['page'])) {
  4965. $page = $this->input->post('page', true);
  4966. $perpage = $this->input->post('perpage', true);
  4967. $sku = $this->input->post('sku', true);
  4968. $warehouse = $this->input->post('warehouse', true);
  4969. $ktime = $this->input->post('ktime', true);
  4970. $jtime = $this->input->post('jtime', true);
  4971. $ktime = strtotime($ktime);
  4972. $jtime = strtotime($jtime);
  4973. $where = "sku != 'Preset'";
  4974. $gj = '';
  4975. if ($sku) {
  4976. $where .= " and sku like '%$sku%'";
  4977. } else {
  4978. if ($ktime && $jtime) {
  4979. $gj = " and time > '$ktime' and time < '$jtime'";
  4980. }
  4981. }
  4982. if ($warehouse) {
  4983. $where .= " and warehouse = '$warehouse'";
  4984. }
  4985. //数据排序
  4986. $order_str = "id desc";
  4987. if (empty($page)) {
  4988. $start = 0;
  4989. $perpage = 1;
  4990. } else {
  4991. $start = ($page - 1) * $perpage;
  4992. }
  4993. //取得信息列表
  4994. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4995. $rows = array();
  4996. $list = array();
  4997. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4998. // foreach ($info_list as $value)
  4999. // {
  5000. // $warehouse = $this->warehouse->read($value['warehouse']);
  5001. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5002. // $number = $value['number'];$ftime = time()-15*24*3600;
  5003. // if($c < 1)
  5004. // {
  5005. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5006. // }
  5007. // }
  5008. $warehouse_list = $this->warehouse->find_all();
  5009. $warehouse_list = array_column($warehouse_list, null, 'id');
  5010. foreach ($info_list as $value) {
  5011. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5012. 'title' => "",
  5013. ];
  5014. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5015. $number = $value['number'];
  5016. $ftime = time() - 15 * 24 * 3600;
  5017. if ($c < 1) {
  5018. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5019. }
  5020. }
  5021. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5022. // $query = $this->db->query($sql);
  5023. // $info_list = $query->result_array();
  5024. // $sql_two = "select title,id from crowd_warehouse";
  5025. // $query_two = $this->db->query($sql_two);
  5026. // $warehouse_list = $query_two->result_array();
  5027. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5028. // foreach ($info_list as $value)
  5029. // {
  5030. // if(isset($warehouse_arr[$value['warehouse']])){
  5031. // $warehouse = $warehouse_arr[$value['warehouse']];
  5032. // }else{
  5033. // $warehouse = [
  5034. // 'id'=>0,
  5035. // 'title'=>"异常",
  5036. // ];
  5037. // }
  5038. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5039. // $number = $value['number'];$ftime = time()-15*24*3600;
  5040. // if($c < 1)
  5041. // {
  5042. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5043. // }
  5044. // }
  5045. $listdata = array_slice($list, $start, $perpage);
  5046. $total = count($list);
  5047. $pagenum = ceil($total / $perpage);
  5048. $over = $total - ($start + $perpage);
  5049. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5050. echo json_encode($rows);
  5051. exit;
  5052. }
  5053. if (isset($post['s'])) {
  5054. $id_arr = $this->input->post('s');
  5055. $id_arr = explode(',', trim($id_arr, ','));
  5056. if (!$id_arr) {
  5057. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5058. exit;
  5059. }
  5060. //循环删除记录
  5061. foreach ($id_arr as $v) {
  5062. $dd = $this->whlabel->read($v);
  5063. if (!isset($dd['id'])) {
  5064. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5065. exit;
  5066. }
  5067. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5068. if (isset($zt[0])) {
  5069. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5070. exit;
  5071. }
  5072. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5073. foreach ($deldd as $vv) {
  5074. $this->whlabel->remove($vv['id']);
  5075. }
  5076. }
  5077. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5078. exit;
  5079. }
  5080. $this->_Template('whlabel_error', $this->data);
  5081. }
  5082. public function _errorexcel()
  5083. {
  5084. $post = $this->input->post(NULL, TRUE);
  5085. if (isset($_GET['page'])) {
  5086. $page = $this->input->get('page', true);
  5087. $perpage = $this->input->get('perpage', true);
  5088. $sku = $this->input->get('sku', true);
  5089. $warehouse = $this->input->get('warehouse', true);
  5090. $ktime = $this->input->get('ktime', true);
  5091. $jtime = $this->input->get('jtime', true);
  5092. $ktime = strtotime($ktime);
  5093. $jtime = strtotime($jtime);
  5094. $where = "sku != 'Preset'";
  5095. $gj = '';
  5096. if ($sku) {
  5097. $where .= " and sku like '%$sku%'";
  5098. } else {
  5099. if ($ktime && $jtime) {
  5100. $gj = " and time > '$ktime' and time < '$jtime'";
  5101. }
  5102. }
  5103. if ($warehouse) {
  5104. $where .= " and warehouse = '$warehouse'";
  5105. }
  5106. //数据排序
  5107. $order_str = "id desc";
  5108. if (empty($page)) {
  5109. $start = 0;
  5110. $perpage = 1;
  5111. } else {
  5112. $start = ($page - 1) * $perpage;
  5113. }
  5114. //取得信息列表
  5115. $rows = array();
  5116. $list = array();
  5117. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5118. foreach ($info_list as $value) {
  5119. $warehouse = $this->warehouse->read($value['warehouse']);
  5120. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5121. $number = $value['number'];
  5122. $ftime = time() - 15 * 24 * 3600;
  5123. if ($c < 1) {
  5124. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5125. }
  5126. }
  5127. $title = "0库存汇总";
  5128. $titlename = "<table border=1>
  5129. <tr align='center'>
  5130. <td>仓库</td>
  5131. <td>SKU</td>
  5132. <td>产品</td>
  5133. <td>当前库存</td>
  5134. </tr>
  5135. </table>";
  5136. $filename = $title . ".xls";
  5137. $tail = "";
  5138. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5139. }
  5140. }
  5141. /**
  5142. *
  5143. *
  5144. * 占单
  5145. *
  5146. *
  5147. **/
  5148. public function _kcyz()
  5149. {
  5150. $post = $this->input->post(NULL, TRUE);
  5151. if (isset($post['warehouse'])) {
  5152. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5153. exit; //不再使用
  5154. $warehouse = $this->input->post('warehouse', true);
  5155. $whlabel = $this->input->post('whlabel', true);
  5156. $id = $this->input->post('id', true);
  5157. $shop = $this->input->post('shop', true);
  5158. $number = $this->input->post('number', true);
  5159. if (!$whlabel || $whlabel == '|') {
  5160. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5161. exit;
  5162. }
  5163. $pp = explode('|', trim($whlabel, '|'));
  5164. $x = 0;
  5165. $save = array();
  5166. foreach ($pp as $va) {
  5167. $num = explode('-', $va);
  5168. if ($number) {
  5169. $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 = '')"); //通用
  5170. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5171. } else {
  5172. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5173. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5174. }
  5175. $x++;
  5176. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5177. $save[] = $x - 1;
  5178. continue; //提前先加X不然出错,所以要减1
  5179. }
  5180. }
  5181. if (isset($save[0])) {
  5182. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5183. exit;
  5184. } else {
  5185. echo json_encode(array('success' => true));
  5186. exit;
  5187. }
  5188. }
  5189. }
  5190. public function _db()
  5191. {
  5192. $post = $this->input->post(NULL, TRUE);
  5193. if (isset($post['page'])) {
  5194. $page = $this->input->post('page', true);
  5195. $perpage = $this->input->post('perpage', true);
  5196. $sku = $this->input->post('sku', true);
  5197. $number = $this->input->post('number', true);
  5198. $warehouse = $this->input->post('warehouse', true);
  5199. $purchase = $this->input->post('purchase', true);
  5200. $orderinfo = $this->input->post('orderinfo', true);
  5201. $waybill = $this->input->post('waybill', true);
  5202. $category = $this->input->post('category', true);
  5203. $size = $this->input->post('size', true);
  5204. $grade = $this->input->post('grade', true);
  5205. $color = $this->input->post('color', true);
  5206. $lowe = $this->input->post('lowe', true);
  5207. $state = $this->input->post('state', true);
  5208. $label = $this->input->post('label', true);
  5209. $timetk = $this->input->post('timetkk', true);
  5210. $timetj = $this->input->post('timetjj', true);
  5211. $timetk = strtotime($timetk);
  5212. $timetj = strtotime($timetj);
  5213. $where = "dbtime > 0";
  5214. if ($timetk && $timetj) {
  5215. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5216. }
  5217. if ($sku) {
  5218. $where .= " and sku = '$sku'";
  5219. }
  5220. if ($warehouse) {
  5221. $where .= " and warehouse = '$warehouse'";
  5222. if ($warehouse == 12) {
  5223. $w = 'specialstock';
  5224. } else {
  5225. $w = 'whlabel';
  5226. }
  5227. }
  5228. if ($purchase) {
  5229. $where .= " and purchase = '$purchase'";
  5230. }
  5231. if ($category) {
  5232. $where .= " and features like '%-$category-%'";
  5233. }
  5234. if ($size) {
  5235. $where .= " and features like '%-$size-%'";
  5236. }
  5237. if ($grade) {
  5238. $where .= " and features like '%-$grade-%'";
  5239. }
  5240. if ($color) {
  5241. $where .= " and features like '%-$color-%'";
  5242. }
  5243. if ($lowe) {
  5244. $where .= " and features like '%-$lowe-%'";
  5245. }
  5246. if ($state != '') {
  5247. $where .= " and state = '$state'";
  5248. }
  5249. //数据排序
  5250. $order_str = "dbtime desc";
  5251. if (empty($page)) {
  5252. $start = 0;
  5253. $perpage = 1;
  5254. } else {
  5255. $start = ($page - 1) * $perpage;
  5256. }
  5257. //取得信息列表
  5258. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5259. foreach ($info_list as $key => $value) {
  5260. $warehouse = $this->$w->read($value['warehouse']);
  5261. $info_list[$key]['warehouse'] = $warehouse['title'];
  5262. $purchase = $this->purchase->read($value['purchase']);
  5263. $info_list[$key]['purchase'] = $purchase['title'];
  5264. if ($value['enter'] != 0) {
  5265. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5266. } else {
  5267. $info_list[$key]['enter'] = "";
  5268. }
  5269. if ($value['dbtime'] != 0) {
  5270. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5271. } else {
  5272. $info_list[$key]['dbtime'] = "";
  5273. }
  5274. if ($value['state'] == 0) {
  5275. $info_list[$key]['state'] = "在库";
  5276. } else if ($value['state'] == 1) {
  5277. $info_list[$key]['state'] = "出库";
  5278. } else if ($value['state'] == 2) {
  5279. $info_list[$key]['state'] = "退库";
  5280. } else if ($value['state'] == 3) {
  5281. $info_list[$key]['state'] = "调拨中";
  5282. } else if ($value['state'] == 4) {
  5283. $info_list[$key]['state'] = "再加工";
  5284. } else if ($value['state'] == 5) {
  5285. $info_list[$key]['state'] = "维修中";
  5286. } else if ($value['state'] == 6) {
  5287. $info_list[$key]['state'] = "盘亏";
  5288. } else if ($value['state'] == 7) {
  5289. $info_list[$key]['state'] = "更换标签";
  5290. } else if ($value['state'] == 8) {
  5291. $info_list[$key]['state'] = "其它";
  5292. } else if ($value['state'] == 9) {
  5293. $info_list[$key]['state'] = "预设";
  5294. }
  5295. }
  5296. $total = $this->whlabel->find_count($where);
  5297. $pagenum = ceil($total / $perpage);
  5298. $over = $total - ($start + $perpage);
  5299. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5300. echo json_encode($rows);
  5301. exit;
  5302. }
  5303. if (isset($post['outsku'])) {
  5304. $time = time();
  5305. $cz = $this->input->post('cz', true);
  5306. $label = $this->input->post('outsku', true);
  5307. $sl = $this->input->post('sl', true);
  5308. $num = $this->input->post('num', true);
  5309. //$warehouse = $this->input->post('warehouse',true);
  5310. if (!$sl) {
  5311. $sl = 1;
  5312. }
  5313. if (!$warehouse) {
  5314. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5315. exit;
  5316. }
  5317. $dblabel = $this->whlabellabel->get_label($label);
  5318. if ($dblabel) {
  5319. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5320. if (count($data) < 1) {
  5321. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5322. exit;
  5323. }
  5324. if (count($data) < $num) {
  5325. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5326. exit;
  5327. }
  5328. for ($i = 0; $i < $sl; $i++) {
  5329. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5330. }
  5331. echo json_encode(array('success' => true));
  5332. exit;
  5333. } else {
  5334. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5335. exit;
  5336. }
  5337. }
  5338. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5339. $this->_Template('whlabel_db', $this->data);
  5340. }
  5341. public function _dbrk()
  5342. {
  5343. $post = $this->input->post(NULL, TRUE);
  5344. if (isset($post['page'])) {
  5345. $page = $this->input->post('page', true);
  5346. $perpage = $this->input->post('perpage', true);
  5347. $sku = $this->input->post('sku', true);
  5348. $number = $this->input->post('number', true);
  5349. $warehouse = $this->input->post('warehouse', true);
  5350. $purchase = $this->input->post('purchase', true);
  5351. $orderinfo = $this->input->post('orderinfo', true);
  5352. $waybill = $this->input->post('waybill', true);
  5353. $category = $this->input->post('category', true);
  5354. $size = $this->input->post('size', true);
  5355. $grade = $this->input->post('grade', true);
  5356. $color = $this->input->post('color', true);
  5357. $lowe = $this->input->post('lowe', true);
  5358. $state = $this->input->post('state', true);
  5359. $label = $this->input->post('label', true);
  5360. $ctime = $this->input->post('ctime', true);
  5361. $timetk = $this->input->post('timetkk', true);
  5362. $timetj = $this->input->post('timetjj', true);
  5363. $timetk = strtotime($timetk);
  5364. $timetj = strtotime($timetj);
  5365. $where = "dbtime > 0";
  5366. if ($timetk && $timetj) {
  5367. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5368. }
  5369. if ($sku) {
  5370. $where .= " and sku = '$sku'";
  5371. }
  5372. if ($warehouse) {
  5373. $where .= " and warehouse = '$warehouse'";
  5374. }
  5375. if ($purchase) {
  5376. $where .= " and purchase = '$purchase'";
  5377. }
  5378. if ($category) {
  5379. $where .= " and features like '%-$category-%'";
  5380. }
  5381. if ($size) {
  5382. $where .= " and features like '%-$size-%'";
  5383. }
  5384. if ($grade) {
  5385. $where .= " and features like '%-$grade-%'";
  5386. }
  5387. if ($color) {
  5388. $where .= " and features like '%-$color-%'";
  5389. }
  5390. if ($lowe) {
  5391. $where .= " and features like '%-$lowe-%'";
  5392. }
  5393. if ($state != '') {
  5394. $where .= " and state = '$state'";
  5395. }
  5396. //数据排序
  5397. $order_str = "dbtime desc";
  5398. if (empty($page)) {
  5399. $start = 0;
  5400. $perpage = 1;
  5401. } else {
  5402. $start = ($page - 1) * $perpage;
  5403. }
  5404. //取得信息列表
  5405. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5406. foreach ($info_list as $key => $value) {
  5407. $warehouse = $this->warehouse->read($value['warehouse']);
  5408. $info_list[$key]['warehouse'] = $warehouse['title'];
  5409. $purchase = $this->purchase->read($value['purchase']);
  5410. $info_list[$key]['purchase'] = $purchase['title'];
  5411. if ($value['enter'] != 0) {
  5412. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5413. } else {
  5414. $info_list[$key]['enter'] = "";
  5415. }
  5416. if ($value['dbtime'] != 0) {
  5417. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5418. } else {
  5419. $info_list[$key]['dbtime'] = "";
  5420. }
  5421. if ($value['state'] == 0) {
  5422. $info_list[$key]['state'] = "在库";
  5423. } else if ($value['state'] == 1) {
  5424. $info_list[$key]['state'] = "出库";
  5425. } else if ($value['state'] == 2) {
  5426. $info_list[$key]['state'] = "退库";
  5427. } else if ($value['state'] == 3) {
  5428. $info_list[$key]['state'] = "调拨中";
  5429. } else if ($value['state'] == 4) {
  5430. $info_list[$key]['state'] = "再加工";
  5431. } else if ($value['state'] == 5) {
  5432. $info_list[$key]['state'] = "维修中";
  5433. } else if ($value['state'] == 6) {
  5434. $info_list[$key]['state'] = "盘亏";
  5435. } else if ($value['state'] == 7) {
  5436. $info_list[$key]['state'] = "更换标签";
  5437. } else if ($value['state'] == 8) {
  5438. $info_list[$key]['state'] = "其它";
  5439. } else if ($value['state'] == 9) {
  5440. $info_list[$key]['state'] = "预设";
  5441. }
  5442. }
  5443. $total = $this->whlabel->find_count($where);
  5444. $pagenum = ceil($total / $perpage);
  5445. $over = $total - ($start + $perpage);
  5446. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5447. echo json_encode($rows);
  5448. exit;
  5449. }
  5450. if (isset($post['rsku'])) {
  5451. $cz = $this->input->post('cz', true);
  5452. $label = $this->input->post('rsku', true);
  5453. $sl = $this->input->post('sl', true);
  5454. $warehouse = $this->input->post('warehouse', true);
  5455. if (!$sl) {
  5456. $sl = 1;
  5457. }
  5458. if (!$warehouse) {
  5459. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5460. exit;
  5461. }
  5462. $dblabel = $this->whlabellabel->get_label($label);
  5463. if ($dblabel) {
  5464. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5465. if (count($data) < 1) {
  5466. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5467. exit;
  5468. }
  5469. if ($sl > count($data)) {
  5470. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5471. exit;
  5472. }
  5473. $time = time();
  5474. for ($i = 0; $i < $sl; $i++) {
  5475. $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']);
  5476. }
  5477. echo json_encode(array('success' => true));
  5478. exit;
  5479. } else {
  5480. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5481. exit;
  5482. }
  5483. }
  5484. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5485. $this->_Template('whlabel_dbrk', $this->data);
  5486. }
  5487. public function _whlabelczdc()
  5488. {
  5489. if (isset($_GET['excel'])) {
  5490. //数据排序
  5491. $order_str = "id desc";
  5492. if (empty($page)) {
  5493. $start = 0;
  5494. $perpage = 1;
  5495. } else {
  5496. $start = ($page - 1) * $perpage;
  5497. }
  5498. $state = $this->input->get('state', true);
  5499. $sku = $this->input->get('sku', true);
  5500. $ctime = $this->input->get('ctime', true);
  5501. $category = $this->input->get('category', true);
  5502. $size = $this->input->get('size', true);
  5503. $grade = $this->input->get('grade', true);
  5504. $color = $this->input->get('color', true);
  5505. $lowe = $this->input->get('lowe', true);
  5506. $timetk = $this->input->get('timetkk', true);
  5507. $timetj = $this->input->get('timetjj', true);
  5508. $timetk = strtotime($timetk);
  5509. $timetj = strtotime($timetj);
  5510. $where = "dbtime > 0";
  5511. if ($timetk && $timetj) {
  5512. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5513. }
  5514. if ($category) {
  5515. $where .= " and features like '%-$category-%'";
  5516. }
  5517. if ($size) {
  5518. $where .= " and features like '%-$size-%'";
  5519. }
  5520. if ($grade) {
  5521. $where .= " and features like '%-$grade-%'";
  5522. }
  5523. if ($color) {
  5524. $where .= " and features like '%-$color-%'";
  5525. }
  5526. if ($lowe) {
  5527. $where .= " and features like '%-$lowe-%'";
  5528. }
  5529. //取得信息列表
  5530. $info_list = $this->whlabel->find_all($where, '*');
  5531. $rows = array();
  5532. $list = array();
  5533. foreach ($info_list as $key => $value) {
  5534. $rows[$value['sku']] = $value; //所有数据sku
  5535. }
  5536. foreach ($rows as $value) {
  5537. $warehouse = $this->warehouse->read($value['warehouse']);
  5538. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5539. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5540. if ($value['orderinfo'] == 0) {
  5541. $info_list[$key]['orderinfo'] = "";
  5542. }
  5543. if ($value['waybill'] == 0) {
  5544. $info_list[$key]['waybill'] = "";
  5545. }
  5546. if ($value['state'] == 0) {
  5547. $value['state'] = "在库";
  5548. } else if ($value['state'] == 3) {
  5549. $value['state'] = "调拨中";
  5550. }
  5551. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5552. }
  5553. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5554. $titlename = "<table border=1>
  5555. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5556. <tr align='center'>
  5557. <td>SKU</td>
  5558. <td>产品</td>
  5559. <td>调拨数量</td>
  5560. <td>入库数量</td>
  5561. </tr>
  5562. </table>";
  5563. $filename = $title . ".xls";
  5564. $tail = "";
  5565. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5566. }
  5567. }
  5568. public function _print($arg_array)
  5569. {
  5570. if (isset($_SESSION['api'])) {
  5571. $user = $this->user->get_api($_SESSION['api']);
  5572. $usp = $user;
  5573. $fgshop = "";
  5574. $sid = "";
  5575. $wid = "";
  5576. $wtype = "";
  5577. $usersp = explode('|', trim($user['shop'], '|'));
  5578. $userwh = explode('|', trim($user['warehouse'], '|'));
  5579. foreach ($usersp as $value) {
  5580. $fgshop .= " shop = " . $value . " or";
  5581. $sid .= " id = " . $value . " or";
  5582. }
  5583. foreach ($userwh as $value) {
  5584. $wid .= " id = " . $value . " or";
  5585. $wtype .= " type = " . $value . " or";
  5586. }
  5587. }
  5588. $post = $this->input->post(NULL, TRUE);
  5589. if (isset($post['tmsku'])) {
  5590. $tmsku = $this->input->post('tmsku', true);
  5591. if (is_numeric($tmsku)) {
  5592. $yyh = $this->whlabellabel->get_label($tmsku);
  5593. } else {
  5594. $yyh = $this->whlabellabel->get_sku($tmsku);
  5595. if(empty($yyh)){
  5596. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5597. if($r['code'] == -1 ){
  5598. echo json_encode(array('success' => false));
  5599. exit;
  5600. }else{
  5601. echo json_encode(array('features' => $r['data'], 'success' => true));
  5602. exit;
  5603. }
  5604. }
  5605. }
  5606. if ($yyh) {
  5607. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5608. exit;
  5609. } else {
  5610. echo json_encode(array('success' => false));
  5611. exit;
  5612. }
  5613. }
  5614. $classid = $this->classid->sku();
  5615. $pm = $classid;
  5616. $scsku = $classid;
  5617. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5618. if (isset($post['warehouse'])) {
  5619. if ($post['warehouse']) {
  5620. $list = array();
  5621. $num = "";
  5622. $title = "";
  5623. $features = "";
  5624. $order = 0;
  5625. $post['shop'] = '';
  5626. $brand = $this->input->post('brand', true);
  5627. if ($brand != '0,') {
  5628. $b = $this->brand->read(rtrim($brand, ','));
  5629. if ($b) {
  5630. $post['shop'] = str_replace('|', ',', $b['shop']);
  5631. }
  5632. }
  5633. $post['details'] = $this->input->post('details', true); //打印数量
  5634. $xbqnum = $this->input->post('xbqnum', true);
  5635. $post['purchase'] = $this->input->post('purchase', true);
  5636. $post['warehouse'] = $this->input->post('warehouse', true);
  5637. $post['purchase'] = $this->input->post('purchase', true);
  5638. $post['retreatwarehouse'] = $post['warehouse'];
  5639. $post['cpbz'] = $this->input->post('cpbz', true);
  5640. $post['state'] = 9;
  5641. $category = $this->input->post('category', true);
  5642. $list['category'] = $category;
  5643. $list['hairtype'] = $this->input->post('hairtype', true);
  5644. $list['grade'] = $this->input->post('grade', true);
  5645. $size = $this->input->post('size', true);
  5646. $list['size'] = rtrim($size, ',');
  5647. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5648. $list['extension'] = $this->input->post('extension', true);
  5649. if ($category == 1297) {
  5650. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5651. }
  5652. if ($category == 1702) {
  5653. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5654. $list['syother'] = $this->input->post('syother', true);
  5655. }
  5656. if ($category == 133) {
  5657. $list['fittype'] = $this->input->post('fittype', true);
  5658. $list['acother'] = $this->input->post('acother', true);
  5659. }
  5660. $list['color'] = $this->input->post('color', true);
  5661. $list['lowe'] = $this->input->post('lowe', true);
  5662. if ($category == 127) {
  5663. $list['type'] = $this->input->post('type', true);
  5664. $list['headroad'] = $this->input->post('headroad', true);
  5665. $list['density'] = $this->input->post('density', true);
  5666. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5667. $list['lacesize'] = $this->input->post('lacesize', true);
  5668. }
  5669. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5670. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5671. }
  5672. if ($category == 128) {
  5673. $list['lacetype'] = $this->input->post('lacetype', true);
  5674. $list['haircap'] = $this->input->post('haircap', true);
  5675. $list['density'] = $this->input->post('density', true);
  5676. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5677. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5678. $list['wigother'] = $this->input->post('wigother', true);
  5679. $list['wigother1'] = $this->input->post('wigother1', true);
  5680. $list['wigother2'] = $this->input->post('wigother2', true);
  5681. }
  5682. if ($category == 129) {
  5683. $list['wide'] = $this->input->post('wide', true);
  5684. }
  5685. if ($category == 131) {
  5686. $list['gifttype'] = $this->input->post('gifttype', true);
  5687. $list['giftother'] = $this->input->post('giftother', true);
  5688. }
  5689. if ($category == 134) {
  5690. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5691. }
  5692. if ($category == 1297) {
  5693. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5694. $list['sywigother'] = $this->input->post('sywigother', true);
  5695. }
  5696. if ($category == 130 || $category == 133 || $category == 1702) {
  5697. $list['items'] = $this->input->post('items', true);
  5698. $list['weight'] = $this->input->post('weight', true);
  5699. }
  5700. if ($category == 1702) {
  5701. $list['syhairther'] = $this->input->post('syhairther', true);
  5702. }
  5703. if($category == 130){
  5704. $list['jfother'] = $this->input->post('jfother', true);
  5705. }
  5706. foreach ($list as $k => $v) {
  5707. if ($v != 0) {
  5708. $num .= $v;
  5709. $features .= $v . '-';
  5710. $post[$k] = $v;
  5711. $typeclass = $this->typeclass->read($v);
  5712. if (isset($pm[$typeclass['classid']])) {
  5713. if (stripos($typeclass['zh'], '|') !== false) {
  5714. $exzh = explode('|', $typeclass['zh']);
  5715. $pm[$typeclass['classid']] = $exzh[0];
  5716. } else {
  5717. $pm[$typeclass['classid']] = $typeclass['zh'];
  5718. }
  5719. }
  5720. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5721. if ($k != 'size') {
  5722. $title .= $typeclass['title'] . " ";
  5723. }
  5724. }
  5725. }
  5726. $typeclass = $this->typeclass->read($list['size']);
  5727. $title .= $typeclass['title'];
  5728. $time = time();
  5729. $post['title'] = rtrim($title, ' ');
  5730. $post['number'] = $num;
  5731. $post['features'] = '-' . $features;
  5732. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5733. $featurespp = explode('-', trim($featurespp, '-'));
  5734. if (isset($featurespp[5])) {
  5735. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5736. } else {
  5737. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5738. }
  5739. $post['enter'] = $time;
  5740. $post['time'] = $time; //操作时间
  5741. $scsku = implode("-", $scsku);
  5742. $zh = implode(" ", $pm);
  5743. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5744. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5745. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5746. $post['sku'] = $bqsku;
  5747. $label = time() . rand(0, 9);
  5748. $post['label'] = $label;
  5749. $cpid = $this->whlabellabel->find_count();
  5750. $post['cpid'] = $cpid + 1;
  5751. $cpid = $post['cpid'];
  5752. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5753. //if($whlabelbarcode)
  5754. //{
  5755. //$post['label'] = $whlabelbarcode['label'];
  5756. //if(!$this->whlabellabel->insert($post))
  5757. //{
  5758. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5759. //}
  5760. //}
  5761. //else
  5762. //{
  5763. $this->db->trans_begin();
  5764. $this->whlabellabel->insert($post);
  5765. //$this->whlabelbarcode->insert($post);
  5766. if ($this->db->trans_status() === TRUE) {
  5767. $this->db->trans_commit();
  5768. } else {
  5769. $this->db->trans_rollback();
  5770. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5771. exit;
  5772. }
  5773. //}
  5774. $warehouse_name = "";
  5775. $warehouse = $post['warehouse'];
  5776. if($warehouse == 12){
  5777. $warehouse_name = "特殊库存库";
  5778. }
  5779. // if($warehouse == 13){
  5780. // $warehouse_name = "许昌仓";
  5781. // }
  5782. // if($warehouse == 5){
  5783. // $warehouse_name = "美国店";
  5784. // }
  5785. // if($warehouse == 16){
  5786. // $warehouse_name = "定制头套仓";
  5787. // }
  5788. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5789. if(!empty($warehouse_name)){
  5790. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5791. }
  5792. $purchase = $this->purchase->read($post['purchase']);
  5793. 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));
  5794. exit; //特殊仓目前不需要仓库选项
  5795. }
  5796. }
  5797. if (isset($_SESSION['api'])) {
  5798. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5799. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5800. $this->data['wlshop'] = $wlshop;
  5801. $this->data['warehouse'] = $warehouse;
  5802. }
  5803. $whlabelwz = $this->whlabelwz->find_all();
  5804. $this->data['whlabelwz'] = $whlabelwz;
  5805. $this->_Template('whlabel_print', $this->data);
  5806. }
  5807. public function _usaprint($arg_array)
  5808. {
  5809. if (isset($_SESSION['api'])) {
  5810. $user = $this->user->get_api($_SESSION['api']);
  5811. $usp = $user;
  5812. $fgshop = "";
  5813. $sid = "";
  5814. $wid = "";
  5815. $wtype = "";
  5816. $usersp = explode('|', trim($user['shop'], '|'));
  5817. $userwh = explode('|', trim($user['warehouse'], '|'));
  5818. foreach ($usersp as $value) {
  5819. $fgshop .= " shop = " . $value . " or";
  5820. $sid .= " id = " . $value . " or";
  5821. }
  5822. foreach ($userwh as $value) {
  5823. $wid .= " id = " . $value . " or";
  5824. $wtype .= " type = " . $value . " or";
  5825. }
  5826. }
  5827. $post = $this->input->post(NULL, TRUE);
  5828. if (isset($post['tmsku'])) {
  5829. $tmsku = $this->input->post('tmsku', true);
  5830. if (is_numeric($tmsku)) {
  5831. $yyh = $this->whlabellabel->get_label($tmsku);
  5832. } else {
  5833. $yyh = $this->whlabellabel->get_sku($tmsku);
  5834. }
  5835. if ($yyh) {
  5836. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5837. exit;
  5838. } else {
  5839. echo json_encode(array('success' => false));
  5840. exit;
  5841. }
  5842. }
  5843. $classid = $this->classid->sku();
  5844. $pm = $classid;
  5845. $scsku = $classid;
  5846. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5847. if (isset($post['warehouse'])) {
  5848. if ($post['warehouse']) {
  5849. $list = array();
  5850. $num = "";
  5851. $title = "";
  5852. $features = "";
  5853. $order = 0;
  5854. $post['shop'] = '';
  5855. $brand = $this->input->post('brand', true);
  5856. if ($brand != '0,') {
  5857. $b = $this->brand->read(rtrim($brand, ','));
  5858. if ($b) {
  5859. $post['shop'] = str_replace('|', ',', $b['shop']);
  5860. }
  5861. }
  5862. $post['details'] = $this->input->post('details', true); //打印数量
  5863. $xbqnum = $this->input->post('xbqnum', true);
  5864. $post['purchase'] = $this->input->post('purchase', true);
  5865. $post['warehouse'] = $this->input->post('warehouse', true);
  5866. $post['purchase'] = $this->input->post('purchase', true);
  5867. $post['retreatwarehouse'] = $post['warehouse'];
  5868. $post['cpbz'] = $this->input->post('cpbz', true);
  5869. $post['state'] = 9;
  5870. $category = $this->input->post('category', true);
  5871. $list['category'] = $category;
  5872. $list['hairtype'] = $this->input->post('hairtype', true);
  5873. $list['grade'] = $this->input->post('grade', true);
  5874. $size = $this->input->post('size', true);
  5875. $list['size'] = rtrim($size, ',');
  5876. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5877. $list['extension'] = $this->input->post('extension', true);
  5878. if ($category == 1297) {
  5879. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5880. }
  5881. if ($category == 1702) {
  5882. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5883. $list['syother'] = $this->input->post('syother', true);
  5884. }
  5885. if ($category == 133) {
  5886. $list['fittype'] = $this->input->post('fittype', true);
  5887. $list['acother'] = $this->input->post('acother', true);
  5888. }
  5889. $list['color'] = $this->input->post('color', true);
  5890. $list['lowe'] = $this->input->post('lowe', true);
  5891. if ($category == 127) {
  5892. $list['type'] = $this->input->post('type', true);
  5893. $list['headroad'] = $this->input->post('headroad', true);
  5894. $list['density'] = $this->input->post('density', true);
  5895. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5896. $list['lacesize'] = $this->input->post('lacesize', true);
  5897. }
  5898. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5899. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5900. }
  5901. if ($category == 128) {
  5902. $list['lacetype'] = $this->input->post('lacetype', true);
  5903. $list['haircap'] = $this->input->post('haircap', true);
  5904. $list['density'] = $this->input->post('density', true);
  5905. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5906. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5907. $list['wigother'] = $this->input->post('wigother', true);
  5908. $list['wigother1'] = $this->input->post('wigother1', true);
  5909. $list['wigother2'] = $this->input->post('wigother2', true);
  5910. }
  5911. if ($category == 129) {
  5912. $list['wide'] = $this->input->post('wide', true);
  5913. }
  5914. if ($category == 131) {
  5915. $list['gifttype'] = $this->input->post('gifttype', true);
  5916. $list['giftother'] = $this->input->post('giftother', true);
  5917. }
  5918. if ($category == 134) {
  5919. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5920. }
  5921. if ($category == 1297) {
  5922. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5923. $list['sywigother'] = $this->input->post('sywigother', true);
  5924. }
  5925. if ($category == 130 || $category == 133 || $category == 1702) {
  5926. $list['items'] = $this->input->post('items', true);
  5927. $list['weight'] = $this->input->post('weight', true);
  5928. }
  5929. if ($category == 1702) {
  5930. $list['syhairther'] = $this->input->post('syhairther', true);
  5931. }
  5932. foreach ($list as $k => $v) {
  5933. if ($v != 0) {
  5934. $num .= $v;
  5935. $features .= $v . '-';
  5936. $post[$k] = $v;
  5937. $typeclass = $this->typeclass->read($v);
  5938. if (isset($pm[$typeclass['classid']])) {
  5939. if (stripos($typeclass['zh'], '|') !== false) {
  5940. $exzh = explode('|', $typeclass['zh']);
  5941. $pm[$typeclass['classid']] = $exzh[0];
  5942. } else {
  5943. $pm[$typeclass['classid']] = $typeclass['zh'];
  5944. }
  5945. }
  5946. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5947. if ($k != 'size') {
  5948. $title .= $typeclass['title'] . " ";
  5949. }
  5950. }
  5951. }
  5952. $typeclass = $this->typeclass->read($list['size']);
  5953. $title .= $typeclass['title'];
  5954. $time = time();
  5955. $post['title'] = rtrim($title, ' ');
  5956. $post['number'] = $num;
  5957. $post['features'] = '-' . $features;
  5958. $fp = $this->whlabel->get_features($post['features']);
  5959. if (!$fp) {
  5960. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5961. exit;
  5962. }
  5963. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5964. $featurespp = explode('-', trim($featurespp, '-'));
  5965. if (isset($featurespp[5])) {
  5966. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5967. } else {
  5968. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5969. }
  5970. $post['enter'] = $time;
  5971. $post['time'] = $time; //操作时间
  5972. $scsku = implode("-", $scsku);
  5973. $zh = implode(" ", $pm);
  5974. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5975. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5976. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5977. $post['sku'] = $fp['sku'];
  5978. $post['label'] = $fp['sku'];
  5979. $cpid = $this->whlabellabel->find_count();
  5980. $post['cpid'] = $cpid + 1;
  5981. $cpid = $post['cpid'];
  5982. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5983. //if($whlabelbarcode)
  5984. //{
  5985. //$post['label'] = $whlabelbarcode['label'];
  5986. //if(!$this->whlabellabel->insert($post))
  5987. //{
  5988. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5989. //}
  5990. //}
  5991. //else
  5992. //{
  5993. $this->db->trans_begin();
  5994. $this->whlabellabel->insert($post);
  5995. //$this->whlabelbarcode->insert($post);
  5996. if ($this->db->trans_status() === TRUE) {
  5997. $this->db->trans_commit();
  5998. } else {
  5999. $this->db->trans_rollback();
  6000. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6001. exit;
  6002. }
  6003. //}
  6004. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6005. $purchase = $this->purchase->read($post['purchase']);
  6006. 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));
  6007. exit; //特殊仓目前不需要仓库选项
  6008. }
  6009. }
  6010. if (isset($_SESSION['api'])) {
  6011. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6012. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6013. $this->data['wlshop'] = $wlshop;
  6014. $this->data['warehouse'] = $warehouse;
  6015. }
  6016. $whlabelwz = $this->whlabelwz->find_all();
  6017. $this->data['whlabelwz'] = $whlabelwz;
  6018. $this->_Template('whlabel_usaprint', $this->data);
  6019. }
  6020. public function _printrk($arg_array)
  6021. {
  6022. $prc = array();
  6023. $purchase = $this->purchase->find_all();
  6024. foreach ($purchase as $k => $v) {
  6025. $prc[$v['id']] = $v['title'];
  6026. }
  6027. $post = $this->input->post(NULL, TRUE);
  6028. if (isset($post['page'])) {
  6029. $page = $this->input->post('page', true);
  6030. $perpage = $this->input->post('perpage', true);
  6031. $sku = $this->input->post('sku', true);
  6032. $bs = $this->input->post('bs', true);
  6033. $number = $this->input->post('number', true);
  6034. $warehouse = $this->input->post('warehouse', true);
  6035. $purchase = $this->input->post('purchase', true);
  6036. $orderinfo = $this->input->post('orderinfo', true);
  6037. $waybill = $this->input->post('waybill', true);
  6038. $category = $this->input->post('category', true);
  6039. $size = $this->input->post('size', true);
  6040. $grade = $this->input->post('grade', true);
  6041. $color = $this->input->post('color', true);
  6042. $lowe = $this->input->post('lowe', true);
  6043. $state = $this->input->post('state', true);
  6044. $label = $this->input->post('label', true);
  6045. $timetk = $this->input->post('ktime', true);
  6046. $timetj = $this->input->post('jtime', true);
  6047. $timetk = strtotime($timetk);
  6048. $timetj = strtotime($timetj);
  6049. $where = "1=1 ";
  6050. if ($timetk && $timetj) {
  6051. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6052. }
  6053. if ($sku) {
  6054. $where .= " and sku = '$sku'";
  6055. }
  6056. if ($bs != '') {
  6057. $where .= " and bs = '$bs'";
  6058. }
  6059. if ($number) {
  6060. $where .= " and number = '$number'";
  6061. }
  6062. if ($warehouse) {
  6063. $where .= " and warehouse = '$warehouse'";
  6064. }
  6065. if ($purchase) {
  6066. $where .= " and purchase = '$purchase'";
  6067. }
  6068. if ($orderinfo) {
  6069. $where .= " and orderinfo = '$orderinfo'";
  6070. }
  6071. if ($waybill) {
  6072. $where .= " and waybill = '$waybill'";
  6073. }
  6074. if ($category) {
  6075. $where .= " and features like '%-$category-%'";
  6076. }
  6077. if ($size) {
  6078. $where .= " and features like '%-$size-%'";
  6079. }
  6080. if ($grade) {
  6081. $where .= " and features like '%-$grade-%'";
  6082. }
  6083. if ($color) {
  6084. $where .= " and features like '%-$color-%'";
  6085. }
  6086. if ($lowe) {
  6087. $where .= " and features like '%-$lowe-%'";
  6088. }
  6089. if ($label) {
  6090. $where .= " and label = '$label'";
  6091. }
  6092. if ($state || $state == 0) {
  6093. $where .= " and state = '$state'";
  6094. }
  6095. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6096. //数据排序
  6097. $order_str = "enter desc";
  6098. if (empty($page)) {
  6099. $start = 0;
  6100. $perpage = 1;
  6101. } else {
  6102. $start = ($page - 1) * $perpage;
  6103. }
  6104. //取得信息列表
  6105. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6106. foreach ($info_list as $key => $value) {
  6107. $warehouse = $this->warehouse->read($value['warehouse']);
  6108. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6109. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6110. if ($value['state'] == 0) {
  6111. $info_list[$key]['state'] = "在库";
  6112. } else if ($value['state'] == 1) {
  6113. $info_list[$key]['state'] = "出库";
  6114. } else if ($value['state'] == 2) {
  6115. $info_list[$key]['state'] = "退库";
  6116. } else if ($value['state'] == 3) {
  6117. $info_list[$key]['state'] = "调拨中";
  6118. } else if ($value['state'] == 4) {
  6119. $info_list[$key]['state'] = "再加工";
  6120. } else if ($value['state'] == 5) {
  6121. $info_list[$key]['state'] = "维修中";
  6122. } else if ($value['state'] == 6) {
  6123. $info_list[$key]['state'] = "盘亏";
  6124. } else if ($value['state'] == 7) {
  6125. $info_list[$key]['state'] = "更换标签";
  6126. } else if ($value['state'] == 8) {
  6127. $info_list[$key]['state'] = "其它";
  6128. } else if ($value['state'] == 9) {
  6129. $info_list[$key]['state'] = "预设";
  6130. } else if ($value['state'] == 10) {
  6131. $info_list[$key]['state'] = "美店零售";
  6132. }
  6133. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6134. }
  6135. $total = $this->$ck->find_count($where);
  6136. $pagenum = ceil($total / $perpage);
  6137. $over = $total - ($start + $perpage);
  6138. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6139. echo json_encode($rows);
  6140. exit;
  6141. }
  6142. if (isset($post['tmsku'])) {
  6143. $time = time();
  6144. $tmsku = $this->input->post('tmsku', true);
  6145. //$post['shop'] = $this->input->post('shop',true);
  6146. $num = $this->input->post('num', true);
  6147. $rktype = $this->input->post('rktype', true);
  6148. if ($num > 200) {
  6149. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6150. exit;
  6151. }
  6152. if (!$rktype) {
  6153. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6154. }
  6155. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6156. /**
  6157. $wz = array();
  6158. foreach ($rk as $key=>$value)
  6159. {
  6160. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6161. }
  6162. if(count($wz) > 1)
  6163. {
  6164. $wz = array_values($wz);
  6165. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6166. }
  6167. **/
  6168. if (isset($rk[0]['purchase'])) {
  6169. $rk = $rk[0];
  6170. $j = 0;
  6171. $post['purchase'] = $rk['purchase'];
  6172. $post['warehouse'] = $rk['warehouse'];
  6173. $post['retreatwarehouse'] = $rk['warehouse'];
  6174. $post['sku'] = $rk['sku'];
  6175. $post['number'] = $rk['number'];
  6176. $post['features'] = $rk['features'];
  6177. $post['title'] = $rk['title'];
  6178. $post['enter'] = $time;
  6179. $post['time'] = $time;
  6180. $post['bs'] = 1;
  6181. $post['shop'] = $rk['shop'];
  6182. $post['details'] = $rk['details'];
  6183. $post['cpid'] = $rk['cpid'];
  6184. $post['cpbz'] = $rk['cpbz'];
  6185. //$post['rktype'] = $rktype;
  6186. $warehouse = $this->warehouse->read($rk['warehouse']);
  6187. if ($warehouse['bdck'] == '') {
  6188. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6189. exit;
  6190. } else {
  6191. $bdck = $warehouse['bdck'];
  6192. }
  6193. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6194. if (isset($pdwz['details'])) {
  6195. if ($pdwz['details'] != $post['details']) {
  6196. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6197. exit;
  6198. }
  6199. }
  6200. $post['featurespp'] = $rk['featurespp'];
  6201. if ($post['warehouse'] == '5') {
  6202. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6203. if ($yza) {
  6204. if ($post['features'] != $yza[0]['features']) {
  6205. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6206. exit;
  6207. }
  6208. }
  6209. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6210. if ($yzb) {
  6211. if ($post['sku'] != $yzb[0]['sku']) {
  6212. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6213. exit;
  6214. }
  6215. }
  6216. }
  6217. for ($i = 0; $i < $num; $i++) {
  6218. $post['label'] = time() . rand(100, 999) . $i;
  6219. if ($this->$bdck->insert($post)) {
  6220. $j++;
  6221. }
  6222. }
  6223. /**
  6224. if($post['warehouse'] != 12)
  6225. {
  6226. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6227. }
  6228. **/
  6229. if ($j == $num) {
  6230. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6231. exit;
  6232. } else {
  6233. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6234. exit;
  6235. }
  6236. } else {
  6237. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6238. exit;
  6239. }
  6240. }
  6241. $this->_Template('whlabel_printrk', $this->data);
  6242. }
  6243. public function _printxzrk($arg_array)
  6244. {
  6245. $post = $this->input->post(NULL, TRUE);
  6246. if (isset($post['wzid'])) {
  6247. $time = time();
  6248. $id = $this->input->post('wzid', true);
  6249. //$post['shop'] = $this->input->post('shop',true);
  6250. $num = 1;
  6251. $rk = $this->whlabellabel->read($id);
  6252. if (isset($rk['purchase'])) {
  6253. $x = 0;
  6254. $post['purchase'] = $rk['purchase'];
  6255. $post['warehouse'] = $rk['warehouse'];
  6256. $post['retreatwarehouse'] = $rk['warehouse'];
  6257. $post['sku'] = $rk['sku'];
  6258. $post['number'] = $rk['number'];
  6259. $post['features'] = $rk['features'];
  6260. $post['title'] = $rk['title'];
  6261. $post['enter'] = $time;
  6262. $post['time'] = $time;
  6263. $post['bs'] = 1;
  6264. $post['shop'] = $rk['shop'];
  6265. $post['details'] = $rk['details'];
  6266. $post['cpid'] = $rk['cpid'];
  6267. $post['cpbz'] = $rk['cpbz'];
  6268. $warehouse = $this->warehouse->read($rk['warehouse']);
  6269. if ($warehouse['bdck'] == '') {
  6270. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6271. exit;
  6272. } else {
  6273. $bdck = $warehouse['bdck'];
  6274. }
  6275. $post['featurespp'] = $rk['featurespp'];
  6276. $this->db->trans_begin();
  6277. for ($i = 0; $i < $num; $i++) {
  6278. $post['label'] = time() . rand(100, 999) . $i;
  6279. $this->$bdck->insert($post);
  6280. }
  6281. /**
  6282. if($post['warehouse'] != 12)
  6283. {
  6284. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6285. }
  6286. **/
  6287. if ($this->db->trans_status() === TRUE) {
  6288. $this->db->trans_commit();
  6289. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6290. exit;
  6291. } else {
  6292. $this->db->trans_rollback();
  6293. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6294. exit;
  6295. }
  6296. } else {
  6297. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6298. exit;
  6299. }
  6300. }
  6301. }
  6302. public function _printck($arg_array)
  6303. {
  6304. $prc = array();
  6305. $purchase = $this->purchase->find_all();
  6306. foreach ($purchase as $k => $v) {
  6307. $prc[$v['id']] = $v['title'];
  6308. }
  6309. $post = $this->input->post(NULL, TRUE);
  6310. if (isset($post['page'])) {
  6311. $page = $this->input->post('page', true);
  6312. $perpage = $this->input->post('perpage', true);
  6313. $sku = $this->input->post('sku', true);
  6314. $bs = $this->input->post('bs', true);
  6315. $number = $this->input->post('number', true);
  6316. $warehouse = $this->input->post('warehouse', true);
  6317. $purchase = $this->input->post('purchase', true);
  6318. $orderinfo = $this->input->post('orderinfo', true);
  6319. $waybill = $this->input->post('waybill', true);
  6320. $category = $this->input->post('category', true);
  6321. $size = $this->input->post('size', true);
  6322. $grade = $this->input->post('grade', true);
  6323. $color = $this->input->post('color', true);
  6324. $lowe = $this->input->post('lowe', true);
  6325. $state = $this->input->post('state', true);
  6326. $label = $this->input->post('label', true);
  6327. $timetk = $this->input->post('ktime', true);
  6328. $timetj = $this->input->post('jtime', true);
  6329. $timetk = strtotime($timetk);
  6330. $timetj = strtotime($timetj);
  6331. $where = "state=1 ";
  6332. if ($timetk && $timetj) {
  6333. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6334. }
  6335. if ($sku) {
  6336. $where .= " and sku = '$sku'";
  6337. }
  6338. if ($bs != '') {
  6339. $where .= " and bs = '$bs'";
  6340. }
  6341. if ($number) {
  6342. $where .= " and number = '$number'";
  6343. }
  6344. if ($warehouse) {
  6345. $where .= " and warehouse = '$warehouse'";
  6346. }
  6347. if ($purchase) {
  6348. $where .= " and purchase = '$purchase'";
  6349. }
  6350. if ($orderinfo) {
  6351. $where .= " and orderinfo = '$orderinfo'";
  6352. }
  6353. if ($waybill) {
  6354. $where .= " and waybill = '$waybill'";
  6355. }
  6356. if ($category) {
  6357. $where .= " and features like '%-$category-%'";
  6358. }
  6359. if ($size) {
  6360. $where .= " and features like '%-$size-%'";
  6361. }
  6362. if ($grade) {
  6363. $where .= " and features like '%-$grade-%'";
  6364. }
  6365. if ($color) {
  6366. $where .= " and features like '%-$color-%'";
  6367. }
  6368. if ($lowe) {
  6369. $where .= " and features like '%-$lowe-%'";
  6370. }
  6371. if ($label) {
  6372. $where .= " and label = '$label'";
  6373. }
  6374. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6375. //数据排序
  6376. $order_str = "outk desc";
  6377. if (empty($page)) {
  6378. $start = 0;
  6379. $perpage = 1;
  6380. } else {
  6381. $start = ($page - 1) * $perpage;
  6382. }
  6383. //取得信息列表
  6384. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6385. foreach ($info_list as $key => $value) {
  6386. $warehouse = $this->warehouse->read($value['warehouse']);
  6387. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6388. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6389. if ($value['state'] == 0) {
  6390. $info_list[$key]['state'] = "在库";
  6391. } else if ($value['state'] == 1) {
  6392. $info_list[$key]['state'] = "出库";
  6393. } else if ($value['state'] == 2) {
  6394. $info_list[$key]['state'] = "退库";
  6395. } else if ($value['state'] == 3) {
  6396. $info_list[$key]['state'] = "调拨中";
  6397. } else if ($value['state'] == 4) {
  6398. $info_list[$key]['state'] = "再加工";
  6399. } else if ($value['state'] == 5) {
  6400. $info_list[$key]['state'] = "维修中";
  6401. } else if ($value['state'] == 6) {
  6402. $info_list[$key]['state'] = "盘亏";
  6403. } else if ($value['state'] == 7) {
  6404. $info_list[$key]['state'] = "更换标签";
  6405. } else if ($value['state'] == 8) {
  6406. $info_list[$key]['state'] = "其它";
  6407. } else if ($value['state'] == 9) {
  6408. $info_list[$key]['state'] = "预设";
  6409. } else if ($value['state'] == 10) {
  6410. $info_list[$key]['state'] = "美店零售";
  6411. }
  6412. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6413. }
  6414. $total = $this->$ck->find_count($where);
  6415. $pagenum = ceil($total / $perpage);
  6416. $over = $total - ($start + $perpage);
  6417. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6418. echo json_encode($rows);
  6419. exit;
  6420. }
  6421. if (isset($post['tmsku'])) {
  6422. $time = time();
  6423. $tmsku = $this->input->post('tmsku', true);
  6424. //$post['shop'] = $this->input->post('shop',true);
  6425. $num = $this->input->post('num', true);
  6426. $cktype = $this->input->post('cktype', true);
  6427. $label = $this->whlabellabel->get_label($tmsku);
  6428. if (!$cktype) {
  6429. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6430. }
  6431. if (!isset($label['warehouse'])) {
  6432. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6433. exit;
  6434. }
  6435. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6436. if (stripos($label['features'], '-126-') !== false) {
  6437. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6438. } else {
  6439. $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 = ''");
  6440. }
  6441. $j = 0;
  6442. if (count($ck) >= $num) {
  6443. for ($i = 0; $i < $num; $i++) {
  6444. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6445. {
  6446. $j++;
  6447. }
  6448. }
  6449. if ($j == $num) {
  6450. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6451. exit;
  6452. } else {
  6453. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6454. exit;
  6455. }
  6456. } else {
  6457. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6458. exit;
  6459. }
  6460. }
  6461. if(isset($_SESSION['api']))
  6462. {
  6463. $user = $this->user->get_api($_SESSION['api']);
  6464. if(in_array($user['power'],[1,27])){
  6465. $vip = 1;
  6466. }
  6467. }
  6468. else
  6469. {
  6470. $vip = 0;
  6471. header('Location: /');exit;
  6472. }
  6473. $this->data['vip'] = $vip;
  6474. $this->_Template('whlabel_printck', $this->data);
  6475. }
  6476. public function _printexcel()
  6477. {
  6478. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6479. $config['upload_path'] = '.' . $dir;
  6480. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6481. $config['allowed_types'] = 'xls|xlsx|csv';
  6482. $config['max_size'] = 10240;
  6483. $this->load->library('upload', $config);
  6484. $this->upload->initialize($config);
  6485. if ($this->upload->do_upload('userfile')) {
  6486. $full_path = $dir . $this->upload->data('file_name');
  6487. $fileName = '.' . $full_path;
  6488. if (!file_exists($fileName)) {
  6489. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6490. exit;
  6491. } else {
  6492. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6493. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6494. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6495. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6496. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6497. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6498. ++$column; //如果列数大于26行
  6499. $list = array();
  6500. for ($i = 2; $i <= $row; $i++) // 行数循环
  6501. {
  6502. $data = array();
  6503. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6504. {
  6505. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6506. }
  6507. $list[] = $data;
  6508. }
  6509. }
  6510. $ed = array();
  6511. $i = 0;
  6512. $j = 0;
  6513. $dcdata = array();
  6514. $yc = '';
  6515. $cmf_arr = array_column($list, '1');
  6516. array_multisort($cmf_arr, SORT_ASC, $list);
  6517. foreach ($list as $key => $value) {
  6518. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6519. if ($typeclass) {
  6520. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6521. } else {
  6522. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6523. $i++;
  6524. continue;
  6525. }
  6526. }
  6527. if ($i > 0) {
  6528. $yc = $i . '条异常';
  6529. }
  6530. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6531. exit;
  6532. }
  6533. }
  6534. public function _uck()
  6535. {
  6536. if (isset($_GET['excel'])) {
  6537. $tc = array();
  6538. $typeclass = $this->typeclass->find_all();
  6539. foreach ($typeclass as $v) {
  6540. $tc[$v['id']] = $v['zh'];
  6541. }
  6542. $data = array();
  6543. $t = array();
  6544. $rq = '';
  6545. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6546. $ts = $ts / (24 * 3600);
  6547. for ($i = 0; $i < $ts; $i++) {
  6548. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6549. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6550. }
  6551. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6552. foreach ($info_list as $k => $v) {
  6553. $features = explode('-', trim($v['features'], '-'));
  6554. if (!isset($features[3]) || !isset($features[4])) {
  6555. continue;
  6556. }
  6557. $data[$k][0] = $tc[$features[0]]; //类型
  6558. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6559. $data[$k][2] = $tc[$features[4]]; //曲度
  6560. $data[$k][3] = '';
  6561. if (isset($data[$k][1])) {
  6562. $data[$k][3] .= $data[$k][1];
  6563. }
  6564. if (isset($data[$k][2])) {
  6565. $data[$k][3] .= $data[$k][2];
  6566. }
  6567. if (isset($features[5])) {
  6568. $data[$k][3] .= $tc[$features[5]];
  6569. }
  6570. if (isset($features[2])) {
  6571. $data[$k][3] .= $tc[$features[2]];
  6572. }
  6573. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6574. $data[$k][4] = $v['sku'];
  6575. $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())) . '))'); //月初库存
  6576. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6577. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6578. $ztrq = '';
  6579. $ztsl = '';
  6580. if (count($zt) > 0) {
  6581. foreach ($zt as $vv) {
  6582. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6583. $ztsl .= $vv['num'] . '<br>';
  6584. }
  6585. }
  6586. $data[$k][] = trim($ztsl, '<br>');
  6587. $data[$k][] = trim($ztrq, '<br>');
  6588. $byck = 0;
  6589. foreach ($t as $vv) {
  6590. $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));
  6591. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6592. $byck += $sl;
  6593. }
  6594. $data[$k][] = ($byck > 0) ? $byck : '';
  6595. }
  6596. $title = "详情 " . date("Y-m-d", time());
  6597. $titlename = "<table border=1>
  6598. <tr align='center'>
  6599. <td>类别</td>
  6600. <td>颜色</td>
  6601. <td>曲度</td>
  6602. <td>名称</td>
  6603. <td>SKU</td>
  6604. <td>月初库存</td>
  6605. <td>剩余库存</td>
  6606. <td>在途数量</td>
  6607. <td>预达日期</td>" .
  6608. $rq
  6609. . "<td>本月出库</td></tr>
  6610. </table>";
  6611. $filename = $title . ".xls";
  6612. $tail = "";
  6613. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6614. }
  6615. }
  6616. public function _whlabelexcelzh()
  6617. {
  6618. if (isset($_GET['excel'])) {
  6619. $where = "sku != 'Preset'";
  6620. //数据排序
  6621. $order_str = "id desc";
  6622. if (empty($page)) {
  6623. $start = 0;
  6624. $perpage = 1;
  6625. } else {
  6626. $start = ($page - 1) * $perpage;
  6627. }
  6628. $category = $this->input->get('category', true);
  6629. $warehouse = $this->input->get('warehouse', true);
  6630. $excelid = $this->input->get('sid', true);
  6631. if ($category) {
  6632. $where .= " and features like '%-$category-%'";
  6633. }
  6634. if ($warehouse) {
  6635. $where .= " and warehouse = '$warehouse'";
  6636. }
  6637. $xzid = '';
  6638. if ($excelid) {
  6639. $excelid = explode(',', trim($excelid, ','));
  6640. foreach ($excelid as $key => $value) {
  6641. $xzid .= " id = " . $value . " or";
  6642. }
  6643. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6644. }
  6645. //取得信息列表
  6646. /**
  6647. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6648. $rows = array();$list = array();
  6649. foreach ($info_list as $key=>$value)
  6650. {
  6651. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6652. }
  6653. **/
  6654. $list = array();
  6655. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6656. foreach ($rows as $key => $value) {
  6657. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6658. $zh = '';
  6659. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6660. foreach ($zt as $v) {
  6661. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6662. }
  6663. $zt = array_sum(array_column($zt, 'num'));
  6664. $number = $value['number'];
  6665. $ftime = time() - 15 * 24 * 3600;
  6666. $warehouse = $this->warehouse->read($value['warehouse']);
  6667. $rows[$key]['warehouse'] = $warehouse['title'];
  6668. $rows[$key]['number'] = $c;
  6669. $rows[$key]['features'] = $zh;
  6670. $rows[$key]['hb'] = $c + $zt;
  6671. }
  6672. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6673. $titlename = "<table border=1>
  6674. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6675. <tr align='center'>
  6676. <td>仓库</td>
  6677. <td>SKU</td>
  6678. <td>产品</td>
  6679. <td>库存数量</td>
  6680. <td>在途数量及预达日期</td>
  6681. <td>在途+库存数量</td>
  6682. </tr>
  6683. </table>";
  6684. $filename = $title . ".xls";
  6685. $tail = "";
  6686. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6687. }
  6688. if (isset($_GET['excel'])) {
  6689. $warehouse = $this->input->get('warehouse', true);
  6690. $sku = $this->input->get('sku', true);
  6691. $cz = $this->input->get('cz', true);
  6692. $text = $this->input->post('text', true);
  6693. $xztime = $this->input->get('xztime', true);
  6694. $timetk = $this->input->get('timetk', true);
  6695. $timetj = $this->input->get('timetj', true);
  6696. $timetk = strtotime($timetk);
  6697. $timetj = strtotime($timetj);
  6698. $where = "time = '0' ";
  6699. if ($warehouse) {
  6700. $where .= " and warehouse = '$warehouse'";
  6701. }
  6702. if ($sku) {
  6703. $where .= " and sku = '$sku'";
  6704. }
  6705. if ($text) {
  6706. $where .= " and text like '%$text%'";
  6707. }
  6708. if ($cz != '') {
  6709. $where .= " and cz = '$cz'";
  6710. }
  6711. if ($timetk && $timetj) {
  6712. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6713. }
  6714. //数据排序
  6715. $order_str = $xztime . " desc";
  6716. //取得信息列表
  6717. $zh = array();
  6718. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6719. foreach ($info_list as $v) {
  6720. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6721. $warehouse = $this->warehouse->read($v['warehouse']);
  6722. $v['warehouse'] = $warehouse['title'];
  6723. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6724. $v['stime'] = date('Y-m-d', $v['stime']);
  6725. if (isset($zh[$v['features']])) {
  6726. $zh[$v['features']]['num'] += $v['num'];
  6727. } else {
  6728. $zh[$v['features']] = $v;
  6729. }
  6730. $zh[$v['features']]['features'] = $c;
  6731. }
  6732. $title = "在途数据" . date('Y-m-d', time());
  6733. $titlename = "<table border=1>
  6734. <tr align='center'>
  6735. <td>仓库</td>
  6736. <td>SKU</td>
  6737. <td>名称</td>
  6738. <td>在途数量</td>
  6739. <td>库存数量</td>
  6740. <td>添加在途日期</td>
  6741. <td>预达日期</td>
  6742. <td>备注</td>
  6743. </tr>
  6744. </table>";
  6745. $filename = $title . ".xls";
  6746. $tail = "";
  6747. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6748. }
  6749. }
  6750. public function _fc()
  6751. {
  6752. $vip = 0;
  6753. if (isset($_SESSION['api'])) {
  6754. $user = $this->user->get_api($_SESSION['api']);
  6755. if ($user['vip'] == 1) {
  6756. $vip = 1;
  6757. }
  6758. } else {
  6759. header('Location: /');
  6760. exit;
  6761. }
  6762. $post = $this->input->post(NULL, TRUE);
  6763. if (isset($post['page'])) {
  6764. $page = $this->input->post('page', true);
  6765. $perpage = $this->input->post('perpage', true);
  6766. $category = $this->input->post('category', true);
  6767. $size = $this->input->post('size', true);
  6768. $grade = $this->input->post('grade', true);
  6769. $color = $this->input->post('color', true);
  6770. $lowe = $this->input->post('lowe', true);
  6771. $sku = $this->input->post('sku');
  6772. $title = $this->input->post('title');
  6773. $warehouse = $this->input->post('warehouse', true);
  6774. $usa = $this->input->post('usa', true);
  6775. $purchase = $this->input->post('purchase', true);
  6776. $lacetype = $this->input->post('lacetype', true);
  6777. $haircap = $this->input->post('haircap', true);
  6778. $density = $this->input->post('density', true);
  6779. $details = $this->input->post('details', true);
  6780. $state = $this->input->post('state', true);
  6781. $ktime = $this->input->post('ktime', true);
  6782. $jtime = $this->input->post('jtime', true);
  6783. $ktime = strtotime($ktime);
  6784. $jtime = strtotime($jtime);
  6785. $where = "state = '11'";
  6786. $gj = "";
  6787. $ck = "";
  6788. if ($lacetype) {
  6789. $where .= " and features like '%-$lacetype-%'";
  6790. }
  6791. if ($category) {
  6792. $where .= " and features like '%-$category-%'";
  6793. }
  6794. if ($size) {
  6795. $where .= " and features like '%-$size-%'";
  6796. }
  6797. if ($grade) {
  6798. $where .= " and features like '%-$grade-%'";
  6799. }
  6800. if ($color) {
  6801. $where .= " and features like '%-$color-%'";
  6802. }
  6803. if ($lowe) {
  6804. $where .= " and features like '%-$lowe-%'";
  6805. }
  6806. if ($haircap) {
  6807. $where .= " and features like '%-$haircap-%'";
  6808. }
  6809. if ($density) {
  6810. $where .= " and features like '%-$density-%'";
  6811. }
  6812. if ($usa) {
  6813. if (!$warehouse) {
  6814. $where .= " and (warehouse = '5' or warehouse = '8')";
  6815. }
  6816. }
  6817. if ($warehouse) {
  6818. $where .= " and warehouse = '$warehouse'";
  6819. }
  6820. if ($details) {
  6821. $where .= " and details = '$details'";
  6822. }
  6823. if ($purchase) {
  6824. $where .= " and purchase = '$purchase'";
  6825. }
  6826. if ($state) {
  6827. $where .= " and state = '$state'";
  6828. }
  6829. if ($ktime && $jtime) {
  6830. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6831. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6832. }
  6833. //数据排序
  6834. $order_str = "id desc";
  6835. if (empty($page)) {
  6836. $start = 0;
  6837. $perpage = 1;
  6838. } else {
  6839. $start = ($page - 1) * $perpage;
  6840. }
  6841. if ($sku) {
  6842. $sku = trim($sku, ' ');
  6843. $sku = trim($sku, ' ');
  6844. $where .= " and sku like '%$sku%'";
  6845. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6846. } else if ($title) {
  6847. $title = trim($title, ' ');
  6848. $title = trim($title, ' ');
  6849. $where .= " and title like '%$title%'";
  6850. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6851. } else {
  6852. //$where .= " and time > '$ktime' and time < '$jtime'";
  6853. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6854. }
  6855. //取得信息列表
  6856. $rows = array();
  6857. $list = array();
  6858. foreach ($info_list as $key => $value) {
  6859. $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'] . '"');
  6860. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6861. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6862. $warehouse = $this->warehouse->read($value['warehouse']);
  6863. $info_list[$key]['warehouse'] = $warehouse['title'];
  6864. $info_list[$key]['number'] = $g;
  6865. $info_list[$key]['features'] = $x;
  6866. $info_list[$key]['x'] = $s;
  6867. }
  6868. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6869. $pagenum = ceil($total / $perpage);
  6870. $over = $total - ($start + $perpage);
  6871. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6872. echo json_encode($rows);
  6873. exit;
  6874. }
  6875. $this->data['vip'] = $vip;
  6876. $this->_Template('whlabel_fc', $this->data);
  6877. }
  6878. public function _fcmb()
  6879. {
  6880. $where = "sku != 'Preset'";
  6881. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6882. foreach ($rows as $k => $v) {
  6883. $warehouse = $this->warehouse->read($v['warehouse']);
  6884. $rows[$k]['warehouse'] = $warehouse['title'];
  6885. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6886. $rows[$k]['t'] = '';
  6887. $rows[$k]['n'] = '';
  6888. }
  6889. $title = "封货产品数据导入模板";
  6890. $titlename = "<table border=1>
  6891. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6892. <tr align='center'>
  6893. <td>仓库</td>
  6894. <td>SKU</td>
  6895. <td>产品</td>
  6896. <td>封存产品总数量</td>
  6897. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6898. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6899. </tr>
  6900. </table>";
  6901. $filename = $title . ".xls";
  6902. $tail = "";
  6903. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6904. }
  6905. public function _fcexcel()
  6906. {
  6907. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6908. $config['upload_path'] = '.' . $dir;
  6909. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6910. $config['allowed_types'] = 'xls|xlsx|csv';
  6911. $config['max_size'] = 10240;
  6912. $this->load->library('upload', $config);
  6913. $this->upload->initialize($config);
  6914. if ($this->upload->do_upload('userfile')) {
  6915. $full_path = $dir . $this->upload->data('file_name');
  6916. $fileName = '.' . $full_path;
  6917. if (!file_exists($fileName)) {
  6918. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6919. exit;
  6920. } else {
  6921. libxml_use_internal_errors(true);
  6922. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6923. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6924. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6925. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6926. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6927. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6928. ++$column; //如果列数大于26行
  6929. $list = array();
  6930. for ($i = 2; $i <= $row; $i++) // 行数循环
  6931. {
  6932. $data = array();
  6933. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6934. {
  6935. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6936. }
  6937. $list[] = $data;
  6938. }
  6939. }
  6940. $i = 0;
  6941. $j = 0;
  6942. $ed = array();
  6943. foreach ($list as $key => $value) {
  6944. $time = time();
  6945. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6946. continue;
  6947. }
  6948. $warehouse = $this->warehouse->get_title($value['0']);
  6949. $sku = $value['1'];
  6950. $type = $value['4']; //调整方式0扣减1删除
  6951. $num = $value['5']; //调整数量
  6952. //$text = $value['4'];//扣减说明
  6953. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6954. if (!$d) //如果没有这个SKU
  6955. {
  6956. $ed[] = array($sku . '-库存中不存在此SKU');
  6957. $j++;
  6958. continue;
  6959. }
  6960. if (!isset($warehouse['id'])) {
  6961. $ed[] = array($sku . '-仓库名错误!');
  6962. $j++;
  6963. continue;
  6964. }
  6965. if ($type == 1 || $type == 2) //扣减库存
  6966. {
  6967. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6968. if (count($data) < abs($num)) {
  6969. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6970. $j++;
  6971. continue;
  6972. }
  6973. if ($type == 1) //转入库存
  6974. {
  6975. for ($i = 0; $i < abs($num); $i++) {
  6976. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6977. }
  6978. } else if ($type == 2) //删除
  6979. {
  6980. for ($i = 0; $i < abs($num); $i++) {
  6981. $this->whlabel->remove($data[$i]['id']);
  6982. }
  6983. }
  6984. } else if ($type == 0) //增加库存
  6985. {
  6986. $post['sku'] = $d['sku'];
  6987. $post['shop'] = '';
  6988. $post['warehouse'] = $warehouse['id'];
  6989. $post['purchase'] = $d['purchase'];
  6990. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6991. $post['state'] = 11;
  6992. $post['title'] = $d['title'];
  6993. $post['number'] = $d['number'];
  6994. $post['features'] = $d['features'];
  6995. $post['enter'] = $time;
  6996. $post['time'] = $time; //操作时间
  6997. for ($i = 0; $i < $num; $i++) {
  6998. $post['label'] = time() . rand(100, 999) . $i;
  6999. $this->whlabel->insert($post);
  7000. }
  7001. }
  7002. sleep(1); //防止入库时间一样,需要延迟1秒
  7003. }
  7004. if ($j > 0) {
  7005. $tt = date('Ymd', time());
  7006. $title = '库存导入错误信息-' . $tt;
  7007. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7008. $tail = "\n";
  7009. $filename = $title . ".xls";
  7010. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7011. $dir = '/data/excel/' . $time . '/';
  7012. $file_name = 'error_' . $time . rand(1000, 9999);
  7013. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7014. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7015. fwrite($myfile, $ecl);
  7016. fclose($myfile);
  7017. $error = $dir . $file_name . '.xls';
  7018. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7019. exit;
  7020. } else {
  7021. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7022. exit;
  7023. }
  7024. }
  7025. }
  7026. public function _fcjxc($arg_array)
  7027. {
  7028. if (isset($_GET['excel'])) {
  7029. $category = $this->input->get('category', true);
  7030. $size = $this->input->get('size', true);
  7031. $grade = $this->input->get('grade', true);
  7032. $color = $this->input->get('color', true);
  7033. $lowe = $this->input->get('lowe', true);
  7034. $sku = $this->input->get('sku');
  7035. $title = $this->input->get('title');
  7036. $warehouse = $arg_array[0];
  7037. $usa = $this->input->get('usa', true);
  7038. $purchase = $this->input->get('purchase', true);
  7039. $lacetype = $this->input->get('lacetype', true);
  7040. $haircap = $this->input->get('haircap', true);
  7041. $density = $this->input->get('density', true);
  7042. $title = $this->input->get('title', true);
  7043. $state = $this->input->get('state', true);
  7044. $ktime = $this->input->get('ktime', true);
  7045. $jtime = $this->input->get('jtime', true);
  7046. $where = "state=11";
  7047. $gj = "";
  7048. $ck = "";
  7049. if ($lacetype) {
  7050. $where .= " and features like '%-$lacetype-%'";
  7051. }
  7052. if ($category) {
  7053. $where .= " and features like '%-$category-%'";
  7054. }
  7055. if ($size) {
  7056. $where .= " and features like '%-$size-%'";
  7057. }
  7058. if ($grade) {
  7059. $where .= " and features like '%-$grade-%'";
  7060. }
  7061. if ($color) {
  7062. $where .= " and features like '%-$color-%'";
  7063. }
  7064. if ($lowe) {
  7065. $where .= " and features like '%-$lowe-%'";
  7066. }
  7067. if ($haircap) {
  7068. $where .= " and features like '%-$haircap-%'";
  7069. }
  7070. if ($density) {
  7071. $where .= " and features like '%-$density-%'";
  7072. }
  7073. if ($usa) {
  7074. if (!$warehouse) {
  7075. $where .= " and (warehouse = '5' or warehouse = '8')";
  7076. }
  7077. }
  7078. if ($warehouse) {
  7079. $where .= " and warehouse = '$warehouse'";
  7080. }
  7081. if ($purchase) {
  7082. $where .= " and purchase = '$purchase'";
  7083. }
  7084. if ($state) {
  7085. $where .= " and state = '$state'";
  7086. }
  7087. $order_str = "id desc";
  7088. if ($sku) {
  7089. $sku = trim($sku, ' ');
  7090. $sku = trim($sku, ' ');
  7091. $where .= " and sku like '%$sku%'";
  7092. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7093. } else if ($title) {
  7094. $title = trim($title, ' ');
  7095. $title = trim($title, ' ');
  7096. $where .= " and title like '%$title%'";
  7097. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7098. } else {
  7099. //$where .= " and time > '$ktime' and time < '$jtime'";
  7100. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7101. }
  7102. //取得信息列表
  7103. $rows = array();
  7104. $list = array();
  7105. foreach ($info_list as $key => $value) {
  7106. $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'] . '"');
  7107. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7108. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7109. $rows[$key] = $value;
  7110. $warehouse = $this->warehouse->read($value['warehouse']);
  7111. $rows[$key]['warehouse'] = $warehouse['title'];
  7112. $rows[$key]['features'] = $g;
  7113. $rows[$key]['a'] = $x;
  7114. $rows[$key]['b'] = $s;
  7115. }
  7116. $title = "总统计表";
  7117. $titlename = "<table border=1>
  7118. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7119. <tr align='center'>
  7120. <td>仓库</td>
  7121. <td>SKU</td>
  7122. <td>产品名称</td>
  7123. <td>录入总量</td>
  7124. <td>取出总量</td>
  7125. <td>剩余总量</td>
  7126. </tr>
  7127. </table>";
  7128. $filename = $title . ".xls";
  7129. $tail = "";
  7130. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7131. }
  7132. $vip = 0;
  7133. if (isset($_SESSION['api'])) {
  7134. $user = $this->user->get_api($_SESSION['api']);
  7135. if ($user['vip'] == 1) {
  7136. $vip = 1;
  7137. }
  7138. } else {
  7139. header('Location: /');
  7140. exit;
  7141. }
  7142. $post = $this->input->post(NULL, TRUE);
  7143. if (isset($post['page'])) {
  7144. $page = $this->input->post('page', true);
  7145. $perpage = $this->input->post('perpage', true);
  7146. $category = $this->input->post('category', true);
  7147. $size = $this->input->post('size', true);
  7148. $grade = $this->input->post('grade', true);
  7149. $color = $this->input->post('color', true);
  7150. $lowe = $this->input->post('lowe', true);
  7151. $sku = $this->input->post('sku');
  7152. $title = $this->input->post('title');
  7153. $warehouse = $arg_array[0];
  7154. $usa = $this->input->post('usa', true);
  7155. $purchase = $this->input->post('purchase', true);
  7156. $lacetype = $this->input->post('lacetype', true);
  7157. $haircap = $this->input->post('haircap', true);
  7158. $density = $this->input->post('density', true);
  7159. $title = $this->input->post('title', true);
  7160. $state = $this->input->post('state', true);
  7161. $ktime = $this->input->post('ktime', true);
  7162. $jtime = $this->input->post('jtime', true);
  7163. $ktime = strtotime($ktime);
  7164. $jtime = strtotime($jtime);
  7165. $where = "state=11";
  7166. $gj = "";
  7167. $ck = "";
  7168. if ($lacetype) {
  7169. $where .= " and features like '%-$lacetype-%'";
  7170. }
  7171. if ($category) {
  7172. $where .= " and features like '%-$category-%'";
  7173. }
  7174. if ($size) {
  7175. $where .= " and features like '%-$size-%'";
  7176. }
  7177. if ($grade) {
  7178. $where .= " and features like '%-$grade-%'";
  7179. }
  7180. if ($color) {
  7181. $where .= " and features like '%-$color-%'";
  7182. }
  7183. if ($lowe) {
  7184. $where .= " and features like '%-$lowe-%'";
  7185. }
  7186. if ($haircap) {
  7187. $where .= " and features like '%-$haircap-%'";
  7188. }
  7189. if ($density) {
  7190. $where .= " and features like '%-$density-%'";
  7191. }
  7192. if ($usa) {
  7193. if (!$warehouse) {
  7194. $where .= " and (warehouse = '5' or warehouse = '8')";
  7195. }
  7196. }
  7197. if ($warehouse) {
  7198. $where .= " and warehouse = '$warehouse'";
  7199. }
  7200. if ($purchase) {
  7201. $where .= " and purchase = '$purchase'";
  7202. }
  7203. if ($state) {
  7204. $where .= " and state = '$state'";
  7205. }
  7206. if ($ktime && $jtime) {
  7207. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7208. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7209. }
  7210. //数据排序
  7211. $order_str = "id desc";
  7212. $xs = 0;
  7213. $rows = array();
  7214. $list = array();
  7215. if (empty($page)) {
  7216. $start = 0;
  7217. $perpage = 1;
  7218. } else {
  7219. $start = ($page - 1) * $perpage;
  7220. }
  7221. if ($sku || $title) {
  7222. if ($title) {
  7223. $title = trim($title, ' ');
  7224. $title = trim($title, ' ');
  7225. $where .= " and title like '%$title%'";
  7226. } else {
  7227. $sku = trim($sku, ' ');
  7228. $sku = trim($sku, ' ');
  7229. $where .= " and sku like '%$sku%'";
  7230. }
  7231. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7232. foreach ($info_list as $key => $value) {
  7233. $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'] . '"');
  7234. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7235. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7236. $rows[$key] = $value;
  7237. $warehouse = $this->warehouse->read($value['warehouse']);
  7238. $rows[$key]['warehouse'] = $warehouse['title'];
  7239. $rows[$key]['features'] = $g;
  7240. $rows[$key]['a'] = $x;
  7241. $rows[$key]['b'] = $s;
  7242. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7243. $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天销量
  7244. $yj = $c / ($xl / 30);
  7245. if ($yj < 7) {
  7246. $rows[$key]['y'] = round($yj) . '天销量';
  7247. } else {
  7248. $rows[$key]['y'] = '正常';
  7249. }
  7250. }
  7251. } else {
  7252. //$where .= " and time > '$ktime' and time < '$jtime'";
  7253. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7254. foreach ($info_list as $key => $value) {
  7255. $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'] . '"');
  7256. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7257. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7258. $zs[$key] = $value;
  7259. $warehouse = $this->warehouse->read($value['warehouse']);
  7260. $zs[$key]['warehouse'] = $warehouse['title'];
  7261. $zs[$key]['features'] = $g;
  7262. $zs[$key]['a'] = $x;
  7263. $zs[$key]['b'] = $s;
  7264. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7265. $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天销量
  7266. $yj = $c / ($xl / 30);
  7267. if ($yj < 7) {
  7268. $zs[$key]['y'] = round($yj) . '天销量';
  7269. $rows[$key] = $zs[$key];
  7270. }
  7271. }
  7272. }
  7273. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7274. $pagenum = ceil($total / $perpage);
  7275. $over = $total - ($start + $perpage);
  7276. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7277. echo json_encode($rows);
  7278. exit;
  7279. }
  7280. $this->data['arg_array'] = $arg_array[0];
  7281. $this->_Template('whlabel_fcjxc', $this->data);
  7282. }
  7283. public function _0kcdel()
  7284. {
  7285. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7286. $config['upload_path'] = '.' . $dir;
  7287. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7288. $config['allowed_types'] = 'xls|xlsx|csv';
  7289. $config['max_size'] = 10240;
  7290. $this->load->library('upload', $config);
  7291. $this->upload->initialize($config);
  7292. if ($this->upload->do_upload('userfile')) {
  7293. $full_path = $dir . $this->upload->data('file_name');
  7294. $fileName = '.' . $full_path;
  7295. if (!file_exists($fileName)) {
  7296. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7297. exit;
  7298. } else {
  7299. require_once "./data/excel/PHPExcel/IOFactory.php";
  7300. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7301. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7302. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7303. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7304. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7305. ++$column; //如果列数大于26行
  7306. $list = array();
  7307. for ($i = 2; $i <= $row; $i++) // 行数循环
  7308. {
  7309. $data = array();
  7310. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7311. {
  7312. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7313. }
  7314. $list[] = $data;
  7315. }
  7316. }
  7317. $i = 0;
  7318. $j = 0;
  7319. $ed = array();
  7320. foreach ($list as $key => $value) {
  7321. $time = time();
  7322. if ($value['0'] == "" || $value['1'] == "") {
  7323. continue;
  7324. }
  7325. $warehouse = $this->warehouse->get_title($value['0']);
  7326. $sku = $value['1'];
  7327. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7328. if (!$d) //如果没有这个SKU
  7329. {
  7330. $ed[] = array($sku . '-库存中不存在此SKU');
  7331. $j++;
  7332. continue;
  7333. }
  7334. if (!isset($warehouse['id'])) {
  7335. $ed[] = array($sku . '-仓库名错误!');
  7336. $j++;
  7337. continue;
  7338. }
  7339. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7340. if ($z < 1) {
  7341. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7342. foreach ($z as $v) {
  7343. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7344. if (count($zt) > 0) {
  7345. $ed[] = array($sku . '-有在途库存无法删除!');
  7346. $j++;
  7347. continue;
  7348. }
  7349. $this->whlabel->remove($v['id']);
  7350. }
  7351. } else {
  7352. $ed[] = array($sku . '-非0库存!');
  7353. $j++;
  7354. continue;
  7355. }
  7356. }
  7357. if ($j > 0) {
  7358. $tt = date('Ymd', time());
  7359. $title = '删除0库存错误信息-' . $tt;
  7360. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7361. $tail = "\n";
  7362. $filename = $title . ".xls";
  7363. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7364. $dir = '/data/excel/' . $time . '/';
  7365. $file_name = 'error_' . $time . rand(1000, 9999);
  7366. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7367. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7368. fwrite($myfile, $ecl);
  7369. fclose($myfile);
  7370. $error = $dir . $file_name . '.xls';
  7371. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7372. exit;
  7373. } else {
  7374. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7375. exit;
  7376. }
  7377. }
  7378. }
  7379. public function _gbhtype()
  7380. {
  7381. $post = $this->input->post(NULL, TRUE);
  7382. if (isset($post['s'])) {
  7383. $n = $this->input->post('n');
  7384. $d = $this->input->post('s');
  7385. if (!$d) {
  7386. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7387. exit;
  7388. }
  7389. $d = explode(',', trim($d, ','));
  7390. $t = $this->whlabel_type->read($n);
  7391. //循环删除记录
  7392. foreach ($d as $v) {
  7393. $u = $this->whlabel->read($v);
  7394. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7395. foreach ($data as $val) {
  7396. $this->whlabel->save(array('type' => $n), $val['id']);
  7397. }
  7398. }
  7399. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7400. }
  7401. }
  7402. //出库、退库导出
  7403. public function _dccrtype()
  7404. {
  7405. $classid = $this->classid->sku();
  7406. $pm = $classid;
  7407. $typeclass = array();
  7408. $tc = $this->typeclass->find_all();
  7409. foreach ($tc as $v) {
  7410. $typeclass[$v['id']] = $v;
  7411. }
  7412. $prc = array();
  7413. $purchase = $this->purchase->find_all();
  7414. foreach ($purchase as $k => $v) {
  7415. $prc[$v['id']] = $v['title'];
  7416. }
  7417. if (isset($_GET['sid'])) {
  7418. $wh = array();
  7419. $w = $this->warehouse->find_all('1=1', 'id,title');
  7420. foreach ($w as $v) {
  7421. $wh[$v['id']] = $v['title'];
  7422. }
  7423. $type = $this->input->get('excel', true);
  7424. $category = $this->input->get('category', true);
  7425. $size = $this->input->get('size', true);
  7426. $grade = $this->input->get('grade', true);
  7427. $color = $this->input->get('color', true);
  7428. $lowe = $this->input->get('lowe', true);
  7429. $sku = $this->input->get('sku', true);
  7430. $warehouse = $this->input->get('warehouse', true);
  7431. $lacetype = $this->input->get('lacetype', true);
  7432. $lacecolor = $this->input->get('lacecolor', true);
  7433. $density = $this->input->get('density', true);
  7434. $haircap = $this->input->get('haircap', true);
  7435. $purchase = $this->input->get('purchase', true);
  7436. $title = $this->input->get('title', true);
  7437. $state = $this->input->get('state', true);
  7438. $sid = $this->input->get('sid', true);
  7439. $ktime = $this->input->get('ktime', true);
  7440. $jtime = $this->input->get('jtime', true);
  7441. $ktime = strtotime($ktime);
  7442. $jtime = strtotime($jtime);
  7443. $where = "1=1";
  7444. $gj = "";
  7445. $ck = "";
  7446. if ($category) {
  7447. $where .= " and features like '%-$category-%'";
  7448. }
  7449. if ($size) {
  7450. $where .= " and features like '%-$size-%'";
  7451. }
  7452. if ($grade) {
  7453. $where .= " and features like '%-$grade-%'";
  7454. }
  7455. if ($color) {
  7456. $where .= " and features like '%-$color-%'";
  7457. }
  7458. if ($lowe) {
  7459. $where .= " and features like '%-$lowe-%'";
  7460. }
  7461. if ($warehouse) {
  7462. $where .= " and warehouse = '$warehouse'";
  7463. }
  7464. if ($purchase) {
  7465. $where .= " and purchase = '$purchase'";
  7466. }
  7467. if ($state) {
  7468. $where .= " and state = '$state'";
  7469. }
  7470. if ($lacetype) {
  7471. $where .= " and features like '%-$lacetype-%'";
  7472. }
  7473. if ($lacecolor) {
  7474. $where .= " and features like '%-$lacecolor-%'";
  7475. }
  7476. if ($density) {
  7477. $where .= " and features like '%-$density-%'";
  7478. }
  7479. if ($haircap) {
  7480. $where .= " and features like '%-$haircap-%'";
  7481. }
  7482. if ($title) {
  7483. $title = trim($title, ' ');
  7484. $title = trim($title, ' ');
  7485. $where .= " and title like '%$title%'";
  7486. }
  7487. if ($sku) {
  7488. $sku = trim($sku, ' ');
  7489. $sku = trim($sku, ' ');
  7490. $where .= " and sku like '%$sku%'";
  7491. }
  7492. if ($ktime && $jtime) {
  7493. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7494. }
  7495. $sidwhere = '';
  7496. if ($sid) {
  7497. $sd = "";
  7498. $s = explode(',', trim($sid, ','));
  7499. foreach ($s as $value) {
  7500. $sd .= " id = " . $value . " or";
  7501. }
  7502. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7503. }
  7504. //数据排序
  7505. $order_str = "time desc";
  7506. if (empty($page)) {
  7507. $start = 0;
  7508. $perpage = 1;
  7509. } else {
  7510. $start = ($page - 1) * $perpage;
  7511. }
  7512. $wh = array();
  7513. $w = $this->warehouse->find_all('1=1', 'id,title');
  7514. foreach ($w as $v) {
  7515. $wh[$v['id']] = $v['title'];
  7516. }
  7517. $wt = array();
  7518. $whlabel_type = $this->whlabel_type->find_all();
  7519. foreach ($whlabel_type as $v) {
  7520. $wt[$v['id']] = $v['title'];
  7521. }
  7522. $classid = $this->classid->sku();
  7523. $list = array();
  7524. $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');
  7525. foreach ($rows_r as $key => $value) {
  7526. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7527. $pm = $classid;
  7528. $jm = $classid;
  7529. $rows_r[$key]['enter'] = '入库';
  7530. $rows_r[$key]['time'] = $value['enter'];
  7531. if ($value['rktype'] == 1) {
  7532. $rows_r[$key]['rktype'] = '采购入库';
  7533. } else if ($value['rktype'] == 2) {
  7534. $rows_r[$key]['rktype'] = '盘盈调整';
  7535. } else if ($value['rktype'] == 3) {
  7536. $rows_r[$key]['rktype'] = '其他调整入库';
  7537. } else if ($value['rktype'] == 4) {
  7538. $rows_r[$key]['rktype'] = '其他调整入库';
  7539. } else if ($value['rktype'] == 5) {
  7540. $rows_r[$key]['rktype'] = '退库入库';
  7541. } else if ($value['rktype'] == 6) {
  7542. $rows_r[$key]['rktype'] = '退货可用入库';
  7543. } else if ($value['rktype'] == 7) {
  7544. $rows_r[$key]['rktype'] = '形态转换入库';
  7545. } else {
  7546. $rows_r[$key]['rktype'] = '';
  7547. }
  7548. $features = explode('-', trim($value['features'], '-'));
  7549. foreach ($features as $v) {
  7550. if (isset($typeclass[$v])) {
  7551. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7552. $pm[$typeclass[$v]['classid']] = $zh[0];
  7553. }
  7554. if (isset($typeclass[$v])) {
  7555. if (isset($jm[$typeclass[$v]['classid']])) {
  7556. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7557. }
  7558. }
  7559. }
  7560. $zh = implode(" ", $pm);
  7561. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7562. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7563. $rows_r[$key]['zh'] = $zh;
  7564. $jm = array_filter($jm);
  7565. $rows_r[$key]['features'] = implode("-", $jm);
  7566. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7567. }
  7568. $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');
  7569. foreach ($rows_c as $key => $value) {
  7570. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7571. $pm = $classid;
  7572. $jm = $classid;
  7573. $rows_c[$key]['time'] = $value['outk'];
  7574. $rows_c[$key]['outk'] = '出库';
  7575. if ($value['cktype'] == 1) {
  7576. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7577. } else if ($value['cktype'] == 2) {
  7578. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7579. } else if ($value['cktype'] == 3) {
  7580. $rows_c[$key]['cktype'] = '盘亏调整';
  7581. } else if ($value['cktype'] == 4) {
  7582. $rows_c[$key]['cktype'] = '其他调整出库';
  7583. } else if ($value['cktype'] == 5) {
  7584. $rows_c[$key]['cktype'] = '形态转换出库';
  7585. } else {
  7586. $rows_c[$key]['cktype'] = '';
  7587. }
  7588. unset($rows_c[$key]['state']);
  7589. $features = explode('-', trim($value['features'], '-'));
  7590. foreach ($features as $v) {
  7591. if (isset($typeclass[$v])) {
  7592. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7593. $pm[$typeclass[$v]['classid']] = $zh[0];
  7594. }
  7595. if (isset($typeclass[$v])) {
  7596. if (isset($jm[$typeclass[$v]['classid']])) {
  7597. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7598. }
  7599. }
  7600. }
  7601. $zh = implode(" ", $pm);
  7602. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7603. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7604. $rows_c[$key]['zh'] = $zh;
  7605. $jm = array_filter($jm);
  7606. $rows_c[$key]['features'] = implode("-", $jm);
  7607. $rows_c[$key]['number'] = 1;
  7608. }
  7609. $merged = $rows_r;
  7610. foreach ($rows_c as $key => $value) {
  7611. if (isset($merged[$key])) {
  7612. $merged[] = $value;
  7613. } else {
  7614. $merged[$key] = $value;
  7615. }
  7616. }
  7617. usort($merged, function ($a, $b) {
  7618. return $a['time'] - $b['time'];
  7619. });
  7620. foreach ($merged as $key => $value) {
  7621. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7622. }
  7623. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7624. $titlename = "<table border=1>
  7625. <tr align='center'>
  7626. <td>仓库</td>
  7627. <td>SKU</td>
  7628. <td>商品名称</td>
  7629. <td>仓库品名</td>
  7630. <td>料号</td>
  7631. <td>时间</td>
  7632. <td>操作</td>
  7633. <td>类型</td>
  7634. <td>数量</td>
  7635. <td>备注</td>
  7636. </tr>
  7637. </table>";
  7638. $filename = $title . ".xlsx";
  7639. $tail = "";
  7640. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7641. }
  7642. }
  7643. /*************************************处理exceljs导出****************************************************/
  7644. public function _excelrjs(){
  7645. if (isset($_GET['excel'])) {
  7646. $category = $this->input->get('category', true);
  7647. $size = $this->input->get('size', true);
  7648. $grade = $this->input->get('grade', true);
  7649. $color = $this->input->get('color', true);
  7650. $lowe = $this->input->get('lowe', true);
  7651. $sku = $this->input->get('sku', true);
  7652. $warehouse = $this->input->get('warehouse', true);
  7653. $purchase = $this->input->get('purchase', true);
  7654. $ktime = $this->input->get('ktime', true);
  7655. $jtime = $this->input->get('jtime', true);
  7656. $ktime = strtotime($ktime);
  7657. $jtime = strtotime($jtime);
  7658. $where = "1=1";
  7659. $gj = "";
  7660. $ck = "";
  7661. if ($category) {
  7662. $where .= " and features like '%-$category-%'";
  7663. }
  7664. if ($size) {
  7665. $where .= " and features like '%-$size-%'";
  7666. }
  7667. if ($grade) {
  7668. $where .= " and features like '%-$grade-%'";
  7669. }
  7670. if ($color) {
  7671. $where .= " and features like '%-$color-%'";
  7672. }
  7673. if ($lowe) {
  7674. $where .= " and features like '%-$lowe-%'";
  7675. }
  7676. if ($warehouse) {
  7677. $where .= " and warehouse = '$warehouse'";
  7678. }
  7679. if ($purchase) {
  7680. $where .= " and purchase = '$purchase'";
  7681. }
  7682. if ($sku) {
  7683. $where .= " and sku = '$sku'";
  7684. }
  7685. if ($ktime && $jtime) {
  7686. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7687. }
  7688. //数据排序
  7689. $order_str = "id desc";
  7690. if (empty($page)) {
  7691. $start = 0;
  7692. $perpage = 1;
  7693. } else {
  7694. $start = ($page - 1) * $perpage;
  7695. }
  7696. $list = array();
  7697. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7698. foreach ($rows as $value) {
  7699. $ck = $this->warehouse->read($value['warehouse']);
  7700. $warehouse = $ck['title'];
  7701. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7702. $retreatwarehouse = $tkck['title'];
  7703. $gy = $this->purchase->read($value['purchase']);
  7704. $purchase = $gy['title'];
  7705. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7706. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7707. }
  7708. if(empty($list)){
  7709. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7710. }else{
  7711. $final_list = [];
  7712. foreach($list as $v){
  7713. $final_list[] = array_values($v);
  7714. }
  7715. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7716. array_unshift($final_list,[
  7717. "仓库","SKU","商品名称","时间","数量"
  7718. ]);
  7719. array_unshift($final_list,[
  7720. $title,"","","",""
  7721. ]);
  7722. $merges = [
  7723. [
  7724. "s"=>["r"=>0,"c"=>0],
  7725. "e"=>["r"=>0,"c"=>4]
  7726. ]
  7727. ];
  7728. $cols = [
  7729. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7730. ];
  7731. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7732. }
  7733. }
  7734. }
  7735. //出库、退库导出
  7736. public function _excelctjs()
  7737. {
  7738. $classid = $this->classid->sku();
  7739. $pm = $classid;
  7740. $typeclass = array();
  7741. $tc = $this->typeclass->find_all();
  7742. foreach ($tc as $v) {
  7743. $typeclass[$v['id']] = $v;
  7744. }
  7745. $prc = array();
  7746. $purchase = $this->purchase->find_all();
  7747. foreach ($purchase as $k => $v) {
  7748. $prc[$v['id']] = $v['title'];
  7749. }
  7750. if (isset($_GET['excel'])) {
  7751. $wh = array();
  7752. $w = $this->warehouse->find_all('1=1', 'id,title');
  7753. foreach ($w as $v) {
  7754. $wh[$v['id']] = $v['title'];
  7755. }
  7756. $type = $this->input->get('excel', true);
  7757. $category = $this->input->get('category', true);
  7758. $size = $this->input->get('size', true);
  7759. $grade = $this->input->get('grade', true);
  7760. $color = $this->input->get('color', true);
  7761. $lowe = $this->input->get('lowe', true);
  7762. $sku = $this->input->get('sku', true);
  7763. $title = $this->input->get('title', true);
  7764. $warehouse = $this->input->get('warehouse', true);
  7765. $purchase = $this->input->get('purchase', true);
  7766. $lacetype = $this->input->get('lacetype', true);
  7767. $haircap = $this->input->get('haircap', true);
  7768. $lacecolor = $this->input->get('lacecolor', true);
  7769. $density = $this->input->get('density', true);
  7770. $details = $this->input->get('details', true);
  7771. $state = $this->input->get('state', true);
  7772. $shop = $this->input->get('shop', true);
  7773. $hairnumber = $this->input->get('hairnumber', true);
  7774. $type_leixi = $this->input->get('type', true);
  7775. $cpbz = $this->input->get('cpbz', true);
  7776. $sm = $this->input->get('sm', true);
  7777. $sid = $this->input->get('sid', true);
  7778. $ktime = $this->input->get('ktime', true);
  7779. $jtime = $this->input->get('jtime', true);
  7780. $ktime = strtotime($ktime);
  7781. $jtime = strtotime($jtime);
  7782. //$where = " 1=1 ";
  7783. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7784. $where = " sku != '' ";
  7785. $gj = "";
  7786. $ck = "";
  7787. if ($category) {
  7788. $where .= " and features like '%-$category-%'";
  7789. }
  7790. if ($size) {
  7791. $where .= " and features like '%-$size-%'";
  7792. }
  7793. if ($grade) {
  7794. $where .= " and features like '%-$grade-%'";
  7795. }
  7796. if ($color) {
  7797. $where .= " and features like '%-$color-%'";
  7798. }
  7799. if ($lowe) {
  7800. $where .= " and features like '%-$lowe-%'";
  7801. }
  7802. if ($warehouse) {
  7803. $where .= " and warehouse = '$warehouse'";
  7804. }
  7805. if ($purchase) {
  7806. $where .= " and purchase = '$purchase'";
  7807. }
  7808. if ($state) {
  7809. $where .= " and state = '$state'";
  7810. }
  7811. if ($lacetype) {
  7812. $where .= " and features like '%-$lacetype-%'";
  7813. }
  7814. if ($lacecolor) {
  7815. $where .= " and features like '%-$lacecolor-%'";
  7816. }
  7817. if ($density) {
  7818. $where .= " and features like '%-$density-%'";
  7819. }
  7820. if ($haircap) {
  7821. $where .= " and features like '%-$haircap-%'";
  7822. }
  7823. if ($details) {
  7824. $where .= " and details = '$details'";
  7825. }
  7826. if ($shop) {
  7827. $where .= " and shop like '%$shop%'";
  7828. }
  7829. if ($title) {
  7830. $title = trim($title, ' ');
  7831. $title = trim($title, ' ');
  7832. $where .= " and title like '%$title%'";
  7833. }
  7834. if (!empty($hairnumber)) {
  7835. $where .= " and features like '%-128-%' ";
  7836. if ($hairnumber < 0) {
  7837. $class_list = $this->typeclass->find_all('classid = 43');
  7838. foreach ($class_list as $v) {
  7839. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7840. }
  7841. } else {
  7842. $where .= " and features like '%-$hairnumber-%'";
  7843. }
  7844. }
  7845. if ($type_leixi) {
  7846. $where .= " and type = '$type_leixi'";
  7847. }
  7848. if ($cpbz) {
  7849. $where .= " and cpbz like '%$cpbz%' ";
  7850. }
  7851. if ($sm) {
  7852. $where .= " and sm like '%$sm%' ";
  7853. }
  7854. if ($sku) {
  7855. $sku = trim($sku, ' ');
  7856. $sku = trim($sku, ' ');
  7857. $where .= " and sku like '%$sku%'";
  7858. }
  7859. if ($ktime && $jtime) {
  7860. if ($type == 1) {
  7861. $tl = '出库';
  7862. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7863. } else if ($type == 2) {
  7864. $tl = '退库';
  7865. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7866. } else if ($type == 3) {
  7867. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7868. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7869. } else if ($type == 4) {
  7870. $tl = '出库+零售';
  7871. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7872. } else if ($type == 5) {
  7873. $tl = '零售';
  7874. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7875. }
  7876. }
  7877. $sidwhere = '';
  7878. if ($sid) {
  7879. $sd = "";
  7880. $s = explode(',', trim($sid, ','));
  7881. foreach ($s as $value) {
  7882. $sd .= " id = " . $value . " or";
  7883. }
  7884. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7885. }
  7886. //数据排序
  7887. $order_str = "time desc";
  7888. if (empty($page)) {
  7889. $start = 0;
  7890. $perpage = 1;
  7891. } else {
  7892. $start = ($page - 1) * $perpage;
  7893. }
  7894. //取得信息列表
  7895. if ($type != 3 && $type != 5) {
  7896. if ($type == 1 || $type == 4) {
  7897. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7898. foreach ($info_list as $key => $value) {
  7899. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7900. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7901. $warehouse = $this->warehouse->read($value['warehouse']);
  7902. $info_list[$key]['warehouse'] = $warehouse['title'];
  7903. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7904. $features = explode('-', trim($features, '-'));
  7905. $pm = $classid;
  7906. foreach ($features as $k => $v) {
  7907. if ($v != 0) {
  7908. if (!isset($typeclass[$v])) {
  7909. continue;
  7910. }
  7911. if (isset($pm[$typeclass[$v]['classid']])) {
  7912. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7913. $tz = explode('|', $typeclass[$v]['zh']);
  7914. $pm[$typeclass[$v]['classid']] = $tz[0];
  7915. } else {
  7916. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7917. }
  7918. }
  7919. }
  7920. }
  7921. $zh = implode(" ", $pm);
  7922. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7923. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7924. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7925. $info_list[$key]['features'] = $zh;
  7926. }
  7927. $final_list = [];
  7928. foreach($info_list as $k=>$v){
  7929. $number = "";
  7930. if(!empty($v['orderinfo'])){
  7931. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7932. if(!empty($tmp_info['number'])){
  7933. $number = $tmp_info['number'];
  7934. }
  7935. }
  7936. $final_list[] = [
  7937. 'warehouse'=>$v['warehouse'],
  7938. 'purchase'=>$v['purchase'],
  7939. 'sku'=>$v['sku'],
  7940. 'title'=>$v['title'],
  7941. 'features'=>$v['features'],
  7942. 'label'=>$v['label'],
  7943. 'orderinfo'=>$v['orderinfo'],
  7944. 'number'=>$number,
  7945. 'waybill'=>$v['waybill'],
  7946. 'outk'=>$v['outk'],
  7947. ];
  7948. }
  7949. } else {
  7950. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7951. foreach ($info_list as $key => $value) {
  7952. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7953. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7954. $warehouse = $this->warehouse->read($value['warehouse']);
  7955. $info_list[$key]['warehouse'] = $warehouse['title'];
  7956. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7957. $features = explode('-', trim($features, '-'));
  7958. $pm = $classid;
  7959. foreach ($features as $k => $v) {
  7960. if ($v != 0) {
  7961. if (!isset($typeclass[$v])) {
  7962. continue;
  7963. }
  7964. if (isset($pm[$typeclass[$v]['classid']])) {
  7965. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7966. $tz = explode('|', $typeclass[$v]['zh']);
  7967. $pm[$typeclass[$v]['classid']] = $tz[0];
  7968. } else {
  7969. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7970. }
  7971. }
  7972. }
  7973. }
  7974. $zh = implode(" ", $pm);
  7975. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7976. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7977. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7978. $info_list[$key]['features'] = $zh;
  7979. }
  7980. $final_list = [];
  7981. foreach($info_list as $k=>$v){
  7982. $number = "";
  7983. if(!empty($v['orderinfo'])){
  7984. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7985. if(!empty($tmp_info['number'])){
  7986. $number = $tmp_info['number'];
  7987. }
  7988. }
  7989. $final_list[] = [
  7990. 'warehouse'=>$v['warehouse'],
  7991. 'purchase'=>$v['purchase'],
  7992. 'sku'=>$v['sku'],
  7993. 'title'=>$v['title'],
  7994. 'features'=>$v['features'],
  7995. 'label'=>$v['label'],
  7996. 'orderinfo'=>$v['orderinfo'],
  7997. 'number'=>$number,
  7998. 'waybill'=>$v['waybill'],
  7999. 'retreat'=>$v['retreat'],
  8000. ];
  8001. }
  8002. }
  8003. if(empty($final_list)){
  8004. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8005. }else{
  8006. $end_list = [];
  8007. foreach($final_list as $v){
  8008. $end_list[] = array_values($v);
  8009. }
  8010. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8011. array_unshift($end_list,[
  8012. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8013. ]);
  8014. array_unshift($end_list,[
  8015. $title,"","","","","","","","",""
  8016. ]);
  8017. $merges = [
  8018. [
  8019. "s"=>["r"=>0,"c"=>0],
  8020. "e"=>["r"=>0,"c"=>9]
  8021. ]
  8022. ];
  8023. $cols = [
  8024. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8025. ];
  8026. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8027. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8028. ] )));
  8029. }
  8030. } else if ($type == 5) {
  8031. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8032. foreach ($info_list as $key => $value) {
  8033. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8034. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8035. $warehouse = $this->warehouse->read($value['warehouse']);
  8036. $info_list[$key]['warehouse'] = $warehouse['title'];
  8037. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8038. $features = explode('-', trim($features, '-'));
  8039. $pm = $classid;
  8040. foreach ($features as $k => $v) {
  8041. if ($v != 0) {
  8042. if (!isset($typeclass[$v])) {
  8043. continue;
  8044. }
  8045. if (isset($pm[$typeclass[$v]['classid']])) {
  8046. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8047. $tz = explode('|', $typeclass[$v]['zh']);
  8048. $pm[$typeclass[$v]['classid']] = $tz[0];
  8049. } else {
  8050. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8051. }
  8052. }
  8053. }
  8054. }
  8055. $zh = implode(" ", $pm);
  8056. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8057. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8058. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8059. $info_list[$key]['features'] = $zh;
  8060. }
  8061. if(empty($info_list)){
  8062. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8063. }else{
  8064. $final_list = [];
  8065. foreach($info_list as $v){
  8066. $final_list[] = array_values($v);
  8067. }
  8068. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8069. array_unshift($final_list,[
  8070. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8071. ]);
  8072. array_unshift($final_list,[
  8073. $title,"","","","","","",
  8074. ]);
  8075. $merges = [
  8076. [
  8077. "s"=>["r"=>0,"c"=>0],
  8078. "e"=>["r"=>0,"c"=>6]
  8079. ]
  8080. ];
  8081. $cols = [
  8082. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8083. ];
  8084. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8085. }
  8086. } else {
  8087. $wh = array();
  8088. $w = $this->warehouse->find_all('1=1', 'id,title');
  8089. foreach ($w as $v) {
  8090. $wh[$v['id']] = $v['title'];
  8091. }
  8092. $wt = array();
  8093. $whlabel_type = $this->whlabel_type->find_all();
  8094. foreach ($whlabel_type as $v) {
  8095. $wt[$v['id']] = $v['title'];
  8096. }
  8097. $classid = $this->classid->sku();
  8098. $list = array();
  8099. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8100. foreach ($rows as $key => $value) {
  8101. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8102. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8103. $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');
  8104. $details = array();
  8105. $cpid = array();
  8106. $cpbz = array();
  8107. $c = 0;
  8108. $g = 0;
  8109. $x = 0;
  8110. $t = 0;
  8111. $s = 0;
  8112. $q = 0;
  8113. foreach ($sd as $k => $v) {
  8114. if ($v['state'] == 0) {
  8115. $c++;
  8116. }
  8117. if ($v['state'] != 9) {
  8118. $g++;
  8119. }
  8120. if ($v['outk'] > 1) {
  8121. $x++;
  8122. }
  8123. if ($v['retreat'] > 0) {
  8124. $t++;
  8125. }
  8126. if ($v['state'] == 8) {
  8127. $s++;
  8128. }
  8129. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8130. $q++;
  8131. }
  8132. $details[$v['details']] = $v['details'];
  8133. if ($v['cpid'] != 0) {
  8134. $cpid[$v['cpid']] = $v['cpid'];
  8135. }
  8136. if ($v['cpbz'] != '') {
  8137. $cpbz[$v['cpbz']] = $v['cpbz'];
  8138. }
  8139. }
  8140. if (isset($wt[$value['type']])) {
  8141. $rows[$key]['type'] = $wt[$value['type']];
  8142. } else {
  8143. $rows[$key]['type'] = '未设置';
  8144. }
  8145. $rows[$key]['details'] = implode("、", $details);
  8146. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8147. $ftime = time() - 15 * 24 * 3600;
  8148. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8149. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8150. $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);
  8151. $rows[$key]['c'] = $c;
  8152. $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);
  8153. $rows[$key]['t'] = $t;
  8154. $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'] . '"');
  8155. $rows[$key]['z'] = $z;
  8156. // $jm = $classid;
  8157. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8158. $features = explode('-', trim($features, '-'));
  8159. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8160. }
  8161. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8162. $final_list =[];
  8163. foreach($tmp_list as $k=>$v){
  8164. $final_list[] = [
  8165. "warehouse"=>$v['warehouse'],
  8166. "purchase"=>$v['purchase'],
  8167. "details"=>$v['details'],
  8168. "cpid"=>$v['cpid'],
  8169. "sku"=>$v['sku'],
  8170. "title"=>$v['title'],
  8171. "features"=>$v['pm'],
  8172. "cpbz"=>$v['cpbz'],
  8173. "sm"=>$v['sm'],
  8174. "type"=>$v['type'],
  8175. "g"=>$v["g"],
  8176. "c"=>$v["c"],
  8177. "x"=>$v["x"],
  8178. "t"=>$v["t"],
  8179. "z"=>$v["z"],
  8180. "jm"=>$v["jm"],
  8181. "weight"=>$v["weight"],
  8182. "asd"=>$v["asd"],
  8183. ];
  8184. }
  8185. if(empty($final_list)){
  8186. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8187. }else{
  8188. $end_list = [];
  8189. foreach($final_list as $v){
  8190. $end_list[] = array_values($v);
  8191. }
  8192. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8193. array_unshift($end_list,[
  8194. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8195. ]);
  8196. array_unshift($end_list,[
  8197. $title,"","","","","","","","","","","","","","","","","",""
  8198. ]);
  8199. $merges = [
  8200. [
  8201. "s"=>["r"=>0,"c"=>0],
  8202. "e"=>["r"=>0,"c"=>6]
  8203. ]
  8204. ];
  8205. $cols = [
  8206. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8207. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8208. ];
  8209. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8210. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8211. ])));
  8212. }
  8213. }
  8214. }
  8215. }
  8216. public function _exceljxcjs(){
  8217. $classid = $this->classid->sku();
  8218. $pm = $classid;
  8219. $typeclass = array();
  8220. $tc = $this->typeclass->find_all();
  8221. foreach ($tc as $v) {
  8222. $typeclass[$v['id']] = $v;
  8223. }
  8224. $prc = array();
  8225. $purchase = $this->purchase->find_all();
  8226. foreach ($purchase as $k => $v) {
  8227. $prc[$v['id']] = $v['title'];
  8228. }
  8229. if(!isset($_GET['excel'])){
  8230. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8231. }
  8232. $where = "sku != 'Preset'";
  8233. //数据排序
  8234. $order_str = "id desc";
  8235. if (empty($page)) {
  8236. $start = 0;
  8237. $perpage = 1;
  8238. } else {
  8239. $start = ($page - 1) * $perpage;
  8240. }
  8241. $category = $this->input->get('category', true);
  8242. $warehouse = $this->input->get('warehouse', true);
  8243. $excelid = $this->input->get('sid', true);
  8244. if ($category) {
  8245. $where .= " and features like '%-$category-%'";
  8246. }
  8247. if ($warehouse) {
  8248. $where .= " and warehouse = '$warehouse'";
  8249. }
  8250. $xzid = '';
  8251. if ($excelid) {
  8252. $excelid = explode(',', trim($excelid, ','));
  8253. foreach ($excelid as $key => $value) {
  8254. $xzid .= " id = " . $value . " or";
  8255. }
  8256. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8257. }
  8258. $wt = array();
  8259. $whlabel_type = $this->whlabel_type->find_all();
  8260. foreach ($whlabel_type as $v) {
  8261. $wt[$v['id']] = $v['title'];
  8262. }
  8263. $wh = array();
  8264. $w = $this->warehouse->find_all('1=1', 'id,title');
  8265. foreach ($w as $v) {
  8266. $wh[$v['id']] = $v['title'];
  8267. }
  8268. $list = array();
  8269. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8270. foreach ($rows as $key => $value) {
  8271. if (isset($wt[$value['type']])) {
  8272. $rows[$key]['type'] = $wt[$value['type']];
  8273. } else {
  8274. $rows[$key]['type'] = '未设置';
  8275. }
  8276. $bm = '03';
  8277. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8278. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8279. $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');
  8280. $details = array();
  8281. $cpid = array();
  8282. $cpbz = array();
  8283. $c = 0;
  8284. $g = 0;
  8285. $x = 0;
  8286. $t = 0;
  8287. $s = 0;
  8288. $q = 0;
  8289. foreach ($sd as $k => $v) {
  8290. if ($v['state'] == 0) {
  8291. $c++;
  8292. if ($v['cpid'] != 0) {
  8293. $cpid[$v['cpid']] = $v['cpid'];
  8294. }
  8295. if ($v['cpbz'] != '') {
  8296. $cpbz[$v['cpbz']] = $v['cpbz'];
  8297. }
  8298. }
  8299. if ($v['state'] != 9) {
  8300. $g++;
  8301. }
  8302. if ($v['state'] == 1) {
  8303. $x++;
  8304. }
  8305. if ($v['state'] == 2) {
  8306. $t++;
  8307. }
  8308. if ($v['state'] == 8) {
  8309. $s++;
  8310. }
  8311. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8312. $q++;
  8313. }
  8314. $details[$v['details']] = $v['details'];
  8315. }
  8316. $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'] . '"');
  8317. $rows[$key]['details'] = implode("、", $details);
  8318. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8319. $number = $value['number'];
  8320. $ftime = time() - 15 * 24 * 3600;
  8321. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8322. $rows[$key]['number'] = $g;
  8323. $rows[$key]['c'] = $c;
  8324. $rows[$key]['x'] = $x;
  8325. $rows[$key]['t'] = $t;
  8326. $rows[$key]['s'] = $s;
  8327. $rows[$key]['q'] = $q;
  8328. $rows[$key]['z'] = $z;
  8329. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8330. $features = explode('-', trim($features, '-'));
  8331. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8332. }
  8333. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8334. $final_list = [];
  8335. foreach ($list as $k => $v) {
  8336. if (empty($v['sku'])) {
  8337. continue;
  8338. }
  8339. $final_list[] = [
  8340. $v["warehouse"],
  8341. $v["purchase"],
  8342. $v["details"],
  8343. $v["cpid"],
  8344. $v["dbcontent"],
  8345. $v["sku"],
  8346. $v["bm"],
  8347. $v["jm"],
  8348. $v["title"],
  8349. $v["pm"],
  8350. $v["cpbz"],
  8351. $v["sm"],
  8352. $v["type"],
  8353. $v["number"],
  8354. $v["c"],
  8355. $v["x"],
  8356. $v["t"],
  8357. $v["s"],
  8358. $v["q"],
  8359. $v["z"],
  8360. $v['weight'],
  8361. ];
  8362. }
  8363. if(empty($final_list)){
  8364. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8365. }
  8366. $title = "总进销存统计表";
  8367. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8368. $merges = [
  8369. [
  8370. "s"=>["r"=>0,"c"=>0],
  8371. "e"=>["r"=>0,"c"=>21]
  8372. ]
  8373. ];
  8374. $cols = [
  8375. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8376. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8377. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8378. ];
  8379. array_unshift($final_list, $first_row);
  8380. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8381. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8382. }
  8383. public function _summaryjs($arg_array)
  8384. {
  8385. $prc = array();
  8386. $purchase = $this->purchase->find_all();
  8387. foreach ($purchase as $k => $v) {
  8388. $prc[$v['id']] = $v['title'];
  8389. }
  8390. if (isset($_GET['excel'])) {
  8391. $ktime = $this->input->get('ktime', true);
  8392. $jtime = $this->input->get('jtime', true);
  8393. $ktime = strtotime($ktime);
  8394. $jtime = strtotime($jtime);
  8395. $where = "1=1";
  8396. if ($ktime && $jtime) {
  8397. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8398. }
  8399. //数据排序
  8400. $order_str = "time desc";
  8401. if (empty($page)) {
  8402. $start = 0;
  8403. $perpage = 1;
  8404. } else {
  8405. $start = ($page - 1) * $perpage;
  8406. }
  8407. //取得信息列表
  8408. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8409. foreach ($info_list as $key => $value) {
  8410. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8411. $warehouse = $this->warehouse->read($value['warehouse']);
  8412. $info_list[$key]['warehouse'] = $warehouse['title'];
  8413. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8414. $details = array();
  8415. $cpid = array();
  8416. foreach ($x as $k => $v) {
  8417. if ($v['details'] != '') {
  8418. $details[$v['details']] = $v['details'];
  8419. }
  8420. if ($v['cpid'] != 0) {
  8421. $cpid[$v['cpid']] = $v['cpid'];
  8422. }
  8423. }
  8424. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8425. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8426. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8427. $info_list[$key]['s'] = $s;
  8428. $info_list[$key]['x'] = count($x);
  8429. }
  8430. if(empty($info_list)){
  8431. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8432. }
  8433. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8434. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8435. $merges = [
  8436. [
  8437. "s"=>["r"=>0,"c"=>0],
  8438. "e"=>["r"=>0,"c"=>7]
  8439. ]
  8440. ];
  8441. $cols = [
  8442. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8443. ];
  8444. $final_list = [];
  8445. foreach($info_list as $k => $v){
  8446. $final_list[] = array_values($v);
  8447. }
  8448. array_unshift($final_list, $first_row);
  8449. array_unshift($final_list,[
  8450. $title,"","","","","","","","",
  8451. ]);
  8452. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8453. $titlename = "<table border=1>
  8454. <tr align='center'>
  8455. <td>仓库</td>
  8456. <td>供应商</td>
  8457. <td>出库位置</td>
  8458. <td>出库编码</td>
  8459. <td>SKU</td>
  8460. <td>产品名</td>
  8461. <td>总剩余库存</td>
  8462. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8463. </tr>
  8464. </table>";
  8465. $filename = $title . ".xls";
  8466. $tail = "";
  8467. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8468. }
  8469. }
  8470. public function _uckjs()
  8471. {
  8472. if (isset($_GET['excel'])) {
  8473. $tc = array();
  8474. $typeclass = $this->typeclass->find_all();
  8475. foreach ($typeclass as $v) {
  8476. $tc[$v['id']] = $v['zh'];
  8477. }
  8478. $first_row = [
  8479. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8480. ];
  8481. $t = array();
  8482. $rq = '';
  8483. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8484. $ts = $ts / (24 * 3600);
  8485. for ($i = 0; $i < $ts; $i++) {
  8486. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8487. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8488. }
  8489. $day_len = count($t);
  8490. $first_row[] = "本月出库";
  8491. $merges = [
  8492. ];
  8493. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8494. $excel_key = 1;
  8495. $final_list = [];
  8496. foreach ($info_list as $k => $v) {
  8497. $features = explode('-', trim($v['features'], '-'));
  8498. if (!isset($features[3]) || !isset($features[4])) {
  8499. continue;
  8500. }
  8501. $tmp = [];
  8502. $tmp[0] = $tc[$features[0]]; //类型
  8503. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8504. $tmp[2] = $tc[$features[4]]; //曲度
  8505. $tmp[3] = '';
  8506. if (isset($data[$k][1])) {
  8507. $tmp[3] .=$tmp[1];
  8508. }
  8509. if (isset($data[$k][2])) {
  8510. $tmp[3] .= $tmp[2];
  8511. }
  8512. if (isset($features[5])) {
  8513. $tmp[3] .= $tc[$features[5]];
  8514. }
  8515. if (isset($features[2])) {
  8516. $tmp[3] .= $tc[$features[2]];
  8517. }
  8518. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8519. $tmp[4] = $v['sku'];
  8520. $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())) . '))'); //月初库存
  8521. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8522. $tmp[7] ="";
  8523. $tmp[8] ="";
  8524. $byck = 0;
  8525. foreach ($t as $vv) {
  8526. $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));
  8527. $tmp[] = ($sl > 0) ? $sl : '';
  8528. $byck += $sl;
  8529. }
  8530. $tmp[] = ($byck > 0) ? $byck : '';
  8531. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8532. // $ztrq = '';
  8533. // $ztsl = '';
  8534. // if (count($zt) > 0) {
  8535. // foreach ($zt as $vv) {
  8536. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8537. // $ztsl .= $vv['num'] . '<br>';
  8538. // }
  8539. // }
  8540. if(empty($zt)){
  8541. $final_list[] = $tmp;
  8542. $excel_key = $excel_key + 1;
  8543. }else{
  8544. $len = count($zt);
  8545. if($len == 1){
  8546. $tmp[7] = $zt[0]['num'] ;
  8547. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8548. $final_list[] = $tmp;
  8549. $excel_key = $excel_key + 1;
  8550. }else{
  8551. foreach($zt as $vv){
  8552. $tmp[7] = "";
  8553. $tmp[8] = "";
  8554. $tmp[7] = $vv['num'];
  8555. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8556. $final_list[] = $tmp;
  8557. }
  8558. $merges[] = [
  8559. "s"=>["r"=>$excel_key,"c"=>0],
  8560. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8561. ];
  8562. $merges[] = [
  8563. "s"=>["r"=>$excel_key,"c"=>1],
  8564. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8565. ];
  8566. $merges[] = [
  8567. "s"=>["r"=>$excel_key,"c"=>2],
  8568. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8569. ];
  8570. $merges[] = [
  8571. "s"=>["r"=>$excel_key,"c"=>3],
  8572. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8573. ];
  8574. $merges[] = [
  8575. "s"=>["r"=>$excel_key,"c"=>4],
  8576. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8577. ];
  8578. $merges[] = [
  8579. "s"=>["r"=>$excel_key,"c"=>5],
  8580. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8581. ];
  8582. $merges[] = [
  8583. "s"=>["r"=>$excel_key,"c"=>6],
  8584. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8585. ];
  8586. for($i=1;$i<=$day_len;$i++){
  8587. $merges[] = [
  8588. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8589. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8590. ];
  8591. }
  8592. $merges[] = [
  8593. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8594. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8595. ];
  8596. $excel_key = $excel_key + $len;
  8597. }
  8598. }
  8599. }
  8600. $title = "详情 " . date("Y-m-d", time());
  8601. if(empty($final_list)){
  8602. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8603. }
  8604. $cols = [
  8605. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8606. ];
  8607. array_unshift($final_list, $first_row);
  8608. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8609. }
  8610. }
  8611. public function _whlabelexcelzhjs(){
  8612. if(empty($_GET['excel'])){
  8613. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8614. }
  8615. $where = "sku != 'Preset' and sku != '' ";
  8616. //数据排序
  8617. $order_str = "id desc";
  8618. if (empty($page)) {
  8619. $start = 0;
  8620. $perpage = 1;
  8621. } else {
  8622. $start = ($page - 1) * $perpage;
  8623. }
  8624. $category = $this->input->get('category', true);
  8625. $warehouse = $this->input->get('warehouse', true);
  8626. $excelid = $this->input->get('sid', true);
  8627. if ($category) {
  8628. $where .= " and features like '%-$category-%'";
  8629. }
  8630. if ($warehouse) {
  8631. $where .= " and warehouse = '$warehouse'";
  8632. }
  8633. $xzid = '';
  8634. if ($excelid) {
  8635. $excelid = explode(',', trim($excelid, ','));
  8636. foreach ($excelid as $key => $value) {
  8637. $xzid .= " id = " . $value . " or";
  8638. }
  8639. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8640. }
  8641. $merges = [
  8642. [
  8643. "s"=>["r"=>0,"c"=>0],
  8644. "e"=>["r"=>0,"c"=>6]
  8645. ]
  8646. ];
  8647. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8648. $excel_index = 2;
  8649. $final_list = [];
  8650. foreach ($rows as $key => $value) {
  8651. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8652. $zh = '';
  8653. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8654. // foreach ($zt_list as $v) {
  8655. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8656. // }
  8657. $zt = array_sum(array_column($zt_list, 'num'));
  8658. $number = $value['number'];
  8659. $ftime = time() - 15 * 24 * 3600;
  8660. $warehouse = $this->warehouse->read($value['warehouse']);
  8661. // $rows[$key]['warehouse'] = $warehouse['title'];
  8662. // $rows[$key]['number'] = $c;
  8663. // $rows[$key]['features'] = $zh;
  8664. //$rows[$key]['hb'] = $c + $zt;
  8665. $tmp = [];
  8666. $tmp[0] = $warehouse['title'];
  8667. $tmp[1] = $value['sku'];
  8668. $tmp[2] = $value['title'];
  8669. $tmp[3] = $c;
  8670. $tmp[4] = "";
  8671. $tmp[5] = $c + $zt;
  8672. if(empty($zt_list)){
  8673. $tmp[4] = "";
  8674. $final_list[] = $tmp;
  8675. $excel_index = $excel_index + 1;
  8676. }else{
  8677. if(count($zt_list) == 1){
  8678. $tmp[4] = "";
  8679. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8680. $final_list[] = $tmp;
  8681. $excel_index = $excel_index + 1;
  8682. }else{
  8683. $len = count($zt_list);
  8684. foreach ($zt_list as $v){
  8685. $tmp[4] = "";
  8686. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8687. $final_list[] = $tmp;
  8688. }
  8689. $merges[] = [
  8690. "s"=>["r"=>$excel_index,"c"=>0],
  8691. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8692. ];
  8693. $merges[] = [
  8694. "s"=>["r"=>$excel_index,"c"=>1],
  8695. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8696. ];
  8697. $merges[] = [
  8698. "s"=>["r"=>$excel_index,"c"=>2],
  8699. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8700. ];
  8701. $merges[] = [
  8702. "s"=>["r"=>$excel_index,"c"=>3],
  8703. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8704. ];
  8705. $merges[] = [
  8706. "s"=>["r"=>$excel_index,"c"=>5],
  8707. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8708. ];
  8709. $excel_index = $excel_index + $len;
  8710. }
  8711. }
  8712. }
  8713. $first_row = [
  8714. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8715. ];
  8716. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8717. if(empty($final_list)){
  8718. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8719. }
  8720. $cols = [
  8721. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8722. ];
  8723. array_unshift($final_list, $first_row);
  8724. array_unshift($final_list, [
  8725. $title,"","","","",""
  8726. ]);
  8727. $end_list = [];
  8728. foreach ($final_list as $key => $value) {
  8729. $end_list[] = array_values($value);
  8730. }
  8731. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8732. }
  8733. //出库、退库导出
  8734. public function _dccrtypejs()
  8735. {
  8736. $classid = $this->classid->sku();
  8737. $pm = $classid;
  8738. $typeclass = array();
  8739. $tc = $this->typeclass->find_all();
  8740. foreach ($tc as $v) {
  8741. $typeclass[$v['id']] = $v;
  8742. }
  8743. $prc = array();
  8744. $purchase = $this->purchase->find_all();
  8745. foreach ($purchase as $k => $v) {
  8746. $prc[$v['id']] = $v['title'];
  8747. }
  8748. if (isset($_GET['sid'])) {
  8749. $wh = array();
  8750. $w = $this->warehouse->find_all('1=1', 'id,title');
  8751. foreach ($w as $v) {
  8752. $wh[$v['id']] = $v['title'];
  8753. }
  8754. $type = $this->input->get('excel', true);
  8755. $category = $this->input->get('category', true);
  8756. $size = $this->input->get('size', true);
  8757. $grade = $this->input->get('grade', true);
  8758. $color = $this->input->get('color', true);
  8759. $lowe = $this->input->get('lowe', true);
  8760. $sku = $this->input->get('sku', true);
  8761. $warehouse = $this->input->get('warehouse', true);
  8762. $lacetype = $this->input->get('lacetype', true);
  8763. $lacecolor = $this->input->get('lacecolor', true);
  8764. $density = $this->input->get('density', true);
  8765. $haircap = $this->input->get('haircap', true);
  8766. $purchase = $this->input->get('purchase', true);
  8767. $title = $this->input->get('title', true);
  8768. $state = $this->input->get('state', true);
  8769. $sid = $this->input->get('sid', true);
  8770. $ktime = $this->input->get('ktime', true);
  8771. $jtime = $this->input->get('jtime', true);
  8772. $ktime = strtotime($ktime);
  8773. $jtime = strtotime($jtime);
  8774. $where = "1=1";
  8775. $gj = "";
  8776. $ck = "";
  8777. if ($category) {
  8778. $where .= " and features like '%-$category-%'";
  8779. }
  8780. if ($size) {
  8781. $where .= " and features like '%-$size-%'";
  8782. }
  8783. if ($grade) {
  8784. $where .= " and features like '%-$grade-%'";
  8785. }
  8786. if ($color) {
  8787. $where .= " and features like '%-$color-%'";
  8788. }
  8789. if ($lowe) {
  8790. $where .= " and features like '%-$lowe-%'";
  8791. }
  8792. if ($warehouse) {
  8793. $where .= " and warehouse = '$warehouse'";
  8794. }
  8795. if ($purchase) {
  8796. $where .= " and purchase = '$purchase'";
  8797. }
  8798. if ($state) {
  8799. $where .= " and state = '$state'";
  8800. }
  8801. if ($lacetype) {
  8802. $where .= " and features like '%-$lacetype-%'";
  8803. }
  8804. if ($lacecolor) {
  8805. $where .= " and features like '%-$lacecolor-%'";
  8806. }
  8807. if ($density) {
  8808. $where .= " and features like '%-$density-%'";
  8809. }
  8810. if ($haircap) {
  8811. $where .= " and features like '%-$haircap-%'";
  8812. }
  8813. if ($title) {
  8814. $title = trim($title, ' ');
  8815. $title = trim($title, ' ');
  8816. $where .= " and title like '%$title%'";
  8817. }
  8818. if ($sku) {
  8819. $sku = trim($sku, ' ');
  8820. $sku = trim($sku, ' ');
  8821. $where .= " and sku like '%$sku%'";
  8822. }
  8823. if ($ktime && $jtime) {
  8824. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8825. }
  8826. $sidwhere = '';
  8827. if ($sid) {
  8828. $sd = "";
  8829. $s = explode(',', trim($sid, ','));
  8830. foreach ($s as $value) {
  8831. $sd .= " id = " . $value . " or";
  8832. }
  8833. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8834. }
  8835. //数据排序
  8836. $order_str = "time desc";
  8837. if (empty($page)) {
  8838. $start = 0;
  8839. $perpage = 1;
  8840. } else {
  8841. $start = ($page - 1) * $perpage;
  8842. }
  8843. $wh = array();
  8844. $w = $this->warehouse->find_all('1=1', 'id,title');
  8845. foreach ($w as $v) {
  8846. $wh[$v['id']] = $v['title'];
  8847. }
  8848. $wt = array();
  8849. $whlabel_type = $this->whlabel_type->find_all();
  8850. foreach ($whlabel_type as $v) {
  8851. $wt[$v['id']] = $v['title'];
  8852. }
  8853. $classid = $this->classid->sku();
  8854. $list = array();
  8855. $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');
  8856. foreach ($rows_r as $key => $value) {
  8857. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8858. $pm = $classid;
  8859. $jm = $classid;
  8860. $rows_r[$key]['enter'] = '入库';
  8861. $rows_r[$key]['time'] = $value['enter'];
  8862. if ($value['rktype'] == 1) {
  8863. $rows_r[$key]['rktype'] = '采购入库';
  8864. } else if ($value['rktype'] == 2) {
  8865. $rows_r[$key]['rktype'] = '盘盈调整';
  8866. } else if ($value['rktype'] == 3) {
  8867. $rows_r[$key]['rktype'] = '其他调整入库';
  8868. } else if ($value['rktype'] == 4) {
  8869. $rows_r[$key]['rktype'] = '其他调整入库';
  8870. } else if ($value['rktype'] == 5) {
  8871. $rows_r[$key]['rktype'] = '退库入库';
  8872. } else if ($value['rktype'] == 6) {
  8873. $rows_r[$key]['rktype'] = '退货可用入库';
  8874. } else if ($value['rktype'] == 7) {
  8875. $rows_r[$key]['rktype'] = '形态转换入库';
  8876. } else {
  8877. $rows_r[$key]['rktype'] = '';
  8878. }
  8879. $features = explode('-', trim($value['features'], '-'));
  8880. foreach ($features as $v) {
  8881. if (isset($typeclass[$v])) {
  8882. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8883. $pm[$typeclass[$v]['classid']] = $zh[0];
  8884. }
  8885. if (isset($typeclass[$v])) {
  8886. if (isset($jm[$typeclass[$v]['classid']])) {
  8887. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8888. }
  8889. }
  8890. }
  8891. $zh = implode(" ", $pm);
  8892. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8893. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8894. $rows_r[$key]['zh'] = $zh;
  8895. $jm = array_filter($jm);
  8896. $rows_r[$key]['features'] = implode("-", $jm);
  8897. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8898. }
  8899. $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');
  8900. foreach ($rows_c as $key => $value) {
  8901. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8902. $pm = $classid;
  8903. $jm = $classid;
  8904. $rows_c[$key]['time'] = $value['outk'];
  8905. $rows_c[$key]['outk'] = '出库';
  8906. if ($value['cktype'] == 1) {
  8907. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8908. } else if ($value['cktype'] == 2) {
  8909. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8910. } else if ($value['cktype'] == 3) {
  8911. $rows_c[$key]['cktype'] = '盘亏调整';
  8912. } else if ($value['cktype'] == 4) {
  8913. $rows_c[$key]['cktype'] = '其他调整出库';
  8914. } else if ($value['cktype'] == 5) {
  8915. $rows_c[$key]['cktype'] = '形态转换出库';
  8916. } else {
  8917. $rows_c[$key]['cktype'] = '';
  8918. }
  8919. unset($rows_c[$key]['state']);
  8920. $features = explode('-', trim($value['features'], '-'));
  8921. foreach ($features as $v) {
  8922. if (isset($typeclass[$v])) {
  8923. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8924. $pm[$typeclass[$v]['classid']] = $zh[0];
  8925. }
  8926. if (isset($typeclass[$v])) {
  8927. if (isset($jm[$typeclass[$v]['classid']])) {
  8928. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8929. }
  8930. }
  8931. }
  8932. $zh = implode(" ", $pm);
  8933. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8934. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8935. $rows_c[$key]['zh'] = $zh;
  8936. $jm = array_filter($jm);
  8937. $rows_c[$key]['features'] = implode("-", $jm);
  8938. $rows_c[$key]['number'] = 1;
  8939. }
  8940. $merged = $rows_r;
  8941. foreach ($rows_c as $key => $value) {
  8942. if (isset($merged[$key])) {
  8943. $merged[] = $value;
  8944. } else {
  8945. $merged[$key] = $value;
  8946. }
  8947. }
  8948. usort($merged, function ($a, $b) {
  8949. return $a['time'] - $b['time'];
  8950. });
  8951. foreach ($merged as $key => $value) {
  8952. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8953. }
  8954. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8955. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8956. $cols = [
  8957. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8958. ];
  8959. $final_list= [];
  8960. foreach($merged as $key => $value){
  8961. $final_list[] = array_values($value) ;
  8962. }
  8963. if(empty($merged)){
  8964. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8965. }
  8966. array_unshift($final_list, $first_row);
  8967. $end_list = [];
  8968. foreach ($final_list as $key => $value) {
  8969. $end_list[] = array_values($value);
  8970. }
  8971. $merges = [];
  8972. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8973. }
  8974. }
  8975. public function _errorexceljs()
  8976. {
  8977. $post = $this->input->post(NULL, TRUE);
  8978. if (isset($_GET['page'])) {
  8979. $page = $this->input->get('page', true);
  8980. $perpage = $this->input->get('perpage', true);
  8981. $sku = $this->input->get('sku', true);
  8982. $warehouse = $this->input->get('warehouse', true);
  8983. $ktime = $this->input->get('ktime', true);
  8984. $jtime = $this->input->get('jtime', true);
  8985. $ktime = strtotime($ktime);
  8986. $jtime = strtotime($jtime);
  8987. $where = "sku != 'Preset'";
  8988. $gj = '';
  8989. if ($sku) {
  8990. $where .= " and sku like '%$sku%'";
  8991. } else {
  8992. if ($ktime && $jtime) {
  8993. $gj = " and time > '$ktime' and time < '$jtime'";
  8994. }
  8995. }
  8996. if ($warehouse) {
  8997. $where .= " and warehouse = '$warehouse'";
  8998. }
  8999. //数据排序
  9000. $order_str = "id desc";
  9001. if (empty($page)) {
  9002. $start = 0;
  9003. $perpage = 1;
  9004. } else {
  9005. $start = ($page - 1) * $perpage;
  9006. }
  9007. //取得信息列表
  9008. $rows = array();
  9009. $list = array();
  9010. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9011. foreach ($info_list as $value) {
  9012. $warehouse = $this->warehouse->read($value['warehouse']);
  9013. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9014. $number = $value['number'];
  9015. $ftime = time() - 15 * 24 * 3600;
  9016. if ($c < 1) {
  9017. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9018. }
  9019. }
  9020. $title = "0库存汇总";
  9021. $first_row = ["仓库","SKU","产品","当前库存"];
  9022. $cols = [
  9023. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9024. ];
  9025. $final_list= [];
  9026. foreach($list as $key => $value){
  9027. $final_list[] = array_values($value) ;
  9028. }
  9029. if(empty($final_list)){
  9030. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9031. }
  9032. array_unshift($final_list, $first_row);
  9033. $merges = [];
  9034. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9035. }
  9036. }
  9037. }