Whlabel.php 310 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154
  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. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. } else if($arg == 'excelctjs'){
  192. $this->_excelctjs();
  193. }else if ($arg == 'exceljxcjs') //进销存信息导出
  194. {
  195. $this->_exceljxcjs();
  196. } else if ($arg == 'summaryjs') //汇总导出
  197. {
  198. $this->_summaryjs($arg_array);
  199. }else if($arg == 'uckjs'){
  200. $this->_uckjs();
  201. }else if ($arg == 'whlabelexcelzhjs') {
  202. $this->_whlabelexcelzhjs();
  203. }else if($arg == 'dccrtypejs'){
  204. $this->_dccrtypejs();
  205. }else if($arg == 'errorexceljs'){
  206. $this->_errorexceljs();
  207. }else if($arg == "w_t_cs"){
  208. $this->_w_t_cs(); //首页
  209. }else {
  210. $this->_index();
  211. }
  212. }
  213. public function _w_t_cs(){
  214. $vip = 0;
  215. if (isset($_SESSION['api'])) {
  216. $user = $this->user->get_api($_SESSION['api']);
  217. $fgshop = "";
  218. $sid = "";
  219. $usersp = explode('|', trim($user['shop'], '|'));
  220. foreach ($usersp as $value) {
  221. $fgshop .= " shop = " . $value . " or";
  222. $sid .= " id = " . $value . " or";
  223. }
  224. if ($user['vip'] == 1) {
  225. $vip = 1;
  226. }
  227. } else {
  228. header('Location: /');
  229. exit;
  230. }
  231. $prc = array();
  232. $purchase = $this->purchase->find_all();
  233. foreach ($purchase as $k => $v) {
  234. $prc[$v['id']] = $v['title'];
  235. }
  236. $company = array();
  237. $ct = $this->company->find_all();
  238. foreach ($ct as $k => $v) {
  239. $company[$v['id']] = $v['title'];
  240. }
  241. $sp = array();
  242. $s = $this->shop->find_all('1=1', 'id,shopname');
  243. foreach ($s as $v) {
  244. $sp[$v['id']] = $v['shopname'];
  245. }
  246. $wh = array();
  247. $w = $this->warehouse->find_all('1=1', 'id,title');
  248. foreach ($w as $v) {
  249. $wh[$v['id']] = $v['title'];
  250. }
  251. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  252. $this->data['shop'] = $wlshop;
  253. $this->data['vip'] = $vip;
  254. $this->_Template('whlabel_typejs', $this->data);
  255. }
  256. //管理
  257. public function _index()
  258. {
  259. $post = $this->input->post(NULL, TRUE);
  260. if (isset($post['page'])) {
  261. $page = $this->input->post('page', true);
  262. $perpage = $this->input->post('perpage', true);
  263. $sku = $this->input->post('sku', true);
  264. $number = $this->input->post('number', true);
  265. $warehouse = $this->input->post('warehouse', true);
  266. $purchase = $this->input->post('purchase', true);
  267. $orderinfo = $this->input->post('orderinfo', true);
  268. $waybill = $this->input->post('waybill', true);
  269. $category = $this->input->post('category', true);
  270. $size = $this->input->post('size', true);
  271. $grade = $this->input->post('grade', true);
  272. $color = $this->input->post('color', true);
  273. $lowe = $this->input->post('lowe', true);
  274. $state = $this->input->post('state', true);
  275. $label = $this->input->post('label', true);
  276. $timetk = $this->input->post('timetkk', true);
  277. $timetj = $this->input->post('timetjj', true);
  278. $timetk = strtotime($timetk);
  279. $timetj = strtotime($timetj);
  280. $where = "1=1 ";
  281. if ($timetk && $timetj) {
  282. $where .= " and time > '$timetk' and time < '$timetj'";
  283. }
  284. if ($sku) {
  285. $where .= " and sku = '$sku'";
  286. }
  287. if ($number) {
  288. $where .= " and number = '$number'";
  289. }
  290. if ($warehouse) {
  291. $where .= " and warehouse = '$warehouse'";
  292. }
  293. if ($purchase) {
  294. $where .= " and purchase = '$purchase'";
  295. }
  296. if ($orderinfo) {
  297. $where .= " and orderinfo = '$orderinfo'";
  298. }
  299. if ($waybill) {
  300. $where .= " and waybill = '$waybill'";
  301. }
  302. if ($category) {
  303. $where .= " and features like '%-$category-%'";
  304. }
  305. if ($size) {
  306. $where .= " and features like '%-$size-%'";
  307. }
  308. if ($grade) {
  309. $where .= " and features like '%-$grade-%'";
  310. }
  311. if ($color) {
  312. $where .= " and features like '%-$color-%'";
  313. }
  314. if ($lowe) {
  315. $where .= " and features like '%-$lowe-%'";
  316. }
  317. if ($label) {
  318. $where .= " and label = '$label'";
  319. }
  320. if ($state != '') {
  321. $where .= " and state = '$state'";
  322. }
  323. //数据排序
  324. $order_str = "time desc";
  325. if (empty($page)) {
  326. $start = 0;
  327. $perpage = 1;
  328. } else {
  329. $start = ($page - 1) * $perpage;
  330. }
  331. //取得信息列表
  332. $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);
  333. foreach ($info_list as $key => $value) {
  334. $warehouse = $this->warehouse->read($value['warehouse']);
  335. $info_list[$key]['warehouse'] = $warehouse['title'];
  336. $purchase = $this->purchase->read($value['purchase']);
  337. $info_list[$key]['purchase'] = $purchase['title'];
  338. if ($value['enter'] != 0) {
  339. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  340. } else {
  341. $info_list[$key]['enter'] = "";
  342. }
  343. if ($value['outk'] != 0) {
  344. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  345. } else {
  346. $info_list[$key]['outk'] = "";
  347. }
  348. if ($value['printing'] != 0) {
  349. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  350. } else {
  351. $info_list[$key]['printing'] = "";
  352. }
  353. if ($value['orderinfo'] == 0) {
  354. $info_list[$key]['orderinfo'] = "";
  355. }
  356. if ($value['waybill'] == 0) {
  357. $info_list[$key]['waybill'] = "";
  358. }
  359. if ($value['state'] == 0) {
  360. $info_list[$key]['state'] = "在库";
  361. } else if ($value['state'] == 1) {
  362. $info_list[$key]['state'] = "出库";
  363. } else if ($value['state'] == 2) {
  364. $info_list[$key]['state'] = "退库";
  365. } else if ($value['state'] == 3) {
  366. $info_list[$key]['state'] = "调拨中";
  367. } else if ($value['state'] == 4) {
  368. $info_list[$key]['state'] = "再加工";
  369. } else if ($value['state'] == 5) {
  370. $info_list[$key]['state'] = "维修中";
  371. } else if ($value['state'] == 6) {
  372. $info_list[$key]['state'] = "盘亏";
  373. } else if ($value['state'] == 7) {
  374. $info_list[$key]['state'] = "更换标签";
  375. } else if ($value['state'] == 8) {
  376. $info_list[$key]['state'] = "其它";
  377. } else if ($value['state'] == 9) {
  378. $info_list[$key]['state'] = "预设";
  379. } else if ($value['state'] == 10) {
  380. $info_list[$key]['state'] = "美店零售";
  381. }
  382. if ($value['text'] == "") {
  383. $info_list[$key]['text'] = "";
  384. }
  385. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  386. }
  387. $total = $this->whlabel->find_count($where);
  388. $pagenum = ceil($total / $perpage);
  389. $over = $total - ($start + $perpage);
  390. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  391. echo json_encode($rows);
  392. exit;
  393. }
  394. if (isset($post['outsku'])) {
  395. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  396. $cz = $this->input->post('cz', true);
  397. if ($cz == '1') {
  398. $sku = $this->input->post('outsku', true);
  399. if ($sku) {
  400. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  401. if (count($data) < 1) {
  402. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  403. exit;
  404. }
  405. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  406. echo json_encode(array('success' => true));
  407. exit;
  408. }
  409. } else {
  410. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  411. exit;
  412. $sku = $this->input->post('outsku', true);
  413. if ($sku) {
  414. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  415. if (count($data) < 1) {
  416. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  417. exit;
  418. }
  419. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  420. echo json_encode(array('success' => true));
  421. exit;
  422. }
  423. }
  424. }
  425. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  426. $this->_Template('whlabel', $this->data);
  427. }
  428. //在库标签
  429. public function _existence()
  430. {
  431. $post = $this->input->post(NULL, TRUE);
  432. if (isset($post['s'])) {
  433. $id_arr = $this->input->post('s');
  434. $id_arr = explode(',', $id_arr);
  435. if (!$id_arr) {
  436. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  437. exit;
  438. }
  439. //循环删除记录
  440. foreach ($id_arr as $v) {
  441. $sid = $this->whlabel->read($v);
  442. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  443. if ($count > 0) {
  444. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  445. exit;
  446. }
  447. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  448. if (count($zt) > 0) {
  449. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  450. exit;
  451. }
  452. $this->whlabel->remove($v);
  453. }
  454. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  455. exit;
  456. }
  457. if (isset($post['page'])) {
  458. $page = $this->input->post('page', true);
  459. $perpage = $this->input->post('perpage', true);
  460. $warehouse = $this->input->post('warehouse', true);
  461. $label = $this->input->post('label', true);
  462. $where = "1=1 and state = 0";
  463. if ($warehouse) {
  464. $where .= " and warehouse = '$warehouse'";
  465. }
  466. if ($label) {
  467. $where .= " and label = '$label'";
  468. }
  469. //数据排序
  470. $order_str = "time asc";
  471. if (empty($page)) {
  472. $start = 0;
  473. $perpage = 1;
  474. } else {
  475. $start = ($page - 1) * $perpage;
  476. }
  477. //取得信息列表
  478. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  479. foreach ($info_list as $key => $value) {
  480. if ($value['enter'] != 0) {
  481. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  482. } else {
  483. $info_list[$key]['enter'] = "";
  484. }
  485. if ($value['printing'] != 0) {
  486. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  487. } else {
  488. $info_list[$key]['printing'] = "";
  489. }
  490. }
  491. $total = $this->whlabel->find_count($where);
  492. $pagenum = ceil($total / $perpage);
  493. $over = $total - ($start + $perpage);
  494. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  495. echo json_encode($rows);
  496. exit;
  497. }
  498. $this->_Template('whlabel_existence', $this->data);
  499. }
  500. //进销存浏览
  501. public function _typedy($arg_array)
  502. {
  503. $prc = array();
  504. $purchase = $this->purchase->find_all();
  505. foreach ($purchase as $k => $v) {
  506. $prc[$v['id']] = $v['title'];
  507. }
  508. $post = $this->input->post(NULL, TRUE);
  509. if (isset($post['page'])) {
  510. $page = $this->input->post('page', true);
  511. $perpage = $this->input->post('perpage', true);
  512. $category = $this->input->post('category', true);
  513. $size = $this->input->post('size', true);
  514. $grade = $this->input->post('grade', true);
  515. $color = $this->input->post('color', true);
  516. $lowe = $this->input->post('lowe', true);
  517. $sku = $this->input->post('sku');
  518. $title = $this->input->post('title');
  519. $warehouse = $this->input->post('warehouse', true);
  520. $usa = $this->input->post('usa', true);
  521. $purchase = $this->input->post('purchase', true);
  522. $lacetype = $this->input->post('lacetype', true);
  523. $haircap = $this->input->post('haircap', true);
  524. $density = $this->input->post('density', true);
  525. $details = $this->input->post('details', true);
  526. $state = $this->input->post('state', true);
  527. $lacecolor = $this->input->post('lacecolor', true);
  528. $hairnumber = $this->input->post('hairnumber', true);
  529. $cklx = $this->input->post('cklx', true);
  530. $ktime = $this->input->post('ktime', true);
  531. $jtime = $this->input->post('jtime', true);
  532. $sm = $this->input->post('sm', true);
  533. $cpbz = $this->input->post('cpbz', true);
  534. $type = $this->input->post('type', true);
  535. $ktime = strtotime($ktime);
  536. $jtime = strtotime($jtime);
  537. $where = "1=1";
  538. $gj = "";
  539. $ck = "";
  540. if ($usa) {
  541. if (!$warehouse) {
  542. $where .= " and (warehouse = '5' or warehouse = '8')";
  543. }
  544. }
  545. if ($warehouse) {
  546. $where .= " and warehouse = '$warehouse'";
  547. }
  548. if ($details) {
  549. $where .= " and details = '$details'";
  550. }
  551. if ($purchase) {
  552. $where .= " and purchase = '$purchase'";
  553. }
  554. if (isset($state)) {
  555. if($state >-1){
  556. $where .= " and state = '$state'";
  557. }
  558. }
  559. if ($lacetype) {
  560. $where .= " and features like '%-$lacetype-%'";
  561. }
  562. if ($category) {
  563. $where .= " and features like '%-$category-%'";
  564. }
  565. if ($size) {
  566. $where .= " and features like '%-$size-%'";
  567. }
  568. if ($grade) {
  569. $where .= " and features like '%-$grade-%'";
  570. }
  571. if ($color) {
  572. $where .= " and features like '%-$color-%'";
  573. }
  574. if ($lowe) {
  575. $where .= " and features like '%-$lowe-%'";
  576. }
  577. if ($haircap) {
  578. $where .= " and features like '%-$haircap-%'";
  579. }
  580. if ($density) {
  581. $where .= " and features like '%-$density-%'";
  582. }
  583. if ($lacecolor) {
  584. $where .= " and features like '%-$lacecolor-%'";
  585. }
  586. if($sm){
  587. $where .= " and sm like '%".$sm."%'";
  588. }
  589. if($cpbz){
  590. $where .= " and cpbz like '%".$cpbz."%'";
  591. }
  592. if($type){
  593. $where .= " and type = ".$type."";
  594. }
  595. if (!empty($hairnumber)) {
  596. $where .= " and features like '%-128-%' ";
  597. if ($hairnumber < 0) {
  598. $class_list = $this->typeclass->find_all('classid = 43');
  599. foreach ($class_list as $v) {
  600. $where .= " and features not like '%-" . $v['id'] . "-%'";
  601. }
  602. } else {
  603. $where .= " and features like '%-$hairnumber-%'";
  604. }
  605. }
  606. $where_add = '';
  607. if ($cklx) {
  608. $shop = $this->shop->read($cklx);
  609. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  610. }
  611. if ($ktime && $jtime) {
  612. $gj = " and enter > '$ktime' and enter < '$jtime'";
  613. $ck = " and outk > '$ktime' and outk < '$jtime'";
  614. }
  615. //数据排序
  616. $order_str = "id desc";
  617. if (empty($page)) {
  618. $start = 0;
  619. $perpage = 1;
  620. } else {
  621. $start = ($page - 1) * $perpage;
  622. }
  623. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  624. if ($sku) {
  625. $sku = trim($sku, ' ');
  626. $sku = trim($sku, ' ');
  627. $where .= " and sku like '%$sku%'";
  628. $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);
  629. } else if ($title) {
  630. $title = trim($title, ' ');
  631. $title = trim($title, ' ');
  632. $where .= " and title like '%$title%'";
  633. $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);
  634. } else {
  635. //$where .= " and time > '$ktime' and time < '$jtime'";
  636. $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);
  637. }
  638. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  639. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  640. foreach ($info_list as $k => $v) {
  641. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  642. unset($info_list[$k]['pm']);
  643. unset($info_list[$k]['jm']);
  644. unset($info_list[$k]['bm']);
  645. }
  646. //取得信息列表
  647. $rows = array();
  648. $list = array();
  649. foreach ($info_list as $key => $value) {
  650. $warehouse = $this->warehouse->read($value['warehouse']);
  651. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  652. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  653. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  654. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  655. $info_list[$key]['label'] = $value['sm'];
  656. $number = $value['number'];
  657. $ftime = time() - 15 * 24 * 3600;
  658. $info_list[$key]['warehouse'] = $warehouse['title'];
  659. $info_list[$key]['features'] = count($c);
  660. $z = count($z); //查看订单号
  661. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  662. $ztdata = '';
  663. if (count($zt) > 0) {
  664. foreach ($zt as $vv) {
  665. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  666. }
  667. }
  668. $info_list[$key]['number'] = $ztdata;
  669. $info_list[$key]['sm'] = $z;
  670. $details = array();
  671. $cpid = array();
  672. foreach ($c as $k => $v) {
  673. $details[$v['details']] = $v['details'];
  674. if ($v['cpid'] != 0) {
  675. $cpid[$v['cpid']] = $v['cpid'];
  676. }
  677. }
  678. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  679. if ($value['shop'] != '') {
  680. $shop = explode(',', trim($value['shop'], ','));
  681. $shop = $this->shop->read($shop[0]);
  682. $info_list[$key]['shop'] = $shop['shopname'];
  683. }
  684. }
  685. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  686. $pagenum = ceil($total / $perpage);
  687. $over = $total - ($start + $perpage);
  688. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  689. echo json_encode($rows);
  690. exit;
  691. }
  692. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  693. $this->_Template('whlabel_typedy', $this->data);
  694. }
  695. //进销存浏览
  696. public function _typedy_ck($arg_array)
  697. {
  698. $prc = array();
  699. $purchase = $this->purchase->find_all();
  700. foreach ($purchase as $k => $v) {
  701. $prc[$v['id']] = $v['title'];
  702. }
  703. $post = $this->input->post(NULL, TRUE);
  704. if (isset($post['page'])) {
  705. $page = $this->input->post('page', true);
  706. $perpage = $this->input->post('perpage', true);
  707. $category = $this->input->post('category', true);
  708. $size = $this->input->post('size', true);
  709. $grade = $this->input->post('grade', true);
  710. $color = $this->input->post('color', true);
  711. $lowe = $this->input->post('lowe', true);
  712. $sku = $this->input->post('sku');
  713. $title = $this->input->post('title');
  714. $warehouse = $this->input->post('warehouse', true);
  715. $usa = $this->input->post('usa', true);
  716. $purchase = $this->input->post('purchase', true);
  717. $lacetype = $this->input->post('lacetype', true);
  718. $haircap = $this->input->post('haircap', true);
  719. $density = $this->input->post('density', true);
  720. $details = $this->input->post('details', true);
  721. $state = $this->input->post('state', true);
  722. $lacecolor = $this->input->post('lacecolor', true);
  723. $cklx = $this->input->post('cklx', true);
  724. $ktime = $this->input->post('ktime', true);
  725. $jtime = $this->input->post('jtime', true);
  726. $ktime = strtotime($ktime);
  727. $jtime = strtotime($jtime);
  728. $where = "1=1";
  729. $gj = "";
  730. $ck = "";
  731. if ($lacetype) {
  732. $where .= " and features like '%-$lacetype-%'";
  733. }
  734. if ($category) {
  735. $where .= " and features like '%-$category-%'";
  736. }
  737. if ($size) {
  738. $where .= " and features like '%-$size-%'";
  739. }
  740. if ($grade) {
  741. $where .= " and features like '%-$grade-%'";
  742. }
  743. if ($color) {
  744. $where .= " and features like '%-$color-%'";
  745. }
  746. if ($lowe) {
  747. $where .= " and features like '%-$lowe-%'";
  748. }
  749. if ($haircap) {
  750. $where .= " and features like '%-$haircap-%'";
  751. }
  752. if ($density) {
  753. $where .= " and features like '%-$density-%'";
  754. }
  755. if ($lacecolor) {
  756. $where .= " and features like '%-$lacecolor-%'";
  757. }
  758. if ($usa) {
  759. if (!$warehouse) {
  760. $where .= " and (warehouse = '5' or warehouse = '8')";
  761. }
  762. }
  763. if ($warehouse) {
  764. $where .= " and warehouse = '$warehouse'";
  765. }
  766. if ($details) {
  767. $where .= " and details = '$details'";
  768. }
  769. if ($purchase) {
  770. $where .= " and purchase = '$purchase'";
  771. }
  772. if ($state) {
  773. $where .= " and state = '$state'";
  774. }
  775. $where_add = '';
  776. if ($cklx) {
  777. $shop = $this->shop->read($cklx);
  778. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  779. }
  780. if ($ktime && $jtime) {
  781. $gj = " and enter > '$ktime' and enter < '$jtime'";
  782. $ck = " and outk > '$ktime' and outk < '$jtime'";
  783. }
  784. //数据排序
  785. $order_str = "id desc";
  786. if (empty($page)) {
  787. $start = 0;
  788. $perpage = 1;
  789. } else {
  790. $start = ($page - 1) * $perpage;
  791. }
  792. if ($sku) {
  793. $sku = trim($sku, ' ');
  794. $sku = trim($sku, ' ');
  795. $where .= " and sku like '%$sku%'";
  796. $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);
  797. } else if ($title) {
  798. $title = trim($title, ' ');
  799. $title = trim($title, ' ');
  800. $where .= " and title like '%$title%'";
  801. $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);
  802. } else {
  803. //$where .= " and time > '$ktime' and time < '$jtime'";
  804. $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);
  805. }
  806. //取得信息列表
  807. $rows = array();
  808. $list = array();
  809. foreach ($info_list as $key => $value) {
  810. $warehouse = $this->warehouse->read($value['warehouse']);
  811. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  812. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  813. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  814. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  815. $ftime = time() - 15 * 24 * 3600;
  816. $info_list[$key]['warehouse'] = $warehouse['title'];
  817. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  818. //$z = count($z);//查看订单号
  819. //$info_list[$key]['zd'] = $z;
  820. $details = array();
  821. $cpid = array();
  822. foreach ($c as $k => $v) {
  823. $details[$v['details']] = $v['details'];
  824. if ($v['cpid'] != 0) {
  825. $cpid[$v['cpid']] = $v['cpid'];
  826. }
  827. }
  828. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  829. if ($value['shop'] != '') {
  830. $shop = explode(',', trim($value['shop'], ','));
  831. $shop = $this->shop->read($shop[0]);
  832. $info_list[$key]['shop'] = $shop['shopname'];
  833. }
  834. }
  835. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  836. $pagenum = ceil($total / $perpage);
  837. $over = $total - ($start + $perpage);
  838. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  839. echo json_encode($rows);
  840. exit;
  841. }
  842. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  843. $this->_Template('whlabel_typedy_ck', $this->data);
  844. }
  845. public function _typeck($arg_array)
  846. {
  847. $prc = array();
  848. $purchase = $this->purchase->find_all();
  849. foreach ($purchase as $k => $v) {
  850. $prc[$v['id']] = $v['title'];
  851. }
  852. $post = $this->input->post(NULL, TRUE);
  853. if (isset($post['page'])) {
  854. $page = $this->input->post('page', true);
  855. $perpage = $this->input->post('perpage', true);
  856. $category = $this->input->post('category', true);
  857. $size = $this->input->post('size', true);
  858. $grade = $this->input->post('grade', true);
  859. $color = $this->input->post('color', true);
  860. $lacecolor = $this->input->post('lacecolor', true);
  861. $lowe = $this->input->post('lowe', true);
  862. $sku = $this->input->post('sku');
  863. $title = $this->input->post('title');
  864. $warehouse = 13;
  865. $usa = $this->input->post('usa', true);
  866. $purchase = $this->input->post('purchase', true);
  867. $lacetype = $this->input->post('lacetype', true);
  868. $haircap = $this->input->post('haircap', true);
  869. $density = $this->input->post('density', true);
  870. $details = $this->input->post('details', true);
  871. $state = $this->input->post('state', true);
  872. $ktime = $this->input->post('ktime', true);
  873. $jtime = $this->input->post('jtime', true);
  874. $ktime = strtotime($ktime);
  875. $jtime = strtotime($jtime);
  876. $where = "1=1";
  877. $gj = "";
  878. $ck = "";
  879. if ($lacetype) {
  880. $where .= " and features like '%-$lacetype-%'";
  881. }
  882. if ($category) {
  883. $where .= " and features like '%-$category-%'";
  884. }
  885. if ($size) {
  886. $where .= " and features like '%-$size-%'";
  887. }
  888. if ($grade) {
  889. $where .= " and features like '%-$grade-%'";
  890. }
  891. if ($color) {
  892. $where .= " and features like '%-$color-%'";
  893. }
  894. if ($lacecolor) {
  895. $where .= " and features like '%-$lacecolor-%'";
  896. }
  897. if ($lowe) {
  898. $where .= " and features like '%-$lowe-%'";
  899. }
  900. if ($haircap) {
  901. $where .= " and features like '%-$haircap-%'";
  902. }
  903. if ($density) {
  904. $where .= " and features like '%-$density-%'";
  905. }
  906. if ($warehouse) {
  907. $where .= " and warehouse = '$warehouse'";
  908. }
  909. if ($details) {
  910. $where .= " and details = '$details'";
  911. }
  912. if ($purchase) {
  913. $where .= " and purchase = '$purchase'";
  914. }
  915. if ($state) {
  916. $where .= " and state = '$state'";
  917. }
  918. if ($ktime && $jtime) {
  919. $gj = " and enter > '$ktime' and enter < '$jtime'";
  920. $ck = " and outk > '$ktime' and outk < '$jtime'";
  921. }
  922. //数据排序
  923. $order_str = "id desc";
  924. if (empty($page)) {
  925. $start = 0;
  926. $perpage = 1;
  927. } else {
  928. $start = ($page - 1) * $perpage;
  929. }
  930. if ($sku) {
  931. $sku = trim($sku, ' ');
  932. $sku = trim($sku, ' ');
  933. $where .= " and sku like '%$sku%'";
  934. } else if ($title) {
  935. $title = trim($title, ' ');
  936. $title = trim($title, ' ');
  937. $where .= " and title like '%$title%'";
  938. }
  939. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  940. //取得信息列表
  941. $t = array();
  942. $typeclass = $this->typeclass->find_all();
  943. foreach ($typeclass as $v) {
  944. $t[$v['id']] = $v;
  945. }
  946. $rows = array();
  947. $list = array();
  948. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  949. foreach ($info_list as $key => $value) {
  950. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  951. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  952. $warehouse = $this->warehouse->read($value['warehouse']);
  953. $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');
  954. $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'] . '"');
  955. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  956. $number = $value['number'];
  957. $ftime = time() - 15 * 24 * 3600;
  958. $z = count($z); //查看订单号
  959. $info_list[$key]['warehouse'] = $warehouse['title'];
  960. $info_list[$key]['features'] = count($c);
  961. $info_list[$key]['number'] = $z;
  962. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  963. $details = array();
  964. $cpid = array();
  965. foreach ($c as $k => $v) {
  966. $details[$v['details']] = $v['details'];
  967. if ($v['cpid'] != 0) {
  968. $cpid[$v['cpid']] = $v['cpid'];
  969. }
  970. }
  971. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  972. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  973. unset($info_list[$key]['pm']);
  974. unset($info_list[$key]['jm']);
  975. unset($info_list[$key]['bm']);
  976. }
  977. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  978. $pagenum = ceil($total / $perpage);
  979. $over = $total - ($start + $perpage);
  980. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  981. echo json_encode($rows);
  982. exit;
  983. }
  984. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  985. $this->_Template('whlabel_typeck', $this->data);
  986. }
  987. //进销存导出
  988. public function _whlabeckdc()
  989. {
  990. $prc = array();
  991. $purchase = $this->purchase->find_all();
  992. foreach ($purchase as $k => $v) {
  993. $prc[$v['id']] = $v['title'];
  994. }
  995. if (isset($_GET['excel'])) {
  996. $where = "sku != 'Preset'";
  997. //数据排序
  998. $order_str = "id desc";
  999. if (empty($page)) {
  1000. $start = 0;
  1001. $perpage = 1;
  1002. } else {
  1003. $start = ($page - 1) * $perpage;
  1004. }
  1005. $category = $this->input->get('category', true);
  1006. $color = $this->input->get('color', true);
  1007. $lowe = $this->input->get('lowe', true);
  1008. $lacetype = $this->input->get('lacetype', true);
  1009. $size = $this->input->get('size', true);
  1010. $density = $this->input->get('density', true);
  1011. $haircap = $this->input->get('haircap', true);
  1012. $sku = $this->input->get('sku', true);
  1013. $details = $this->input->get('details', true);
  1014. $warehouse = 13;
  1015. $excelid = $this->input->get('sid', true);
  1016. if ($category) {
  1017. $where .= " and features like '%-$category-%'";
  1018. }
  1019. if ($color) {
  1020. $where .= " and features like '%-$color-%'";
  1021. }
  1022. if ($lowe) {
  1023. $where .= " and features like '%-$lowe-%'";
  1024. }
  1025. if ($lacetype) {
  1026. $where .= " and features like '%-$lacetype-%'";
  1027. }
  1028. if ($size) {
  1029. $where .= " and features like '%-$size-%'";
  1030. }
  1031. if ($density) {
  1032. $where .= " and features like '%-$density-%'";
  1033. }
  1034. if ($haircap) {
  1035. $where .= " and features like '%-$haircap-%'";
  1036. }
  1037. if ($warehouse) {
  1038. $where .= " and warehouse = '$warehouse'";
  1039. }
  1040. if ($sku) {
  1041. $where .= " and sku like '%$sku%'";
  1042. }
  1043. if ($details) {
  1044. $where .= " and details = '$details'";
  1045. }
  1046. $xzid = '';
  1047. if ($excelid) {
  1048. $excelid = explode(',', trim($excelid, ','));
  1049. foreach ($excelid as $key => $value) {
  1050. $xzid .= " id = " . $value . " or";
  1051. }
  1052. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1053. }
  1054. //取得信息列表
  1055. /**
  1056. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1057. $rows = array();$list = array();
  1058. foreach ($info_list as $key=>$value)
  1059. {
  1060. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1061. }
  1062. **/
  1063. $wh = array();
  1064. $w = $this->warehouse->find_all('1=1', 'id,title');
  1065. foreach ($w as $v) {
  1066. $wh[$v['id']] = $v['title'];
  1067. }
  1068. $tc = array();
  1069. $tcdata = array();
  1070. $list = array();
  1071. $classid = $this->classid->sku();
  1072. $tcall = $this->typeclass->find_all();
  1073. $typeclass = array();
  1074. foreach ($tcall as $v)
  1075. {
  1076. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1077. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1078. }
  1079. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1080. foreach ($rows as $key => $value) {
  1081. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1082. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1083. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1084. $rows[$key]['cpbz'] = $u9_info['bm'];
  1085. $rows[$key]['cs'] = $u9_info['jm'];
  1086. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1087. $details = array();
  1088. $cpid = array();
  1089. $cpbz = array();
  1090. $c = 0;
  1091. $g = 0;
  1092. $x = 0;
  1093. $t = 0;
  1094. $s = 0;
  1095. $q = 0;
  1096. foreach ($sd as $k => $v) {
  1097. if ($v['state'] == 0) {
  1098. $c++;
  1099. }
  1100. if ($v['state'] != 9) {
  1101. $g++;
  1102. }
  1103. if ($v['state'] == 1) {
  1104. $x++;
  1105. }
  1106. if ($v['state'] == 2) {
  1107. $t++;
  1108. }
  1109. if ($v['state'] == 8) {
  1110. $s++;
  1111. }
  1112. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1113. $q++;
  1114. }
  1115. $details[$v['details']] = $v['details'];
  1116. if ($v['cpid'] != 0) {
  1117. $cpid[$v['cpid']] = $v['cpid'];
  1118. }
  1119. if ($v['cpbz'] != '') {
  1120. $cpbz[$v['cpbz']] = $v['cpbz'];
  1121. }
  1122. }
  1123. $rows[$key]['details'] = implode("、", $details);
  1124. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1125. $number = $value['number'];
  1126. $ftime = time() - 15 * 24 * 3600;
  1127. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1128. $rows[$key]['number'] = $g;
  1129. $rows[$key]['features'] = $c;
  1130. $rows[$key]['x'] = $x;
  1131. $rows[$key]['t'] = $t;
  1132. $rows[$key]['s'] = $s;
  1133. $rows[$key]['q'] = $q;
  1134. $rows[$key]['wzsl'] = count($details);
  1135. }
  1136. $title = "进销存统计表" . date('Y-m-d', time());
  1137. $titlename = "<table border=1>
  1138. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1139. <tr align='center'>
  1140. <td>仓库</td>
  1141. <td>供应商</td>
  1142. <td>位置</td>
  1143. <td>库存编码</td>
  1144. <td>SKU</td>
  1145. <td>用友编码</td>
  1146. <td>用友料号</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. </tr>
  1157. </table>";
  1158. $filename = $title . ".xls";
  1159. $tail = "";
  1160. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1161. }
  1162. }
  1163. public function _type()
  1164. {
  1165. $vip = 0;
  1166. if (isset($_SESSION['api'])) {
  1167. $user = $this->user->get_api($_SESSION['api']);
  1168. $fgshop = "";
  1169. $sid = "";
  1170. $usersp = explode('|', trim($user['shop'], '|'));
  1171. foreach ($usersp as $value) {
  1172. $fgshop .= " shop = " . $value . " or";
  1173. $sid .= " id = " . $value . " or";
  1174. }
  1175. if ($user['vip'] == 1) {
  1176. $vip = 1;
  1177. }
  1178. } else {
  1179. header('Location: /');
  1180. exit;
  1181. }
  1182. $prc = array();
  1183. $purchase = $this->purchase->find_all();
  1184. foreach ($purchase as $k => $v) {
  1185. $prc[$v['id']] = $v['title'];
  1186. }
  1187. $company = array();
  1188. $ct = $this->company->find_all();
  1189. foreach ($ct as $k => $v) {
  1190. $company[$v['id']] = $v['title'];
  1191. }
  1192. $sp = array();
  1193. $s = $this->shop->find_all('1=1', 'id,shopname');
  1194. foreach ($s as $v) {
  1195. $sp[$v['id']] = $v['shopname'];
  1196. }
  1197. $wh = array();
  1198. $w = $this->warehouse->find_all('1=1', 'id,title');
  1199. foreach ($w as $v) {
  1200. $wh[$v['id']] = $v['title'];
  1201. }
  1202. $post = $this->input->post(NULL, TRUE);
  1203. if (isset($post['page'])) {
  1204. $page = $this->input->post('page', true);
  1205. $perpage = $this->input->post('perpage', true);
  1206. $category = $this->input->post('category', true);
  1207. $size = $this->input->post('size', true);
  1208. $grade = $this->input->post('grade', true);
  1209. $color = $this->input->post('color', true);
  1210. $lowe = $this->input->post('lowe', true);
  1211. $sku = $this->input->post('sku');
  1212. $title = $this->input->post('title');
  1213. $warehouse = $this->input->post('warehouse', true);
  1214. $usa = $this->input->post('usa', true);
  1215. $purchase = $this->input->post('purchase', true);
  1216. $lacetype = $this->input->post('lacetype', true);
  1217. $haircap = $this->input->post('haircap', true);
  1218. $density = $this->input->post('density', true);
  1219. $details = $this->input->post('details', true);
  1220. $state = $this->input->post('state', true);
  1221. $shop = $this->input->post('shop', true);
  1222. $lacecolor = $this->input->post('lacecolor', true);
  1223. $hairnumber = $this->input->post('hairnumber', true);
  1224. $type = $this->input->post('type', true);
  1225. $ktime = $this->input->post('ktime', true);
  1226. $jtime = $this->input->post('jtime', true);
  1227. $ktime = strtotime($ktime);
  1228. $jtime = strtotime($jtime);
  1229. $cpbz = $this->input->post('cpbz', true);
  1230. $sm = $this->input->post('sm', true);
  1231. $where = "1=1";
  1232. $gj = "";
  1233. $ck = "";
  1234. if ($usa) {
  1235. if (!$warehouse) {
  1236. $where .= " and (warehouse = '5' or warehouse = '8')";
  1237. }
  1238. }
  1239. if ($warehouse) {
  1240. $where .= " and warehouse = '$warehouse'";
  1241. }
  1242. if ($details) {
  1243. $where .= " and details = '$details'";
  1244. }
  1245. if ($purchase) {
  1246. $where .= " and purchase = '$purchase'";
  1247. }
  1248. if ($state) {
  1249. $where .= " and state = '$state'";
  1250. }
  1251. if ($shop) {
  1252. $where .= " and shop like '%$shop%'";
  1253. }
  1254. if ($type) {
  1255. $where .= " and type = '$type'";
  1256. }
  1257. if ($ktime && $jtime) {
  1258. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1259. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1260. }
  1261. if ($cpbz) {
  1262. $where .= " and cpbz like '%$cpbz%' ";
  1263. }
  1264. if ($sm) {
  1265. $where .= " and sm like '%$sm%' ";
  1266. }
  1267. if ($lacecolor) {
  1268. $where .= " and features like '%-$lacecolor-%'";
  1269. }
  1270. if ($lacetype) {
  1271. $where .= " and features like '%-$lacetype-%'";
  1272. }
  1273. if ($category) {
  1274. $where .= " and features like '%-$category-%'";
  1275. }
  1276. if ($size) {
  1277. $where .= " and features like '%-$size-%'";
  1278. }
  1279. if ($grade) {
  1280. $where .= " and features like '%-$grade-%'";
  1281. }
  1282. if ($color) {
  1283. $where .= " and features like '%-$color-%'";
  1284. }
  1285. if ($lowe) {
  1286. $where .= " and features like '%-$lowe-%'";
  1287. }
  1288. if ($haircap) {
  1289. $where .= " and features like '%-$haircap-%'";
  1290. }
  1291. if ($density) {
  1292. $where .= " and features like '%-$density-%'";
  1293. }
  1294. if (!empty($hairnumber)) {
  1295. $where .= " and features like '%-128-%' ";
  1296. if ($hairnumber < 0) {
  1297. $class_list = $this->typeclass->find_all('classid = 43');
  1298. foreach ($class_list as $v) {
  1299. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1300. }
  1301. } else {
  1302. $where .= " and features like '%-$hairnumber-%'";
  1303. }
  1304. }
  1305. //数据排序
  1306. $order_str = "id desc";
  1307. if (empty($page)) {
  1308. $start = 0;
  1309. $perpage = 1;
  1310. } else {
  1311. $start = ($page - 1) * $perpage;
  1312. }
  1313. $fjnr = '';
  1314. if ($sku) {
  1315. $sku = trim($sku, ' ');
  1316. $sku = trim($sku, ' ');
  1317. $fjnr .= " and sku like '%$sku%'";
  1318. }
  1319. if ($title) {
  1320. $title = trim($title, ' ');
  1321. $title = trim($title, ' ');
  1322. $fjnr .= " and title like '%$title%'";
  1323. }
  1324. $wt = array();
  1325. $whlabel_type = $this->whlabel_type->find_all();
  1326. foreach ($whlabel_type as $v) {
  1327. $wt[$v['id']] = $v['title'];
  1328. }
  1329. //$where .= " and time > '$ktime' and time < '$jtime'";
  1330. $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
  1331. //取得信息列表
  1332. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1333. $rows = array();
  1334. $list = array();
  1335. foreach ($info_list as $key => $value) {
  1336. if (isset($wt[$value['type']])) {
  1337. $info_list[$key]['type'] = $wt[$value['type']];
  1338. } else {
  1339. $info_list[$key]['type'] = '未设置';
  1340. }
  1341. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1342. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1343. $ztdata = '';
  1344. if (count($zt) > 0) {
  1345. foreach ($zt as $vv) {
  1346. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1347. }
  1348. }
  1349. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1350. $cdata = array_filter($qbdata, function ($item) {
  1351. return $item['state'] < 1;
  1352. });
  1353. $c = array_sum(array_column($cdata, 'jnum'));
  1354. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1355. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1356. });
  1357. $g = array_sum(array_column($gdata, 'jnum'));
  1358. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1359. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1360. });
  1361. $x = array_sum(array_column($xdata, 'jnum'));
  1362. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1363. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1364. });
  1365. $t = array_sum(array_column($tdata, 'jnum'));
  1366. // $zdata = array_filter($qbdata, function ($item) {
  1367. // return $item['zd'] != "" && $item['state'] < 1;
  1368. // });
  1369. // $z = array_sum(array_column($zdata, 'jnum'));
  1370. $zdata = array_filter($qbdata, function ($item) {
  1371. return $item['zd'] != "" && $item['state'] < 1;
  1372. });
  1373. $z = array_sum(array_column($zdata, 'jnum'));
  1374. //$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');
  1375. //$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'].'"');
  1376. //$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'].'"');
  1377. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1378. //$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'].'"');
  1379. $details = array();
  1380. $cpid = array();
  1381. $od = array();
  1382. $odid = '';
  1383. $companytitle = '';
  1384. $shop_list = [];
  1385. foreach ($qbdata as $v) {
  1386. if ($v['zd'] != "" && $v['state'] < 1) {
  1387. if (!isset($od[$v['zd']])) {
  1388. $od[$v['zd']] = 1; //所有数据sku
  1389. } else {
  1390. $od[$v['zd']] = $od[$v['zd']] + 1;
  1391. }
  1392. }
  1393. if ($v['state'] < 1) {
  1394. $details[$v['details']] = $v['details'];
  1395. if ($v['cpid'] != 0) {
  1396. $cpid[$v['cpid']] = $v['cpid'];
  1397. }
  1398. }
  1399. if($v['state'] == 0){
  1400. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1401. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1402. }
  1403. if ($v['shop'] != '') {
  1404. $shop = explode(',', trim($v['shop'], ','));
  1405. foreach ($shop as $vv) {
  1406. if (!in_array($vv, $shop_list)) {
  1407. $shop_list[] = $vv;
  1408. }
  1409. }
  1410. }
  1411. }
  1412. }
  1413. foreach ($od as $k => $vv) {
  1414. $odid .= $k . '数量' . $vv;
  1415. }
  1416. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1417. $info_list[$key]['label'] = $value['sm'];
  1418. $number = $value['number'];
  1419. $ftime = time() - 15 * 24 * 3600;
  1420. $z = $z . '(' . $odid . ')'; //查看订单号
  1421. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1422. $info_list[$key]['features'] = $c;
  1423. $info_list[$key]['number'] = $ztdata;
  1424. $info_list[$key]['sm'] = $g;
  1425. $info_list[$key]['x'] = $x;
  1426. $info_list[$key]['t'] = $t;
  1427. $info_list[$key]['z'] = $z;
  1428. /**
  1429. foreach ($cdata as $k=>$v)
  1430. {
  1431. $details[$v['details']] = $v['details'];
  1432. if($v['cpid'] != 0)
  1433. {
  1434. $cpid[$v['cpid']] = $v['cpid'];
  1435. }
  1436. }
  1437. **/
  1438. $info_list[$key]['shop'] = '';
  1439. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1440. // if ($value['shop'] != '') {
  1441. // $shop = explode(',', trim($value['shop'], ','));
  1442. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1443. // }
  1444. $shop_list = array_unique($shop_list);
  1445. $shop_str = '';
  1446. foreach ($shop_list as $v) {
  1447. if(isset($sp[$v])){
  1448. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1449. }
  1450. }
  1451. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1452. /**
  1453. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1454. if(isset($companytitle[0]))
  1455. {
  1456. foreach ($companytitle as $k=>$v)
  1457. {
  1458. if($v['companytitle'] != '')
  1459. {
  1460. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1461. }
  1462. }
  1463. }
  1464. **/
  1465. }
  1466. $final_all_list = [];
  1467. foreach ($info_list as $k => $v) {
  1468. $final_all_list[] = [
  1469. 'id' => $v['id'],
  1470. "warehouse" => $v["warehouse"],
  1471. "purchase" => $v["purchase"],
  1472. "sku" => $v["sku"],
  1473. "title" => $v["title"] . "<br/>" . $v["pm"],
  1474. "details" => $v["details"],
  1475. "shop" => $v["shop"],
  1476. "cpbz" => $v["cpbz"],
  1477. 'label' => $v['label'],
  1478. "type" => $v["type"],
  1479. "features" => $v["features"],
  1480. "number" => $v["number"],
  1481. "sm" => $v["sm"],
  1482. "x" => $v["x"],
  1483. "t" => $v["t"],
  1484. "z" => $v["z"]
  1485. ];
  1486. }
  1487. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1488. $pagenum = ceil($total / $perpage);
  1489. $over = $total - ($start + $perpage);
  1490. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1491. echo json_encode($rows);
  1492. exit;
  1493. }
  1494. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1495. $this->data['shop'] = $wlshop;
  1496. $this->data['vip'] = $vip;
  1497. $this->_Template('whlabel_type', $this->data);
  1498. }
  1499. //美仓进销存浏览
  1500. public function _usatype()
  1501. {
  1502. if (isset($_SESSION['api'])) {
  1503. $user = $this->user->get_api($_SESSION['api']);
  1504. $usp = $user;
  1505. $fgshop = "";
  1506. $sid = "";
  1507. $wid = "";
  1508. $wtype = "";
  1509. $userwh = explode('|', trim($user['warehouse'], '|'));
  1510. foreach ($userwh as $value) {
  1511. $wid .= " id = " . $value . " or";
  1512. $wtype .= " type = " . $value . " or";
  1513. }
  1514. }
  1515. $prc = array();
  1516. $purchase = $this->purchase->find_all();
  1517. foreach ($purchase as $k => $v) {
  1518. $prc[$v['id']] = $v['title'];
  1519. }
  1520. $post = $this->input->post(NULL, TRUE);
  1521. if (isset($post['page'])) {
  1522. $page = $this->input->post('page', true);
  1523. $perpage = $this->input->post('perpage', true);
  1524. $category = $this->input->post('category', true);
  1525. $size = $this->input->post('size', true);
  1526. $grade = $this->input->post('grade', true);
  1527. $color = $this->input->post('color', true);
  1528. $lowe = $this->input->post('lowe', true);
  1529. $sku = $this->input->post('sku');
  1530. $title = $this->input->post('title');
  1531. $warehouse = $this->input->post('warehouse', true);
  1532. $usa = $this->input->post('usa', true);
  1533. $purchase = $this->input->post('purchase', true);
  1534. $lacetype = $this->input->post('lacetype', true);
  1535. $haircap = $this->input->post('haircap', true);
  1536. $density = $this->input->post('density', true);
  1537. $details = $this->input->post('details', true);
  1538. $state = $this->input->post('state', true);
  1539. $lacecolor = $this->input->post('lacecolor', true);
  1540. $cklx = $this->input->post('cklx', true);
  1541. $ktime = $this->input->post('ktime', true);
  1542. $jtime = $this->input->post('jtime', true);
  1543. $ktime = strtotime($ktime);
  1544. $jtime = strtotime($jtime);
  1545. $where = "1=1";
  1546. $gj = "";
  1547. $ck = "";
  1548. if ($lacetype) {
  1549. $where .= " and features like '%-$lacetype-%'";
  1550. }
  1551. if ($category) {
  1552. $where .= " and features like '%-$category-%'";
  1553. }
  1554. if ($size) {
  1555. $where .= " and features like '%-$size-%'";
  1556. }
  1557. if ($grade) {
  1558. $where .= " and features like '%-$grade-%'";
  1559. }
  1560. if ($color) {
  1561. $where .= " and features like '%-$color-%'";
  1562. }
  1563. if ($lowe) {
  1564. $where .= " and features like '%-$lowe-%'";
  1565. }
  1566. if ($haircap) {
  1567. $where .= " and features like '%-$haircap-%'";
  1568. }
  1569. if ($density) {
  1570. $where .= " and features like '%-$density-%'";
  1571. }
  1572. if ($lacecolor) {
  1573. $where .= " and features like '%-$lacecolor-%'";
  1574. }
  1575. if ($usa) {
  1576. if (!$warehouse) {
  1577. $where .= " and (warehouse = '5' or warehouse = '8')";
  1578. }
  1579. }
  1580. if ($warehouse) {
  1581. $where .= " and warehouse = '$warehouse'";
  1582. }
  1583. if ($details) {
  1584. $where .= " and details = '$details'";
  1585. }
  1586. if ($purchase) {
  1587. $where .= " and purchase = '$purchase'";
  1588. }
  1589. if ($state) {
  1590. $where .= " and state = '$state'";
  1591. }
  1592. $where_add = '';
  1593. if ($cklx) {
  1594. $shop = $this->shop->read($cklx);
  1595. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1596. }
  1597. if ($ktime && $jtime) {
  1598. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1599. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1600. }
  1601. //数据排序
  1602. $order_str = "id desc";
  1603. if (empty($page)) {
  1604. $start = 0;
  1605. $perpage = 1;
  1606. } else {
  1607. $start = ($page - 1) * $perpage;
  1608. }
  1609. if ($sku) {
  1610. $sku = trim($sku, ' ');
  1611. $sku = trim($sku, ' ');
  1612. $where .= " and sku like '%$sku%'";
  1613. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1614. } else if ($title) {
  1615. $title = trim($title, ' ');
  1616. $title = trim($title, ' ');
  1617. $where .= " and title like '%$title%'";
  1618. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1619. } else {
  1620. //$where .= " and time > '$ktime' and time < '$jtime'";
  1621. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1622. }
  1623. //取得信息列表
  1624. $rows = array();
  1625. $list = array();
  1626. foreach ($info_list as $key => $value) {
  1627. $warehouse = $this->warehouse->read($value['warehouse']);
  1628. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1629. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1630. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1631. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1632. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1633. $od = array();
  1634. $odid = '';
  1635. foreach ($z as $v) {
  1636. if (!isset($od[$v['zd']])) {
  1637. $od[$v['zd']] = 1; //所有数据sku
  1638. } else {
  1639. $od[$v['zd']] = $od[$v['zd']] + 1;
  1640. }
  1641. }
  1642. foreach ($od as $k => $vv) {
  1643. $odid .= $k . '数量' . $vv . ' ';
  1644. }
  1645. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1646. $info_list[$key]['features'] = $c;
  1647. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1648. $ztdata = '';
  1649. if (count($zt) > 0) {
  1650. foreach ($zt as $vv) {
  1651. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1652. }
  1653. }
  1654. $info_list[$key]['warehouse'] = $ztdata;
  1655. $info_list[$key]['g'] = $g;
  1656. $info_list[$key]['x'] = $x;
  1657. $info_list[$key]['t'] = $t;
  1658. $info_list[$key]['z'] = $z;
  1659. }
  1660. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1661. $pagenum = ceil($total / $perpage);
  1662. $over = $total - ($start + $perpage);
  1663. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1664. echo json_encode($rows);
  1665. exit;
  1666. }
  1667. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1668. $this->data['warehouse'] = $warehouse;
  1669. $this->_Template('whlabel_typeusa', $this->data);
  1670. }
  1671. //美仓进销存浏览
  1672. public function _usatypeapp()
  1673. {
  1674. $post = $this->input->post(NULL, TRUE);
  1675. if (isset($post['page'])) {
  1676. $page = $this->input->post('page', true);
  1677. $perpage = $this->input->post('perpage', true);
  1678. $sku = $this->input->post('sku', true);
  1679. $warehouse = 5;
  1680. $title = $this->input->post('title', true);
  1681. $state = $this->input->post('state', true);
  1682. $ktime = $this->input->post('ktime', true);
  1683. $jtime = $this->input->post('jtime', true);
  1684. $ktime = strtotime($ktime);
  1685. $jtime = strtotime($jtime);
  1686. $where = "1=1";
  1687. $gj = "";
  1688. $ck = "";
  1689. if ($title) {
  1690. $st = explode(' ', trim($title, ' '));
  1691. foreach ($st as $v) {
  1692. $where .= " and title like '%$v%'";
  1693. }
  1694. }
  1695. if ($warehouse) {
  1696. $where .= " and warehouse = '$warehouse'";
  1697. }
  1698. if ($state) {
  1699. $where .= " and state = '$state'";
  1700. }
  1701. if ($sku) {
  1702. $where .= " and sku like '%$sku%'";
  1703. }
  1704. if ($ktime && $jtime) {
  1705. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1706. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1707. }
  1708. //数据排序
  1709. $order_str = "id desc";
  1710. if (empty($page)) {
  1711. $start = 0;
  1712. $perpage = 1;
  1713. } else {
  1714. $start = ($page - 1) * $perpage;
  1715. }
  1716. //取得信息列表
  1717. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1718. $rows = array();
  1719. $list = array();
  1720. foreach ($info_list as $key => $value) {
  1721. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1722. }
  1723. $rowsdq = array_slice($rows, $start, $perpage);
  1724. foreach ($rowsdq as $value) {
  1725. $warehouse = $this->warehouse->read($value['warehouse']);
  1726. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1727. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1728. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1729. $od = array();
  1730. $odid = '';
  1731. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1732. }
  1733. $total = count($rows);
  1734. $pagenum = ceil($total / $perpage);
  1735. $over = $total - ($start + $perpage);
  1736. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1737. echo json_encode($rows);
  1738. exit;
  1739. }
  1740. $this->_Template('phone/p_usatypeapp', $this->data);
  1741. }
  1742. //入库操作
  1743. public function _enteradd()
  1744. {
  1745. $dt = 0;
  1746. if (isset($_SESSION['api'])) {
  1747. $user = $this->user->get_api($_SESSION['api']);
  1748. $usp = $user;
  1749. $fgshop = "";
  1750. $sid = "";
  1751. $user = explode('|', trim($user['shop'], '|'));
  1752. foreach ($user as $value) {
  1753. $fgshop .= " shop = " . $value . " or";
  1754. $sid .= " id = " . $value . " or";
  1755. }
  1756. }
  1757. $tc = $this->typeclass->find_all();
  1758. $typeclass = array();
  1759. foreach ($tc as $v) {
  1760. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1761. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1762. }
  1763. $post = $this->input->post(NULL, TRUE);
  1764. if (isset($post['sku'])) {
  1765. $list = array();
  1766. $num = "";
  1767. $title = "";
  1768. $features = "";
  1769. $order = $this->input->post('order', true);
  1770. $shop = $this->input->post('shop', true);
  1771. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1772. $sku = $this->input->post('sku', true);
  1773. $post['sm'] = $this->input->post('sm', true);
  1774. $post['warehouse'] = $this->input->post('warehouse', true);
  1775. $post['purchase'] = $this->input->post('purchase', true);
  1776. $post['retreatwarehouse'] = $post['warehouse'];
  1777. $post['state'] = $this->input->post('state', true);
  1778. $post['rktype'] = $this->input->post('rktype', true);
  1779. $post['text'] = $this->input->post('text', true);
  1780. $category = $this->input->post('category', true);
  1781. $list['category'] = $category;
  1782. $list['hairtype'] = $this->input->post('hairtype', true);
  1783. $list['grade'] = $this->input->post('grade', true);
  1784. $size = $this->input->post('size', true);
  1785. $xzsku = $this->input->post('xzsku', true);
  1786. $list['size'] = rtrim($size, ',');
  1787. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1788. $list['extension'] = $this->input->post('extension', true);
  1789. if ($category == 1297) {
  1790. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1791. }
  1792. if ($category == 1702) {
  1793. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1794. $list['syother'] = $this->input->post('syother', true);
  1795. }
  1796. if ($category == 133) {
  1797. $list['fittype'] = $this->input->post('fittype', true);
  1798. $list['acother'] = $this->input->post('acother', true);
  1799. }
  1800. $list['color'] = $this->input->post('color', true);
  1801. $list['lowe'] = $this->input->post('lowe', true);
  1802. if (!$post['purchase']) {
  1803. $post['purchase'] = 1;
  1804. }
  1805. if ($category == 127) {
  1806. $list['type'] = $this->input->post('type', true);
  1807. $list['headroad'] = $this->input->post('headroad', true);
  1808. $list['density'] = $this->input->post('density', true);
  1809. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1810. $list['lacesize'] = $this->input->post('lacesize', true);
  1811. }
  1812. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1813. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1814. }
  1815. if ($category == 128) {
  1816. $list['lacetype'] = $this->input->post('lacetype', true);
  1817. $list['haircap'] = $this->input->post('haircap', true);
  1818. $list['density'] = $this->input->post('density', true);
  1819. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1820. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1821. $list['wigother'] = $this->input->post('wigother', true);
  1822. $list['wigother1'] = $this->input->post('wigother1', true);
  1823. $list['wigother2'] = $this->input->post('wigother2', true);
  1824. }
  1825. if ($category == 129) {
  1826. $list['wide'] = $this->input->post('wide', true);
  1827. }
  1828. if ($category == 131) {
  1829. $list['gifttype'] = $this->input->post('gifttype', true);
  1830. $list['giftother'] = $this->input->post('giftother', true);
  1831. }
  1832. if ($category == 134) {
  1833. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1834. }
  1835. if ($category == 1297) {
  1836. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1837. $list['sywigother'] = $this->input->post('sywigother', true);
  1838. }
  1839. if ($category == 130 || $category == 133 || $category == 1702) {
  1840. $list['items'] = $this->input->post('items', true);
  1841. $list['weight'] = $this->input->post('weight', true);
  1842. }
  1843. if ($category == 1702) {
  1844. $list['syhairther'] = $this->input->post('syhairther', true);
  1845. }
  1846. $classid = $this->classid->sku();
  1847. $scsku = $classid;
  1848. $pm = $classid;
  1849. foreach ($list as $k => $v) {
  1850. if ($v != 0) {
  1851. $num .= $v;
  1852. $features .= $v . '-';
  1853. $post[$k] = $v;
  1854. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1855. if ($k != 'size') {
  1856. $title .= $typeclass[$v]['title'] . " ";
  1857. }
  1858. if (isset($pm[$typeclass[$v]['classid']])) {
  1859. if ($typeclass[$v]['title'] == '9A') {
  1860. $pm[$typeclass[$v]['classid']] = '9A';
  1861. } else if ($typeclass[$v]['title'] == '10A') {
  1862. $pm[$typeclass[$v]['classid']] = '10A';
  1863. } else {
  1864. $clzh = $typeclass[$v]['zh'];
  1865. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1866. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1867. $clzh = $clzh[0];
  1868. }
  1869. $pm[$typeclass[$v]['classid']] = $clzh;
  1870. }
  1871. }
  1872. }
  1873. }
  1874. $zh = implode(" ", $pm);
  1875. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1876. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1877. if ($list['size']) {
  1878. $typeclass = $this->typeclass->read($list['size']);
  1879. $title .= $typeclass['title'];
  1880. }
  1881. $time = time();
  1882. if ($xzsku) {
  1883. $scsku = implode("-", $scsku);
  1884. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1885. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1886. $post['sku'] = trim($scsku, ' ');
  1887. } else {
  1888. $post['sku'] = $sku;
  1889. }
  1890. //$post['sku'] = trim($sku,' ');
  1891. $post['title'] = rtrim($title, ' ');
  1892. $post['number'] = $num;
  1893. $post['features'] = '-' . $features;
  1894. $post['enter'] = $time;
  1895. $post['time'] = $time; //操作时间
  1896. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1897. if ($yza) {
  1898. if ($post['features'] != $yza[0]['features']) {
  1899. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1900. exit;
  1901. }
  1902. }
  1903. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1904. if ($yzb) {
  1905. if ($post['sku'] != $yzb[0]['sku']) {
  1906. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1907. exit;
  1908. }
  1909. }
  1910. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1911. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1912. exit;
  1913. }
  1914. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1915. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1916. exit;
  1917. }
  1918. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1919. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1920. exit;
  1921. }
  1922. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1923. if (isset($yz[0]['type'])) {
  1924. $post['type'] = $yz[0]['type'];
  1925. }
  1926. if ($post['state'] == 9) //如果选择预设库存
  1927. {
  1928. $this->whlabel->insert($post);
  1929. } else {
  1930. /**
  1931. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1932. if($ljg == 1)
  1933. {
  1934. for($i=0;$i<$order;$i++)
  1935. {
  1936. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1937. $this->whlabel->insert($post);
  1938. }
  1939. }
  1940. **/
  1941. //if($post['warehouse'] == '5')
  1942. //{
  1943. //}
  1944. $yydata = $post;
  1945. $yydata['zh'] = $zh;
  1946. /**
  1947. $wl = $this->apiyy->get_cjlp($yydata);
  1948. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1949. {
  1950. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1951. }
  1952. if($wl['Data'][0]['m_isSucess'] != 1)
  1953. {
  1954. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1955. }
  1956. **/
  1957. for ($i = 0; $i < $order; $i++) {
  1958. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1959. $this->whlabel->insert($post);
  1960. }
  1961. }
  1962. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1963. exit;
  1964. }
  1965. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1966. $this->data['wlshop'] = $wlshop;
  1967. $this->_Template('whlabel_enteradd', $this->data);
  1968. }
  1969. //修改产品
  1970. public function _enteredit($arg_array)
  1971. {
  1972. $dt = 0;
  1973. if (isset($_SESSION['api'])) {
  1974. $user = $this->user->get_api($_SESSION['api']);
  1975. $usp = $user;
  1976. $fgshop = "";
  1977. $sid = "";
  1978. $user = explode('|', trim($user['shop'], '|'));
  1979. foreach ($user as $value) {
  1980. $fgshop .= " shop = " . $value . " or";
  1981. $sid .= " id = " . $value . " or";
  1982. }
  1983. }
  1984. $post = $this->input->post(NULL, TRUE);
  1985. if (isset($post['sku'])) {
  1986. $list = array();
  1987. $num = "";
  1988. $title = "";
  1989. $features = "";
  1990. $id = $this->input->post('id', true);
  1991. $order = $this->input->post('order', true);
  1992. $shop = $this->input->post('shop', true);
  1993. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1994. $post['sku'] = $this->input->post('sku', true);
  1995. $post['sm'] = $this->input->post('sm', true);
  1996. $post['warehouse'] = $this->input->post('warehouse', true);
  1997. $post['purchase'] = $this->input->post('purchase', true);
  1998. $post['retreatwarehouse'] = $post['warehouse'];
  1999. $category = $this->input->post('category', true);
  2000. $list['category'] = $category;
  2001. $list['hairtype'] = $this->input->post('hairtype', true);
  2002. $list['grade'] = $this->input->post('grade', true);
  2003. $size = $this->input->post('size', true);
  2004. $list['size'] = rtrim($size, ',');
  2005. $post['rktype'] = $this->input->post('rktype', true);
  2006. $post['text'] = $this->input->post('text', true);
  2007. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2008. $list['extension'] = $this->input->post('extension', true);
  2009. if ($category == 1297) {
  2010. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2011. }
  2012. if ($category == 1702) {
  2013. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2014. $list['syother'] = $this->input->post('syother', true);
  2015. }
  2016. if ($category == 133) {
  2017. $list['fittype'] = $this->input->post('fittype', true);
  2018. $list['acother'] = $this->input->post('acother', true);
  2019. }
  2020. $list['color'] = $this->input->post('color', true);
  2021. $list['lowe'] = $this->input->post('lowe', true);
  2022. if (!$post['purchase']) {
  2023. $post['purchase'] = 1;
  2024. }
  2025. if ($category == 127) {
  2026. $list['type'] = $this->input->post('type', true);
  2027. $list['headroad'] = $this->input->post('headroad', true);
  2028. $list['density'] = $this->input->post('density', true);
  2029. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2030. $list['lacesize'] = $this->input->post('lacesize', true);
  2031. }
  2032. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2033. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2034. }
  2035. if ($category == 128) {
  2036. $list['lacetype'] = $this->input->post('lacetype', true);
  2037. $list['haircap'] = $this->input->post('haircap', true);
  2038. $list['density'] = $this->input->post('density', true);
  2039. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2040. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2041. $list['wigother'] = $this->input->post('wigother', true);
  2042. $list['wigother1'] = $this->input->post('wigother1', true);
  2043. $list['wigother2'] = $this->input->post('wigother2', true);
  2044. }
  2045. if ($category == 129) {
  2046. $list['wide'] = $this->input->post('wide', true);
  2047. }
  2048. if ($category == 131) {
  2049. $list['gifttype'] = $this->input->post('gifttype', true);
  2050. $list['giftother'] = $this->input->post('giftother', true);
  2051. }
  2052. if ($category == 134) {
  2053. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2054. }
  2055. if ($category == 1297) {
  2056. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2057. $list['sywigother'] = $this->input->post('sywigother', true);
  2058. }
  2059. if ($category == 130 || $category == 133 || $category == 1702) {
  2060. $list['items'] = $this->input->post('items', true);
  2061. $list['weight'] = $this->input->post('weight', true);
  2062. }
  2063. if ($category == 1702) {
  2064. $list['syhairther'] = $this->input->post('syhairther', true);
  2065. }
  2066. foreach ($list as $k => $v) {
  2067. if ($v != 0) {
  2068. $num .= $v;
  2069. $features .= $v . '-';
  2070. $typeclass = $this->typeclass->read($v);
  2071. if ($k != 'size') {
  2072. $title .= $typeclass['title'] . " ";
  2073. }
  2074. }
  2075. }
  2076. $typeclass = $this->typeclass->read($list['size']);
  2077. $title .= $typeclass['title'];
  2078. $time = time();
  2079. $post['title'] = rtrim($title, ' ');
  2080. $post['number'] = $num;
  2081. $post['features'] = '-' . $features;
  2082. $post['time'] = $time; //操作时间
  2083. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2084. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2085. exit;
  2086. }
  2087. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2088. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2089. exit;
  2090. }
  2091. $uid = $this->whlabel->read($id);
  2092. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2093. if ($datanum > 0) {
  2094. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2095. exit;
  2096. }
  2097. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2098. {
  2099. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2100. if ($yza) {
  2101. if ($post['features'] != $yza[0]['features']) {
  2102. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2103. exit;
  2104. }
  2105. }
  2106. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2107. if ($yzb) {
  2108. if ($post['sku'] != $yzb[0]['sku']) {
  2109. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2110. exit;
  2111. }
  2112. }
  2113. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2114. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2115. exit;
  2116. }
  2117. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2118. foreach ($data as $v) {
  2119. $post['id'] = $v['id'];
  2120. $this->whlabel->save($post, $v['id']);
  2121. }
  2122. } else {
  2123. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2124. if ($data > 0) {
  2125. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2126. exit;
  2127. } else {
  2128. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2129. foreach ($data as $v) {
  2130. $post['id'] = $v['id'];
  2131. $this->whlabel->save($post, $v['id']);
  2132. }
  2133. }
  2134. }
  2135. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2136. exit;
  2137. }
  2138. $uid = $this->whlabel->read($arg_array[0]);
  2139. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2140. $this->data['enter'] = $uid;
  2141. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2142. $this->data['wlshop'] = $wlshop;
  2143. $this->_Template('whlabel_enteredit', $this->data);
  2144. }
  2145. //入库浏览
  2146. public function _enter()
  2147. {
  2148. $post = $this->input->post(NULL, TRUE);
  2149. if (isset($post['s'])) {
  2150. $id_arr = $this->input->post('s');
  2151. $id_arr = explode(',', $id_arr);
  2152. if (!$id_arr) {
  2153. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2154. exit;
  2155. }
  2156. //循环删除记录
  2157. foreach ($id_arr as $v) {
  2158. $sid = $this->whlabel->read($v);
  2159. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2160. if ($count > 0) {
  2161. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2162. exit;
  2163. }
  2164. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2165. foreach ($info_list as $va) {
  2166. $this->whlabel->remove($va['id']);
  2167. }
  2168. }
  2169. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2170. exit;
  2171. }
  2172. $sp = array();
  2173. $s = $this->shop->find_all('1=1', 'id,shopname');
  2174. foreach ($s as $v) {
  2175. $sp[$v['id']] = $v['shopname'];
  2176. }
  2177. $wh = array();
  2178. $w = $this->warehouse->find_all('1=1', 'id,title');
  2179. foreach ($w as $v) {
  2180. $wh[$v['id']] = $v['title'];
  2181. }
  2182. if (isset($post['page'])) {
  2183. $page = $this->input->post('page', true);
  2184. $perpage = $this->input->post('perpage', true);
  2185. $category = $this->input->post('category', true);
  2186. $size = $this->input->post('size', true);
  2187. $grade = $this->input->post('grade', true);
  2188. $color = $this->input->post('color', true);
  2189. $lowe = $this->input->post('lowe', true);
  2190. $sku = $this->input->post('sku', true);
  2191. $warehouse = $this->input->post('warehouse', true);
  2192. $purchase = $this->input->post('purchase', true);
  2193. $ktime = $this->input->post('ktime', true);
  2194. $jtime = $this->input->post('jtime', true);
  2195. $ktime = strtotime($ktime);
  2196. $jtime = strtotime($jtime);
  2197. $where = "1=1";
  2198. $gj = "";
  2199. $ck = "";
  2200. if ($category) {
  2201. $where .= " and features like '%-$category-%'";
  2202. }
  2203. if ($size) {
  2204. $where .= " and features like '%-$size-%'";
  2205. }
  2206. if ($grade) {
  2207. $where .= " and features like '%-$grade-%'";
  2208. }
  2209. if ($color) {
  2210. $where .= " and features like '%-$color-%'";
  2211. }
  2212. if ($lowe) {
  2213. $where .= " and features like '%-$lowe-%'";
  2214. }
  2215. if ($warehouse) {
  2216. $where .= " and warehouse = '$warehouse'";
  2217. }
  2218. if ($purchase) {
  2219. $where .= " and purchase = '$purchase'";
  2220. }
  2221. if ($sku) {
  2222. $where .= " and sku like '%$sku%'";
  2223. }
  2224. if ($ktime && $jtime) {
  2225. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2226. }
  2227. //数据排序
  2228. $order_str = "enter desc";
  2229. if (empty($page)) {
  2230. $start = 0;
  2231. $perpage = 1;
  2232. } else {
  2233. $start = ($page - 1) * $perpage;
  2234. }
  2235. //取得信息列表
  2236. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2237. foreach ($info_list as $k => $v) {
  2238. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2239. if ($v['shop'] == '') {
  2240. $s = '通用';
  2241. } else {
  2242. $info_list[$k]['shop'] = '';
  2243. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2244. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2245. }
  2246. }
  2247. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2248. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2249. $info_list[$k]['g'] = $g;
  2250. }
  2251. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2252. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2253. $pagenum = ceil($total / $perpage);
  2254. $over = $total - ($start + $perpage);
  2255. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2256. echo json_encode($rows);
  2257. exit;
  2258. }
  2259. $this->_Template('whlabel_enter', $this->data);
  2260. }
  2261. //出库浏览
  2262. public function _out()
  2263. {
  2264. $post = $this->input->post(NULL, TRUE);
  2265. if (isset($post['page'])) {
  2266. $page = $this->input->post('page', true);
  2267. $perpage = $this->input->post('perpage', true);
  2268. $category = $this->input->post('category', true);
  2269. $size = $this->input->post('size', true);
  2270. $grade = $this->input->post('grade', true);
  2271. $color = $this->input->post('color', true);
  2272. $lowe = $this->input->post('lowe', true);
  2273. $sku = $this->input->post('sku', true);
  2274. $warehouse = $this->input->post('warehouse', true);
  2275. $purchase = $this->input->post('purchase', true);
  2276. $state = $this->input->post('state', true);
  2277. $ktime = $this->input->post('ktime', true);
  2278. $jtime = $this->input->post('jtime', true);
  2279. $ktime = strtotime($ktime);
  2280. $jtime = strtotime($jtime);
  2281. $where = "state=3";
  2282. $gj = "";
  2283. $ck = "";
  2284. if ($category) {
  2285. $where .= " and features like '%-$category-%'";
  2286. }
  2287. if ($size) {
  2288. $where .= " and features like '%-$size-%'";
  2289. }
  2290. if ($grade) {
  2291. $where .= " and features like '%-$grade-%'";
  2292. }
  2293. if ($color) {
  2294. $where .= " and features like '%-$color-%'";
  2295. }
  2296. if ($lowe) {
  2297. $where .= " and features like '%-$lowe-%'";
  2298. }
  2299. if ($state) {
  2300. $where .= " and state = '$state'";
  2301. }
  2302. if ($warehouse) {
  2303. $where .= " and warehouse = '$warehouse'";
  2304. }
  2305. if ($purchase) {
  2306. $where .= " and purchase = '$purchase'";
  2307. }
  2308. if ($sku) {
  2309. $where .= " and sku = '$sku'";
  2310. }
  2311. if ($ktime && $jtime) {
  2312. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2313. }
  2314. //数据排序
  2315. $order_str = "id desc";
  2316. if (empty($page)) {
  2317. $start = 0;
  2318. $perpage = 1;
  2319. } else {
  2320. $start = ($page - 1) * $perpage;
  2321. }
  2322. //取得信息列表
  2323. $info_list = $this->whlabel->find_all($where, 'sku');
  2324. $rows = array();
  2325. $list = array();
  2326. foreach ($info_list as $key => $value) {
  2327. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2328. }
  2329. $rows = array_unique($rows); //删除重复记录
  2330. foreach ($rows as $key => $value) {
  2331. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2332. $ck = $this->warehouse->read($data['warehouse']);
  2333. $warehouse = $ck['title'];
  2334. $gy = $this->purchase->read($data['purchase']);
  2335. $purchase = $gy['purchase'];
  2336. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2337. $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);
  2338. }
  2339. $total = count($list);
  2340. $pagenum = ceil($total / $perpage);
  2341. $over = $total - ($start + $perpage);
  2342. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2343. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2344. echo json_encode($rows);
  2345. exit;
  2346. }
  2347. $this->_Template('whlabel_out', $this->data);
  2348. }
  2349. //出库标签浏览
  2350. public function _label()
  2351. {
  2352. $post = $this->input->post(NULL, TRUE);
  2353. if (isset($post['page'])) {
  2354. $page = $this->input->post('page', true);
  2355. $perpage = $this->input->post('perpage', true);
  2356. $sku = $this->input->post('sku', true);
  2357. $warehouse = $this->input->post('warehouse', true);
  2358. $purchase = $this->input->post('purchase', true);
  2359. $orderinfo = $this->input->post('orderinfo', true);
  2360. $waybill = $this->input->post('waybill', true);
  2361. $category = $this->input->post('category', true);
  2362. $size = $this->input->post('size', true);
  2363. $grade = $this->input->post('grade', true);
  2364. $color = $this->input->post('color', true);
  2365. $lowe = $this->input->post('lowe', true);
  2366. $where = "state=1";
  2367. if ($sku) {
  2368. $where .= " and sku = '$sku'";
  2369. }
  2370. if ($warehouse) {
  2371. $where .= " and warehouse = '$warehouse'";
  2372. }
  2373. if ($purchase) {
  2374. $where .= " and purchase = '$purchase'";
  2375. }
  2376. if ($orderinfo) {
  2377. $where .= " and orderinfo = '$orderinfo'";
  2378. }
  2379. if ($waybill) {
  2380. $where .= " and waybill = '$waybill'";
  2381. }
  2382. if ($category) {
  2383. $where .= " and features like '%-$category-%'";
  2384. }
  2385. if ($size) {
  2386. $where .= " and features like '%-$size-%'";
  2387. }
  2388. if ($grade) {
  2389. $where .= " and features like '%-$grade-%'";
  2390. }
  2391. if ($color) {
  2392. $where .= " and features like '%-$color-%'";
  2393. }
  2394. if ($lowe) {
  2395. $where .= " and features like '%-$lowe-%'";
  2396. }
  2397. //数据排序
  2398. $order_str = "outk desc";
  2399. if (empty($page)) {
  2400. $start = 0;
  2401. $perpage = 1;
  2402. } else {
  2403. $start = ($page - 1) * $perpage;
  2404. }
  2405. //取得信息列表
  2406. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2407. foreach ($info_list as $key => $value) {
  2408. $warehouse = $this->warehouse->read($value['warehouse']);
  2409. $info_list[$key]['warehouse'] = $warehouse['title'];
  2410. $purchase = $this->purchase->read($value['purchase']);
  2411. $info_list[$key]['purchase'] = $purchase['title'];
  2412. if ($value['outk'] != 0) {
  2413. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2414. } else {
  2415. $info_list[$key]['outk'] = "";
  2416. }
  2417. if ($value['orderinfo'] == 0) {
  2418. $info_list[$key]['orderinfo'] = "";
  2419. }
  2420. if ($value['waybill'] == 0) {
  2421. $info_list[$key]['waybill'] = "";
  2422. }
  2423. }
  2424. $total = $this->whlabel->find_count($where);
  2425. $pagenum = ceil($total / $perpage);
  2426. $over = $total - ($start + $perpage);
  2427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2428. echo json_encode($rows);
  2429. exit;
  2430. }
  2431. $this->_Template('whlabel_label', $this->data);
  2432. }
  2433. //独立站出库订单
  2434. public function _outorder()
  2435. {
  2436. if (isset($_SESSION['api'])) {
  2437. $user = $this->user->get_api($_SESSION['api']);
  2438. $usp = $user;
  2439. $fgshop = "";
  2440. $sid = "";
  2441. $user = explode('|', trim($user['shop'], '|'));
  2442. foreach ($user as $value) {
  2443. $fgshop .= " shop = " . $value . " or";
  2444. $sid .= " id = " . $value . " or";
  2445. }
  2446. } else {
  2447. echo "请重新登录";
  2448. }
  2449. $post = $this->input->post(NULL, TRUE);
  2450. if (isset($post['page'])) {
  2451. $page = $this->input->post('page', true);
  2452. $perpage = $this->input->post('perpage', true);
  2453. $warehouse = $this->input->post('warehouse', true);
  2454. $xztime = $this->input->post('xztime', true);
  2455. $timetk = $this->input->post('timetkk', true);
  2456. $timetj = $this->input->post('timetjj', true);
  2457. $shop = $this->input->post('shop', true);
  2458. $source = $this->input->post('source', true);
  2459. $orderinfo = $this->input->post('orderinfo', true);
  2460. $number = $this->input->post('number', true);
  2461. $sfxh = $this->input->post('sfxh', true);
  2462. $express = $this->input->post('express', true);
  2463. $waybill = $this->input->post('waybill', true);
  2464. $library = $this->input->post('library', true);
  2465. $country = $this->input->post('country', true);
  2466. $so = $this->input->post('so', true);
  2467. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2468. $print = $this->input->post('print', true);
  2469. $state = $this->input->post('state', true);
  2470. $orderurl = $this->input->post('orderurl', true);
  2471. $productid = $this->input->post('productid', true);
  2472. $timetk = strtotime($timetk);
  2473. $timetj = strtotime($timetj);
  2474. /**
  2475. $sj = $this->input->post('sj',true);
  2476. if($sj)
  2477. {
  2478. $sj = $this->input->post('sj',true);
  2479. }
  2480. else
  2481. {
  2482. $sj = "fullorder";
  2483. }
  2484. **/
  2485. $sj = "fullorder";
  2486. $where = "1=1";
  2487. if ($warehouse) {
  2488. $where .= " and type = '$warehouse'";
  2489. }
  2490. if ($timetk && $timetj) {
  2491. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2492. }
  2493. if ($orderinfo) {
  2494. $where .= " and orderinfo = '$orderinfo'";
  2495. }
  2496. if ($number) {
  2497. $where .= " and number = '$number'";
  2498. }
  2499. if ($express) {
  2500. $where .= " and express = '$express'";
  2501. }
  2502. if ($waybill) {
  2503. $where .= " and waybill = '$waybill'";
  2504. }
  2505. if ($library) {
  2506. $where .= " and library = '$library'";
  2507. }
  2508. if ($print) {
  2509. $where .= " and print = '$print'";
  2510. }
  2511. if ($libraryconfirm) {
  2512. $where .= " and libraryconfirm = '$libraryconfirm'";
  2513. }
  2514. if ($state) {
  2515. $where .= " and state = '$state'";
  2516. }
  2517. if ($shop) {
  2518. $where .= " and shop = '$shop'";
  2519. }
  2520. if ($country) {
  2521. $where .= " and country = '$country'";
  2522. }
  2523. if ($sfxh != '') {
  2524. $where .= " and sfxh = '$sfxh'";
  2525. }
  2526. if ($so) {
  2527. $where .= " and shipremarks like '%$so%'";
  2528. }
  2529. if ($source) {
  2530. if ($source == '2d') {
  2531. $where .= " and source >= '2'";
  2532. } else {
  2533. $where .= " and source = '$source'";
  2534. }
  2535. }
  2536. if (isset($_SESSION['api'])) {
  2537. foreach ($user as $value) {
  2538. $fgshop .= " shop = " . $value . " or";
  2539. }
  2540. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2541. }
  2542. if ($orderurl) {
  2543. $url = $this->orderurl->read($orderurl);
  2544. $where .= " and link like '%" . $url['url'] . "%'";
  2545. }
  2546. if($productid){
  2547. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2548. }
  2549. //数据排序
  2550. $order_str = "librarytime desc";
  2551. if (empty($page)) {
  2552. $start = 0;
  2553. $perpage = 1;
  2554. } else {
  2555. $start = ($page - 1) * $perpage;
  2556. }
  2557. //取得信息列表
  2558. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2559. //格式化数据
  2560. foreach ($info_list as $key => $value) {
  2561. $shop = $this->shop->read($value['shop']);
  2562. $info_list[$key]['shop'] = $shop['shopname'];
  2563. $express = $this->express->read($value['express']);
  2564. $info_list[$key]['express'] = $express['servicename'];
  2565. $warehouse = $this->warehouse->read($value['type']);
  2566. $info_list[$key]['type'] = $warehouse['title'];
  2567. if ($value['librarytime'] == '0') {
  2568. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2569. } else {
  2570. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2571. }
  2572. }
  2573. $total = $this->$sj->find_count($where);
  2574. $pagenum = ceil($total / $perpage);
  2575. $over = $total - ($start + $perpage);
  2576. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2577. echo json_encode($rows);
  2578. exit;
  2579. }
  2580. $this->data['express'] = $this->express->find_all();
  2581. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2582. $this->data['wlshop'] = $wlshop;
  2583. $user = $this->user->get_api($_SESSION['api']);
  2584. $powerid = $this->power->read($user['power']);
  2585. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2586. $pid = '';
  2587. foreach ($powertext as $v) {
  2588. $pid .= " id = " . $v . " or";
  2589. }
  2590. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2591. $this->data['fullorderexcel'] = $fullorderexcel;
  2592. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2593. $this->data['orderurl'] = $orderurl;
  2594. $this->_Template('whlabel_outorder', $this->data);
  2595. }
  2596. //tt出库
  2597. public function _toutorder()
  2598. {
  2599. $fgshop = "";
  2600. $sid = "";
  2601. if (isset($_SESSION['api'])) {
  2602. $user = $this->user->get_api($_SESSION['api']);
  2603. $usp = $user;
  2604. $user = explode('|', trim($user['shop'], '|'));
  2605. foreach ($user as $value) {
  2606. $fgshop .= " shop = " . $value . " or";
  2607. $sid .= " id = " . $value . " or";
  2608. }
  2609. } else {
  2610. echo "请重新登录";
  2611. die;
  2612. }
  2613. $post = $this->input->post(NULL, TRUE);
  2614. if (isset($post['page'])) {
  2615. $page = $this->input->post('page', true);
  2616. $perpage = $this->input->post('perpage', true);
  2617. $warehouse = $this->input->post('warehouse', true);
  2618. $xztime = $this->input->post('xztime', true);
  2619. $timetk = $this->input->post('timetkk', true);
  2620. $timetj = $this->input->post('timetjj', true);
  2621. $shop = $this->input->post('shop', true);
  2622. $source = $this->input->post('source', true);
  2623. $orderinfo = $this->input->post('orderinfo', true);
  2624. $number = $this->input->post('number', true);
  2625. $sfxh = $this->input->post('sfxh', true);
  2626. $express = $this->input->post('express', true);
  2627. $waybill = $this->input->post('waybill', true);
  2628. $library = $this->input->post('library', true);
  2629. $country = $this->input->post('country', true);
  2630. $so = $this->input->post('so', true);
  2631. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2632. $print = $this->input->post('print', true);
  2633. $state = $this->input->post('state', true);
  2634. $orderurl = $this->input->post('orderurl', true);
  2635. $timetk = strtotime($timetk);
  2636. $timetj = strtotime($timetj);
  2637. /**
  2638. $sj = $this->input->post('sj',true);
  2639. if($sj)
  2640. {
  2641. $sj = $this->input->post('sj',true);
  2642. }
  2643. else
  2644. {
  2645. $sj = "fullorder";
  2646. }
  2647. **/
  2648. $sj = "fullordertt";
  2649. $where = "1=1";
  2650. if ($warehouse) {
  2651. $where .= " and type = '$warehouse'";
  2652. }
  2653. if ($timetk && $timetj) {
  2654. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2655. }
  2656. if ($orderinfo) {
  2657. $where .= " and orderinfo = '$orderinfo'";
  2658. }
  2659. if ($number) {
  2660. $where .= " and number = '$number'";
  2661. }
  2662. if ($express) {
  2663. $where .= " and express = '$express'";
  2664. }
  2665. if ($waybill) {
  2666. $where .= " and waybill = '$waybill'";
  2667. }
  2668. if ($library) {
  2669. $where .= " and library = '$library'";
  2670. }
  2671. if ($print) {
  2672. $where .= " and print = '$print'";
  2673. }
  2674. if ($libraryconfirm) {
  2675. $where .= " and libraryconfirm = '$libraryconfirm'";
  2676. }
  2677. if ($state) {
  2678. $where .= " and state = '$state'";
  2679. }
  2680. if ($shop) {
  2681. $where .= " and shop = '$shop'";
  2682. }
  2683. if ($country) {
  2684. $where .= " and country = '$country'";
  2685. }
  2686. if ($sfxh != '') {
  2687. $where .= " and sfxh = '$sfxh'";
  2688. }
  2689. if ($so) {
  2690. $where .= " and shipremarks like '%$so%'";
  2691. }
  2692. if ($source) {
  2693. if ($source == '2d') {
  2694. $where .= " and source >= '2'";
  2695. } else {
  2696. $where .= " and source = '$source'";
  2697. }
  2698. }
  2699. if (isset($_SESSION['api'])) {
  2700. foreach ($user as $value) {
  2701. $fgshop .= " shop = " . $value . " or";
  2702. }
  2703. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2704. }
  2705. if ($orderurl) {
  2706. $url = $this->orderurl->read($orderurl);
  2707. $where .= " and link like '%" . $url['url'] . "%'";
  2708. }
  2709. //数据排序
  2710. $order_str = "librarytime desc";
  2711. if (empty($page)) {
  2712. $start = 0;
  2713. $perpage = 1;
  2714. } else {
  2715. $start = ($page - 1) * $perpage;
  2716. }
  2717. //取得信息列表
  2718. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2719. //格式化数据
  2720. foreach ($info_list as $key => $value) {
  2721. $shop = $this->shop->read($value['shop']);
  2722. $info_list[$key]['shop'] = $shop['shopname'];
  2723. $express = $this->express->read($value['express']);
  2724. $info_list[$key]['express'] = $express['servicename'];
  2725. $warehouse = $this->warehouse->read($value['type']);
  2726. $info_list[$key]['type'] = $warehouse['title'];
  2727. if ($value['librarytime'] == '0') {
  2728. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2729. } else {
  2730. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2731. }
  2732. }
  2733. $total = $this->$sj->find_count($where);
  2734. $pagenum = ceil($total / $perpage);
  2735. $over = $total - ($start + $perpage);
  2736. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2737. echo json_encode($rows);
  2738. exit;
  2739. }
  2740. $this->data['express'] = $this->express->find_all();
  2741. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2742. $this->data['wlshop'] = $wlshop;
  2743. $user = $this->user->get_api($_SESSION['api']);
  2744. $powerid = $this->power->read($user['power']);
  2745. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2746. $pid = '';
  2747. foreach ($powertext as $v) {
  2748. $pid .= " id = " . $v . " or";
  2749. }
  2750. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2751. $this->data['fullorderexcel'] = $fullorderexcel;
  2752. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2753. $this->data['orderurl'] = $orderurl;
  2754. $this->_Template('whlabel_toutorder', $this->data);
  2755. }
  2756. //tt出库
  2757. public function _aoutorder()
  2758. {
  2759. if (isset($_SESSION['api'])) {
  2760. $user = $this->user->get_api($_SESSION['api']);
  2761. $usp = $user;
  2762. $fgshop = "";
  2763. $sid = "";
  2764. $user = explode('|', trim($user['shop'], '|'));
  2765. foreach ($user as $value) {
  2766. $fgshop .= " shop = " . $value . " or";
  2767. $sid .= " id = " . $value . " or";
  2768. }
  2769. } else {
  2770. echo "请重新登录";
  2771. }
  2772. $post = $this->input->post(NULL, TRUE);
  2773. if (isset($post['page'])) {
  2774. $page = $this->input->post('page', true);
  2775. $perpage = $this->input->post('perpage', true);
  2776. $warehouse = $this->input->post('warehouse', true);
  2777. $xztime = $this->input->post('xztime', true);
  2778. $timetk = $this->input->post('timetkk', true);
  2779. $timetj = $this->input->post('timetjj', true);
  2780. $shop = $this->input->post('shop', true);
  2781. $source = $this->input->post('source', true);
  2782. $orderinfo = $this->input->post('orderinfo', true);
  2783. $number = $this->input->post('number', true);
  2784. $sfxh = $this->input->post('sfxh', true);
  2785. $express = $this->input->post('express', true);
  2786. $waybill = $this->input->post('waybill', true);
  2787. $library = $this->input->post('library', true);
  2788. $country = $this->input->post('country', true);
  2789. $so = $this->input->post('so', true);
  2790. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2791. $print = $this->input->post('print', true);
  2792. $state = $this->input->post('state', true);
  2793. $orderurl = $this->input->post('orderurl', true);
  2794. $timetk = strtotime($timetk);
  2795. $timetj = strtotime($timetj);
  2796. /**
  2797. $sj = $this->input->post('sj',true);
  2798. if($sj)
  2799. {
  2800. $sj = $this->input->post('sj',true);
  2801. }
  2802. else
  2803. {
  2804. $sj = "fullorder";
  2805. }
  2806. **/
  2807. $sj = "fullorderamz";
  2808. $where = "1=1";
  2809. if ($warehouse) {
  2810. $where .= " and type = '$warehouse'";
  2811. }
  2812. if ($timetk && $timetj) {
  2813. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2814. }
  2815. if ($orderinfo) {
  2816. $where .= " and orderinfo = '$orderinfo'";
  2817. }
  2818. if ($number) {
  2819. $where .= " and number = '$number'";
  2820. }
  2821. if ($express) {
  2822. $where .= " and express = '$express'";
  2823. }
  2824. if ($waybill) {
  2825. $where .= " and waybill = '$waybill'";
  2826. }
  2827. if ($library) {
  2828. $where .= " and library = '$library'";
  2829. }
  2830. if ($print) {
  2831. $where .= " and print = '$print'";
  2832. }
  2833. if ($libraryconfirm) {
  2834. $where .= " and libraryconfirm = '$libraryconfirm'";
  2835. }
  2836. if ($state) {
  2837. $where .= " and state = '$state'";
  2838. }
  2839. if ($shop) {
  2840. $where .= " and shop = '$shop'";
  2841. }
  2842. if ($country) {
  2843. $where .= " and country = '$country'";
  2844. }
  2845. if ($sfxh != '') {
  2846. $where .= " and sfxh = '$sfxh'";
  2847. }
  2848. if ($so) {
  2849. $where .= " and shipremarks like '%$so%'";
  2850. }
  2851. if ($source) {
  2852. if ($source == '2d') {
  2853. $where .= " and source >= '2'";
  2854. } else {
  2855. $where .= " and source = '$source'";
  2856. }
  2857. }
  2858. if (isset($_SESSION['api'])) {
  2859. foreach ($user as $value) {
  2860. $fgshop .= " shop = " . $value . " or";
  2861. }
  2862. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2863. }
  2864. if ($orderurl) {
  2865. $url = $this->orderurl->read($orderurl);
  2866. $where .= " and link like '%" . $url['url'] . "%'";
  2867. }
  2868. //数据排序
  2869. $order_str = "librarytime desc";
  2870. if (empty($page)) {
  2871. $start = 0;
  2872. $perpage = 1;
  2873. } else {
  2874. $start = ($page - 1) * $perpage;
  2875. }
  2876. //取得信息列表
  2877. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2878. //格式化数据
  2879. foreach ($info_list as $key => $value) {
  2880. $shop = $this->shop->read($value['shop']);
  2881. $info_list[$key]['shop'] = $shop['shopname'];
  2882. $express = $this->express->read($value['express']);
  2883. $info_list[$key]['express'] = $express['servicename'];
  2884. $warehouse = $this->warehouse->read($value['type']);
  2885. $info_list[$key]['type'] = $warehouse['title'];
  2886. if ($value['librarytime'] == '0') {
  2887. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2888. } else {
  2889. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2890. }
  2891. }
  2892. $total = $this->$sj->find_count($where);
  2893. $pagenum = ceil($total / $perpage);
  2894. $over = $total - ($start + $perpage);
  2895. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2896. echo json_encode($rows);
  2897. exit;
  2898. }
  2899. $this->data['express'] = $this->express->find_all();
  2900. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2901. $this->data['wlshop'] = $wlshop;
  2902. $user = $this->user->get_api($_SESSION['api']);
  2903. $powerid = $this->power->read($user['power']);
  2904. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2905. $pid = '';
  2906. foreach ($powertext as $v) {
  2907. $pid .= " id = " . $v . " or";
  2908. }
  2909. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2910. $this->data['fullorderexcel'] = $fullorderexcel;
  2911. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2912. $this->data['orderurl'] = $orderurl;
  2913. $this->_Template('whlabel_aoutorder', $this->data);
  2914. }
  2915. //速卖通出库订单
  2916. public function _soutorder()
  2917. {
  2918. if (isset($_SESSION['api'])) {
  2919. $user = $this->user->get_api($_SESSION['api']);
  2920. $usp = $user;
  2921. $fgshop = "";
  2922. $sid = "";
  2923. $user = explode('|', trim($user['shop'], '|'));
  2924. foreach ($user as $value) {
  2925. $sid .= " id = " . $value . " or";
  2926. }
  2927. }
  2928. $post = $this->input->post(NULL, TRUE);
  2929. if (isset($post['page'])) {
  2930. $page = $this->input->post('page', true);
  2931. $perpage = $this->input->post('perpage', true);
  2932. $warehouse = $this->input->post('warehouse', true);
  2933. $xztime = $this->input->post('xztime', true);
  2934. $timetk = $this->input->post('timetkk', true);
  2935. $timetj = $this->input->post('timetjj', true);
  2936. $shop = $this->input->post('shop', true);
  2937. $source = $this->input->post('source', true);
  2938. $orderinfo = $this->input->post('orderinfo', true);
  2939. $number = $this->input->post('number', true);
  2940. $express = $this->input->post('express', true);
  2941. $waybill = $this->input->post('waybill', true);
  2942. $library = $this->input->post('library', true);
  2943. $country = $this->input->post('country', true);
  2944. $sfxh = $this->input->post('sfxh', true);
  2945. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2946. $print = $this->input->post('print', true);
  2947. $state = $this->input->post('state', true);
  2948. $so = $this->input->post('so', true);
  2949. $timetk = strtotime($timetk);
  2950. $timetj = strtotime($timetj);
  2951. /**
  2952. $sj = $this->input->post('sj',true);
  2953. if($sj)
  2954. {
  2955. $sj = $this->input->post('sj',true);
  2956. }
  2957. else
  2958. {
  2959. $sj = "fullorder";
  2960. }
  2961. **/
  2962. $sj = "fullordersmt";
  2963. $where = "1=1";
  2964. if ($warehouse) {
  2965. $where .= " and type = '$warehouse'";
  2966. }
  2967. if ($timetk && $timetj) {
  2968. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2969. }
  2970. if ($orderinfo) {
  2971. $where .= " and orderinfo = '$orderinfo'";
  2972. }
  2973. if ($number) {
  2974. $where .= " and number = '$number'";
  2975. }
  2976. if ($express) {
  2977. $where .= " and express = '$express'";
  2978. }
  2979. if ($waybill) {
  2980. $where .= " and waybill = '$waybill'";
  2981. }
  2982. if ($library) {
  2983. $where .= " and library = '$library'";
  2984. }
  2985. if ($print) {
  2986. $where .= " and print = '$print'";
  2987. }
  2988. if ($libraryconfirm) {
  2989. $where .= " and libraryconfirm = '$libraryconfirm'";
  2990. }
  2991. if ($state) {
  2992. $where .= " and state = '$state'";
  2993. }
  2994. if ($shop) {
  2995. $where .= " and shop = '$shop'";
  2996. }
  2997. if ($sfxh != '') {
  2998. $where .= " and sfxh = '$sfxh'";
  2999. }
  3000. if ($so) {
  3001. $where .= " and shipremarks like '%$so%'";
  3002. }
  3003. if ($source) {
  3004. $where .= " and source = '$source'";
  3005. }
  3006. if ($country) {
  3007. $where .= " and country = '$country'";
  3008. } else {
  3009. if (isset($_SESSION['api'])) {
  3010. foreach ($user as $value) {
  3011. $fgshop .= " shop = " . $value . " or";
  3012. }
  3013. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3014. }
  3015. }
  3016. //数据排序
  3017. $order_str = "librarytime desc";
  3018. if (empty($page)) {
  3019. $start = 0;
  3020. $perpage = 1;
  3021. } else {
  3022. $start = ($page - 1) * $perpage;
  3023. }
  3024. //取得信息列表
  3025. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3026. //格式化数据
  3027. foreach ($info_list as $key => $value) {
  3028. $shop = $this->shop->read($value['shop']);
  3029. $info_list[$key]['shop'] = $shop['shopname'];
  3030. $express = $this->express->read($value['express']);
  3031. $info_list[$key]['express'] = $express['servicename'];
  3032. $warehouse = $this->warehouse->read($value['type']);
  3033. $info_list[$key]['type'] = $warehouse['title'];
  3034. if ($value['librarytime'] == '0') {
  3035. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3036. } else {
  3037. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3038. }
  3039. }
  3040. $total = $this->$sj->find_count($where);
  3041. $pagenum = ceil($total / $perpage);
  3042. $over = $total - ($start + $perpage);
  3043. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3044. echo json_encode($rows);
  3045. exit;
  3046. }
  3047. $this->data['express'] = $this->express->find_all();
  3048. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3049. $this->data['wlshop'] = $wlshop;
  3050. $user = $this->user->get_api($_SESSION['api']);
  3051. $powerid = $this->power->read($user['power']);
  3052. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3053. $pid = '';
  3054. foreach ($powertext as $v) {
  3055. $pid .= " id = " . $v . " or";
  3056. }
  3057. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3058. $this->data['fullorderexcel'] = $fullorderexcel;
  3059. $this->_Template('whlabel_soutorder', $this->data);
  3060. }
  3061. //订单退库
  3062. public function _retreat()
  3063. {
  3064. $post = $this->input->post(NULL, TRUE);
  3065. if (isset($post['page'])) {
  3066. $page = $this->input->post('page', true);
  3067. $perpage = $this->input->post('perpage', true);
  3068. $warehouse = $this->input->post('warehouse', true);
  3069. $timetk = $this->input->post('timetk', true);
  3070. $timetj = $this->input->post('timetj', true);
  3071. $shop = $this->input->post('shop', true);
  3072. $source = $this->input->post('source', true);
  3073. $state = $this->input->post('state', true);
  3074. $review = $this->input->post('review', true);
  3075. $state = $this->input->post('state', true);
  3076. $express = $this->input->post('express', true);
  3077. $orderinfo = $this->input->post('orderinfo', true);
  3078. $user = $this->input->post('user', true);
  3079. $name = $this->input->post('name', true);
  3080. $waybill = $this->input->post('waybill', true);
  3081. $timetk = strtotime($timetk);
  3082. $timetj = strtotime($timetj);
  3083. $where = "(state=206 or state=210) and mergeid = 0";
  3084. if ($warehouse) {
  3085. $where .= " and state = '$warehouse'";
  3086. }
  3087. if ($timetk && $timetj) {
  3088. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3089. }
  3090. if ($shop) {
  3091. $where .= " and shop = '$shop'";
  3092. }
  3093. if ($source) {
  3094. $where .= " and source = '$source'";
  3095. }
  3096. if ($state) {
  3097. $where .= " and state = '$state'";
  3098. }
  3099. if ($review) {
  3100. $where .= " and review = '$review'";
  3101. }
  3102. if ($state) {
  3103. $where .= " and state = '$state'";
  3104. }
  3105. if ($express) {
  3106. $where .= " and express = '$express'";
  3107. }
  3108. if ($orderinfo) {
  3109. $where .= " and orderinfo = '$orderinfo'";
  3110. }
  3111. if ($user) {
  3112. $where .= " and user = '$user'";
  3113. }
  3114. if ($name) {
  3115. $where .= " and name = '$name'";
  3116. }
  3117. if ($waybill) {
  3118. $where .= " and waybill = '$waybill'";
  3119. }
  3120. //数据排序
  3121. $order_str = "id desc";
  3122. if (empty($page)) {
  3123. $start = 0;
  3124. $perpage = 1;
  3125. } else {
  3126. $start = ($page - 1) * $perpage;
  3127. }
  3128. //取得信息列表
  3129. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3130. //格式化数据
  3131. foreach ($info_list as $key => $value) {
  3132. $shop = $this->shop->read($value['shop']);
  3133. $info_list[$key]['shop'] = $shop['shopname'];
  3134. $warehouse = $this->warehouse->read($value['warehouse']);
  3135. $info_list[$key]['warehouse'] = $warehouse['title'];
  3136. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3137. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3138. if ($value['waybill'] == 0) {
  3139. $info_list[$key]['waybill'] = "";
  3140. }
  3141. $express = $this->express->read($value['express']);
  3142. $info_list[$key]['express'] = $express['title'];
  3143. $typeclass = $this->typeclass->read($value['state']);
  3144. $info_list[$key]['state'] = $typeclass['title'];
  3145. }
  3146. $total = $this->fullorder->find_count($where);
  3147. $pagenum = ceil($total / $perpage);
  3148. $over = $total - ($start + $perpage);
  3149. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3150. echo json_encode($rows);
  3151. exit;
  3152. }
  3153. $this->data['express'] = $this->express->find_all();
  3154. $this->_Template('whlabel_retreat', $this->data);
  3155. }
  3156. //退库标签浏览
  3157. public function _retreatlk()
  3158. {
  3159. $post = $this->input->post(NULL, TRUE);
  3160. if (isset($post['page'])) {
  3161. $page = $this->input->post('page', true);
  3162. $perpage = $this->input->post('perpage', true);
  3163. $timetk = $this->input->post('timetk', true);
  3164. $timetj = $this->input->post('timetj', true);
  3165. $sku = $this->input->post('sku', true);
  3166. $warehouse = $this->input->post('warehouse', true);
  3167. $purchase = $this->input->post('purchase', true);
  3168. $orderinfo = $this->input->post('orderinfo', true);
  3169. $waybill = $this->input->post('waybill', true);
  3170. $category = $this->input->post('category', true);
  3171. $size = $this->input->post('size', true);
  3172. $grade = $this->input->post('grade', true);
  3173. $color = $this->input->post('color', true);
  3174. $lowe = $this->input->post('lowe', true);
  3175. $state = $this->input->post('state', true);
  3176. $timetk = strtotime($timetk);
  3177. $timetj = strtotime($timetj);
  3178. $where = "state=2";
  3179. if ($timetk && $timetj) {
  3180. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3181. }
  3182. if ($sku) {
  3183. $where .= " and sku = '$sku'";
  3184. }
  3185. if ($warehouse) {
  3186. $where .= " and warehouse = '$warehouse'";
  3187. }
  3188. if ($purchase) {
  3189. $where .= " and purchase = '$purchase'";
  3190. }
  3191. if ($orderinfo) {
  3192. $where .= " and orderinfo = '$orderinfo'";
  3193. }
  3194. if ($waybill) {
  3195. $where .= " and waybill = '$waybill'";
  3196. }
  3197. if ($category) {
  3198. $where .= " and features like '%-$category-%'";
  3199. }
  3200. if ($size) {
  3201. $where .= " and features like '%-$size-%'";
  3202. }
  3203. if ($grade) {
  3204. $where .= " and features like '%-$grade-%'";
  3205. }
  3206. if ($color) {
  3207. $where .= " and features like '%-$color-%'";
  3208. }
  3209. if ($lowe) {
  3210. $where .= " and features like '%-$lowe-%'";
  3211. }
  3212. //数据排序
  3213. $order_str = "time desc";
  3214. if (empty($page)) {
  3215. $start = 0;
  3216. $perpage = 1;
  3217. } else {
  3218. $start = ($page - 1) * $perpage;
  3219. }
  3220. //取得信息列表
  3221. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3222. foreach ($info_list as $key => $value) {
  3223. $warehouse = $this->warehouse->read($value['warehouse']);
  3224. $info_list[$key]['warehouse'] = $warehouse['title'];
  3225. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3226. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3227. $purchase = $this->purchase->read($value['purchase']);
  3228. $info_list[$key]['purchase'] = $purchase['title'];
  3229. if ($value['outk'] != 0) {
  3230. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3231. } else {
  3232. $info_list[$key]['outk'] = "";
  3233. }
  3234. if ($value['retreat'] != 0) {
  3235. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3236. } else {
  3237. $info_list[$key]['retreat'] = "";
  3238. }
  3239. if ($value['orderinfo'] == 0) {
  3240. $info_list[$key]['orderinfo'] = "";
  3241. }
  3242. if ($value['waybill'] == 0) {
  3243. $info_list[$key]['waybill'] = "";
  3244. }
  3245. }
  3246. $total = $this->whlabel->find_count($where);
  3247. $pagenum = ceil($total / $perpage);
  3248. $over = $total - ($start + $perpage);
  3249. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3250. echo json_encode($rows);
  3251. exit;
  3252. }
  3253. $this->_Template('whlabel_retreatlk', $this->data);
  3254. }
  3255. //更换标签及浏览
  3256. public function _change()
  3257. {
  3258. $post = $this->input->post(NULL, TRUE);
  3259. if (isset($post['page'])) {
  3260. $page = $this->input->post('page', true);
  3261. $perpage = $this->input->post('perpage', true);
  3262. $timetk = $this->input->post('timetk', true);
  3263. $timetj = $this->input->post('timetj', true);
  3264. $label = $this->input->post('label', true);
  3265. $oldlabel = $this->input->post('oldlabel', true);
  3266. $timetk = strtotime($timetk);
  3267. $timetj = strtotime($timetj);
  3268. $where = "state=10 ";
  3269. if ($timetk && $timetj) {
  3270. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3271. }
  3272. if ($label) {
  3273. $where .= " and label = '$label'";
  3274. }
  3275. if ($oldlabel) {
  3276. $where .= " and oldlabel = '$oldlabel'";
  3277. }
  3278. //数据排序
  3279. $order_str = "time asc";
  3280. if (empty($page)) {
  3281. $start = 0;
  3282. $perpage = 1;
  3283. } else {
  3284. $start = ($page - 1) * $perpage;
  3285. }
  3286. //取得信息列表
  3287. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3288. foreach ($info_list as $key => $value) {
  3289. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3290. }
  3291. $total = $this->whlabel->find_count($where);
  3292. $pagenum = ceil($total / $perpage);
  3293. $over = $total - ($start + $perpage);
  3294. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3295. echo json_encode($rows);
  3296. exit;
  3297. }
  3298. $this->_Template('whlabel_change', $this->data);
  3299. }
  3300. //产品标签
  3301. public function _cpbqdc()
  3302. {
  3303. if (isset($_GET['excel'])) {
  3304. $where = "1=1";
  3305. //数据排序
  3306. $order_str = "id desc";
  3307. if (empty($page)) {
  3308. $start = 0;
  3309. $perpage = 1;
  3310. } else {
  3311. $start = ($page - 1) * $perpage;
  3312. }
  3313. $warehouse = $this->input->get('warehouse', true);
  3314. $state = $this->input->get('state', true);
  3315. $timetk = $this->input->get('timetkk', true);
  3316. $timetj = $this->input->get('timetjj', true);
  3317. $timetk = strtotime($timetk);
  3318. $timetj = strtotime($timetj);
  3319. if ($warehouse) {
  3320. $where .= " and warehouse = '$warehouse'";
  3321. }
  3322. if ($state || $state == 0) {
  3323. $where .= " and state = '$state'";
  3324. }
  3325. if ($timetk && $timetj) {
  3326. $where .= " and time > '$timetk' and time < '$timetj'";
  3327. }
  3328. //取得信息列表
  3329. $info_list = $this->whlabel->find_all($where, '*');
  3330. $rows = array();
  3331. $list = array();
  3332. foreach ($info_list as $key => $value) {
  3333. $rows[$value['time']] = $value; //所有数据sku
  3334. }
  3335. foreach ($rows as $value) {
  3336. $warehouse = $this->warehouse->read($value['warehouse']);
  3337. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3338. $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);
  3339. }
  3340. $title = "产品标签统计表";
  3341. $titlename = "<table border=1>
  3342. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3343. <tr align='center'>
  3344. <td>仓库</td>
  3345. <td>SKU</td>
  3346. <td>产品</td>
  3347. <td>入库时间</td>
  3348. <td>操作时间</td>
  3349. <td>备注</td>
  3350. <td>数量</td>
  3351. </tr>
  3352. </table>";
  3353. $filename = $title . ".xls";
  3354. $tail = "";
  3355. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3356. }
  3357. }
  3358. //进销存导出
  3359. public function _exceljxc()
  3360. {
  3361. $classid = $this->classid->sku();
  3362. $pm = $classid;
  3363. $typeclass = array();
  3364. $tc = $this->typeclass->find_all();
  3365. foreach ($tc as $v) {
  3366. $typeclass[$v['id']] = $v;
  3367. }
  3368. $prc = array();
  3369. $purchase = $this->purchase->find_all();
  3370. foreach ($purchase as $k => $v) {
  3371. $prc[$v['id']] = $v['title'];
  3372. }
  3373. if (isset($_GET['excel'])) {
  3374. $where = "sku != 'Preset'";
  3375. //数据排序
  3376. $order_str = "id desc";
  3377. if (empty($page)) {
  3378. $start = 0;
  3379. $perpage = 1;
  3380. } else {
  3381. $start = ($page - 1) * $perpage;
  3382. }
  3383. $category = $this->input->get('category', true);
  3384. $warehouse = $this->input->get('warehouse', true);
  3385. $excelid = $this->input->get('sid', true);
  3386. if ($category) {
  3387. $where .= " and features like '%-$category-%'";
  3388. }
  3389. if ($warehouse) {
  3390. $where .= " and warehouse = '$warehouse'";
  3391. }
  3392. $xzid = '';
  3393. if ($excelid) {
  3394. $excelid = explode(',', trim($excelid, ','));
  3395. foreach ($excelid as $key => $value) {
  3396. $xzid .= " id = " . $value . " or";
  3397. }
  3398. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3399. }
  3400. //取得信息列表
  3401. /**
  3402. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3403. $rows = array();$list = array();
  3404. foreach ($info_list as $key=>$value)
  3405. {
  3406. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3407. }
  3408. **/
  3409. $wt = array();
  3410. $whlabel_type = $this->whlabel_type->find_all();
  3411. foreach ($whlabel_type as $v) {
  3412. $wt[$v['id']] = $v['title'];
  3413. }
  3414. $wh = array();
  3415. $w = $this->warehouse->find_all('1=1', 'id,title');
  3416. foreach ($w as $v) {
  3417. $wh[$v['id']] = $v['title'];
  3418. }
  3419. $list = array();
  3420. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3421. foreach ($rows as $key => $value) {
  3422. if (isset($wt[$value['type']])) {
  3423. $rows[$key]['type'] = $wt[$value['type']];
  3424. } else {
  3425. $rows[$key]['type'] = '未设置';
  3426. }
  3427. $bm = '03';
  3428. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3429. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3430. $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');
  3431. $details = array();
  3432. $cpid = array();
  3433. $cpbz = array();
  3434. $c = 0;
  3435. $g = 0;
  3436. $x = 0;
  3437. $t = 0;
  3438. $s = 0;
  3439. $q = 0;
  3440. foreach ($sd as $k => $v) {
  3441. if ($v['state'] == 0) {
  3442. $c++;
  3443. if ($v['cpid'] != 0) {
  3444. $cpid[$v['cpid']] = $v['cpid'];
  3445. }
  3446. if ($v['cpbz'] != '') {
  3447. $cpbz[$v['cpbz']] = $v['cpbz'];
  3448. }
  3449. }
  3450. if ($v['state'] != 9) {
  3451. $g++;
  3452. }
  3453. if ($v['state'] == 1) {
  3454. $x++;
  3455. }
  3456. if ($v['state'] == 2) {
  3457. $t++;
  3458. }
  3459. if ($v['state'] == 8) {
  3460. $s++;
  3461. }
  3462. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3463. $q++;
  3464. }
  3465. $details[$v['details']] = $v['details'];
  3466. }
  3467. $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'] . '"');
  3468. $rows[$key]['details'] = implode("、", $details);
  3469. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3470. $number = $value['number'];
  3471. $ftime = time() - 15 * 24 * 3600;
  3472. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3473. $rows[$key]['number'] = $g;
  3474. $rows[$key]['c'] = $c;
  3475. $rows[$key]['x'] = $x;
  3476. $rows[$key]['t'] = $t;
  3477. $rows[$key]['s'] = $s;
  3478. $rows[$key]['q'] = $q;
  3479. $rows[$key]['z'] = $z;
  3480. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3481. $features = explode('-', trim($features, '-'));
  3482. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3483. // $pm = $classid;
  3484. // $jm = $classid;
  3485. // foreach($features as $k=>$v)
  3486. // {
  3487. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3488. // {
  3489. // if($typeclass[$v]['bm'] != '')
  3490. // {
  3491. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3492. // }
  3493. // }
  3494. // if($v != 0)
  3495. // {
  3496. // if(!isset($typeclass[$v]))
  3497. // {
  3498. // continue;
  3499. // }
  3500. // if(isset($pm[$typeclass[$v]['classid']]))
  3501. // {
  3502. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3503. // {
  3504. // $tz = explode('|',$typeclass[$v]['zh']);
  3505. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3506. // }
  3507. // else
  3508. // {
  3509. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3510. // }
  3511. // }
  3512. // if(isset($jm[$typeclass[$v]['classid']]))
  3513. // {
  3514. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3515. // }
  3516. // }
  3517. // }
  3518. // $jm = array_filter($jm);
  3519. // $rows[$key]['bs'] = implode("-",$jm);
  3520. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3521. // $zh = implode(" ",$pm);
  3522. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3523. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3524. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3525. // $rows[$key]['features'] = $zh;
  3526. }
  3527. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3528. $final_list = [];
  3529. foreach ($list as $k => $v) {
  3530. if (empty($v['sku'])) {
  3531. continue;
  3532. }
  3533. $final_list[] = [
  3534. "warehouse" => $v["warehouse"],
  3535. "purchase" => $v["purchase"],
  3536. "details" => $v["details"],
  3537. "cpid" => $v["cpid"],
  3538. "dbcontent" => $v["dbcontent"],
  3539. "sku" => $v["sku"],
  3540. "cs" => $v["bm"],
  3541. "bs" => $v["jm"],
  3542. "title" => $v["title"],
  3543. "features" => $v["pm"],
  3544. "cpbz" => $v["cpbz"],
  3545. "sm" => $v["sm"],
  3546. "type" => $v["type"],
  3547. "number" => $v["number"],
  3548. "c" => $v["c"],
  3549. "x" => $v["x"],
  3550. "t" => $v["t"],
  3551. "s" => $v["s"],
  3552. "q" => $v["q"],
  3553. "z" => $v["z"],
  3554. "weight" => $v['weight'],
  3555. ];
  3556. }
  3557. $title = "总进销存统计表";
  3558. $titlename = "<table border=1>
  3559. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3560. <tr align='center'>
  3561. <td>仓库</td>
  3562. <td>供应商</td>
  3563. <td>位置</td>
  3564. <td>库存编码</td>
  3565. <td>类目</td>
  3566. <td>SKU</td>
  3567. <td>用友编码</td>
  3568. <td>用友料号</td>
  3569. <td>商品名称</td>
  3570. <td>商品中文</td>
  3571. <td>产品备注</td>
  3572. <td>说明</td>
  3573. <td>类型</td>
  3574. <td>入库总量</td>
  3575. <td>库存数量</td>
  3576. <td>销售数量</td>
  3577. <td>退货数量</td>
  3578. <td>删除数量</td>
  3579. <td>其它操作</td>
  3580. <td>占单数量</td>
  3581. <td>重量(g)</td>
  3582. </tr>
  3583. </table>";
  3584. $filename = $title . ".xls";
  3585. $tail = "";
  3586. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3587. }
  3588. }
  3589. //入库导出
  3590. public function _excelr()
  3591. {
  3592. if (isset($_GET['excel'])) {
  3593. $category = $this->input->get('category', true);
  3594. $size = $this->input->get('size', true);
  3595. $grade = $this->input->get('grade', true);
  3596. $color = $this->input->get('color', true);
  3597. $lowe = $this->input->get('lowe', true);
  3598. $sku = $this->input->get('sku', true);
  3599. $warehouse = $this->input->get('warehouse', true);
  3600. $purchase = $this->input->get('purchase', true);
  3601. $ktime = $this->input->get('ktime', true);
  3602. $jtime = $this->input->get('jtime', true);
  3603. $ktime = strtotime($ktime);
  3604. $jtime = strtotime($jtime);
  3605. $where = "1=1";
  3606. $gj = "";
  3607. $ck = "";
  3608. if ($category) {
  3609. $where .= " and features like '%-$category-%'";
  3610. }
  3611. if ($size) {
  3612. $where .= " and features like '%-$size-%'";
  3613. }
  3614. if ($grade) {
  3615. $where .= " and features like '%-$grade-%'";
  3616. }
  3617. if ($color) {
  3618. $where .= " and features like '%-$color-%'";
  3619. }
  3620. if ($lowe) {
  3621. $where .= " and features like '%-$lowe-%'";
  3622. }
  3623. if ($warehouse) {
  3624. $where .= " and warehouse = '$warehouse'";
  3625. }
  3626. if ($purchase) {
  3627. $where .= " and purchase = '$purchase'";
  3628. }
  3629. if ($sku) {
  3630. $where .= " and sku = '$sku'";
  3631. }
  3632. if ($ktime && $jtime) {
  3633. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3634. }
  3635. //数据排序
  3636. $order_str = "id desc";
  3637. if (empty($page)) {
  3638. $start = 0;
  3639. $perpage = 1;
  3640. } else {
  3641. $start = ($page - 1) * $perpage;
  3642. }
  3643. $list = array();
  3644. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3645. foreach ($rows as $value) {
  3646. $ck = $this->warehouse->read($value['warehouse']);
  3647. $warehouse = $ck['title'];
  3648. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3649. $retreatwarehouse = $tkck['title'];
  3650. $gy = $this->purchase->read($value['purchase']);
  3651. $purchase = $gy['title'];
  3652. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3653. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3654. }
  3655. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3656. $titlename = "<table border=1>
  3657. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3658. <tr align='center'>
  3659. <td>仓库</td>
  3660. <td>SKU</td>
  3661. <td>产品</td>
  3662. <td>时间</td>
  3663. <td>数量</td>
  3664. </tr>
  3665. </table>";
  3666. $filename = $title . ".xls";
  3667. $tail = "";
  3668. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3669. }
  3670. }
  3671. //出库、退库导出
  3672. public function _excelct()
  3673. {
  3674. $classid = $this->classid->sku();
  3675. $pm = $classid;
  3676. $typeclass = array();
  3677. $tc = $this->typeclass->find_all();
  3678. foreach ($tc as $v) {
  3679. $typeclass[$v['id']] = $v;
  3680. }
  3681. $prc = array();
  3682. $purchase = $this->purchase->find_all();
  3683. foreach ($purchase as $k => $v) {
  3684. $prc[$v['id']] = $v['title'];
  3685. }
  3686. if (isset($_GET['excel'])) {
  3687. $wh = array();
  3688. $w = $this->warehouse->find_all('1=1', 'id,title');
  3689. foreach ($w as $v) {
  3690. $wh[$v['id']] = $v['title'];
  3691. }
  3692. $type = $this->input->get('excel', true);
  3693. $category = $this->input->get('category', true);
  3694. $size = $this->input->get('size', true);
  3695. $grade = $this->input->get('grade', true);
  3696. $color = $this->input->get('color', true);
  3697. $lowe = $this->input->get('lowe', true);
  3698. $sku = $this->input->get('sku', true);
  3699. $title = $this->input->get('title', true);
  3700. $warehouse = $this->input->get('warehouse', true);
  3701. $purchase = $this->input->get('purchase', true);
  3702. $lacetype = $this->input->get('lacetype', true);
  3703. $haircap = $this->input->get('haircap', true);
  3704. $lacecolor = $this->input->get('lacecolor', true);
  3705. $density = $this->input->get('density', true);
  3706. $details = $this->input->get('details', true);
  3707. $state = $this->input->get('state', true);
  3708. $shop = $this->input->get('shop', true);
  3709. $hairnumber = $this->input->get('hairnumber', true);
  3710. $type_leixi = $this->input->get('type', true);
  3711. $cpbz = $this->input->get('cpbz', true);
  3712. $sm = $this->input->get('sm', true);
  3713. $sid = $this->input->get('sid', true);
  3714. $ktime = $this->input->get('ktime', true);
  3715. $jtime = $this->input->get('jtime', true);
  3716. $ktime = strtotime($ktime);
  3717. $jtime = strtotime($jtime);
  3718. //$where = " 1=1 ";
  3719. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3720. $where = " sku != '' ";
  3721. $gj = "";
  3722. $ck = "";
  3723. if ($category) {
  3724. $where .= " and features like '%-$category-%'";
  3725. }
  3726. if ($size) {
  3727. $where .= " and features like '%-$size-%'";
  3728. }
  3729. if ($grade) {
  3730. $where .= " and features like '%-$grade-%'";
  3731. }
  3732. if ($color) {
  3733. $where .= " and features like '%-$color-%'";
  3734. }
  3735. if ($lowe) {
  3736. $where .= " and features like '%-$lowe-%'";
  3737. }
  3738. if ($warehouse) {
  3739. $where .= " and warehouse = '$warehouse'";
  3740. }
  3741. if ($purchase) {
  3742. $where .= " and purchase = '$purchase'";
  3743. }
  3744. if ($state) {
  3745. $where .= " and state = '$state'";
  3746. }
  3747. if ($lacetype) {
  3748. $where .= " and features like '%-$lacetype-%'";
  3749. }
  3750. if ($lacecolor) {
  3751. $where .= " and features like '%-$lacecolor-%'";
  3752. }
  3753. if ($density) {
  3754. $where .= " and features like '%-$density-%'";
  3755. }
  3756. if ($haircap) {
  3757. $where .= " and features like '%-$haircap-%'";
  3758. }
  3759. if ($details) {
  3760. $where .= " and details = '$details'";
  3761. }
  3762. if ($shop) {
  3763. $where .= " and shop like '%$shop%'";
  3764. }
  3765. if ($title) {
  3766. $title = trim($title, ' ');
  3767. $title = trim($title, ' ');
  3768. $where .= " and title like '%$title%'";
  3769. }
  3770. if (!empty($hairnumber)) {
  3771. $where .= " and features like '%-128-%' ";
  3772. if ($hairnumber < 0) {
  3773. $class_list = $this->typeclass->find_all('classid = 43');
  3774. foreach ($class_list as $v) {
  3775. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3776. }
  3777. } else {
  3778. $where .= " and features like '%-$hairnumber-%'";
  3779. }
  3780. }
  3781. if ($type_leixi) {
  3782. $where .= " and type = '$type_leixi'";
  3783. }
  3784. if ($cpbz) {
  3785. $where .= " and cpbz like '%$cpbz%' ";
  3786. }
  3787. if ($sm) {
  3788. $where .= " and sm like '%$sm%' ";
  3789. }
  3790. if ($sku) {
  3791. $sku = trim($sku, ' ');
  3792. $sku = trim($sku, ' ');
  3793. $where .= " and sku like '%$sku%'";
  3794. }
  3795. if ($ktime && $jtime) {
  3796. if ($type == 1) {
  3797. $tl = '出库';
  3798. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3799. } else if ($type == 2) {
  3800. $tl = '退库';
  3801. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3802. } else if ($type == 3) {
  3803. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3804. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3805. } else if ($type == 4) {
  3806. $tl = '出库+零售';
  3807. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3808. } else if ($type == 5) {
  3809. $tl = '零售';
  3810. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3811. }
  3812. }
  3813. $sidwhere = '';
  3814. if ($sid) {
  3815. $sd = "";
  3816. $s = explode(',', trim($sid, ','));
  3817. foreach ($s as $value) {
  3818. $sd .= " id = " . $value . " or";
  3819. }
  3820. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3821. }
  3822. //数据排序
  3823. $order_str = "time desc";
  3824. if (empty($page)) {
  3825. $start = 0;
  3826. $perpage = 1;
  3827. } else {
  3828. $start = ($page - 1) * $perpage;
  3829. }
  3830. //取得信息列表
  3831. if ($type != 3 && $type != 5) {
  3832. if ($type == 1 || $type == 4) {
  3833. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3834. foreach ($info_list as $key => $value) {
  3835. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3836. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3837. $warehouse = $this->warehouse->read($value['warehouse']);
  3838. $info_list[$key]['warehouse'] = $warehouse['title'];
  3839. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3840. $features = explode('-', trim($features, '-'));
  3841. $pm = $classid;
  3842. foreach ($features as $k => $v) {
  3843. if ($v != 0) {
  3844. if (!isset($typeclass[$v])) {
  3845. continue;
  3846. }
  3847. if (isset($pm[$typeclass[$v]['classid']])) {
  3848. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3849. $tz = explode('|', $typeclass[$v]['zh']);
  3850. $pm[$typeclass[$v]['classid']] = $tz[0];
  3851. } else {
  3852. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3853. }
  3854. }
  3855. }
  3856. }
  3857. $zh = implode(" ", $pm);
  3858. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3859. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3860. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3861. $info_list[$key]['features'] = $zh;
  3862. }
  3863. $final_list = [];
  3864. foreach($info_list as $k=>$v){
  3865. $number = "";
  3866. if(!empty($v['orderinfo'])){
  3867. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3868. if(!empty($tmp_info['number'])){
  3869. $number = $tmp_info['number'];
  3870. }
  3871. }
  3872. $final_list[] = [
  3873. 'warehouse'=>$v['warehouse'],
  3874. 'purchase'=>$v['purchase'],
  3875. 'sku'=>$v['sku'],
  3876. 'title'=>$v['title'],
  3877. 'features'=>$v['features'],
  3878. 'label'=>$v['label'],
  3879. 'orderinfo'=>$v['orderinfo'],
  3880. 'number'=>$number,
  3881. 'waybill'=>$v['waybill'],
  3882. 'outk'=>$v['outk'],
  3883. ];
  3884. }
  3885. } else {
  3886. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3887. foreach ($info_list as $key => $value) {
  3888. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3889. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3890. $warehouse = $this->warehouse->read($value['warehouse']);
  3891. $info_list[$key]['warehouse'] = $warehouse['title'];
  3892. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3893. $features = explode('-', trim($features, '-'));
  3894. $pm = $classid;
  3895. foreach ($features as $k => $v) {
  3896. if ($v != 0) {
  3897. if (!isset($typeclass[$v])) {
  3898. continue;
  3899. }
  3900. if (isset($pm[$typeclass[$v]['classid']])) {
  3901. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3902. $tz = explode('|', $typeclass[$v]['zh']);
  3903. $pm[$typeclass[$v]['classid']] = $tz[0];
  3904. } else {
  3905. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3906. }
  3907. }
  3908. }
  3909. }
  3910. $zh = implode(" ", $pm);
  3911. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3912. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3913. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3914. $info_list[$key]['features'] = $zh;
  3915. }
  3916. $final_list = [];
  3917. foreach($info_list as $k=>$v){
  3918. $number = "";
  3919. if(!empty($v['orderinfo'])){
  3920. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3921. if(!empty($tmp_info['number'])){
  3922. $number = $tmp_info['number'];
  3923. }
  3924. }
  3925. $final_list[] = [
  3926. 'warehouse'=>$v['warehouse'],
  3927. 'purchase'=>$v['purchase'],
  3928. 'sku'=>$v['sku'],
  3929. 'title'=>$v['title'],
  3930. 'features'=>$v['features'],
  3931. 'label'=>$v['label'],
  3932. 'orderinfo'=>$v['orderinfo'],
  3933. 'number'=>$number,
  3934. 'waybill'=>$v['waybill'],
  3935. 'retreat'=>$v['retreat'],
  3936. ];
  3937. }
  3938. }
  3939. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3940. $titlename = "<table border=1>
  3941. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3942. <tr align='center'>
  3943. <td>仓库</td>
  3944. <td>供应商</td>
  3945. <td>SKU</td>
  3946. <td>商品名称</td>
  3947. <td>商品中文</td>
  3948. <td>标签</td>
  3949. <td>订单号</td>
  3950. <td>订单编码</td>
  3951. <td>运单号</td>
  3952. <td>" . $tl . "时间(中国时间)</td>
  3953. </tr>
  3954. </table>";
  3955. $filename = $title . ".xls";
  3956. $tail = "";
  3957. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3958. } else if ($type == 5) {
  3959. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3960. foreach ($info_list as $key => $value) {
  3961. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3962. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3963. $warehouse = $this->warehouse->read($value['warehouse']);
  3964. $info_list[$key]['warehouse'] = $warehouse['title'];
  3965. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3966. $features = explode('-', trim($features, '-'));
  3967. $pm = $classid;
  3968. foreach ($features as $k => $v) {
  3969. if ($v != 0) {
  3970. if (!isset($typeclass[$v])) {
  3971. continue;
  3972. }
  3973. if (isset($pm[$typeclass[$v]['classid']])) {
  3974. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3975. $tz = explode('|', $typeclass[$v]['zh']);
  3976. $pm[$typeclass[$v]['classid']] = $tz[0];
  3977. } else {
  3978. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3979. }
  3980. }
  3981. }
  3982. }
  3983. $zh = implode(" ", $pm);
  3984. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3985. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3986. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3987. $info_list[$key]['features'] = $zh;
  3988. }
  3989. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3990. $titlename = "<table border=1>
  3991. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3992. <tr align='center'>
  3993. <td>仓库</td>
  3994. <td>供应商</td>
  3995. <td>SKU</td>
  3996. <td>商品名称</td>
  3997. <td>商品中文</td>
  3998. <td>标签</td>
  3999. <td>" . $tl . "时间(中国时间)</td>
  4000. </tr>
  4001. </table>";
  4002. $filename = $title . ".xls";
  4003. $tail = "";
  4004. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4005. } else {
  4006. /**
  4007. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4008. $rows = array();$list = array();
  4009. foreach ($info_list as $key=>$value)
  4010. {
  4011. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4012. }
  4013. **/
  4014. $wh = array();
  4015. $w = $this->warehouse->find_all('1=1', 'id,title');
  4016. foreach ($w as $v) {
  4017. $wh[$v['id']] = $v['title'];
  4018. }
  4019. $wt = array();
  4020. $whlabel_type = $this->whlabel_type->find_all();
  4021. foreach ($whlabel_type as $v) {
  4022. $wt[$v['id']] = $v['title'];
  4023. }
  4024. $classid = $this->classid->sku();
  4025. $list = array();
  4026. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4027. foreach ($rows as $key => $value) {
  4028. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4029. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4030. $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');
  4031. $details = array();
  4032. $cpid = array();
  4033. $cpbz = array();
  4034. $c = 0;
  4035. $g = 0;
  4036. $x = 0;
  4037. $t = 0;
  4038. $s = 0;
  4039. $q = 0;
  4040. foreach ($sd as $k => $v) {
  4041. if ($v['state'] == 0) {
  4042. $c++;
  4043. }
  4044. if ($v['state'] != 9) {
  4045. $g++;
  4046. }
  4047. if ($v['outk'] > 1) {
  4048. $x++;
  4049. }
  4050. if ($v['retreat'] > 0) {
  4051. $t++;
  4052. }
  4053. if ($v['state'] == 8) {
  4054. $s++;
  4055. }
  4056. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4057. $q++;
  4058. }
  4059. $details[$v['details']] = $v['details'];
  4060. if ($v['cpid'] != 0) {
  4061. $cpid[$v['cpid']] = $v['cpid'];
  4062. }
  4063. if ($v['cpbz'] != '') {
  4064. $cpbz[$v['cpbz']] = $v['cpbz'];
  4065. }
  4066. }
  4067. if (isset($wt[$value['type']])) {
  4068. $rows[$key]['type'] = $wt[$value['type']];
  4069. } else {
  4070. $rows[$key]['type'] = '未设置';
  4071. }
  4072. $rows[$key]['details'] = implode("、", $details);
  4073. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4074. $ftime = time() - 15 * 24 * 3600;
  4075. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4076. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4077. $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);
  4078. $rows[$key]['c'] = $c;
  4079. $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);
  4080. $rows[$key]['t'] = $t;
  4081. $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'] . '"');
  4082. $rows[$key]['z'] = $z;
  4083. // $jm = $classid;
  4084. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4085. $features = explode('-', trim($features, '-'));
  4086. // $pm = $classid;
  4087. // foreach ($features as $k => $v) {
  4088. // if ($v != 0) {
  4089. // if (!isset($typeclass[$v])) {
  4090. // continue;
  4091. // }
  4092. // if (isset($pm[$typeclass[$v]['classid']])) {
  4093. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4094. // $tz = explode('|', $typeclass[$v]['zh']);
  4095. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4096. // } else {
  4097. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4098. // }
  4099. // if (isset($jm[$typeclass[$v]['classid']])) {
  4100. // if ($typeclass[$v]['jm']) {
  4101. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4102. // }
  4103. // }
  4104. // }
  4105. // }
  4106. // }
  4107. // $zh = implode(" ", $pm);
  4108. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4109. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4110. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4111. // $rows[$key]['features'] = $zh;
  4112. // $jm = array_filter($jm); //去除空值
  4113. // $jm = implode("-", $jm);
  4114. // $rows[$key]['jm'] = $jm;
  4115. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4116. }
  4117. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4118. // echo "<pre>";
  4119. // print_r($tmp_list);
  4120. // die;
  4121. $final_list =[];
  4122. foreach($tmp_list as $k=>$v){
  4123. $final_list[] = [
  4124. "warehouse"=>$v['warehouse'],
  4125. "purchase"=>$v['purchase'],
  4126. "details"=>$v['details'],
  4127. "cpid"=>$v['cpid'],
  4128. "sku"=>$v['sku'],
  4129. "title"=>$v['title'],
  4130. "features"=>$v['pm'],
  4131. "cpbz"=>$v['cpbz'],
  4132. "sm"=>$v['sm'],
  4133. "type"=>$v['type'],
  4134. "g"=>$v["g"],
  4135. "c"=>$v["c"],
  4136. "x"=>$v["x"],
  4137. "t"=>$v["t"],
  4138. "z"=>$v["z"],
  4139. "jm"=>$v["jm"],
  4140. "weight"=>$v["weight"],
  4141. "asd"=>$v["asd"],
  4142. ];
  4143. }
  4144. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4145. $titlename = "<table border=1>
  4146. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4147. <tr align='center'>
  4148. <td>仓库</td>
  4149. <td>供应商</td>
  4150. <td>位置</td>
  4151. <td>库存编码</td>
  4152. <td>SKU</td>
  4153. <td>商品名称</td>
  4154. <td>商品中文</td>
  4155. <td>产品备注</td>
  4156. <td>说明</td>
  4157. <td>类型</td>
  4158. <td>入库总量</td>
  4159. <td>库存数量</td>
  4160. <td>销售数量</td>
  4161. <td>退货数量</td>
  4162. <td>占单数量</td>
  4163. <td>料号</td>
  4164. <td>重量</td>
  4165. <td>类目</td>
  4166. </tr>
  4167. </table>";
  4168. $filename = $title . ".xls";
  4169. $tail = "";
  4170. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4171. }
  4172. }
  4173. }
  4174. //出库+入库数据整合
  4175. public function _excelcr()
  4176. {
  4177. if (isset($_GET['excel'])) {
  4178. $type = $this->input->get('excel', true);
  4179. $category = $this->input->get('category', true);
  4180. $size = $this->input->get('size', true);
  4181. $grade = $this->input->get('grade', true);
  4182. $color = $this->input->get('color', true);
  4183. $lowe = $this->input->get('lowe', true);
  4184. $sku = $this->input->get('sku', true);
  4185. $warehouse = $this->input->get('warehouse', true);
  4186. $purchase = $this->input->get('purchase', true);
  4187. $state = $this->input->get('state', true);
  4188. $sid = $this->input->get('sid', true);
  4189. $ktime = $this->input->get('ktime', true);
  4190. $jtime = $this->input->get('jtime', true);
  4191. $ktime = strtotime($ktime);
  4192. $jtime = strtotime($jtime);
  4193. $where = "1=1";
  4194. $gj = "";
  4195. $ck = "";
  4196. if ($category) {
  4197. $where .= " and features like '%-$category-%'";
  4198. }
  4199. if ($size) {
  4200. $where .= " and features like '%-$size-%'";
  4201. }
  4202. if ($grade) {
  4203. $where .= " and features like '%-$grade-%'";
  4204. }
  4205. if ($color) {
  4206. $where .= " and features like '%-$color-%'";
  4207. }
  4208. if ($lowe) {
  4209. $where .= " and features like '%-$lowe-%'";
  4210. }
  4211. if ($warehouse) {
  4212. $where .= " and warehouse = '$warehouse'";
  4213. }
  4214. if ($purchase) {
  4215. $where .= " and purchase = '$purchase'";
  4216. }
  4217. if ($state) {
  4218. $where .= " and state = '$state'";
  4219. }
  4220. if ($sku) {
  4221. $where .= " and sku like '%$sku%'";
  4222. }
  4223. if ($ktime && $jtime) {
  4224. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4225. }
  4226. $sidwhere = '';
  4227. if ($sid) {
  4228. $sd = "";
  4229. $s = explode(',', trim($sid, ','));
  4230. foreach ($s as $value) {
  4231. $sd .= " id = " . $value . " or";
  4232. }
  4233. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4234. }
  4235. //取得信息列表
  4236. $timeread = $ktime;
  4237. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4238. $timelist = array();
  4239. for ($i = 0; $i < $timenum; $i++) {
  4240. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4241. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4242. }
  4243. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4244. //echo "<pre>";
  4245. //print_r($info_list);
  4246. //exit();
  4247. $rows = array();
  4248. $list = array();
  4249. foreach ($info_list as $key => $value) {
  4250. $thistime = $timelist;
  4251. if (isset($rows[strtolower($value['sku'])])) {
  4252. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4253. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4254. }
  4255. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4256. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4257. }
  4258. } else {
  4259. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4260. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4261. }
  4262. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4263. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4264. }
  4265. $rows[strtolower($value['sku'])] = $thistime;
  4266. }
  4267. }
  4268. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4269. <head>
  4270. <!--[if gte mso 9]><xml>
  4271. <x:ExcelWorkbook>
  4272. <x:ExcelWorksheets>
  4273. <x:ExcelWorksheet>
  4274. <x:Name>EXCEL</x:Name>
  4275. <x:WorksheetOptions>
  4276. <x:Print>
  4277. <x:ValidPrinterInfo />
  4278. </x:Print>
  4279. </x:WorksheetOptions>
  4280. </x:ExcelWorksheet>
  4281. </x:ExcelWorksheets>
  4282. </x:ExcelWorkbook>
  4283. </xml>
  4284. <![endif]-->
  4285. </head><body>";
  4286. $str .= "<table border=1><tr><td>SKU</td>";
  4287. foreach ($timelist as $k => $v) {
  4288. $str .= "<td>" . $k . "出库</td>";
  4289. $str .= "<td>" . $k . "入库</td>";
  4290. }
  4291. $str .= "</tr></table>";
  4292. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4293. foreach ($rows as $key => $val) {
  4294. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4295. foreach ($val as $k => $v) {
  4296. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4297. if ($val[$k]['r'] > 0) {
  4298. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4299. } else {
  4300. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4301. }
  4302. }
  4303. $str .= "</tr>";
  4304. }
  4305. $str .= "</table>";
  4306. $str .= "</body></html>";
  4307. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4308. header("Content-type: application/octet-stream");
  4309. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4310. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4311. header("Pragma: no-cache");
  4312. header("Expires: 0");
  4313. exit($str);
  4314. }
  4315. }
  4316. //数量调整模板导出
  4317. public function _presetout()
  4318. {
  4319. if (isset($_GET['excel'])) {
  4320. $where = "sku != 'Preset' and purchase != 0";
  4321. //数据排序
  4322. $order_str = "id desc";
  4323. if (empty($page)) {
  4324. $start = 0;
  4325. $perpage = 1;
  4326. } else {
  4327. $start = ($page - 1) * $perpage;
  4328. }
  4329. //取得信息列表
  4330. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4331. $rows = array();
  4332. $list = array();
  4333. foreach ($info_list as $value) {
  4334. $warehouse = $this->warehouse->read($value['warehouse']);
  4335. $number = $value['number'];
  4336. $ftime = time() - 15 * 24 * 3600;
  4337. $purchase = $this->purchase->read($value['purchase']);
  4338. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4339. }
  4340. $title = "库存模板";
  4341. $titlename = "<table border=1>
  4342. <tr align='center'>
  4343. <td>仓库</td>
  4344. <td>供应商编码</td>
  4345. <td>SKU</td>
  4346. <td>增减数量(正数或负数)</td>
  4347. <td>增减备注</td>
  4348. <td>扣减方式:0减少库存1删除库存</td>
  4349. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4350. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4351. </tr>
  4352. </table>";
  4353. $filename = $title . ".xls";
  4354. $tail = "";
  4355. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4356. }
  4357. }
  4358. //数量调整模板导入
  4359. public function _presetedit()
  4360. {
  4361. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4362. $config['upload_path'] = '.' . $dir;
  4363. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4364. $config['allowed_types'] = 'xls|xlsx|csv';
  4365. $config['max_size'] = 10240;
  4366. $this->load->library('upload', $config);
  4367. $this->upload->initialize($config);
  4368. if ($this->upload->do_upload('userfile')) {
  4369. $full_path = $dir . $this->upload->data('file_name');
  4370. $fileName = '.' . $full_path;
  4371. if (!file_exists($fileName)) {
  4372. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4373. exit;
  4374. } else {
  4375. require_once "./data/excel/PHPExcel/IOFactory.php";
  4376. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4377. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4378. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4379. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4380. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4381. ++$column; //如果列数大于26行
  4382. $list = array();
  4383. for ($i = 2; $i <= $row; $i++) // 行数循环
  4384. {
  4385. $data = array();
  4386. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4387. {
  4388. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4389. }
  4390. $list[] = $data;
  4391. }
  4392. }
  4393. $i = 0;
  4394. $j = 0;
  4395. $ed = array();
  4396. foreach ($list as $key => $value) {
  4397. $time = time();
  4398. if ($value['0'] == "") {
  4399. continue;
  4400. }
  4401. $warehouse = $this->warehouse->get_title($value['0']);
  4402. $purchase = $this->purchase->get_bm($value['1']);
  4403. $sku = $value['2'];
  4404. $num = $value['3']; //调整数量
  4405. $text = $value['4']; //扣减说明
  4406. $type = $value['5']; //调整方式0扣减1删除
  4407. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4408. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4409. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4410. if (!$purchase) //如果没有这个SKU
  4411. {
  4412. $ed[] = array($purchase . '-不存在此供应商编码');
  4413. $j++;
  4414. continue;
  4415. }
  4416. if (!$d) //如果没有这个SKU
  4417. {
  4418. $ed[] = array($sku . '-库存中不存在此SKU');
  4419. $j++;
  4420. continue;
  4421. }
  4422. if (!isset($warehouse['id'])) {
  4423. $ed[] = array($sku . '-仓库名错误!');
  4424. $j++;
  4425. continue;
  4426. }
  4427. if ($type != '0' && $type != '1') {
  4428. $ed[] = array($sku . '-扣减方式填写错误!');
  4429. $j++;
  4430. continue;
  4431. }
  4432. if ($num < 0) //扣减库存
  4433. {
  4434. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4435. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4436. $j++;
  4437. continue;
  4438. }
  4439. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4440. if (count($data) < abs($num)) {
  4441. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4442. $j++;
  4443. continue;
  4444. }
  4445. if ($type == 0) //如果扣减方式为 扣减库存
  4446. {
  4447. for ($i = 0; $i < abs($num); $i++) {
  4448. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4449. }
  4450. } else if ($type == 1) {
  4451. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4452. if (count($zt) > 0) {
  4453. $ed[] = array($sku . '-有在途库存无法删除!');
  4454. $j++;
  4455. continue;
  4456. }
  4457. for ($i = 0; $i < abs($num); $i++) {
  4458. $this->whlabel->remove($data[$i]['id']);
  4459. }
  4460. }
  4461. } else if ($num > 0) //增加库存
  4462. {
  4463. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4464. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4465. $j++;
  4466. continue;
  4467. }
  4468. $post['sku'] = $d['sku'];
  4469. $post['shop'] = $d['shop'];
  4470. $post['warehouse'] = $warehouse['id'];
  4471. $post['purchase'] = $purchase['id'];
  4472. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4473. $post['state'] = 0;
  4474. $post['title'] = $d['title'];
  4475. $post['number'] = $d['number'];
  4476. $post['features'] = $d['features'];
  4477. $post['enter'] = $time;
  4478. $post['time'] = $time; //操作时间
  4479. $post['rktype'] = $rktype;
  4480. for ($i = 0; $i < $num; $i++) {
  4481. $post['label'] = time() . rand(100, 999) . $i;
  4482. $this->whlabel->insert($post);
  4483. }
  4484. }
  4485. sleep(1); //防止入库时间一样,需要延迟1秒
  4486. }
  4487. if ($j > 0) {
  4488. $tt = date('Ymd', time());
  4489. $title = '库存导入错误信息-' . $tt;
  4490. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4491. $tail = "\n";
  4492. $filename = $title . ".xls";
  4493. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4494. $dir = '/data/excel/' . $time . '/';
  4495. $file_name = 'error_' . $time . rand(1000, 9999);
  4496. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4497. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4498. fwrite($myfile, $ecl);
  4499. fclose($myfile);
  4500. $error = $dir . $file_name . '.xls';
  4501. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4502. exit;
  4503. } else {
  4504. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4505. exit;
  4506. }
  4507. }
  4508. }
  4509. //笛卡儿积
  4510. function cp($ps, $sets, $list)
  4511. {
  4512. $result = array();
  4513. $j = 0;
  4514. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4515. if ($i == 0) {
  4516. $result = $sets[$i];
  4517. }
  4518. $tmp = array();
  4519. foreach ($result as $res) {
  4520. foreach ($sets[$i + 1] as $set) {
  4521. $tmp[] = $res . ',' . $set;
  4522. }
  4523. }
  4524. $result = $tmp;
  4525. }
  4526. $this->db->trans_begin();
  4527. foreach ($result as $v) {
  4528. $post = array();
  4529. $title = "";
  4530. $num = "";
  4531. $data = explode(',', $v);
  4532. for ($i = 0; $i < count($list); $i++) {
  4533. $post[$list[$i]] = $data[$i];
  4534. $typeclass = $this->typeclass->read($data[$i]);
  4535. $title = $title . $typeclass['title'] . " ";
  4536. if ($data[$i] != 0) {
  4537. $num .= $data[$i]; //所有数据ID拼接
  4538. }
  4539. }
  4540. foreach ($ps as $kp => $vp) {
  4541. $post[$kp] = $vp;
  4542. }
  4543. $post['number'] = $num;
  4544. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4545. if ($info_list) {
  4546. $j++;
  4547. } else {
  4548. $skunum = $this->whlabel->find_count();
  4549. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4550. $post['title'] = rtrim($title, ' ');
  4551. $this->whlabel->insert($post);
  4552. }
  4553. }
  4554. if ($this->db->trans_status() === FALSE) {
  4555. $this->db->trans_commit();
  4556. return NULL;
  4557. } else {
  4558. $this->db->trans_commit();
  4559. return $j;
  4560. }
  4561. }
  4562. public function _kj($arg_array)
  4563. {
  4564. if (isset($_POST['sku'])) {
  4565. $time = time();
  4566. $sku = $this->input->post('sku', true);
  4567. $warehouse = $this->input->post('warehouse', true);
  4568. $num = $this->input->post('num', true);
  4569. $text = $this->input->post('text', true);
  4570. $purchase = $this->input->post('purchase', true);
  4571. $cktype = $this->input->post('cktype', true);
  4572. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4573. if ($cktype != 1 && $text == '') {
  4574. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4575. exit;
  4576. }
  4577. if ($num > count($order)) {
  4578. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4579. exit;
  4580. } else {
  4581. for ($i = 0; $i < $num; $i++) {
  4582. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4583. }
  4584. }
  4585. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4586. exit;
  4587. }
  4588. $uid = $this->whlabel->read($arg_array[0]);
  4589. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4590. $this->data['data'] = $uid;
  4591. $this->_Template('whlabel_kj', $this->data);
  4592. }
  4593. public function _summary($arg_array)
  4594. {
  4595. $prc = array();
  4596. $purchase = $this->purchase->find_all();
  4597. foreach ($purchase as $k => $v) {
  4598. $prc[$v['id']] = $v['title'];
  4599. }
  4600. if (isset($_GET['excel'])) {
  4601. $ktime = $this->input->get('ktime', true);
  4602. $jtime = $this->input->get('jtime', true);
  4603. $ktime = strtotime($ktime);
  4604. $jtime = strtotime($jtime);
  4605. $where = "1=1";
  4606. if ($ktime && $jtime) {
  4607. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4608. }
  4609. //数据排序
  4610. $order_str = "time desc";
  4611. if (empty($page)) {
  4612. $start = 0;
  4613. $perpage = 1;
  4614. } else {
  4615. $start = ($page - 1) * $perpage;
  4616. }
  4617. //取得信息列表
  4618. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4619. foreach ($info_list as $key => $value) {
  4620. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4621. $warehouse = $this->warehouse->read($value['warehouse']);
  4622. $info_list[$key]['warehouse'] = $warehouse['title'];
  4623. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4624. $details = array();
  4625. $cpid = array();
  4626. foreach ($x as $k => $v) {
  4627. if ($v['details'] != '') {
  4628. $details[$v['details']] = $v['details'];
  4629. }
  4630. if ($v['cpid'] != 0) {
  4631. $cpid[$v['cpid']] = $v['cpid'];
  4632. }
  4633. }
  4634. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4635. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4636. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4637. $info_list[$key]['s'] = $s;
  4638. $info_list[$key]['x'] = count($x);
  4639. }
  4640. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4641. $titlename = "<table border=1>
  4642. <tr align='center'>
  4643. <td>仓库</td>
  4644. <td>供应商</td>
  4645. <td>出库位置</td>
  4646. <td>出库编码</td>
  4647. <td>SKU</td>
  4648. <td>产品名</td>
  4649. <td>总剩余库存</td>
  4650. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4651. </tr>
  4652. </table>";
  4653. $filename = $title . ".xls";
  4654. $tail = "";
  4655. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4656. }
  4657. }
  4658. //usps发货清单
  4659. public function _manifest()
  4660. {
  4661. if (isset($_POST['manifest'])) {
  4662. $wltext = $this->input->post('wltext', true);
  4663. $time = time() - 16 * 3600;
  4664. $ptime = strtotime(date('Y-m-d', $time));
  4665. $waybill = array();
  4666. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4667. foreach ($fullorder as $v) {
  4668. $waybill[$v['waybill']] = $v['waybill'];
  4669. }
  4670. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4671. foreach ($fullordersmt as $v) {
  4672. $waybill[$v['waybill']] = $v['waybill'];
  4673. }
  4674. $wltext = explode(';', $wltext);
  4675. foreach ($wltext as $v) {
  4676. if (isset($waybill[$v])) {
  4677. unset($waybill[$v]);
  4678. }
  4679. }
  4680. $data = $this->usps->get_manifest($waybill);
  4681. if (isset($data['Description'])) {
  4682. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4683. exit;
  4684. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4685. $bctime = date('Ymd', time());
  4686. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4687. echo json_encode(array('msg' => $pdf, 'success' => true));
  4688. exit;
  4689. } else {
  4690. echo json_encode(array('msg' => $data, 'success' => false));
  4691. exit;
  4692. }
  4693. }
  4694. }
  4695. public function _pdf($pdf, $title, $bctime)
  4696. {
  4697. $pdf_path = './data/pdf/' . $bctime . '/';
  4698. $file_base64 = $pdf;
  4699. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4700. $file_base64 = base64_decode($file_base64);
  4701. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4702. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4703. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4704. }
  4705. /**
  4706. *
  4707. *
  4708. *
  4709. 进销存占单异常索引
  4710. *
  4711. *
  4712. *
  4713. **/
  4714. public function _abnormal()
  4715. {
  4716. $post = $this->input->post(NULL, TRUE);
  4717. if (isset($post['page'])) {
  4718. $page = $this->input->post('page', true);
  4719. $perpage = $this->input->post('perpage', true);
  4720. $sku = $this->input->post('sku', true);
  4721. $where = "1=1";
  4722. //数据排序
  4723. $order_str = "id desc";
  4724. if (empty($page)) {
  4725. $start = 0;
  4726. $perpage = 1;
  4727. } else {
  4728. $start = ($page - 1) * $perpage;
  4729. }
  4730. //取得信息列表
  4731. $info_list = $this->whlabel->find_all($where, '*');
  4732. $rows = array();
  4733. $list = array();
  4734. foreach ($info_list as $key => $value) {
  4735. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4736. }
  4737. foreach ($rows as $value) {
  4738. $warehouse = $this->warehouse->read($value['warehouse']);
  4739. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4740. $number = $value['number'];
  4741. $ftime = time() - 15 * 24 * 3600;
  4742. if ($value['shop'] != '') {
  4743. $shop = $value['shop'];
  4744. $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');
  4745. $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');
  4746. $order = array_merge($orderdlz, $ordersmt);
  4747. $od = 0;
  4748. $a = '';
  4749. $orid = '';
  4750. foreach ($order as $v) {
  4751. $or = explode('|', ltrim($v['whlabel'], '|'));
  4752. for ($i = 0; $i < count($or); $i++) {
  4753. $orod = explode('-', $or[$i]);
  4754. if ($orod[0] == $number) {
  4755. $od += $orod[1];
  4756. }
  4757. }
  4758. $orid .= $v['number'] . '-';
  4759. }
  4760. } else {
  4761. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4762. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4763. $order = array_merge($orderdlz, $ordersmt);
  4764. $od = 0;
  4765. $a = '';
  4766. $orid = '';
  4767. $qt = array();
  4768. foreach ($order as $v) {
  4769. $or = explode('|', ltrim($v['whlabel'], '|'));
  4770. for ($i = 0; $i < count($or); $i++) {
  4771. $orod = explode('-', $or[$i]);
  4772. if ($orod[0] == $number) {
  4773. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4774. if ($czzs > 0) {
  4775. if (isset($qt[$v['shop']])) {
  4776. if ($qt[$v['shop']] < $orod[1]) {
  4777. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4778. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4779. } else {
  4780. $qt[$v['shop']] -= $orod[1];
  4781. }
  4782. } else {
  4783. $qt[$v['shop']] = $czzs;
  4784. }
  4785. } else {
  4786. $od += $orod[1];
  4787. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4788. }
  4789. }
  4790. }
  4791. }
  4792. }
  4793. $z = $od . '(' . $orid . ')'; //查看订单号
  4794. //$z = $od;
  4795. if ($od > $c) {
  4796. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4797. }
  4798. }
  4799. $listdata = array_slice($list, $start, $perpage);
  4800. $total = count($list);
  4801. $pagenum = ceil($total / $perpage);
  4802. $over = $total - ($start + $perpage);
  4803. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4804. echo json_encode($rows);
  4805. exit;
  4806. }
  4807. $this->_Template('whlabel_abnormal', $this->data);
  4808. }
  4809. /**
  4810. *
  4811. *
  4812. *
  4813. 进销存占单异常索引
  4814. *
  4815. *
  4816. *
  4817. **/
  4818. public function _error()
  4819. {
  4820. $post = $this->input->post(NULL, TRUE);
  4821. if (isset($post['page'])) {
  4822. $page = $this->input->post('page', true);
  4823. $perpage = $this->input->post('perpage', true);
  4824. $sku = $this->input->post('sku', true);
  4825. $warehouse = $this->input->post('warehouse', true);
  4826. $ktime = $this->input->post('ktime', true);
  4827. $jtime = $this->input->post('jtime', true);
  4828. $ktime = strtotime($ktime);
  4829. $jtime = strtotime($jtime);
  4830. $where = "sku != 'Preset'";
  4831. $gj = '';
  4832. if ($sku) {
  4833. $where .= " and sku like '%$sku%'";
  4834. } else {
  4835. if ($ktime && $jtime) {
  4836. $gj = " and time > '$ktime' and time < '$jtime'";
  4837. }
  4838. }
  4839. if ($warehouse) {
  4840. $where .= " and warehouse = '$warehouse'";
  4841. }
  4842. //数据排序
  4843. $order_str = "id desc";
  4844. if (empty($page)) {
  4845. $start = 0;
  4846. $perpage = 1;
  4847. } else {
  4848. $start = ($page - 1) * $perpage;
  4849. }
  4850. //取得信息列表
  4851. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4852. $rows = array();
  4853. $list = array();
  4854. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4855. // foreach ($info_list as $value)
  4856. // {
  4857. // $warehouse = $this->warehouse->read($value['warehouse']);
  4858. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4859. // $number = $value['number'];$ftime = time()-15*24*3600;
  4860. // if($c < 1)
  4861. // {
  4862. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4863. // }
  4864. // }
  4865. $warehouse_list = $this->warehouse->find_all();
  4866. $warehouse_list = array_column($warehouse_list, null, 'id');
  4867. foreach ($info_list as $value) {
  4868. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4869. 'title' => "",
  4870. ];
  4871. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4872. $number = $value['number'];
  4873. $ftime = time() - 15 * 24 * 3600;
  4874. if ($c < 1) {
  4875. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4876. }
  4877. }
  4878. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4879. // $query = $this->db->query($sql);
  4880. // $info_list = $query->result_array();
  4881. // $sql_two = "select title,id from crowd_warehouse";
  4882. // $query_two = $this->db->query($sql_two);
  4883. // $warehouse_list = $query_two->result_array();
  4884. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4885. // foreach ($info_list as $value)
  4886. // {
  4887. // if(isset($warehouse_arr[$value['warehouse']])){
  4888. // $warehouse = $warehouse_arr[$value['warehouse']];
  4889. // }else{
  4890. // $warehouse = [
  4891. // 'id'=>0,
  4892. // 'title'=>"异常",
  4893. // ];
  4894. // }
  4895. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4896. // $number = $value['number'];$ftime = time()-15*24*3600;
  4897. // if($c < 1)
  4898. // {
  4899. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4900. // }
  4901. // }
  4902. $listdata = array_slice($list, $start, $perpage);
  4903. $total = count($list);
  4904. $pagenum = ceil($total / $perpage);
  4905. $over = $total - ($start + $perpage);
  4906. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4907. echo json_encode($rows);
  4908. exit;
  4909. }
  4910. if (isset($post['s'])) {
  4911. $id_arr = $this->input->post('s');
  4912. $id_arr = explode(',', trim($id_arr, ','));
  4913. if (!$id_arr) {
  4914. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4915. exit;
  4916. }
  4917. //循环删除记录
  4918. foreach ($id_arr as $v) {
  4919. $dd = $this->whlabel->read($v);
  4920. if (!isset($dd['id'])) {
  4921. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4922. exit;
  4923. }
  4924. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4925. if (isset($zt[0])) {
  4926. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4927. exit;
  4928. }
  4929. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4930. foreach ($deldd as $vv) {
  4931. $this->whlabel->remove($vv['id']);
  4932. }
  4933. }
  4934. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4935. exit;
  4936. }
  4937. $this->_Template('whlabel_error', $this->data);
  4938. }
  4939. public function _errorexcel()
  4940. {
  4941. $post = $this->input->post(NULL, TRUE);
  4942. if (isset($_GET['page'])) {
  4943. $page = $this->input->get('page', true);
  4944. $perpage = $this->input->get('perpage', true);
  4945. $sku = $this->input->get('sku', true);
  4946. $warehouse = $this->input->get('warehouse', true);
  4947. $ktime = $this->input->get('ktime', true);
  4948. $jtime = $this->input->get('jtime', true);
  4949. $ktime = strtotime($ktime);
  4950. $jtime = strtotime($jtime);
  4951. $where = "sku != 'Preset'";
  4952. $gj = '';
  4953. if ($sku) {
  4954. $where .= " and sku like '%$sku%'";
  4955. } else {
  4956. if ($ktime && $jtime) {
  4957. $gj = " and time > '$ktime' and time < '$jtime'";
  4958. }
  4959. }
  4960. if ($warehouse) {
  4961. $where .= " and warehouse = '$warehouse'";
  4962. }
  4963. //数据排序
  4964. $order_str = "id desc";
  4965. if (empty($page)) {
  4966. $start = 0;
  4967. $perpage = 1;
  4968. } else {
  4969. $start = ($page - 1) * $perpage;
  4970. }
  4971. //取得信息列表
  4972. $rows = array();
  4973. $list = array();
  4974. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4975. foreach ($info_list as $value) {
  4976. $warehouse = $this->warehouse->read($value['warehouse']);
  4977. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4978. $number = $value['number'];
  4979. $ftime = time() - 15 * 24 * 3600;
  4980. if ($c < 1) {
  4981. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4982. }
  4983. }
  4984. $title = "0库存汇总";
  4985. $titlename = "<table border=1>
  4986. <tr align='center'>
  4987. <td>仓库</td>
  4988. <td>SKU</td>
  4989. <td>产品</td>
  4990. <td>当前库存</td>
  4991. </tr>
  4992. </table>";
  4993. $filename = $title . ".xls";
  4994. $tail = "";
  4995. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4996. }
  4997. }
  4998. /**
  4999. *
  5000. *
  5001. * 占单
  5002. *
  5003. *
  5004. **/
  5005. public function _kcyz()
  5006. {
  5007. $post = $this->input->post(NULL, TRUE);
  5008. if (isset($post['warehouse'])) {
  5009. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5010. exit; //不再使用
  5011. $warehouse = $this->input->post('warehouse', true);
  5012. $whlabel = $this->input->post('whlabel', true);
  5013. $id = $this->input->post('id', true);
  5014. $shop = $this->input->post('shop', true);
  5015. $number = $this->input->post('number', true);
  5016. if (!$whlabel || $whlabel == '|') {
  5017. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5018. exit;
  5019. }
  5020. $pp = explode('|', trim($whlabel, '|'));
  5021. $x = 0;
  5022. $save = array();
  5023. foreach ($pp as $va) {
  5024. $num = explode('-', $va);
  5025. if ($number) {
  5026. $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 = '')"); //通用
  5027. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5028. } else {
  5029. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5030. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5031. }
  5032. $x++;
  5033. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5034. $save[] = $x - 1;
  5035. continue; //提前先加X不然出错,所以要减1
  5036. }
  5037. }
  5038. if (isset($save[0])) {
  5039. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5040. exit;
  5041. } else {
  5042. echo json_encode(array('success' => true));
  5043. exit;
  5044. }
  5045. }
  5046. }
  5047. public function _db()
  5048. {
  5049. $post = $this->input->post(NULL, TRUE);
  5050. if (isset($post['page'])) {
  5051. $page = $this->input->post('page', true);
  5052. $perpage = $this->input->post('perpage', true);
  5053. $sku = $this->input->post('sku', true);
  5054. $number = $this->input->post('number', true);
  5055. $warehouse = $this->input->post('warehouse', true);
  5056. $purchase = $this->input->post('purchase', true);
  5057. $orderinfo = $this->input->post('orderinfo', true);
  5058. $waybill = $this->input->post('waybill', true);
  5059. $category = $this->input->post('category', true);
  5060. $size = $this->input->post('size', true);
  5061. $grade = $this->input->post('grade', true);
  5062. $color = $this->input->post('color', true);
  5063. $lowe = $this->input->post('lowe', true);
  5064. $state = $this->input->post('state', true);
  5065. $label = $this->input->post('label', true);
  5066. $timetk = $this->input->post('timetkk', true);
  5067. $timetj = $this->input->post('timetjj', true);
  5068. $timetk = strtotime($timetk);
  5069. $timetj = strtotime($timetj);
  5070. $where = "dbtime > 0";
  5071. if ($timetk && $timetj) {
  5072. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5073. }
  5074. if ($sku) {
  5075. $where .= " and sku = '$sku'";
  5076. }
  5077. if ($warehouse) {
  5078. $where .= " and warehouse = '$warehouse'";
  5079. if ($warehouse == 12) {
  5080. $w = 'specialstock';
  5081. } else {
  5082. $w = 'whlabel';
  5083. }
  5084. }
  5085. if ($purchase) {
  5086. $where .= " and purchase = '$purchase'";
  5087. }
  5088. if ($category) {
  5089. $where .= " and features like '%-$category-%'";
  5090. }
  5091. if ($size) {
  5092. $where .= " and features like '%-$size-%'";
  5093. }
  5094. if ($grade) {
  5095. $where .= " and features like '%-$grade-%'";
  5096. }
  5097. if ($color) {
  5098. $where .= " and features like '%-$color-%'";
  5099. }
  5100. if ($lowe) {
  5101. $where .= " and features like '%-$lowe-%'";
  5102. }
  5103. if ($state != '') {
  5104. $where .= " and state = '$state'";
  5105. }
  5106. //数据排序
  5107. $order_str = "dbtime desc";
  5108. if (empty($page)) {
  5109. $start = 0;
  5110. $perpage = 1;
  5111. } else {
  5112. $start = ($page - 1) * $perpage;
  5113. }
  5114. //取得信息列表
  5115. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5116. foreach ($info_list as $key => $value) {
  5117. $warehouse = $this->$w->read($value['warehouse']);
  5118. $info_list[$key]['warehouse'] = $warehouse['title'];
  5119. $purchase = $this->purchase->read($value['purchase']);
  5120. $info_list[$key]['purchase'] = $purchase['title'];
  5121. if ($value['enter'] != 0) {
  5122. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5123. } else {
  5124. $info_list[$key]['enter'] = "";
  5125. }
  5126. if ($value['dbtime'] != 0) {
  5127. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5128. } else {
  5129. $info_list[$key]['dbtime'] = "";
  5130. }
  5131. if ($value['state'] == 0) {
  5132. $info_list[$key]['state'] = "在库";
  5133. } else if ($value['state'] == 1) {
  5134. $info_list[$key]['state'] = "出库";
  5135. } else if ($value['state'] == 2) {
  5136. $info_list[$key]['state'] = "退库";
  5137. } else if ($value['state'] == 3) {
  5138. $info_list[$key]['state'] = "调拨中";
  5139. } else if ($value['state'] == 4) {
  5140. $info_list[$key]['state'] = "再加工";
  5141. } else if ($value['state'] == 5) {
  5142. $info_list[$key]['state'] = "维修中";
  5143. } else if ($value['state'] == 6) {
  5144. $info_list[$key]['state'] = "盘亏";
  5145. } else if ($value['state'] == 7) {
  5146. $info_list[$key]['state'] = "更换标签";
  5147. } else if ($value['state'] == 8) {
  5148. $info_list[$key]['state'] = "其它";
  5149. } else if ($value['state'] == 9) {
  5150. $info_list[$key]['state'] = "预设";
  5151. }
  5152. }
  5153. $total = $this->whlabel->find_count($where);
  5154. $pagenum = ceil($total / $perpage);
  5155. $over = $total - ($start + $perpage);
  5156. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5157. echo json_encode($rows);
  5158. exit;
  5159. }
  5160. if (isset($post['outsku'])) {
  5161. $time = time();
  5162. $cz = $this->input->post('cz', true);
  5163. $label = $this->input->post('outsku', true);
  5164. $sl = $this->input->post('sl', true);
  5165. $num = $this->input->post('num', true);
  5166. //$warehouse = $this->input->post('warehouse',true);
  5167. if (!$sl) {
  5168. $sl = 1;
  5169. }
  5170. if (!$warehouse) {
  5171. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5172. exit;
  5173. }
  5174. $dblabel = $this->whlabellabel->get_label($label);
  5175. if ($dblabel) {
  5176. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5177. if (count($data) < 1) {
  5178. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5179. exit;
  5180. }
  5181. if (count($data) < $num) {
  5182. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5183. exit;
  5184. }
  5185. for ($i = 0; $i < $sl; $i++) {
  5186. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5187. }
  5188. echo json_encode(array('success' => true));
  5189. exit;
  5190. } else {
  5191. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5192. exit;
  5193. }
  5194. }
  5195. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5196. $this->_Template('whlabel_db', $this->data);
  5197. }
  5198. public function _dbrk()
  5199. {
  5200. $post = $this->input->post(NULL, TRUE);
  5201. if (isset($post['page'])) {
  5202. $page = $this->input->post('page', true);
  5203. $perpage = $this->input->post('perpage', true);
  5204. $sku = $this->input->post('sku', true);
  5205. $number = $this->input->post('number', true);
  5206. $warehouse = $this->input->post('warehouse', true);
  5207. $purchase = $this->input->post('purchase', true);
  5208. $orderinfo = $this->input->post('orderinfo', true);
  5209. $waybill = $this->input->post('waybill', true);
  5210. $category = $this->input->post('category', true);
  5211. $size = $this->input->post('size', true);
  5212. $grade = $this->input->post('grade', true);
  5213. $color = $this->input->post('color', true);
  5214. $lowe = $this->input->post('lowe', true);
  5215. $state = $this->input->post('state', true);
  5216. $label = $this->input->post('label', true);
  5217. $ctime = $this->input->post('ctime', true);
  5218. $timetk = $this->input->post('timetkk', true);
  5219. $timetj = $this->input->post('timetjj', true);
  5220. $timetk = strtotime($timetk);
  5221. $timetj = strtotime($timetj);
  5222. $where = "dbtime > 0";
  5223. if ($timetk && $timetj) {
  5224. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5225. }
  5226. if ($sku) {
  5227. $where .= " and sku = '$sku'";
  5228. }
  5229. if ($warehouse) {
  5230. $where .= " and warehouse = '$warehouse'";
  5231. }
  5232. if ($purchase) {
  5233. $where .= " and purchase = '$purchase'";
  5234. }
  5235. if ($category) {
  5236. $where .= " and features like '%-$category-%'";
  5237. }
  5238. if ($size) {
  5239. $where .= " and features like '%-$size-%'";
  5240. }
  5241. if ($grade) {
  5242. $where .= " and features like '%-$grade-%'";
  5243. }
  5244. if ($color) {
  5245. $where .= " and features like '%-$color-%'";
  5246. }
  5247. if ($lowe) {
  5248. $where .= " and features like '%-$lowe-%'";
  5249. }
  5250. if ($state != '') {
  5251. $where .= " and state = '$state'";
  5252. }
  5253. //数据排序
  5254. $order_str = "dbtime desc";
  5255. if (empty($page)) {
  5256. $start = 0;
  5257. $perpage = 1;
  5258. } else {
  5259. $start = ($page - 1) * $perpage;
  5260. }
  5261. //取得信息列表
  5262. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5263. foreach ($info_list as $key => $value) {
  5264. $warehouse = $this->warehouse->read($value['warehouse']);
  5265. $info_list[$key]['warehouse'] = $warehouse['title'];
  5266. $purchase = $this->purchase->read($value['purchase']);
  5267. $info_list[$key]['purchase'] = $purchase['title'];
  5268. if ($value['enter'] != 0) {
  5269. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5270. } else {
  5271. $info_list[$key]['enter'] = "";
  5272. }
  5273. if ($value['dbtime'] != 0) {
  5274. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5275. } else {
  5276. $info_list[$key]['dbtime'] = "";
  5277. }
  5278. if ($value['state'] == 0) {
  5279. $info_list[$key]['state'] = "在库";
  5280. } else if ($value['state'] == 1) {
  5281. $info_list[$key]['state'] = "出库";
  5282. } else if ($value['state'] == 2) {
  5283. $info_list[$key]['state'] = "退库";
  5284. } else if ($value['state'] == 3) {
  5285. $info_list[$key]['state'] = "调拨中";
  5286. } else if ($value['state'] == 4) {
  5287. $info_list[$key]['state'] = "再加工";
  5288. } else if ($value['state'] == 5) {
  5289. $info_list[$key]['state'] = "维修中";
  5290. } else if ($value['state'] == 6) {
  5291. $info_list[$key]['state'] = "盘亏";
  5292. } else if ($value['state'] == 7) {
  5293. $info_list[$key]['state'] = "更换标签";
  5294. } else if ($value['state'] == 8) {
  5295. $info_list[$key]['state'] = "其它";
  5296. } else if ($value['state'] == 9) {
  5297. $info_list[$key]['state'] = "预设";
  5298. }
  5299. }
  5300. $total = $this->whlabel->find_count($where);
  5301. $pagenum = ceil($total / $perpage);
  5302. $over = $total - ($start + $perpage);
  5303. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5304. echo json_encode($rows);
  5305. exit;
  5306. }
  5307. if (isset($post['rsku'])) {
  5308. $cz = $this->input->post('cz', true);
  5309. $label = $this->input->post('rsku', true);
  5310. $sl = $this->input->post('sl', true);
  5311. $warehouse = $this->input->post('warehouse', true);
  5312. if (!$sl) {
  5313. $sl = 1;
  5314. }
  5315. if (!$warehouse) {
  5316. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5317. exit;
  5318. }
  5319. $dblabel = $this->whlabellabel->get_label($label);
  5320. if ($dblabel) {
  5321. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5322. if (count($data) < 1) {
  5323. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5324. exit;
  5325. }
  5326. if ($sl > count($data)) {
  5327. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5328. exit;
  5329. }
  5330. $time = time();
  5331. for ($i = 0; $i < $sl; $i++) {
  5332. $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']);
  5333. }
  5334. echo json_encode(array('success' => true));
  5335. exit;
  5336. } else {
  5337. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5338. exit;
  5339. }
  5340. }
  5341. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5342. $this->_Template('whlabel_dbrk', $this->data);
  5343. }
  5344. public function _whlabelczdc()
  5345. {
  5346. if (isset($_GET['excel'])) {
  5347. //数据排序
  5348. $order_str = "id desc";
  5349. if (empty($page)) {
  5350. $start = 0;
  5351. $perpage = 1;
  5352. } else {
  5353. $start = ($page - 1) * $perpage;
  5354. }
  5355. $state = $this->input->get('state', true);
  5356. $sku = $this->input->get('sku', true);
  5357. $ctime = $this->input->get('ctime', true);
  5358. $category = $this->input->get('category', true);
  5359. $size = $this->input->get('size', true);
  5360. $grade = $this->input->get('grade', true);
  5361. $color = $this->input->get('color', true);
  5362. $lowe = $this->input->get('lowe', true);
  5363. $timetk = $this->input->get('timetkk', true);
  5364. $timetj = $this->input->get('timetjj', true);
  5365. $timetk = strtotime($timetk);
  5366. $timetj = strtotime($timetj);
  5367. $where = "dbtime > 0";
  5368. if ($timetk && $timetj) {
  5369. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5370. }
  5371. if ($category) {
  5372. $where .= " and features like '%-$category-%'";
  5373. }
  5374. if ($size) {
  5375. $where .= " and features like '%-$size-%'";
  5376. }
  5377. if ($grade) {
  5378. $where .= " and features like '%-$grade-%'";
  5379. }
  5380. if ($color) {
  5381. $where .= " and features like '%-$color-%'";
  5382. }
  5383. if ($lowe) {
  5384. $where .= " and features like '%-$lowe-%'";
  5385. }
  5386. //取得信息列表
  5387. $info_list = $this->whlabel->find_all($where, '*');
  5388. $rows = array();
  5389. $list = array();
  5390. foreach ($info_list as $key => $value) {
  5391. $rows[$value['sku']] = $value; //所有数据sku
  5392. }
  5393. foreach ($rows as $value) {
  5394. $warehouse = $this->warehouse->read($value['warehouse']);
  5395. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5396. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5397. if ($value['orderinfo'] == 0) {
  5398. $info_list[$key]['orderinfo'] = "";
  5399. }
  5400. if ($value['waybill'] == 0) {
  5401. $info_list[$key]['waybill'] = "";
  5402. }
  5403. if ($value['state'] == 0) {
  5404. $value['state'] = "在库";
  5405. } else if ($value['state'] == 3) {
  5406. $value['state'] = "调拨中";
  5407. }
  5408. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5409. }
  5410. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5411. $titlename = "<table border=1>
  5412. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5413. <tr align='center'>
  5414. <td>SKU</td>
  5415. <td>产品</td>
  5416. <td>调拨数量</td>
  5417. <td>入库数量</td>
  5418. </tr>
  5419. </table>";
  5420. $filename = $title . ".xls";
  5421. $tail = "";
  5422. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5423. }
  5424. }
  5425. public function _print($arg_array)
  5426. {
  5427. if (isset($_SESSION['api'])) {
  5428. $user = $this->user->get_api($_SESSION['api']);
  5429. $usp = $user;
  5430. $fgshop = "";
  5431. $sid = "";
  5432. $wid = "";
  5433. $wtype = "";
  5434. $usersp = explode('|', trim($user['shop'], '|'));
  5435. $userwh = explode('|', trim($user['warehouse'], '|'));
  5436. foreach ($usersp as $value) {
  5437. $fgshop .= " shop = " . $value . " or";
  5438. $sid .= " id = " . $value . " or";
  5439. }
  5440. foreach ($userwh as $value) {
  5441. $wid .= " id = " . $value . " or";
  5442. $wtype .= " type = " . $value . " or";
  5443. }
  5444. }
  5445. $post = $this->input->post(NULL, TRUE);
  5446. if (isset($post['tmsku'])) {
  5447. $tmsku = $this->input->post('tmsku', true);
  5448. if (is_numeric($tmsku)) {
  5449. $yyh = $this->whlabellabel->get_label($tmsku);
  5450. } else {
  5451. $yyh = $this->whlabellabel->get_sku($tmsku);
  5452. }
  5453. if ($yyh) {
  5454. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5455. exit;
  5456. } else {
  5457. echo json_encode(array('success' => false));
  5458. exit;
  5459. }
  5460. }
  5461. $classid = $this->classid->sku();
  5462. $pm = $classid;
  5463. $scsku = $classid;
  5464. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5465. if (isset($post['warehouse'])) {
  5466. if ($post['warehouse']) {
  5467. $list = array();
  5468. $num = "";
  5469. $title = "";
  5470. $features = "";
  5471. $order = 0;
  5472. $post['shop'] = '';
  5473. $brand = $this->input->post('brand', true);
  5474. if ($brand != '0,') {
  5475. $b = $this->brand->read(rtrim($brand, ','));
  5476. if ($b) {
  5477. $post['shop'] = str_replace('|', ',', $b['shop']);
  5478. }
  5479. }
  5480. $post['details'] = $this->input->post('details', true); //打印数量
  5481. $xbqnum = $this->input->post('xbqnum', true);
  5482. $post['purchase'] = $this->input->post('purchase', true);
  5483. $post['warehouse'] = $this->input->post('warehouse', true);
  5484. $post['purchase'] = $this->input->post('purchase', true);
  5485. $post['retreatwarehouse'] = $post['warehouse'];
  5486. $post['cpbz'] = $this->input->post('cpbz', true);
  5487. $post['state'] = 9;
  5488. $category = $this->input->post('category', true);
  5489. $list['category'] = $category;
  5490. $list['hairtype'] = $this->input->post('hairtype', true);
  5491. $list['grade'] = $this->input->post('grade', true);
  5492. $size = $this->input->post('size', true);
  5493. $list['size'] = rtrim($size, ',');
  5494. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5495. $list['extension'] = $this->input->post('extension', true);
  5496. if ($category == 1297) {
  5497. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5498. }
  5499. if ($category == 1702) {
  5500. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5501. $list['syother'] = $this->input->post('syother', true);
  5502. }
  5503. if ($category == 133) {
  5504. $list['fittype'] = $this->input->post('fittype', true);
  5505. $list['acother'] = $this->input->post('acother', true);
  5506. }
  5507. $list['color'] = $this->input->post('color', true);
  5508. $list['lowe'] = $this->input->post('lowe', true);
  5509. if ($category == 127) {
  5510. $list['type'] = $this->input->post('type', true);
  5511. $list['headroad'] = $this->input->post('headroad', true);
  5512. $list['density'] = $this->input->post('density', true);
  5513. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5514. $list['lacesize'] = $this->input->post('lacesize', true);
  5515. }
  5516. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5517. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5518. }
  5519. if ($category == 128) {
  5520. $list['lacetype'] = $this->input->post('lacetype', true);
  5521. $list['haircap'] = $this->input->post('haircap', true);
  5522. $list['density'] = $this->input->post('density', true);
  5523. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5524. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5525. $list['wigother'] = $this->input->post('wigother', true);
  5526. $list['wigother1'] = $this->input->post('wigother1', true);
  5527. $list['wigother2'] = $this->input->post('wigother2', true);
  5528. }
  5529. if ($category == 129) {
  5530. $list['wide'] = $this->input->post('wide', true);
  5531. }
  5532. if ($category == 131) {
  5533. $list['gifttype'] = $this->input->post('gifttype', true);
  5534. $list['giftother'] = $this->input->post('giftother', true);
  5535. }
  5536. if ($category == 134) {
  5537. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5538. }
  5539. if ($category == 1297) {
  5540. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5541. $list['sywigother'] = $this->input->post('sywigother', true);
  5542. }
  5543. if ($category == 130 || $category == 133 || $category == 1702) {
  5544. $list['items'] = $this->input->post('items', true);
  5545. $list['weight'] = $this->input->post('weight', true);
  5546. }
  5547. if ($category == 1702) {
  5548. $list['syhairther'] = $this->input->post('syhairther', true);
  5549. }
  5550. foreach ($list as $k => $v) {
  5551. if ($v != 0) {
  5552. $num .= $v;
  5553. $features .= $v . '-';
  5554. $post[$k] = $v;
  5555. $typeclass = $this->typeclass->read($v);
  5556. if (isset($pm[$typeclass['classid']])) {
  5557. if (stripos($typeclass['zh'], '|') !== false) {
  5558. $exzh = explode('|', $typeclass['zh']);
  5559. $pm[$typeclass['classid']] = $exzh[0];
  5560. } else {
  5561. $pm[$typeclass['classid']] = $typeclass['zh'];
  5562. }
  5563. }
  5564. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5565. if ($k != 'size') {
  5566. $title .= $typeclass['title'] . " ";
  5567. }
  5568. }
  5569. }
  5570. $typeclass = $this->typeclass->read($list['size']);
  5571. $title .= $typeclass['title'];
  5572. $time = time();
  5573. $post['title'] = rtrim($title, ' ');
  5574. $post['number'] = $num;
  5575. $post['features'] = '-' . $features;
  5576. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5577. $featurespp = explode('-', trim($featurespp, '-'));
  5578. if (isset($featurespp[5])) {
  5579. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5580. } else {
  5581. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5582. }
  5583. $post['enter'] = $time;
  5584. $post['time'] = $time; //操作时间
  5585. $scsku = implode("-", $scsku);
  5586. $zh = implode(" ", $pm);
  5587. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5588. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5589. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5590. $post['sku'] = $bqsku;
  5591. $label = time() . rand(0, 9);
  5592. $post['label'] = $label;
  5593. $cpid = $this->whlabellabel->find_count();
  5594. $post['cpid'] = $cpid + 1;
  5595. $cpid = $post['cpid'];
  5596. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5597. //if($whlabelbarcode)
  5598. //{
  5599. //$post['label'] = $whlabelbarcode['label'];
  5600. //if(!$this->whlabellabel->insert($post))
  5601. //{
  5602. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5603. //}
  5604. //}
  5605. //else
  5606. //{
  5607. $this->db->trans_begin();
  5608. $this->whlabellabel->insert($post);
  5609. //$this->whlabelbarcode->insert($post);
  5610. if ($this->db->trans_status() === TRUE) {
  5611. $this->db->trans_commit();
  5612. } else {
  5613. $this->db->trans_rollback();
  5614. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5615. exit;
  5616. }
  5617. //}
  5618. $warehouse_name = "";
  5619. $warehouse = $post['warehouse'];
  5620. if($warehouse == 12){
  5621. $warehouse_name = "特殊库存库";
  5622. }
  5623. // if($warehouse == 13){
  5624. // $warehouse_name = "许昌仓";
  5625. // }
  5626. // if($warehouse == 5){
  5627. // $warehouse_name = "美国店";
  5628. // }
  5629. // if($warehouse == 16){
  5630. // $warehouse_name = "定制头套仓";
  5631. // }
  5632. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5633. if(!empty($warehouse_name)){
  5634. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5635. }
  5636. $purchase = $this->purchase->read($post['purchase']);
  5637. 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));
  5638. exit; //特殊仓目前不需要仓库选项
  5639. }
  5640. }
  5641. if (isset($_SESSION['api'])) {
  5642. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5643. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5644. $this->data['wlshop'] = $wlshop;
  5645. $this->data['warehouse'] = $warehouse;
  5646. }
  5647. $whlabelwz = $this->whlabelwz->find_all();
  5648. $this->data['whlabelwz'] = $whlabelwz;
  5649. $this->_Template('whlabel_print', $this->data);
  5650. }
  5651. public function _usaprint($arg_array)
  5652. {
  5653. if (isset($_SESSION['api'])) {
  5654. $user = $this->user->get_api($_SESSION['api']);
  5655. $usp = $user;
  5656. $fgshop = "";
  5657. $sid = "";
  5658. $wid = "";
  5659. $wtype = "";
  5660. $usersp = explode('|', trim($user['shop'], '|'));
  5661. $userwh = explode('|', trim($user['warehouse'], '|'));
  5662. foreach ($usersp as $value) {
  5663. $fgshop .= " shop = " . $value . " or";
  5664. $sid .= " id = " . $value . " or";
  5665. }
  5666. foreach ($userwh as $value) {
  5667. $wid .= " id = " . $value . " or";
  5668. $wtype .= " type = " . $value . " or";
  5669. }
  5670. }
  5671. $post = $this->input->post(NULL, TRUE);
  5672. if (isset($post['tmsku'])) {
  5673. $tmsku = $this->input->post('tmsku', true);
  5674. if (is_numeric($tmsku)) {
  5675. $yyh = $this->whlabellabel->get_label($tmsku);
  5676. } else {
  5677. $yyh = $this->whlabellabel->get_sku($tmsku);
  5678. }
  5679. if ($yyh) {
  5680. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5681. exit;
  5682. } else {
  5683. echo json_encode(array('success' => false));
  5684. exit;
  5685. }
  5686. }
  5687. $classid = $this->classid->sku();
  5688. $pm = $classid;
  5689. $scsku = $classid;
  5690. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5691. if (isset($post['warehouse'])) {
  5692. if ($post['warehouse']) {
  5693. $list = array();
  5694. $num = "";
  5695. $title = "";
  5696. $features = "";
  5697. $order = 0;
  5698. $post['shop'] = '';
  5699. $brand = $this->input->post('brand', true);
  5700. if ($brand != '0,') {
  5701. $b = $this->brand->read(rtrim($brand, ','));
  5702. if ($b) {
  5703. $post['shop'] = str_replace('|', ',', $b['shop']);
  5704. }
  5705. }
  5706. $post['details'] = $this->input->post('details', true); //打印数量
  5707. $xbqnum = $this->input->post('xbqnum', true);
  5708. $post['purchase'] = $this->input->post('purchase', true);
  5709. $post['warehouse'] = $this->input->post('warehouse', true);
  5710. $post['purchase'] = $this->input->post('purchase', true);
  5711. $post['retreatwarehouse'] = $post['warehouse'];
  5712. $post['cpbz'] = $this->input->post('cpbz', true);
  5713. $post['state'] = 9;
  5714. $category = $this->input->post('category', true);
  5715. $list['category'] = $category;
  5716. $list['hairtype'] = $this->input->post('hairtype', true);
  5717. $list['grade'] = $this->input->post('grade', true);
  5718. $size = $this->input->post('size', true);
  5719. $list['size'] = rtrim($size, ',');
  5720. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5721. $list['extension'] = $this->input->post('extension', true);
  5722. if ($category == 1297) {
  5723. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5724. }
  5725. if ($category == 1702) {
  5726. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5727. $list['syother'] = $this->input->post('syother', true);
  5728. }
  5729. if ($category == 133) {
  5730. $list['fittype'] = $this->input->post('fittype', true);
  5731. $list['acother'] = $this->input->post('acother', true);
  5732. }
  5733. $list['color'] = $this->input->post('color', true);
  5734. $list['lowe'] = $this->input->post('lowe', true);
  5735. if ($category == 127) {
  5736. $list['type'] = $this->input->post('type', true);
  5737. $list['headroad'] = $this->input->post('headroad', true);
  5738. $list['density'] = $this->input->post('density', true);
  5739. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5740. $list['lacesize'] = $this->input->post('lacesize', true);
  5741. }
  5742. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5743. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5744. }
  5745. if ($category == 128) {
  5746. $list['lacetype'] = $this->input->post('lacetype', true);
  5747. $list['haircap'] = $this->input->post('haircap', true);
  5748. $list['density'] = $this->input->post('density', true);
  5749. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5750. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5751. $list['wigother'] = $this->input->post('wigother', true);
  5752. $list['wigother1'] = $this->input->post('wigother1', true);
  5753. $list['wigother2'] = $this->input->post('wigother2', true);
  5754. }
  5755. if ($category == 129) {
  5756. $list['wide'] = $this->input->post('wide', true);
  5757. }
  5758. if ($category == 131) {
  5759. $list['gifttype'] = $this->input->post('gifttype', true);
  5760. $list['giftother'] = $this->input->post('giftother', true);
  5761. }
  5762. if ($category == 134) {
  5763. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5764. }
  5765. if ($category == 1297) {
  5766. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5767. $list['sywigother'] = $this->input->post('sywigother', true);
  5768. }
  5769. if ($category == 130 || $category == 133 || $category == 1702) {
  5770. $list['items'] = $this->input->post('items', true);
  5771. $list['weight'] = $this->input->post('weight', true);
  5772. }
  5773. if ($category == 1702) {
  5774. $list['syhairther'] = $this->input->post('syhairther', true);
  5775. }
  5776. foreach ($list as $k => $v) {
  5777. if ($v != 0) {
  5778. $num .= $v;
  5779. $features .= $v . '-';
  5780. $post[$k] = $v;
  5781. $typeclass = $this->typeclass->read($v);
  5782. if (isset($pm[$typeclass['classid']])) {
  5783. if (stripos($typeclass['zh'], '|') !== false) {
  5784. $exzh = explode('|', $typeclass['zh']);
  5785. $pm[$typeclass['classid']] = $exzh[0];
  5786. } else {
  5787. $pm[$typeclass['classid']] = $typeclass['zh'];
  5788. }
  5789. }
  5790. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5791. if ($k != 'size') {
  5792. $title .= $typeclass['title'] . " ";
  5793. }
  5794. }
  5795. }
  5796. $typeclass = $this->typeclass->read($list['size']);
  5797. $title .= $typeclass['title'];
  5798. $time = time();
  5799. $post['title'] = rtrim($title, ' ');
  5800. $post['number'] = $num;
  5801. $post['features'] = '-' . $features;
  5802. $fp = $this->whlabel->get_features($post['features']);
  5803. if (!$fp) {
  5804. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5805. exit;
  5806. }
  5807. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5808. $featurespp = explode('-', trim($featurespp, '-'));
  5809. if (isset($featurespp[5])) {
  5810. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5811. } else {
  5812. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5813. }
  5814. $post['enter'] = $time;
  5815. $post['time'] = $time; //操作时间
  5816. $scsku = implode("-", $scsku);
  5817. $zh = implode(" ", $pm);
  5818. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5819. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5820. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5821. $post['sku'] = $fp['sku'];
  5822. $post['label'] = $fp['sku'];
  5823. $cpid = $this->whlabellabel->find_count();
  5824. $post['cpid'] = $cpid + 1;
  5825. $cpid = $post['cpid'];
  5826. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5827. //if($whlabelbarcode)
  5828. //{
  5829. //$post['label'] = $whlabelbarcode['label'];
  5830. //if(!$this->whlabellabel->insert($post))
  5831. //{
  5832. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5833. //}
  5834. //}
  5835. //else
  5836. //{
  5837. $this->db->trans_begin();
  5838. $this->whlabellabel->insert($post);
  5839. //$this->whlabelbarcode->insert($post);
  5840. if ($this->db->trans_status() === TRUE) {
  5841. $this->db->trans_commit();
  5842. } else {
  5843. $this->db->trans_rollback();
  5844. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5845. exit;
  5846. }
  5847. //}
  5848. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5849. $purchase = $this->purchase->read($post['purchase']);
  5850. 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));
  5851. exit; //特殊仓目前不需要仓库选项
  5852. }
  5853. }
  5854. if (isset($_SESSION['api'])) {
  5855. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5856. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5857. $this->data['wlshop'] = $wlshop;
  5858. $this->data['warehouse'] = $warehouse;
  5859. }
  5860. $whlabelwz = $this->whlabelwz->find_all();
  5861. $this->data['whlabelwz'] = $whlabelwz;
  5862. $this->_Template('whlabel_usaprint', $this->data);
  5863. }
  5864. public function _printrk($arg_array)
  5865. {
  5866. $prc = array();
  5867. $purchase = $this->purchase->find_all();
  5868. foreach ($purchase as $k => $v) {
  5869. $prc[$v['id']] = $v['title'];
  5870. }
  5871. $post = $this->input->post(NULL, TRUE);
  5872. if (isset($post['page'])) {
  5873. $page = $this->input->post('page', true);
  5874. $perpage = $this->input->post('perpage', true);
  5875. $sku = $this->input->post('sku', true);
  5876. $bs = $this->input->post('bs', true);
  5877. $number = $this->input->post('number', true);
  5878. $warehouse = $this->input->post('warehouse', true);
  5879. $purchase = $this->input->post('purchase', true);
  5880. $orderinfo = $this->input->post('orderinfo', true);
  5881. $waybill = $this->input->post('waybill', true);
  5882. $category = $this->input->post('category', true);
  5883. $size = $this->input->post('size', true);
  5884. $grade = $this->input->post('grade', true);
  5885. $color = $this->input->post('color', true);
  5886. $lowe = $this->input->post('lowe', true);
  5887. $state = $this->input->post('state', true);
  5888. $label = $this->input->post('label', true);
  5889. $timetk = $this->input->post('ktime', true);
  5890. $timetj = $this->input->post('jtime', true);
  5891. $timetk = strtotime($timetk);
  5892. $timetj = strtotime($timetj);
  5893. $where = "1=1 ";
  5894. if ($timetk && $timetj) {
  5895. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5896. }
  5897. if ($sku) {
  5898. $where .= " and sku = '$sku'";
  5899. }
  5900. if ($bs != '') {
  5901. $where .= " and bs = '$bs'";
  5902. }
  5903. if ($number) {
  5904. $where .= " and number = '$number'";
  5905. }
  5906. if ($warehouse) {
  5907. $where .= " and warehouse = '$warehouse'";
  5908. }
  5909. if ($purchase) {
  5910. $where .= " and purchase = '$purchase'";
  5911. }
  5912. if ($orderinfo) {
  5913. $where .= " and orderinfo = '$orderinfo'";
  5914. }
  5915. if ($waybill) {
  5916. $where .= " and waybill = '$waybill'";
  5917. }
  5918. if ($category) {
  5919. $where .= " and features like '%-$category-%'";
  5920. }
  5921. if ($size) {
  5922. $where .= " and features like '%-$size-%'";
  5923. }
  5924. if ($grade) {
  5925. $where .= " and features like '%-$grade-%'";
  5926. }
  5927. if ($color) {
  5928. $where .= " and features like '%-$color-%'";
  5929. }
  5930. if ($lowe) {
  5931. $where .= " and features like '%-$lowe-%'";
  5932. }
  5933. if ($label) {
  5934. $where .= " and label = '$label'";
  5935. }
  5936. if ($state || $state == 0) {
  5937. $where .= " and state = '$state'";
  5938. }
  5939. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5940. //数据排序
  5941. $order_str = "enter desc";
  5942. if (empty($page)) {
  5943. $start = 0;
  5944. $perpage = 1;
  5945. } else {
  5946. $start = ($page - 1) * $perpage;
  5947. }
  5948. //取得信息列表
  5949. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5950. foreach ($info_list as $key => $value) {
  5951. $warehouse = $this->warehouse->read($value['warehouse']);
  5952. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5953. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5954. if ($value['state'] == 0) {
  5955. $info_list[$key]['state'] = "在库";
  5956. } else if ($value['state'] == 1) {
  5957. $info_list[$key]['state'] = "出库";
  5958. } else if ($value['state'] == 2) {
  5959. $info_list[$key]['state'] = "退库";
  5960. } else if ($value['state'] == 3) {
  5961. $info_list[$key]['state'] = "调拨中";
  5962. } else if ($value['state'] == 4) {
  5963. $info_list[$key]['state'] = "再加工";
  5964. } else if ($value['state'] == 5) {
  5965. $info_list[$key]['state'] = "维修中";
  5966. } else if ($value['state'] == 6) {
  5967. $info_list[$key]['state'] = "盘亏";
  5968. } else if ($value['state'] == 7) {
  5969. $info_list[$key]['state'] = "更换标签";
  5970. } else if ($value['state'] == 8) {
  5971. $info_list[$key]['state'] = "其它";
  5972. } else if ($value['state'] == 9) {
  5973. $info_list[$key]['state'] = "预设";
  5974. } else if ($value['state'] == 10) {
  5975. $info_list[$key]['state'] = "美店零售";
  5976. }
  5977. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5978. }
  5979. $total = $this->$ck->find_count($where);
  5980. $pagenum = ceil($total / $perpage);
  5981. $over = $total - ($start + $perpage);
  5982. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5983. echo json_encode($rows);
  5984. exit;
  5985. }
  5986. if (isset($post['tmsku'])) {
  5987. $time = time();
  5988. $tmsku = $this->input->post('tmsku', true);
  5989. //$post['shop'] = $this->input->post('shop',true);
  5990. $num = $this->input->post('num', true);
  5991. $rktype = $this->input->post('rktype', true);
  5992. if ($num > 200) {
  5993. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5994. exit;
  5995. }
  5996. if (!$rktype) {
  5997. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5998. }
  5999. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6000. /**
  6001. $wz = array();
  6002. foreach ($rk as $key=>$value)
  6003. {
  6004. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6005. }
  6006. if(count($wz) > 1)
  6007. {
  6008. $wz = array_values($wz);
  6009. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6010. }
  6011. **/
  6012. if (isset($rk[0]['purchase'])) {
  6013. $rk = $rk[0];
  6014. $j = 0;
  6015. $post['purchase'] = $rk['purchase'];
  6016. $post['warehouse'] = $rk['warehouse'];
  6017. $post['retreatwarehouse'] = $rk['warehouse'];
  6018. $post['sku'] = $rk['sku'];
  6019. $post['number'] = $rk['number'];
  6020. $post['features'] = $rk['features'];
  6021. $post['title'] = $rk['title'];
  6022. $post['enter'] = $time;
  6023. $post['time'] = $time;
  6024. $post['bs'] = 1;
  6025. $post['shop'] = $rk['shop'];
  6026. $post['details'] = $rk['details'];
  6027. $post['cpid'] = $rk['cpid'];
  6028. $post['cpbz'] = $rk['cpbz'];
  6029. //$post['rktype'] = $rktype;
  6030. $warehouse = $this->warehouse->read($rk['warehouse']);
  6031. if ($warehouse['bdck'] == '') {
  6032. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6033. exit;
  6034. } else {
  6035. $bdck = $warehouse['bdck'];
  6036. }
  6037. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6038. if (isset($pdwz['details'])) {
  6039. if ($pdwz['details'] != $post['details']) {
  6040. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6041. exit;
  6042. }
  6043. }
  6044. $post['featurespp'] = $rk['featurespp'];
  6045. if ($post['warehouse'] == '5') {
  6046. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6047. if ($yza) {
  6048. if ($post['features'] != $yza[0]['features']) {
  6049. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6050. exit;
  6051. }
  6052. }
  6053. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6054. if ($yzb) {
  6055. if ($post['sku'] != $yzb[0]['sku']) {
  6056. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6057. exit;
  6058. }
  6059. }
  6060. }
  6061. for ($i = 0; $i < $num; $i++) {
  6062. $post['label'] = time() . rand(100, 999) . $i;
  6063. if ($this->$bdck->insert($post)) {
  6064. $j++;
  6065. }
  6066. }
  6067. /**
  6068. if($post['warehouse'] != 12)
  6069. {
  6070. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6071. }
  6072. **/
  6073. if ($j == $num) {
  6074. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6075. exit;
  6076. } else {
  6077. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6078. exit;
  6079. }
  6080. } else {
  6081. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6082. exit;
  6083. }
  6084. }
  6085. $this->_Template('whlabel_printrk', $this->data);
  6086. }
  6087. public function _printxzrk($arg_array)
  6088. {
  6089. $post = $this->input->post(NULL, TRUE);
  6090. if (isset($post['wzid'])) {
  6091. $time = time();
  6092. $id = $this->input->post('wzid', true);
  6093. //$post['shop'] = $this->input->post('shop',true);
  6094. $num = 1;
  6095. $rk = $this->whlabellabel->read($id);
  6096. if (isset($rk['purchase'])) {
  6097. $x = 0;
  6098. $post['purchase'] = $rk['purchase'];
  6099. $post['warehouse'] = $rk['warehouse'];
  6100. $post['retreatwarehouse'] = $rk['warehouse'];
  6101. $post['sku'] = $rk['sku'];
  6102. $post['number'] = $rk['number'];
  6103. $post['features'] = $rk['features'];
  6104. $post['title'] = $rk['title'];
  6105. $post['enter'] = $time;
  6106. $post['time'] = $time;
  6107. $post['bs'] = 1;
  6108. $post['shop'] = $rk['shop'];
  6109. $post['details'] = $rk['details'];
  6110. $post['cpid'] = $rk['cpid'];
  6111. $post['cpbz'] = $rk['cpbz'];
  6112. $warehouse = $this->warehouse->read($rk['warehouse']);
  6113. if ($warehouse['bdck'] == '') {
  6114. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6115. exit;
  6116. } else {
  6117. $bdck = $warehouse['bdck'];
  6118. }
  6119. $post['featurespp'] = $rk['featurespp'];
  6120. $this->db->trans_begin();
  6121. for ($i = 0; $i < $num; $i++) {
  6122. $post['label'] = time() . rand(100, 999) . $i;
  6123. $this->$bdck->insert($post);
  6124. }
  6125. /**
  6126. if($post['warehouse'] != 12)
  6127. {
  6128. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6129. }
  6130. **/
  6131. if ($this->db->trans_status() === TRUE) {
  6132. $this->db->trans_commit();
  6133. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6134. exit;
  6135. } else {
  6136. $this->db->trans_rollback();
  6137. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6138. exit;
  6139. }
  6140. } else {
  6141. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6142. exit;
  6143. }
  6144. }
  6145. }
  6146. public function _printck($arg_array)
  6147. {
  6148. $prc = array();
  6149. $purchase = $this->purchase->find_all();
  6150. foreach ($purchase as $k => $v) {
  6151. $prc[$v['id']] = $v['title'];
  6152. }
  6153. $post = $this->input->post(NULL, TRUE);
  6154. if (isset($post['page'])) {
  6155. $page = $this->input->post('page', true);
  6156. $perpage = $this->input->post('perpage', true);
  6157. $sku = $this->input->post('sku', true);
  6158. $bs = $this->input->post('bs', true);
  6159. $number = $this->input->post('number', true);
  6160. $warehouse = $this->input->post('warehouse', true);
  6161. $purchase = $this->input->post('purchase', true);
  6162. $orderinfo = $this->input->post('orderinfo', true);
  6163. $waybill = $this->input->post('waybill', true);
  6164. $category = $this->input->post('category', true);
  6165. $size = $this->input->post('size', true);
  6166. $grade = $this->input->post('grade', true);
  6167. $color = $this->input->post('color', true);
  6168. $lowe = $this->input->post('lowe', true);
  6169. $state = $this->input->post('state', true);
  6170. $label = $this->input->post('label', true);
  6171. $timetk = $this->input->post('ktime', true);
  6172. $timetj = $this->input->post('jtime', true);
  6173. $timetk = strtotime($timetk);
  6174. $timetj = strtotime($timetj);
  6175. $where = "state=1 ";
  6176. if ($timetk && $timetj) {
  6177. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6178. }
  6179. if ($sku) {
  6180. $where .= " and sku = '$sku'";
  6181. }
  6182. if ($bs != '') {
  6183. $where .= " and bs = '$bs'";
  6184. }
  6185. if ($number) {
  6186. $where .= " and number = '$number'";
  6187. }
  6188. if ($warehouse) {
  6189. $where .= " and warehouse = '$warehouse'";
  6190. }
  6191. if ($purchase) {
  6192. $where .= " and purchase = '$purchase'";
  6193. }
  6194. if ($orderinfo) {
  6195. $where .= " and orderinfo = '$orderinfo'";
  6196. }
  6197. if ($waybill) {
  6198. $where .= " and waybill = '$waybill'";
  6199. }
  6200. if ($category) {
  6201. $where .= " and features like '%-$category-%'";
  6202. }
  6203. if ($size) {
  6204. $where .= " and features like '%-$size-%'";
  6205. }
  6206. if ($grade) {
  6207. $where .= " and features like '%-$grade-%'";
  6208. }
  6209. if ($color) {
  6210. $where .= " and features like '%-$color-%'";
  6211. }
  6212. if ($lowe) {
  6213. $where .= " and features like '%-$lowe-%'";
  6214. }
  6215. if ($label) {
  6216. $where .= " and label = '$label'";
  6217. }
  6218. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6219. //数据排序
  6220. $order_str = "outk desc";
  6221. if (empty($page)) {
  6222. $start = 0;
  6223. $perpage = 1;
  6224. } else {
  6225. $start = ($page - 1) * $perpage;
  6226. }
  6227. //取得信息列表
  6228. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6229. foreach ($info_list as $key => $value) {
  6230. $warehouse = $this->warehouse->read($value['warehouse']);
  6231. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6232. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6233. if ($value['state'] == 0) {
  6234. $info_list[$key]['state'] = "在库";
  6235. } else if ($value['state'] == 1) {
  6236. $info_list[$key]['state'] = "出库";
  6237. } else if ($value['state'] == 2) {
  6238. $info_list[$key]['state'] = "退库";
  6239. } else if ($value['state'] == 3) {
  6240. $info_list[$key]['state'] = "调拨中";
  6241. } else if ($value['state'] == 4) {
  6242. $info_list[$key]['state'] = "再加工";
  6243. } else if ($value['state'] == 5) {
  6244. $info_list[$key]['state'] = "维修中";
  6245. } else if ($value['state'] == 6) {
  6246. $info_list[$key]['state'] = "盘亏";
  6247. } else if ($value['state'] == 7) {
  6248. $info_list[$key]['state'] = "更换标签";
  6249. } else if ($value['state'] == 8) {
  6250. $info_list[$key]['state'] = "其它";
  6251. } else if ($value['state'] == 9) {
  6252. $info_list[$key]['state'] = "预设";
  6253. } else if ($value['state'] == 10) {
  6254. $info_list[$key]['state'] = "美店零售";
  6255. }
  6256. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6257. }
  6258. $total = $this->$ck->find_count($where);
  6259. $pagenum = ceil($total / $perpage);
  6260. $over = $total - ($start + $perpage);
  6261. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6262. echo json_encode($rows);
  6263. exit;
  6264. }
  6265. if (isset($post['tmsku'])) {
  6266. $time = time();
  6267. $tmsku = $this->input->post('tmsku', true);
  6268. //$post['shop'] = $this->input->post('shop',true);
  6269. $num = $this->input->post('num', true);
  6270. $cktype = $this->input->post('cktype', true);
  6271. $label = $this->whlabellabel->get_label($tmsku);
  6272. if (!$cktype) {
  6273. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6274. }
  6275. if (!isset($label['warehouse'])) {
  6276. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6277. exit;
  6278. }
  6279. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6280. if (stripos($label['features'], '-126-') !== false) {
  6281. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6282. } else {
  6283. $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 = ''");
  6284. }
  6285. $j = 0;
  6286. if (count($ck) >= $num) {
  6287. for ($i = 0; $i < $num; $i++) {
  6288. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6289. {
  6290. $j++;
  6291. }
  6292. }
  6293. if ($j == $num) {
  6294. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6295. exit;
  6296. } else {
  6297. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6298. exit;
  6299. }
  6300. } else {
  6301. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6302. exit;
  6303. }
  6304. }
  6305. if(isset($_SESSION['api']))
  6306. {
  6307. $user = $this->user->get_api($_SESSION['api']);
  6308. if(in_array($user['power'],[1,27])){
  6309. $vip = 1;
  6310. }
  6311. }
  6312. else
  6313. {
  6314. $vip = 0;
  6315. header('Location: /');exit;
  6316. }
  6317. $this->data['vip'] = $vip;
  6318. $this->_Template('whlabel_printck', $this->data);
  6319. }
  6320. public function _printexcel()
  6321. {
  6322. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6323. $config['upload_path'] = '.' . $dir;
  6324. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6325. $config['allowed_types'] = 'xls|xlsx|csv';
  6326. $config['max_size'] = 10240;
  6327. $this->load->library('upload', $config);
  6328. $this->upload->initialize($config);
  6329. if ($this->upload->do_upload('userfile')) {
  6330. $full_path = $dir . $this->upload->data('file_name');
  6331. $fileName = '.' . $full_path;
  6332. if (!file_exists($fileName)) {
  6333. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6334. exit;
  6335. } else {
  6336. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6337. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6338. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6339. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6340. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6341. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6342. ++$column; //如果列数大于26行
  6343. $list = array();
  6344. for ($i = 2; $i <= $row; $i++) // 行数循环
  6345. {
  6346. $data = array();
  6347. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6348. {
  6349. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6350. }
  6351. $list[] = $data;
  6352. }
  6353. }
  6354. $ed = array();
  6355. $i = 0;
  6356. $j = 0;
  6357. $dcdata = array();
  6358. $yc = '';
  6359. $cmf_arr = array_column($list, '1');
  6360. array_multisort($cmf_arr, SORT_ASC, $list);
  6361. foreach ($list as $key => $value) {
  6362. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6363. if ($typeclass) {
  6364. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6365. } else {
  6366. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6367. $i++;
  6368. continue;
  6369. }
  6370. }
  6371. if ($i > 0) {
  6372. $yc = $i . '条异常';
  6373. }
  6374. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6375. exit;
  6376. }
  6377. }
  6378. public function _uck()
  6379. {
  6380. if (isset($_GET['excel'])) {
  6381. $tc = array();
  6382. $typeclass = $this->typeclass->find_all();
  6383. foreach ($typeclass as $v) {
  6384. $tc[$v['id']] = $v['zh'];
  6385. }
  6386. $data = array();
  6387. $t = array();
  6388. $rq = '';
  6389. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6390. $ts = $ts / (24 * 3600);
  6391. for ($i = 0; $i < $ts; $i++) {
  6392. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6393. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6394. }
  6395. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6396. foreach ($info_list as $k => $v) {
  6397. $features = explode('-', trim($v['features'], '-'));
  6398. if (!isset($features[3]) || !isset($features[4])) {
  6399. continue;
  6400. }
  6401. $data[$k][0] = $tc[$features[0]]; //类型
  6402. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6403. $data[$k][2] = $tc[$features[4]]; //曲度
  6404. $data[$k][3] = '';
  6405. if (isset($data[$k][1])) {
  6406. $data[$k][3] .= $data[$k][1];
  6407. }
  6408. if (isset($data[$k][2])) {
  6409. $data[$k][3] .= $data[$k][2];
  6410. }
  6411. if (isset($features[5])) {
  6412. $data[$k][3] .= $tc[$features[5]];
  6413. }
  6414. if (isset($features[2])) {
  6415. $data[$k][3] .= $tc[$features[2]];
  6416. }
  6417. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6418. $data[$k][4] = $v['sku'];
  6419. $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())) . '))'); //月初库存
  6420. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6421. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6422. $ztrq = '';
  6423. $ztsl = '';
  6424. if (count($zt) > 0) {
  6425. foreach ($zt as $vv) {
  6426. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6427. $ztsl .= $vv['num'] . '<br>';
  6428. }
  6429. }
  6430. $data[$k][] = trim($ztsl, '<br>');
  6431. $data[$k][] = trim($ztrq, '<br>');
  6432. $byck = 0;
  6433. foreach ($t as $vv) {
  6434. $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));
  6435. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6436. $byck += $sl;
  6437. }
  6438. $data[$k][] = ($byck > 0) ? $byck : '';
  6439. }
  6440. $title = "详情 " . date("Y-m-d", time());
  6441. $titlename = "<table border=1>
  6442. <tr align='center'>
  6443. <td>类别</td>
  6444. <td>颜色</td>
  6445. <td>曲度</td>
  6446. <td>名称</td>
  6447. <td>SKU</td>
  6448. <td>月初库存</td>
  6449. <td>剩余库存</td>
  6450. <td>在途数量</td>
  6451. <td>预达日期</td>" .
  6452. $rq
  6453. . "<td>本月出库</td></tr>
  6454. </table>";
  6455. $filename = $title . ".xls";
  6456. $tail = "";
  6457. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6458. }
  6459. }
  6460. public function _whlabelexcelzh()
  6461. {
  6462. if (isset($_GET['excel'])) {
  6463. $where = "sku != 'Preset'";
  6464. //数据排序
  6465. $order_str = "id desc";
  6466. if (empty($page)) {
  6467. $start = 0;
  6468. $perpage = 1;
  6469. } else {
  6470. $start = ($page - 1) * $perpage;
  6471. }
  6472. $category = $this->input->get('category', true);
  6473. $warehouse = $this->input->get('warehouse', true);
  6474. $excelid = $this->input->get('sid', true);
  6475. if ($category) {
  6476. $where .= " and features like '%-$category-%'";
  6477. }
  6478. if ($warehouse) {
  6479. $where .= " and warehouse = '$warehouse'";
  6480. }
  6481. $xzid = '';
  6482. if ($excelid) {
  6483. $excelid = explode(',', trim($excelid, ','));
  6484. foreach ($excelid as $key => $value) {
  6485. $xzid .= " id = " . $value . " or";
  6486. }
  6487. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6488. }
  6489. //取得信息列表
  6490. /**
  6491. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6492. $rows = array();$list = array();
  6493. foreach ($info_list as $key=>$value)
  6494. {
  6495. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6496. }
  6497. **/
  6498. $list = array();
  6499. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6500. foreach ($rows as $key => $value) {
  6501. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6502. $zh = '';
  6503. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6504. foreach ($zt as $v) {
  6505. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6506. }
  6507. $zt = array_sum(array_column($zt, 'num'));
  6508. $number = $value['number'];
  6509. $ftime = time() - 15 * 24 * 3600;
  6510. $warehouse = $this->warehouse->read($value['warehouse']);
  6511. $rows[$key]['warehouse'] = $warehouse['title'];
  6512. $rows[$key]['number'] = $c;
  6513. $rows[$key]['features'] = $zh;
  6514. $rows[$key]['hb'] = $c + $zt;
  6515. }
  6516. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6517. $titlename = "<table border=1>
  6518. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6519. <tr align='center'>
  6520. <td>仓库</td>
  6521. <td>SKU</td>
  6522. <td>产品</td>
  6523. <td>库存数量</td>
  6524. <td>在途数量及预达日期</td>
  6525. <td>在途+库存数量</td>
  6526. </tr>
  6527. </table>";
  6528. $filename = $title . ".xls";
  6529. $tail = "";
  6530. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6531. }
  6532. if (isset($_GET['excel'])) {
  6533. $warehouse = $this->input->get('warehouse', true);
  6534. $sku = $this->input->get('sku', true);
  6535. $cz = $this->input->get('cz', true);
  6536. $text = $this->input->post('text', true);
  6537. $xztime = $this->input->get('xztime', true);
  6538. $timetk = $this->input->get('timetk', true);
  6539. $timetj = $this->input->get('timetj', true);
  6540. $timetk = strtotime($timetk);
  6541. $timetj = strtotime($timetj);
  6542. $where = "time = '0' ";
  6543. if ($warehouse) {
  6544. $where .= " and warehouse = '$warehouse'";
  6545. }
  6546. if ($sku) {
  6547. $where .= " and sku = '$sku'";
  6548. }
  6549. if ($text) {
  6550. $where .= " and text like '%$text%'";
  6551. }
  6552. if ($cz != '') {
  6553. $where .= " and cz = '$cz'";
  6554. }
  6555. if ($timetk && $timetj) {
  6556. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6557. }
  6558. //数据排序
  6559. $order_str = $xztime . " desc";
  6560. //取得信息列表
  6561. $zh = array();
  6562. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6563. foreach ($info_list as $v) {
  6564. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6565. $warehouse = $this->warehouse->read($v['warehouse']);
  6566. $v['warehouse'] = $warehouse['title'];
  6567. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6568. $v['stime'] = date('Y-m-d', $v['stime']);
  6569. if (isset($zh[$v['features']])) {
  6570. $zh[$v['features']]['num'] += $v['num'];
  6571. } else {
  6572. $zh[$v['features']] = $v;
  6573. }
  6574. $zh[$v['features']]['features'] = $c;
  6575. }
  6576. $title = "在途数据" . date('Y-m-d', time());
  6577. $titlename = "<table border=1>
  6578. <tr align='center'>
  6579. <td>仓库</td>
  6580. <td>SKU</td>
  6581. <td>名称</td>
  6582. <td>在途数量</td>
  6583. <td>库存数量</td>
  6584. <td>添加在途日期</td>
  6585. <td>预达日期</td>
  6586. <td>备注</td>
  6587. </tr>
  6588. </table>";
  6589. $filename = $title . ".xls";
  6590. $tail = "";
  6591. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6592. }
  6593. }
  6594. public function _fc()
  6595. {
  6596. $vip = 0;
  6597. if (isset($_SESSION['api'])) {
  6598. $user = $this->user->get_api($_SESSION['api']);
  6599. if ($user['vip'] == 1) {
  6600. $vip = 1;
  6601. }
  6602. } else {
  6603. header('Location: /');
  6604. exit;
  6605. }
  6606. $post = $this->input->post(NULL, TRUE);
  6607. if (isset($post['page'])) {
  6608. $page = $this->input->post('page', true);
  6609. $perpage = $this->input->post('perpage', true);
  6610. $category = $this->input->post('category', true);
  6611. $size = $this->input->post('size', true);
  6612. $grade = $this->input->post('grade', true);
  6613. $color = $this->input->post('color', true);
  6614. $lowe = $this->input->post('lowe', true);
  6615. $sku = $this->input->post('sku');
  6616. $title = $this->input->post('title');
  6617. $warehouse = $this->input->post('warehouse', true);
  6618. $usa = $this->input->post('usa', true);
  6619. $purchase = $this->input->post('purchase', true);
  6620. $lacetype = $this->input->post('lacetype', true);
  6621. $haircap = $this->input->post('haircap', true);
  6622. $density = $this->input->post('density', true);
  6623. $details = $this->input->post('details', true);
  6624. $state = $this->input->post('state', true);
  6625. $ktime = $this->input->post('ktime', true);
  6626. $jtime = $this->input->post('jtime', true);
  6627. $ktime = strtotime($ktime);
  6628. $jtime = strtotime($jtime);
  6629. $where = "state = '11'";
  6630. $gj = "";
  6631. $ck = "";
  6632. if ($lacetype) {
  6633. $where .= " and features like '%-$lacetype-%'";
  6634. }
  6635. if ($category) {
  6636. $where .= " and features like '%-$category-%'";
  6637. }
  6638. if ($size) {
  6639. $where .= " and features like '%-$size-%'";
  6640. }
  6641. if ($grade) {
  6642. $where .= " and features like '%-$grade-%'";
  6643. }
  6644. if ($color) {
  6645. $where .= " and features like '%-$color-%'";
  6646. }
  6647. if ($lowe) {
  6648. $where .= " and features like '%-$lowe-%'";
  6649. }
  6650. if ($haircap) {
  6651. $where .= " and features like '%-$haircap-%'";
  6652. }
  6653. if ($density) {
  6654. $where .= " and features like '%-$density-%'";
  6655. }
  6656. if ($usa) {
  6657. if (!$warehouse) {
  6658. $where .= " and (warehouse = '5' or warehouse = '8')";
  6659. }
  6660. }
  6661. if ($warehouse) {
  6662. $where .= " and warehouse = '$warehouse'";
  6663. }
  6664. if ($details) {
  6665. $where .= " and details = '$details'";
  6666. }
  6667. if ($purchase) {
  6668. $where .= " and purchase = '$purchase'";
  6669. }
  6670. if ($state) {
  6671. $where .= " and state = '$state'";
  6672. }
  6673. if ($ktime && $jtime) {
  6674. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6675. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6676. }
  6677. //数据排序
  6678. $order_str = "id desc";
  6679. if (empty($page)) {
  6680. $start = 0;
  6681. $perpage = 1;
  6682. } else {
  6683. $start = ($page - 1) * $perpage;
  6684. }
  6685. if ($sku) {
  6686. $sku = trim($sku, ' ');
  6687. $sku = trim($sku, ' ');
  6688. $where .= " and sku like '%$sku%'";
  6689. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6690. } else if ($title) {
  6691. $title = trim($title, ' ');
  6692. $title = trim($title, ' ');
  6693. $where .= " and title like '%$title%'";
  6694. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6695. } else {
  6696. //$where .= " and time > '$ktime' and time < '$jtime'";
  6697. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6698. }
  6699. //取得信息列表
  6700. $rows = array();
  6701. $list = array();
  6702. foreach ($info_list as $key => $value) {
  6703. $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'] . '"');
  6704. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6705. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6706. $warehouse = $this->warehouse->read($value['warehouse']);
  6707. $info_list[$key]['warehouse'] = $warehouse['title'];
  6708. $info_list[$key]['number'] = $g;
  6709. $info_list[$key]['features'] = $x;
  6710. $info_list[$key]['x'] = $s;
  6711. }
  6712. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6713. $pagenum = ceil($total / $perpage);
  6714. $over = $total - ($start + $perpage);
  6715. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6716. echo json_encode($rows);
  6717. exit;
  6718. }
  6719. $this->data['vip'] = $vip;
  6720. $this->_Template('whlabel_fc', $this->data);
  6721. }
  6722. public function _fcmb()
  6723. {
  6724. $where = "sku != 'Preset'";
  6725. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6726. foreach ($rows as $k => $v) {
  6727. $warehouse = $this->warehouse->read($v['warehouse']);
  6728. $rows[$k]['warehouse'] = $warehouse['title'];
  6729. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6730. $rows[$k]['t'] = '';
  6731. $rows[$k]['n'] = '';
  6732. }
  6733. $title = "封货产品数据导入模板";
  6734. $titlename = "<table border=1>
  6735. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6736. <tr align='center'>
  6737. <td>仓库</td>
  6738. <td>SKU</td>
  6739. <td>产品</td>
  6740. <td>封存产品总数量</td>
  6741. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6742. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6743. </tr>
  6744. </table>";
  6745. $filename = $title . ".xls";
  6746. $tail = "";
  6747. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6748. }
  6749. public function _fcexcel()
  6750. {
  6751. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6752. $config['upload_path'] = '.' . $dir;
  6753. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6754. $config['allowed_types'] = 'xls|xlsx|csv';
  6755. $config['max_size'] = 10240;
  6756. $this->load->library('upload', $config);
  6757. $this->upload->initialize($config);
  6758. if ($this->upload->do_upload('userfile')) {
  6759. $full_path = $dir . $this->upload->data('file_name');
  6760. $fileName = '.' . $full_path;
  6761. if (!file_exists($fileName)) {
  6762. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6763. exit;
  6764. } else {
  6765. libxml_use_internal_errors(true);
  6766. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6767. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6768. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6769. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6770. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6771. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6772. ++$column; //如果列数大于26行
  6773. $list = array();
  6774. for ($i = 2; $i <= $row; $i++) // 行数循环
  6775. {
  6776. $data = array();
  6777. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6778. {
  6779. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6780. }
  6781. $list[] = $data;
  6782. }
  6783. }
  6784. $i = 0;
  6785. $j = 0;
  6786. $ed = array();
  6787. foreach ($list as $key => $value) {
  6788. $time = time();
  6789. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6790. continue;
  6791. }
  6792. $warehouse = $this->warehouse->get_title($value['0']);
  6793. $sku = $value['1'];
  6794. $type = $value['4']; //调整方式0扣减1删除
  6795. $num = $value['5']; //调整数量
  6796. //$text = $value['4'];//扣减说明
  6797. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6798. if (!$d) //如果没有这个SKU
  6799. {
  6800. $ed[] = array($sku . '-库存中不存在此SKU');
  6801. $j++;
  6802. continue;
  6803. }
  6804. if (!isset($warehouse['id'])) {
  6805. $ed[] = array($sku . '-仓库名错误!');
  6806. $j++;
  6807. continue;
  6808. }
  6809. if ($type == 1 || $type == 2) //扣减库存
  6810. {
  6811. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6812. if (count($data) < abs($num)) {
  6813. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6814. $j++;
  6815. continue;
  6816. }
  6817. if ($type == 1) //转入库存
  6818. {
  6819. for ($i = 0; $i < abs($num); $i++) {
  6820. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6821. }
  6822. } else if ($type == 2) //删除
  6823. {
  6824. for ($i = 0; $i < abs($num); $i++) {
  6825. $this->whlabel->remove($data[$i]['id']);
  6826. }
  6827. }
  6828. } else if ($type == 0) //增加库存
  6829. {
  6830. $post['sku'] = $d['sku'];
  6831. $post['shop'] = '';
  6832. $post['warehouse'] = $warehouse['id'];
  6833. $post['purchase'] = $d['purchase'];
  6834. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6835. $post['state'] = 11;
  6836. $post['title'] = $d['title'];
  6837. $post['number'] = $d['number'];
  6838. $post['features'] = $d['features'];
  6839. $post['enter'] = $time;
  6840. $post['time'] = $time; //操作时间
  6841. for ($i = 0; $i < $num; $i++) {
  6842. $post['label'] = time() . rand(100, 999) . $i;
  6843. $this->whlabel->insert($post);
  6844. }
  6845. }
  6846. sleep(1); //防止入库时间一样,需要延迟1秒
  6847. }
  6848. if ($j > 0) {
  6849. $tt = date('Ymd', time());
  6850. $title = '库存导入错误信息-' . $tt;
  6851. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6852. $tail = "\n";
  6853. $filename = $title . ".xls";
  6854. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6855. $dir = '/data/excel/' . $time . '/';
  6856. $file_name = 'error_' . $time . rand(1000, 9999);
  6857. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6858. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6859. fwrite($myfile, $ecl);
  6860. fclose($myfile);
  6861. $error = $dir . $file_name . '.xls';
  6862. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6863. exit;
  6864. } else {
  6865. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6866. exit;
  6867. }
  6868. }
  6869. }
  6870. public function _fcjxc($arg_array)
  6871. {
  6872. if (isset($_GET['excel'])) {
  6873. $category = $this->input->get('category', true);
  6874. $size = $this->input->get('size', true);
  6875. $grade = $this->input->get('grade', true);
  6876. $color = $this->input->get('color', true);
  6877. $lowe = $this->input->get('lowe', true);
  6878. $sku = $this->input->get('sku');
  6879. $title = $this->input->get('title');
  6880. $warehouse = $arg_array[0];
  6881. $usa = $this->input->get('usa', true);
  6882. $purchase = $this->input->get('purchase', true);
  6883. $lacetype = $this->input->get('lacetype', true);
  6884. $haircap = $this->input->get('haircap', true);
  6885. $density = $this->input->get('density', true);
  6886. $title = $this->input->get('title', true);
  6887. $state = $this->input->get('state', true);
  6888. $ktime = $this->input->get('ktime', true);
  6889. $jtime = $this->input->get('jtime', true);
  6890. $where = "state=11";
  6891. $gj = "";
  6892. $ck = "";
  6893. if ($lacetype) {
  6894. $where .= " and features like '%-$lacetype-%'";
  6895. }
  6896. if ($category) {
  6897. $where .= " and features like '%-$category-%'";
  6898. }
  6899. if ($size) {
  6900. $where .= " and features like '%-$size-%'";
  6901. }
  6902. if ($grade) {
  6903. $where .= " and features like '%-$grade-%'";
  6904. }
  6905. if ($color) {
  6906. $where .= " and features like '%-$color-%'";
  6907. }
  6908. if ($lowe) {
  6909. $where .= " and features like '%-$lowe-%'";
  6910. }
  6911. if ($haircap) {
  6912. $where .= " and features like '%-$haircap-%'";
  6913. }
  6914. if ($density) {
  6915. $where .= " and features like '%-$density-%'";
  6916. }
  6917. if ($usa) {
  6918. if (!$warehouse) {
  6919. $where .= " and (warehouse = '5' or warehouse = '8')";
  6920. }
  6921. }
  6922. if ($warehouse) {
  6923. $where .= " and warehouse = '$warehouse'";
  6924. }
  6925. if ($purchase) {
  6926. $where .= " and purchase = '$purchase'";
  6927. }
  6928. if ($state) {
  6929. $where .= " and state = '$state'";
  6930. }
  6931. $order_str = "id desc";
  6932. if ($sku) {
  6933. $sku = trim($sku, ' ');
  6934. $sku = trim($sku, ' ');
  6935. $where .= " and sku like '%$sku%'";
  6936. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6937. } else if ($title) {
  6938. $title = trim($title, ' ');
  6939. $title = trim($title, ' ');
  6940. $where .= " and title like '%$title%'";
  6941. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6942. } else {
  6943. //$where .= " and time > '$ktime' and time < '$jtime'";
  6944. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6945. }
  6946. //取得信息列表
  6947. $rows = array();
  6948. $list = array();
  6949. foreach ($info_list as $key => $value) {
  6950. $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'] . '"');
  6951. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6952. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6953. $rows[$key] = $value;
  6954. $warehouse = $this->warehouse->read($value['warehouse']);
  6955. $rows[$key]['warehouse'] = $warehouse['title'];
  6956. $rows[$key]['features'] = $g;
  6957. $rows[$key]['a'] = $x;
  6958. $rows[$key]['b'] = $s;
  6959. }
  6960. $title = "总统计表";
  6961. $titlename = "<table border=1>
  6962. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6963. <tr align='center'>
  6964. <td>仓库</td>
  6965. <td>SKU</td>
  6966. <td>产品名称</td>
  6967. <td>录入总量</td>
  6968. <td>取出总量</td>
  6969. <td>剩余总量</td>
  6970. </tr>
  6971. </table>";
  6972. $filename = $title . ".xls";
  6973. $tail = "";
  6974. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6975. }
  6976. $vip = 0;
  6977. if (isset($_SESSION['api'])) {
  6978. $user = $this->user->get_api($_SESSION['api']);
  6979. if ($user['vip'] == 1) {
  6980. $vip = 1;
  6981. }
  6982. } else {
  6983. header('Location: /');
  6984. exit;
  6985. }
  6986. $post = $this->input->post(NULL, TRUE);
  6987. if (isset($post['page'])) {
  6988. $page = $this->input->post('page', true);
  6989. $perpage = $this->input->post('perpage', true);
  6990. $category = $this->input->post('category', true);
  6991. $size = $this->input->post('size', true);
  6992. $grade = $this->input->post('grade', true);
  6993. $color = $this->input->post('color', true);
  6994. $lowe = $this->input->post('lowe', true);
  6995. $sku = $this->input->post('sku');
  6996. $title = $this->input->post('title');
  6997. $warehouse = $arg_array[0];
  6998. $usa = $this->input->post('usa', true);
  6999. $purchase = $this->input->post('purchase', true);
  7000. $lacetype = $this->input->post('lacetype', true);
  7001. $haircap = $this->input->post('haircap', true);
  7002. $density = $this->input->post('density', true);
  7003. $title = $this->input->post('title', true);
  7004. $state = $this->input->post('state', true);
  7005. $ktime = $this->input->post('ktime', true);
  7006. $jtime = $this->input->post('jtime', true);
  7007. $ktime = strtotime($ktime);
  7008. $jtime = strtotime($jtime);
  7009. $where = "state=11";
  7010. $gj = "";
  7011. $ck = "";
  7012. if ($lacetype) {
  7013. $where .= " and features like '%-$lacetype-%'";
  7014. }
  7015. if ($category) {
  7016. $where .= " and features like '%-$category-%'";
  7017. }
  7018. if ($size) {
  7019. $where .= " and features like '%-$size-%'";
  7020. }
  7021. if ($grade) {
  7022. $where .= " and features like '%-$grade-%'";
  7023. }
  7024. if ($color) {
  7025. $where .= " and features like '%-$color-%'";
  7026. }
  7027. if ($lowe) {
  7028. $where .= " and features like '%-$lowe-%'";
  7029. }
  7030. if ($haircap) {
  7031. $where .= " and features like '%-$haircap-%'";
  7032. }
  7033. if ($density) {
  7034. $where .= " and features like '%-$density-%'";
  7035. }
  7036. if ($usa) {
  7037. if (!$warehouse) {
  7038. $where .= " and (warehouse = '5' or warehouse = '8')";
  7039. }
  7040. }
  7041. if ($warehouse) {
  7042. $where .= " and warehouse = '$warehouse'";
  7043. }
  7044. if ($purchase) {
  7045. $where .= " and purchase = '$purchase'";
  7046. }
  7047. if ($state) {
  7048. $where .= " and state = '$state'";
  7049. }
  7050. if ($ktime && $jtime) {
  7051. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7052. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7053. }
  7054. //数据排序
  7055. $order_str = "id desc";
  7056. $xs = 0;
  7057. $rows = array();
  7058. $list = array();
  7059. if (empty($page)) {
  7060. $start = 0;
  7061. $perpage = 1;
  7062. } else {
  7063. $start = ($page - 1) * $perpage;
  7064. }
  7065. if ($sku || $title) {
  7066. if ($title) {
  7067. $title = trim($title, ' ');
  7068. $title = trim($title, ' ');
  7069. $where .= " and title like '%$title%'";
  7070. } else {
  7071. $sku = trim($sku, ' ');
  7072. $sku = trim($sku, ' ');
  7073. $where .= " and sku like '%$sku%'";
  7074. }
  7075. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7076. foreach ($info_list as $key => $value) {
  7077. $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'] . '"');
  7078. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7079. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7080. $rows[$key] = $value;
  7081. $warehouse = $this->warehouse->read($value['warehouse']);
  7082. $rows[$key]['warehouse'] = $warehouse['title'];
  7083. $rows[$key]['features'] = $g;
  7084. $rows[$key]['a'] = $x;
  7085. $rows[$key]['b'] = $s;
  7086. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7087. $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天销量
  7088. $yj = $c / ($xl / 30);
  7089. if ($yj < 7) {
  7090. $rows[$key]['y'] = round($yj) . '天销量';
  7091. } else {
  7092. $rows[$key]['y'] = '正常';
  7093. }
  7094. }
  7095. } else {
  7096. //$where .= " and time > '$ktime' and time < '$jtime'";
  7097. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7098. foreach ($info_list as $key => $value) {
  7099. $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'] . '"');
  7100. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7101. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7102. $zs[$key] = $value;
  7103. $warehouse = $this->warehouse->read($value['warehouse']);
  7104. $zs[$key]['warehouse'] = $warehouse['title'];
  7105. $zs[$key]['features'] = $g;
  7106. $zs[$key]['a'] = $x;
  7107. $zs[$key]['b'] = $s;
  7108. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7109. $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天销量
  7110. $yj = $c / ($xl / 30);
  7111. if ($yj < 7) {
  7112. $zs[$key]['y'] = round($yj) . '天销量';
  7113. $rows[$key] = $zs[$key];
  7114. }
  7115. }
  7116. }
  7117. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7118. $pagenum = ceil($total / $perpage);
  7119. $over = $total - ($start + $perpage);
  7120. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7121. echo json_encode($rows);
  7122. exit;
  7123. }
  7124. $this->data['arg_array'] = $arg_array[0];
  7125. $this->_Template('whlabel_fcjxc', $this->data);
  7126. }
  7127. public function _0kcdel()
  7128. {
  7129. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7130. $config['upload_path'] = '.' . $dir;
  7131. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7132. $config['allowed_types'] = 'xls|xlsx|csv';
  7133. $config['max_size'] = 10240;
  7134. $this->load->library('upload', $config);
  7135. $this->upload->initialize($config);
  7136. if ($this->upload->do_upload('userfile')) {
  7137. $full_path = $dir . $this->upload->data('file_name');
  7138. $fileName = '.' . $full_path;
  7139. if (!file_exists($fileName)) {
  7140. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7141. exit;
  7142. } else {
  7143. require_once "./data/excel/PHPExcel/IOFactory.php";
  7144. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7145. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7146. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7147. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7148. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7149. ++$column; //如果列数大于26行
  7150. $list = array();
  7151. for ($i = 2; $i <= $row; $i++) // 行数循环
  7152. {
  7153. $data = array();
  7154. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7155. {
  7156. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7157. }
  7158. $list[] = $data;
  7159. }
  7160. }
  7161. $i = 0;
  7162. $j = 0;
  7163. $ed = array();
  7164. foreach ($list as $key => $value) {
  7165. $time = time();
  7166. if ($value['0'] == "" || $value['1'] == "") {
  7167. continue;
  7168. }
  7169. $warehouse = $this->warehouse->get_title($value['0']);
  7170. $sku = $value['1'];
  7171. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7172. if (!$d) //如果没有这个SKU
  7173. {
  7174. $ed[] = array($sku . '-库存中不存在此SKU');
  7175. $j++;
  7176. continue;
  7177. }
  7178. if (!isset($warehouse['id'])) {
  7179. $ed[] = array($sku . '-仓库名错误!');
  7180. $j++;
  7181. continue;
  7182. }
  7183. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7184. if ($z < 1) {
  7185. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7186. foreach ($z as $v) {
  7187. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7188. if (count($zt) > 0) {
  7189. $ed[] = array($sku . '-有在途库存无法删除!');
  7190. $j++;
  7191. continue;
  7192. }
  7193. $this->whlabel->remove($v['id']);
  7194. }
  7195. } else {
  7196. $ed[] = array($sku . '-非0库存!');
  7197. $j++;
  7198. continue;
  7199. }
  7200. }
  7201. if ($j > 0) {
  7202. $tt = date('Ymd', time());
  7203. $title = '删除0库存错误信息-' . $tt;
  7204. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7205. $tail = "\n";
  7206. $filename = $title . ".xls";
  7207. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7208. $dir = '/data/excel/' . $time . '/';
  7209. $file_name = 'error_' . $time . rand(1000, 9999);
  7210. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7211. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7212. fwrite($myfile, $ecl);
  7213. fclose($myfile);
  7214. $error = $dir . $file_name . '.xls';
  7215. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7216. exit;
  7217. } else {
  7218. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7219. exit;
  7220. }
  7221. }
  7222. }
  7223. public function _gbhtype()
  7224. {
  7225. $post = $this->input->post(NULL, TRUE);
  7226. if (isset($post['s'])) {
  7227. $n = $this->input->post('n');
  7228. $d = $this->input->post('s');
  7229. if (!$d) {
  7230. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7231. exit;
  7232. }
  7233. $d = explode(',', trim($d, ','));
  7234. $t = $this->whlabel_type->read($n);
  7235. //循环删除记录
  7236. foreach ($d as $v) {
  7237. $u = $this->whlabel->read($v);
  7238. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7239. foreach ($data as $val) {
  7240. $this->whlabel->save(array('type' => $n), $val['id']);
  7241. }
  7242. }
  7243. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7244. }
  7245. }
  7246. //出库、退库导出
  7247. public function _dccrtype()
  7248. {
  7249. $classid = $this->classid->sku();
  7250. $pm = $classid;
  7251. $typeclass = array();
  7252. $tc = $this->typeclass->find_all();
  7253. foreach ($tc as $v) {
  7254. $typeclass[$v['id']] = $v;
  7255. }
  7256. $prc = array();
  7257. $purchase = $this->purchase->find_all();
  7258. foreach ($purchase as $k => $v) {
  7259. $prc[$v['id']] = $v['title'];
  7260. }
  7261. if (isset($_GET['sid'])) {
  7262. $wh = array();
  7263. $w = $this->warehouse->find_all('1=1', 'id,title');
  7264. foreach ($w as $v) {
  7265. $wh[$v['id']] = $v['title'];
  7266. }
  7267. $type = $this->input->get('excel', true);
  7268. $category = $this->input->get('category', true);
  7269. $size = $this->input->get('size', true);
  7270. $grade = $this->input->get('grade', true);
  7271. $color = $this->input->get('color', true);
  7272. $lowe = $this->input->get('lowe', true);
  7273. $sku = $this->input->get('sku', true);
  7274. $warehouse = $this->input->get('warehouse', true);
  7275. $lacetype = $this->input->get('lacetype', true);
  7276. $lacecolor = $this->input->get('lacecolor', true);
  7277. $density = $this->input->get('density', true);
  7278. $haircap = $this->input->get('haircap', true);
  7279. $purchase = $this->input->get('purchase', true);
  7280. $title = $this->input->get('title', true);
  7281. $state = $this->input->get('state', true);
  7282. $sid = $this->input->get('sid', true);
  7283. $ktime = $this->input->get('ktime', true);
  7284. $jtime = $this->input->get('jtime', true);
  7285. $ktime = strtotime($ktime);
  7286. $jtime = strtotime($jtime);
  7287. $where = "1=1";
  7288. $gj = "";
  7289. $ck = "";
  7290. if ($category) {
  7291. $where .= " and features like '%-$category-%'";
  7292. }
  7293. if ($size) {
  7294. $where .= " and features like '%-$size-%'";
  7295. }
  7296. if ($grade) {
  7297. $where .= " and features like '%-$grade-%'";
  7298. }
  7299. if ($color) {
  7300. $where .= " and features like '%-$color-%'";
  7301. }
  7302. if ($lowe) {
  7303. $where .= " and features like '%-$lowe-%'";
  7304. }
  7305. if ($warehouse) {
  7306. $where .= " and warehouse = '$warehouse'";
  7307. }
  7308. if ($purchase) {
  7309. $where .= " and purchase = '$purchase'";
  7310. }
  7311. if ($state) {
  7312. $where .= " and state = '$state'";
  7313. }
  7314. if ($lacetype) {
  7315. $where .= " and features like '%-$lacetype-%'";
  7316. }
  7317. if ($lacecolor) {
  7318. $where .= " and features like '%-$lacecolor-%'";
  7319. }
  7320. if ($density) {
  7321. $where .= " and features like '%-$density-%'";
  7322. }
  7323. if ($haircap) {
  7324. $where .= " and features like '%-$haircap-%'";
  7325. }
  7326. if ($title) {
  7327. $title = trim($title, ' ');
  7328. $title = trim($title, ' ');
  7329. $where .= " and title like '%$title%'";
  7330. }
  7331. if ($sku) {
  7332. $sku = trim($sku, ' ');
  7333. $sku = trim($sku, ' ');
  7334. $where .= " and sku like '%$sku%'";
  7335. }
  7336. if ($ktime && $jtime) {
  7337. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7338. }
  7339. $sidwhere = '';
  7340. if ($sid) {
  7341. $sd = "";
  7342. $s = explode(',', trim($sid, ','));
  7343. foreach ($s as $value) {
  7344. $sd .= " id = " . $value . " or";
  7345. }
  7346. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7347. }
  7348. //数据排序
  7349. $order_str = "time desc";
  7350. if (empty($page)) {
  7351. $start = 0;
  7352. $perpage = 1;
  7353. } else {
  7354. $start = ($page - 1) * $perpage;
  7355. }
  7356. $wh = array();
  7357. $w = $this->warehouse->find_all('1=1', 'id,title');
  7358. foreach ($w as $v) {
  7359. $wh[$v['id']] = $v['title'];
  7360. }
  7361. $wt = array();
  7362. $whlabel_type = $this->whlabel_type->find_all();
  7363. foreach ($whlabel_type as $v) {
  7364. $wt[$v['id']] = $v['title'];
  7365. }
  7366. $classid = $this->classid->sku();
  7367. $list = array();
  7368. $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');
  7369. foreach ($rows_r as $key => $value) {
  7370. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7371. $pm = $classid;
  7372. $jm = $classid;
  7373. $rows_r[$key]['enter'] = '入库';
  7374. $rows_r[$key]['time'] = $value['enter'];
  7375. if ($value['rktype'] == 1) {
  7376. $rows_r[$key]['rktype'] = '采购入库';
  7377. } else if ($value['rktype'] == 2) {
  7378. $rows_r[$key]['rktype'] = '盘盈调整';
  7379. } else if ($value['rktype'] == 3) {
  7380. $rows_r[$key]['rktype'] = '其他调整入库';
  7381. } else if ($value['rktype'] == 4) {
  7382. $rows_r[$key]['rktype'] = '其他调整入库';
  7383. } else if ($value['rktype'] == 5) {
  7384. $rows_r[$key]['rktype'] = '退库入库';
  7385. } else if ($value['rktype'] == 6) {
  7386. $rows_r[$key]['rktype'] = '退货可用入库';
  7387. } else if ($value['rktype'] == 7) {
  7388. $rows_r[$key]['rktype'] = '形态转换入库';
  7389. } else {
  7390. $rows_r[$key]['rktype'] = '';
  7391. }
  7392. $features = explode('-', trim($value['features'], '-'));
  7393. foreach ($features as $v) {
  7394. if (isset($typeclass[$v])) {
  7395. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7396. $pm[$typeclass[$v]['classid']] = $zh[0];
  7397. }
  7398. if (isset($typeclass[$v])) {
  7399. if (isset($jm[$typeclass[$v]['classid']])) {
  7400. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7401. }
  7402. }
  7403. }
  7404. $zh = implode(" ", $pm);
  7405. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7406. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7407. $rows_r[$key]['zh'] = $zh;
  7408. $jm = array_filter($jm);
  7409. $rows_r[$key]['features'] = implode("-", $jm);
  7410. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7411. }
  7412. $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');
  7413. foreach ($rows_c as $key => $value) {
  7414. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7415. $pm = $classid;
  7416. $jm = $classid;
  7417. $rows_c[$key]['time'] = $value['outk'];
  7418. $rows_c[$key]['outk'] = '出库';
  7419. if ($value['cktype'] == 1) {
  7420. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7421. } else if ($value['cktype'] == 2) {
  7422. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7423. } else if ($value['cktype'] == 3) {
  7424. $rows_c[$key]['cktype'] = '盘亏调整';
  7425. } else if ($value['cktype'] == 4) {
  7426. $rows_c[$key]['cktype'] = '其他调整出库';
  7427. } else if ($value['cktype'] == 5) {
  7428. $rows_c[$key]['cktype'] = '形态转换出库';
  7429. } else {
  7430. $rows_c[$key]['cktype'] = '';
  7431. }
  7432. unset($rows_c[$key]['state']);
  7433. $features = explode('-', trim($value['features'], '-'));
  7434. foreach ($features as $v) {
  7435. if (isset($typeclass[$v])) {
  7436. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7437. $pm[$typeclass[$v]['classid']] = $zh[0];
  7438. }
  7439. if (isset($typeclass[$v])) {
  7440. if (isset($jm[$typeclass[$v]['classid']])) {
  7441. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7442. }
  7443. }
  7444. }
  7445. $zh = implode(" ", $pm);
  7446. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7447. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7448. $rows_c[$key]['zh'] = $zh;
  7449. $jm = array_filter($jm);
  7450. $rows_c[$key]['features'] = implode("-", $jm);
  7451. $rows_c[$key]['number'] = 1;
  7452. }
  7453. $merged = $rows_r;
  7454. foreach ($rows_c as $key => $value) {
  7455. if (isset($merged[$key])) {
  7456. $merged[] = $value;
  7457. } else {
  7458. $merged[$key] = $value;
  7459. }
  7460. }
  7461. usort($merged, function ($a, $b) {
  7462. return $a['time'] - $b['time'];
  7463. });
  7464. foreach ($merged as $key => $value) {
  7465. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7466. }
  7467. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7468. $titlename = "<table border=1>
  7469. <tr align='center'>
  7470. <td>仓库</td>
  7471. <td>SKU</td>
  7472. <td>商品名称</td>
  7473. <td>仓库品名</td>
  7474. <td>料号</td>
  7475. <td>时间</td>
  7476. <td>操作</td>
  7477. <td>类型</td>
  7478. <td>数量</td>
  7479. <td>备注</td>
  7480. </tr>
  7481. </table>";
  7482. $filename = $title . ".xlsx";
  7483. $tail = "";
  7484. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7485. }
  7486. }
  7487. /*************************************处理exceljs导出****************************************************/
  7488. public function _excelrjs(){
  7489. if (isset($_GET['excel'])) {
  7490. $category = $this->input->get('category', true);
  7491. $size = $this->input->get('size', true);
  7492. $grade = $this->input->get('grade', true);
  7493. $color = $this->input->get('color', true);
  7494. $lowe = $this->input->get('lowe', true);
  7495. $sku = $this->input->get('sku', true);
  7496. $warehouse = $this->input->get('warehouse', true);
  7497. $purchase = $this->input->get('purchase', true);
  7498. $ktime = $this->input->get('ktime', true);
  7499. $jtime = $this->input->get('jtime', true);
  7500. $ktime = strtotime($ktime);
  7501. $jtime = strtotime($jtime);
  7502. $where = "1=1";
  7503. $gj = "";
  7504. $ck = "";
  7505. if ($category) {
  7506. $where .= " and features like '%-$category-%'";
  7507. }
  7508. if ($size) {
  7509. $where .= " and features like '%-$size-%'";
  7510. }
  7511. if ($grade) {
  7512. $where .= " and features like '%-$grade-%'";
  7513. }
  7514. if ($color) {
  7515. $where .= " and features like '%-$color-%'";
  7516. }
  7517. if ($lowe) {
  7518. $where .= " and features like '%-$lowe-%'";
  7519. }
  7520. if ($warehouse) {
  7521. $where .= " and warehouse = '$warehouse'";
  7522. }
  7523. if ($purchase) {
  7524. $where .= " and purchase = '$purchase'";
  7525. }
  7526. if ($sku) {
  7527. $where .= " and sku = '$sku'";
  7528. }
  7529. if ($ktime && $jtime) {
  7530. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7531. }
  7532. //数据排序
  7533. $order_str = "id desc";
  7534. if (empty($page)) {
  7535. $start = 0;
  7536. $perpage = 1;
  7537. } else {
  7538. $start = ($page - 1) * $perpage;
  7539. }
  7540. $list = array();
  7541. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7542. foreach ($rows as $value) {
  7543. $ck = $this->warehouse->read($value['warehouse']);
  7544. $warehouse = $ck['title'];
  7545. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7546. $retreatwarehouse = $tkck['title'];
  7547. $gy = $this->purchase->read($value['purchase']);
  7548. $purchase = $gy['title'];
  7549. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7550. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7551. }
  7552. if(empty($list)){
  7553. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7554. }else{
  7555. $final_list = [];
  7556. foreach($list as $v){
  7557. $final_list[] = array_values($v);
  7558. }
  7559. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7560. array_unshift($final_list,[
  7561. "仓库","SKU","商品名称","时间","数量"
  7562. ]);
  7563. array_unshift($final_list,[
  7564. $title,"","","",""
  7565. ]);
  7566. $merges = [
  7567. [
  7568. "s"=>["r"=>0,"c"=>0],
  7569. "e"=>["r"=>0,"c"=>4]
  7570. ]
  7571. ];
  7572. $cols = [
  7573. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7574. ];
  7575. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7576. }
  7577. }
  7578. }
  7579. //出库、退库导出
  7580. public function _excelctjs()
  7581. {
  7582. $classid = $this->classid->sku();
  7583. $pm = $classid;
  7584. $typeclass = array();
  7585. $tc = $this->typeclass->find_all();
  7586. foreach ($tc as $v) {
  7587. $typeclass[$v['id']] = $v;
  7588. }
  7589. $prc = array();
  7590. $purchase = $this->purchase->find_all();
  7591. foreach ($purchase as $k => $v) {
  7592. $prc[$v['id']] = $v['title'];
  7593. }
  7594. if (isset($_GET['excel'])) {
  7595. $wh = array();
  7596. $w = $this->warehouse->find_all('1=1', 'id,title');
  7597. foreach ($w as $v) {
  7598. $wh[$v['id']] = $v['title'];
  7599. }
  7600. $type = $this->input->get('excel', true);
  7601. $category = $this->input->get('category', true);
  7602. $size = $this->input->get('size', true);
  7603. $grade = $this->input->get('grade', true);
  7604. $color = $this->input->get('color', true);
  7605. $lowe = $this->input->get('lowe', true);
  7606. $sku = $this->input->get('sku', true);
  7607. $title = $this->input->get('title', true);
  7608. $warehouse = $this->input->get('warehouse', true);
  7609. $purchase = $this->input->get('purchase', true);
  7610. $lacetype = $this->input->get('lacetype', true);
  7611. $haircap = $this->input->get('haircap', true);
  7612. $lacecolor = $this->input->get('lacecolor', true);
  7613. $density = $this->input->get('density', true);
  7614. $details = $this->input->get('details', true);
  7615. $state = $this->input->get('state', true);
  7616. $shop = $this->input->get('shop', true);
  7617. $hairnumber = $this->input->get('hairnumber', true);
  7618. $type_leixi = $this->input->get('type', true);
  7619. $cpbz = $this->input->get('cpbz', true);
  7620. $sm = $this->input->get('sm', true);
  7621. $sid = $this->input->get('sid', true);
  7622. $ktime = $this->input->get('ktime', true);
  7623. $jtime = $this->input->get('jtime', true);
  7624. $ktime = strtotime($ktime);
  7625. $jtime = strtotime($jtime);
  7626. //$where = " 1=1 ";
  7627. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7628. $where = " sku != '' ";
  7629. $gj = "";
  7630. $ck = "";
  7631. if ($category) {
  7632. $where .= " and features like '%-$category-%'";
  7633. }
  7634. if ($size) {
  7635. $where .= " and features like '%-$size-%'";
  7636. }
  7637. if ($grade) {
  7638. $where .= " and features like '%-$grade-%'";
  7639. }
  7640. if ($color) {
  7641. $where .= " and features like '%-$color-%'";
  7642. }
  7643. if ($lowe) {
  7644. $where .= " and features like '%-$lowe-%'";
  7645. }
  7646. if ($warehouse) {
  7647. $where .= " and warehouse = '$warehouse'";
  7648. }
  7649. if ($purchase) {
  7650. $where .= " and purchase = '$purchase'";
  7651. }
  7652. if ($state) {
  7653. $where .= " and state = '$state'";
  7654. }
  7655. if ($lacetype) {
  7656. $where .= " and features like '%-$lacetype-%'";
  7657. }
  7658. if ($lacecolor) {
  7659. $where .= " and features like '%-$lacecolor-%'";
  7660. }
  7661. if ($density) {
  7662. $where .= " and features like '%-$density-%'";
  7663. }
  7664. if ($haircap) {
  7665. $where .= " and features like '%-$haircap-%'";
  7666. }
  7667. if ($details) {
  7668. $where .= " and details = '$details'";
  7669. }
  7670. if ($shop) {
  7671. $where .= " and shop like '%$shop%'";
  7672. }
  7673. if ($title) {
  7674. $title = trim($title, ' ');
  7675. $title = trim($title, ' ');
  7676. $where .= " and title like '%$title%'";
  7677. }
  7678. if (!empty($hairnumber)) {
  7679. $where .= " and features like '%-128-%' ";
  7680. if ($hairnumber < 0) {
  7681. $class_list = $this->typeclass->find_all('classid = 43');
  7682. foreach ($class_list as $v) {
  7683. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7684. }
  7685. } else {
  7686. $where .= " and features like '%-$hairnumber-%'";
  7687. }
  7688. }
  7689. if ($type_leixi) {
  7690. $where .= " and type = '$type_leixi'";
  7691. }
  7692. if ($cpbz) {
  7693. $where .= " and cpbz like '%$cpbz%' ";
  7694. }
  7695. if ($sm) {
  7696. $where .= " and sm like '%$sm%' ";
  7697. }
  7698. if ($sku) {
  7699. $sku = trim($sku, ' ');
  7700. $sku = trim($sku, ' ');
  7701. $where .= " and sku like '%$sku%'";
  7702. }
  7703. if ($ktime && $jtime) {
  7704. if ($type == 1) {
  7705. $tl = '出库';
  7706. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7707. } else if ($type == 2) {
  7708. $tl = '退库';
  7709. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7710. } else if ($type == 3) {
  7711. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7712. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7713. } else if ($type == 4) {
  7714. $tl = '出库+零售';
  7715. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7716. } else if ($type == 5) {
  7717. $tl = '零售';
  7718. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7719. }
  7720. }
  7721. $sidwhere = '';
  7722. if ($sid) {
  7723. $sd = "";
  7724. $s = explode(',', trim($sid, ','));
  7725. foreach ($s as $value) {
  7726. $sd .= " id = " . $value . " or";
  7727. }
  7728. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7729. }
  7730. //数据排序
  7731. $order_str = "time desc";
  7732. if (empty($page)) {
  7733. $start = 0;
  7734. $perpage = 1;
  7735. } else {
  7736. $start = ($page - 1) * $perpage;
  7737. }
  7738. //取得信息列表
  7739. if ($type != 3 && $type != 5) {
  7740. if ($type == 1 || $type == 4) {
  7741. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7742. foreach ($info_list as $key => $value) {
  7743. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7744. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7745. $warehouse = $this->warehouse->read($value['warehouse']);
  7746. $info_list[$key]['warehouse'] = $warehouse['title'];
  7747. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7748. $features = explode('-', trim($features, '-'));
  7749. $pm = $classid;
  7750. foreach ($features as $k => $v) {
  7751. if ($v != 0) {
  7752. if (!isset($typeclass[$v])) {
  7753. continue;
  7754. }
  7755. if (isset($pm[$typeclass[$v]['classid']])) {
  7756. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7757. $tz = explode('|', $typeclass[$v]['zh']);
  7758. $pm[$typeclass[$v]['classid']] = $tz[0];
  7759. } else {
  7760. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7761. }
  7762. }
  7763. }
  7764. }
  7765. $zh = implode(" ", $pm);
  7766. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7767. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7768. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7769. $info_list[$key]['features'] = $zh;
  7770. }
  7771. $final_list = [];
  7772. foreach($info_list as $k=>$v){
  7773. $number = "";
  7774. if(!empty($v['orderinfo'])){
  7775. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7776. if(!empty($tmp_info['number'])){
  7777. $number = $tmp_info['number'];
  7778. }
  7779. }
  7780. $final_list[] = [
  7781. 'warehouse'=>$v['warehouse'],
  7782. 'purchase'=>$v['purchase'],
  7783. 'sku'=>$v['sku'],
  7784. 'title'=>$v['title'],
  7785. 'features'=>$v['features'],
  7786. 'label'=>$v['label'],
  7787. 'orderinfo'=>$v['orderinfo'],
  7788. 'number'=>$number,
  7789. 'waybill'=>$v['waybill'],
  7790. 'outk'=>$v['outk'],
  7791. ];
  7792. }
  7793. } else {
  7794. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7795. foreach ($info_list as $key => $value) {
  7796. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7797. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7798. $warehouse = $this->warehouse->read($value['warehouse']);
  7799. $info_list[$key]['warehouse'] = $warehouse['title'];
  7800. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7801. $features = explode('-', trim($features, '-'));
  7802. $pm = $classid;
  7803. foreach ($features as $k => $v) {
  7804. if ($v != 0) {
  7805. if (!isset($typeclass[$v])) {
  7806. continue;
  7807. }
  7808. if (isset($pm[$typeclass[$v]['classid']])) {
  7809. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7810. $tz = explode('|', $typeclass[$v]['zh']);
  7811. $pm[$typeclass[$v]['classid']] = $tz[0];
  7812. } else {
  7813. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7814. }
  7815. }
  7816. }
  7817. }
  7818. $zh = implode(" ", $pm);
  7819. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7820. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7821. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7822. $info_list[$key]['features'] = $zh;
  7823. }
  7824. $final_list = [];
  7825. foreach($info_list as $k=>$v){
  7826. $number = "";
  7827. if(!empty($v['orderinfo'])){
  7828. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7829. if(!empty($tmp_info['number'])){
  7830. $number = $tmp_info['number'];
  7831. }
  7832. }
  7833. $final_list[] = [
  7834. 'warehouse'=>$v['warehouse'],
  7835. 'purchase'=>$v['purchase'],
  7836. 'sku'=>$v['sku'],
  7837. 'title'=>$v['title'],
  7838. 'features'=>$v['features'],
  7839. 'label'=>$v['label'],
  7840. 'orderinfo'=>$v['orderinfo'],
  7841. 'number'=>$number,
  7842. 'waybill'=>$v['waybill'],
  7843. 'retreat'=>$v['retreat'],
  7844. ];
  7845. }
  7846. }
  7847. if(empty($final_list)){
  7848. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7849. }else{
  7850. $end_list = [];
  7851. foreach($final_list as $v){
  7852. $end_list[] = array_values($v);
  7853. }
  7854. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7855. array_unshift($end_list,[
  7856. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7857. ]);
  7858. array_unshift($end_list,[
  7859. $title,"","","","","","","","",""
  7860. ]);
  7861. $merges = [
  7862. [
  7863. "s"=>["r"=>0,"c"=>0],
  7864. "e"=>["r"=>0,"c"=>9]
  7865. ]
  7866. ];
  7867. $cols = [
  7868. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  7869. ];
  7870. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  7871. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  7872. ] )));
  7873. }
  7874. } else if ($type == 5) {
  7875. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  7876. foreach ($info_list as $key => $value) {
  7877. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7878. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7879. $warehouse = $this->warehouse->read($value['warehouse']);
  7880. $info_list[$key]['warehouse'] = $warehouse['title'];
  7881. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7882. $features = explode('-', trim($features, '-'));
  7883. $pm = $classid;
  7884. foreach ($features as $k => $v) {
  7885. if ($v != 0) {
  7886. if (!isset($typeclass[$v])) {
  7887. continue;
  7888. }
  7889. if (isset($pm[$typeclass[$v]['classid']])) {
  7890. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7891. $tz = explode('|', $typeclass[$v]['zh']);
  7892. $pm[$typeclass[$v]['classid']] = $tz[0];
  7893. } else {
  7894. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7895. }
  7896. }
  7897. }
  7898. }
  7899. $zh = implode(" ", $pm);
  7900. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7901. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7902. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7903. $info_list[$key]['features'] = $zh;
  7904. }
  7905. if(empty($info_list)){
  7906. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7907. }else{
  7908. $final_list = [];
  7909. foreach($info_list as $v){
  7910. $final_list[] = array_values($v);
  7911. }
  7912. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  7913. array_unshift($final_list,[
  7914. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  7915. ]);
  7916. array_unshift($final_list,[
  7917. $title,"","","","","","",
  7918. ]);
  7919. $merges = [
  7920. [
  7921. "s"=>["r"=>0,"c"=>0],
  7922. "e"=>["r"=>0,"c"=>6]
  7923. ]
  7924. ];
  7925. $cols = [
  7926. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  7927. ];
  7928. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  7929. }
  7930. } else {
  7931. $wh = array();
  7932. $w = $this->warehouse->find_all('1=1', 'id,title');
  7933. foreach ($w as $v) {
  7934. $wh[$v['id']] = $v['title'];
  7935. }
  7936. $wt = array();
  7937. $whlabel_type = $this->whlabel_type->find_all();
  7938. foreach ($whlabel_type as $v) {
  7939. $wt[$v['id']] = $v['title'];
  7940. }
  7941. $classid = $this->classid->sku();
  7942. $list = array();
  7943. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  7944. foreach ($rows as $key => $value) {
  7945. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7946. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7947. $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');
  7948. $details = array();
  7949. $cpid = array();
  7950. $cpbz = array();
  7951. $c = 0;
  7952. $g = 0;
  7953. $x = 0;
  7954. $t = 0;
  7955. $s = 0;
  7956. $q = 0;
  7957. foreach ($sd as $k => $v) {
  7958. if ($v['state'] == 0) {
  7959. $c++;
  7960. }
  7961. if ($v['state'] != 9) {
  7962. $g++;
  7963. }
  7964. if ($v['outk'] > 1) {
  7965. $x++;
  7966. }
  7967. if ($v['retreat'] > 0) {
  7968. $t++;
  7969. }
  7970. if ($v['state'] == 8) {
  7971. $s++;
  7972. }
  7973. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  7974. $q++;
  7975. }
  7976. $details[$v['details']] = $v['details'];
  7977. if ($v['cpid'] != 0) {
  7978. $cpid[$v['cpid']] = $v['cpid'];
  7979. }
  7980. if ($v['cpbz'] != '') {
  7981. $cpbz[$v['cpbz']] = $v['cpbz'];
  7982. }
  7983. }
  7984. if (isset($wt[$value['type']])) {
  7985. $rows[$key]['type'] = $wt[$value['type']];
  7986. } else {
  7987. $rows[$key]['type'] = '未设置';
  7988. }
  7989. $rows[$key]['details'] = implode("、", $details);
  7990. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  7991. $ftime = time() - 15 * 24 * 3600;
  7992. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  7993. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  7994. $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);
  7995. $rows[$key]['c'] = $c;
  7996. $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);
  7997. $rows[$key]['t'] = $t;
  7998. $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'] . '"');
  7999. $rows[$key]['z'] = $z;
  8000. // $jm = $classid;
  8001. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8002. $features = explode('-', trim($features, '-'));
  8003. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8004. }
  8005. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8006. $final_list =[];
  8007. foreach($tmp_list as $k=>$v){
  8008. $final_list[] = [
  8009. "warehouse"=>$v['warehouse'],
  8010. "purchase"=>$v['purchase'],
  8011. "details"=>$v['details'],
  8012. "cpid"=>$v['cpid'],
  8013. "sku"=>$v['sku'],
  8014. "title"=>$v['title'],
  8015. "features"=>$v['pm'],
  8016. "cpbz"=>$v['cpbz'],
  8017. "sm"=>$v['sm'],
  8018. "type"=>$v['type'],
  8019. "g"=>$v["g"],
  8020. "c"=>$v["c"],
  8021. "x"=>$v["x"],
  8022. "t"=>$v["t"],
  8023. "z"=>$v["z"],
  8024. "jm"=>$v["jm"],
  8025. "weight"=>$v["weight"],
  8026. "asd"=>$v["asd"],
  8027. ];
  8028. }
  8029. if(empty($final_list)){
  8030. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8031. }else{
  8032. $end_list = [];
  8033. foreach($final_list as $v){
  8034. $end_list[] = array_values($v);
  8035. }
  8036. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8037. array_unshift($end_list,[
  8038. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8039. ]);
  8040. array_unshift($end_list,[
  8041. $title,"","","","","","","","","","","","","","","","","",""
  8042. ]);
  8043. $merges = [
  8044. [
  8045. "s"=>["r"=>0,"c"=>0],
  8046. "e"=>["r"=>0,"c"=>6]
  8047. ]
  8048. ];
  8049. $cols = [
  8050. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8051. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8052. ];
  8053. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8054. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8055. ])));
  8056. }
  8057. }
  8058. }
  8059. }
  8060. public function _exceljxcjs(){
  8061. $classid = $this->classid->sku();
  8062. $pm = $classid;
  8063. $typeclass = array();
  8064. $tc = $this->typeclass->find_all();
  8065. foreach ($tc as $v) {
  8066. $typeclass[$v['id']] = $v;
  8067. }
  8068. $prc = array();
  8069. $purchase = $this->purchase->find_all();
  8070. foreach ($purchase as $k => $v) {
  8071. $prc[$v['id']] = $v['title'];
  8072. }
  8073. if(!isset($_GET['excel'])){
  8074. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8075. }
  8076. $where = "sku != 'Preset'";
  8077. //数据排序
  8078. $order_str = "id desc";
  8079. if (empty($page)) {
  8080. $start = 0;
  8081. $perpage = 1;
  8082. } else {
  8083. $start = ($page - 1) * $perpage;
  8084. }
  8085. $category = $this->input->get('category', true);
  8086. $warehouse = $this->input->get('warehouse', true);
  8087. $excelid = $this->input->get('sid', true);
  8088. if ($category) {
  8089. $where .= " and features like '%-$category-%'";
  8090. }
  8091. if ($warehouse) {
  8092. $where .= " and warehouse = '$warehouse'";
  8093. }
  8094. $xzid = '';
  8095. if ($excelid) {
  8096. $excelid = explode(',', trim($excelid, ','));
  8097. foreach ($excelid as $key => $value) {
  8098. $xzid .= " id = " . $value . " or";
  8099. }
  8100. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8101. }
  8102. $wt = array();
  8103. $whlabel_type = $this->whlabel_type->find_all();
  8104. foreach ($whlabel_type as $v) {
  8105. $wt[$v['id']] = $v['title'];
  8106. }
  8107. $wh = array();
  8108. $w = $this->warehouse->find_all('1=1', 'id,title');
  8109. foreach ($w as $v) {
  8110. $wh[$v['id']] = $v['title'];
  8111. }
  8112. $list = array();
  8113. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8114. foreach ($rows as $key => $value) {
  8115. if (isset($wt[$value['type']])) {
  8116. $rows[$key]['type'] = $wt[$value['type']];
  8117. } else {
  8118. $rows[$key]['type'] = '未设置';
  8119. }
  8120. $bm = '03';
  8121. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8122. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8123. $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');
  8124. $details = array();
  8125. $cpid = array();
  8126. $cpbz = array();
  8127. $c = 0;
  8128. $g = 0;
  8129. $x = 0;
  8130. $t = 0;
  8131. $s = 0;
  8132. $q = 0;
  8133. foreach ($sd as $k => $v) {
  8134. if ($v['state'] == 0) {
  8135. $c++;
  8136. if ($v['cpid'] != 0) {
  8137. $cpid[$v['cpid']] = $v['cpid'];
  8138. }
  8139. if ($v['cpbz'] != '') {
  8140. $cpbz[$v['cpbz']] = $v['cpbz'];
  8141. }
  8142. }
  8143. if ($v['state'] != 9) {
  8144. $g++;
  8145. }
  8146. if ($v['state'] == 1) {
  8147. $x++;
  8148. }
  8149. if ($v['state'] == 2) {
  8150. $t++;
  8151. }
  8152. if ($v['state'] == 8) {
  8153. $s++;
  8154. }
  8155. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8156. $q++;
  8157. }
  8158. $details[$v['details']] = $v['details'];
  8159. }
  8160. $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'] . '"');
  8161. $rows[$key]['details'] = implode("、", $details);
  8162. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8163. $number = $value['number'];
  8164. $ftime = time() - 15 * 24 * 3600;
  8165. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8166. $rows[$key]['number'] = $g;
  8167. $rows[$key]['c'] = $c;
  8168. $rows[$key]['x'] = $x;
  8169. $rows[$key]['t'] = $t;
  8170. $rows[$key]['s'] = $s;
  8171. $rows[$key]['q'] = $q;
  8172. $rows[$key]['z'] = $z;
  8173. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8174. $features = explode('-', trim($features, '-'));
  8175. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8176. }
  8177. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8178. $final_list = [];
  8179. foreach ($list as $k => $v) {
  8180. if (empty($v['sku'])) {
  8181. continue;
  8182. }
  8183. $final_list[] = [
  8184. $v["warehouse"],
  8185. $v["purchase"],
  8186. $v["details"],
  8187. $v["cpid"],
  8188. $v["dbcontent"],
  8189. $v["sku"],
  8190. $v["bm"],
  8191. $v["jm"],
  8192. $v["title"],
  8193. $v["pm"],
  8194. $v["cpbz"],
  8195. $v["sm"],
  8196. $v["type"],
  8197. $v["number"],
  8198. $v["c"],
  8199. $v["x"],
  8200. $v["t"],
  8201. $v["s"],
  8202. $v["q"],
  8203. $v["z"],
  8204. $v['weight'],
  8205. ];
  8206. }
  8207. if(empty($final_list)){
  8208. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8209. }
  8210. $title = "总进销存统计表";
  8211. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8212. $merges = [
  8213. [
  8214. "s"=>["r"=>0,"c"=>0],
  8215. "e"=>["r"=>0,"c"=>21]
  8216. ]
  8217. ];
  8218. $cols = [
  8219. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8220. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8221. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8222. ];
  8223. array_unshift($final_list, $first_row);
  8224. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8225. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8226. }
  8227. public function _summaryjs($arg_array)
  8228. {
  8229. $prc = array();
  8230. $purchase = $this->purchase->find_all();
  8231. foreach ($purchase as $k => $v) {
  8232. $prc[$v['id']] = $v['title'];
  8233. }
  8234. if (isset($_GET['excel'])) {
  8235. $ktime = $this->input->get('ktime', true);
  8236. $jtime = $this->input->get('jtime', true);
  8237. $ktime = strtotime($ktime);
  8238. $jtime = strtotime($jtime);
  8239. $where = "1=1";
  8240. if ($ktime && $jtime) {
  8241. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8242. }
  8243. //数据排序
  8244. $order_str = "time desc";
  8245. if (empty($page)) {
  8246. $start = 0;
  8247. $perpage = 1;
  8248. } else {
  8249. $start = ($page - 1) * $perpage;
  8250. }
  8251. //取得信息列表
  8252. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8253. foreach ($info_list as $key => $value) {
  8254. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8255. $warehouse = $this->warehouse->read($value['warehouse']);
  8256. $info_list[$key]['warehouse'] = $warehouse['title'];
  8257. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8258. $details = array();
  8259. $cpid = array();
  8260. foreach ($x as $k => $v) {
  8261. if ($v['details'] != '') {
  8262. $details[$v['details']] = $v['details'];
  8263. }
  8264. if ($v['cpid'] != 0) {
  8265. $cpid[$v['cpid']] = $v['cpid'];
  8266. }
  8267. }
  8268. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8269. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8270. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8271. $info_list[$key]['s'] = $s;
  8272. $info_list[$key]['x'] = count($x);
  8273. }
  8274. if(empty($info_list)){
  8275. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8276. }
  8277. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8278. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8279. $merges = [
  8280. [
  8281. "s"=>["r"=>0,"c"=>0],
  8282. "e"=>["r"=>0,"c"=>7]
  8283. ]
  8284. ];
  8285. $cols = [
  8286. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8287. ];
  8288. $final_list = [];
  8289. foreach($info_list as $k => $v){
  8290. $final_list[] = array_values($v);
  8291. }
  8292. array_unshift($final_list, $first_row);
  8293. array_unshift($final_list,[
  8294. $title,"","","","","","","","",
  8295. ]);
  8296. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8297. $titlename = "<table border=1>
  8298. <tr align='center'>
  8299. <td>仓库</td>
  8300. <td>供应商</td>
  8301. <td>出库位置</td>
  8302. <td>出库编码</td>
  8303. <td>SKU</td>
  8304. <td>产品名</td>
  8305. <td>总剩余库存</td>
  8306. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8307. </tr>
  8308. </table>";
  8309. $filename = $title . ".xls";
  8310. $tail = "";
  8311. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8312. }
  8313. }
  8314. public function _uckjs()
  8315. {
  8316. if (isset($_GET['excel'])) {
  8317. $tc = array();
  8318. $typeclass = $this->typeclass->find_all();
  8319. foreach ($typeclass as $v) {
  8320. $tc[$v['id']] = $v['zh'];
  8321. }
  8322. $first_row = [
  8323. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8324. ];
  8325. $t = array();
  8326. $rq = '';
  8327. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8328. $ts = $ts / (24 * 3600);
  8329. for ($i = 0; $i < $ts; $i++) {
  8330. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8331. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8332. }
  8333. $day_len = count($t);
  8334. $first_row[] = "本月出库";
  8335. $merges = [
  8336. ];
  8337. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8338. $excel_key = 1;
  8339. $final_list = [];
  8340. foreach ($info_list as $k => $v) {
  8341. $features = explode('-', trim($v['features'], '-'));
  8342. if (!isset($features[3]) || !isset($features[4])) {
  8343. continue;
  8344. }
  8345. $tmp = [];
  8346. $tmp[0] = $tc[$features[0]]; //类型
  8347. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8348. $tmp[2] = $tc[$features[4]]; //曲度
  8349. $tmp[3] = '';
  8350. if (isset($data[$k][1])) {
  8351. $tmp[3] .=$tmp[1];
  8352. }
  8353. if (isset($data[$k][2])) {
  8354. $tmp[3] .= $tmp[2];
  8355. }
  8356. if (isset($features[5])) {
  8357. $tmp[3] .= $tc[$features[5]];
  8358. }
  8359. if (isset($features[2])) {
  8360. $tmp[3] .= $tc[$features[2]];
  8361. }
  8362. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8363. $tmp[4] = $v['sku'];
  8364. $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())) . '))'); //月初库存
  8365. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8366. $tmp[7] ="";
  8367. $tmp[8] ="";
  8368. $byck = 0;
  8369. foreach ($t as $vv) {
  8370. $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));
  8371. $tmp[] = ($sl > 0) ? $sl : '';
  8372. $byck += $sl;
  8373. }
  8374. $tmp[] = ($byck > 0) ? $byck : '';
  8375. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8376. // $ztrq = '';
  8377. // $ztsl = '';
  8378. // if (count($zt) > 0) {
  8379. // foreach ($zt as $vv) {
  8380. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8381. // $ztsl .= $vv['num'] . '<br>';
  8382. // }
  8383. // }
  8384. if(empty($zt)){
  8385. $final_list[] = $tmp;
  8386. $excel_key = $excel_key + 1;
  8387. }else{
  8388. $len = count($zt);
  8389. if($len == 1){
  8390. $tmp[7] = $zt[0]['num'] ;
  8391. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8392. $final_list[] = $tmp;
  8393. $excel_key = $excel_key + 1;
  8394. }else{
  8395. foreach($zt as $vv){
  8396. $tmp[7] = "";
  8397. $tmp[8] = "";
  8398. $tmp[7] = $vv['num'];
  8399. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8400. $final_list[] = $tmp;
  8401. }
  8402. $merges[] = [
  8403. "s"=>["r"=>$excel_key,"c"=>0],
  8404. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8405. ];
  8406. $merges[] = [
  8407. "s"=>["r"=>$excel_key,"c"=>1],
  8408. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8409. ];
  8410. $merges[] = [
  8411. "s"=>["r"=>$excel_key,"c"=>2],
  8412. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8413. ];
  8414. $merges[] = [
  8415. "s"=>["r"=>$excel_key,"c"=>3],
  8416. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8417. ];
  8418. $merges[] = [
  8419. "s"=>["r"=>$excel_key,"c"=>4],
  8420. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8421. ];
  8422. $merges[] = [
  8423. "s"=>["r"=>$excel_key,"c"=>5],
  8424. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8425. ];
  8426. $merges[] = [
  8427. "s"=>["r"=>$excel_key,"c"=>6],
  8428. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8429. ];
  8430. for($i=1;$i<=$day_len;$i++){
  8431. $merges[] = [
  8432. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8433. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8434. ];
  8435. }
  8436. $merges[] = [
  8437. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8438. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8439. ];
  8440. $excel_key = $excel_key + $len;
  8441. }
  8442. }
  8443. }
  8444. $title = "详情 " . date("Y-m-d", time());
  8445. if(empty($final_list)){
  8446. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8447. }
  8448. $cols = [
  8449. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8450. ];
  8451. array_unshift($final_list, $first_row);
  8452. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8453. }
  8454. }
  8455. public function _whlabelexcelzhjs(){
  8456. if(empty($_GET['excel'])){
  8457. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8458. }
  8459. $where = "sku != 'Preset' and sku != '' ";
  8460. //数据排序
  8461. $order_str = "id desc";
  8462. if (empty($page)) {
  8463. $start = 0;
  8464. $perpage = 1;
  8465. } else {
  8466. $start = ($page - 1) * $perpage;
  8467. }
  8468. $category = $this->input->get('category', true);
  8469. $warehouse = $this->input->get('warehouse', true);
  8470. $excelid = $this->input->get('sid', true);
  8471. if ($category) {
  8472. $where .= " and features like '%-$category-%'";
  8473. }
  8474. if ($warehouse) {
  8475. $where .= " and warehouse = '$warehouse'";
  8476. }
  8477. $xzid = '';
  8478. if ($excelid) {
  8479. $excelid = explode(',', trim($excelid, ','));
  8480. foreach ($excelid as $key => $value) {
  8481. $xzid .= " id = " . $value . " or";
  8482. }
  8483. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8484. }
  8485. $merges = [
  8486. [
  8487. "s"=>["r"=>0,"c"=>0],
  8488. "e"=>["r"=>0,"c"=>6]
  8489. ]
  8490. ];
  8491. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8492. $excel_index = 2;
  8493. $final_list = [];
  8494. foreach ($rows as $key => $value) {
  8495. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8496. $zh = '';
  8497. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8498. // foreach ($zt_list as $v) {
  8499. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8500. // }
  8501. $zt = array_sum(array_column($zt_list, 'num'));
  8502. $number = $value['number'];
  8503. $ftime = time() - 15 * 24 * 3600;
  8504. $warehouse = $this->warehouse->read($value['warehouse']);
  8505. // $rows[$key]['warehouse'] = $warehouse['title'];
  8506. // $rows[$key]['number'] = $c;
  8507. // $rows[$key]['features'] = $zh;
  8508. //$rows[$key]['hb'] = $c + $zt;
  8509. $tmp = [];
  8510. $tmp[0] = $warehouse['title'];
  8511. $tmp[1] = $value['sku'];
  8512. $tmp[2] = $value['title'];
  8513. $tmp[3] = $c;
  8514. $tmp[4] = "";
  8515. $tmp[5] = $c + $zt;
  8516. if(empty($zt_list)){
  8517. $tmp[4] = "";
  8518. $final_list[] = $tmp;
  8519. $excel_index = $excel_index + 1;
  8520. }else{
  8521. if(count($zt_list) == 1){
  8522. $tmp[4] = "";
  8523. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8524. $final_list[] = $tmp;
  8525. $excel_index = $excel_index + 1;
  8526. }else{
  8527. $len = count($zt_list);
  8528. foreach ($zt_list as $v){
  8529. $tmp[4] = "";
  8530. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8531. $final_list[] = $tmp;
  8532. }
  8533. $merges[] = [
  8534. "s"=>["r"=>$excel_index,"c"=>0],
  8535. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8536. ];
  8537. $merges[] = [
  8538. "s"=>["r"=>$excel_index,"c"=>1],
  8539. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8540. ];
  8541. $merges[] = [
  8542. "s"=>["r"=>$excel_index,"c"=>2],
  8543. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8544. ];
  8545. $merges[] = [
  8546. "s"=>["r"=>$excel_index,"c"=>3],
  8547. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8548. ];
  8549. $merges[] = [
  8550. "s"=>["r"=>$excel_index,"c"=>5],
  8551. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8552. ];
  8553. $excel_index = $excel_index + $len;
  8554. }
  8555. }
  8556. }
  8557. $first_row = [
  8558. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8559. ];
  8560. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8561. if(empty($final_list)){
  8562. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8563. }
  8564. $cols = [
  8565. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8566. ];
  8567. array_unshift($final_list, $first_row);
  8568. array_unshift($final_list, [
  8569. $title,"","","","",""
  8570. ]);
  8571. $end_list = [];
  8572. foreach ($final_list as $key => $value) {
  8573. $end_list[] = array_values($value);
  8574. }
  8575. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8576. }
  8577. //出库、退库导出
  8578. public function _dccrtypejs()
  8579. {
  8580. $classid = $this->classid->sku();
  8581. $pm = $classid;
  8582. $typeclass = array();
  8583. $tc = $this->typeclass->find_all();
  8584. foreach ($tc as $v) {
  8585. $typeclass[$v['id']] = $v;
  8586. }
  8587. $prc = array();
  8588. $purchase = $this->purchase->find_all();
  8589. foreach ($purchase as $k => $v) {
  8590. $prc[$v['id']] = $v['title'];
  8591. }
  8592. if (isset($_GET['sid'])) {
  8593. $wh = array();
  8594. $w = $this->warehouse->find_all('1=1', 'id,title');
  8595. foreach ($w as $v) {
  8596. $wh[$v['id']] = $v['title'];
  8597. }
  8598. $type = $this->input->get('excel', true);
  8599. $category = $this->input->get('category', true);
  8600. $size = $this->input->get('size', true);
  8601. $grade = $this->input->get('grade', true);
  8602. $color = $this->input->get('color', true);
  8603. $lowe = $this->input->get('lowe', true);
  8604. $sku = $this->input->get('sku', true);
  8605. $warehouse = $this->input->get('warehouse', true);
  8606. $lacetype = $this->input->get('lacetype', true);
  8607. $lacecolor = $this->input->get('lacecolor', true);
  8608. $density = $this->input->get('density', true);
  8609. $haircap = $this->input->get('haircap', true);
  8610. $purchase = $this->input->get('purchase', true);
  8611. $title = $this->input->get('title', true);
  8612. $state = $this->input->get('state', true);
  8613. $sid = $this->input->get('sid', true);
  8614. $ktime = $this->input->get('ktime', true);
  8615. $jtime = $this->input->get('jtime', true);
  8616. $ktime = strtotime($ktime);
  8617. $jtime = strtotime($jtime);
  8618. $where = "1=1";
  8619. $gj = "";
  8620. $ck = "";
  8621. if ($category) {
  8622. $where .= " and features like '%-$category-%'";
  8623. }
  8624. if ($size) {
  8625. $where .= " and features like '%-$size-%'";
  8626. }
  8627. if ($grade) {
  8628. $where .= " and features like '%-$grade-%'";
  8629. }
  8630. if ($color) {
  8631. $where .= " and features like '%-$color-%'";
  8632. }
  8633. if ($lowe) {
  8634. $where .= " and features like '%-$lowe-%'";
  8635. }
  8636. if ($warehouse) {
  8637. $where .= " and warehouse = '$warehouse'";
  8638. }
  8639. if ($purchase) {
  8640. $where .= " and purchase = '$purchase'";
  8641. }
  8642. if ($state) {
  8643. $where .= " and state = '$state'";
  8644. }
  8645. if ($lacetype) {
  8646. $where .= " and features like '%-$lacetype-%'";
  8647. }
  8648. if ($lacecolor) {
  8649. $where .= " and features like '%-$lacecolor-%'";
  8650. }
  8651. if ($density) {
  8652. $where .= " and features like '%-$density-%'";
  8653. }
  8654. if ($haircap) {
  8655. $where .= " and features like '%-$haircap-%'";
  8656. }
  8657. if ($title) {
  8658. $title = trim($title, ' ');
  8659. $title = trim($title, ' ');
  8660. $where .= " and title like '%$title%'";
  8661. }
  8662. if ($sku) {
  8663. $sku = trim($sku, ' ');
  8664. $sku = trim($sku, ' ');
  8665. $where .= " and sku like '%$sku%'";
  8666. }
  8667. if ($ktime && $jtime) {
  8668. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8669. }
  8670. $sidwhere = '';
  8671. if ($sid) {
  8672. $sd = "";
  8673. $s = explode(',', trim($sid, ','));
  8674. foreach ($s as $value) {
  8675. $sd .= " id = " . $value . " or";
  8676. }
  8677. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8678. }
  8679. //数据排序
  8680. $order_str = "time desc";
  8681. if (empty($page)) {
  8682. $start = 0;
  8683. $perpage = 1;
  8684. } else {
  8685. $start = ($page - 1) * $perpage;
  8686. }
  8687. $wh = array();
  8688. $w = $this->warehouse->find_all('1=1', 'id,title');
  8689. foreach ($w as $v) {
  8690. $wh[$v['id']] = $v['title'];
  8691. }
  8692. $wt = array();
  8693. $whlabel_type = $this->whlabel_type->find_all();
  8694. foreach ($whlabel_type as $v) {
  8695. $wt[$v['id']] = $v['title'];
  8696. }
  8697. $classid = $this->classid->sku();
  8698. $list = array();
  8699. $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');
  8700. foreach ($rows_r as $key => $value) {
  8701. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8702. $pm = $classid;
  8703. $jm = $classid;
  8704. $rows_r[$key]['enter'] = '入库';
  8705. $rows_r[$key]['time'] = $value['enter'];
  8706. if ($value['rktype'] == 1) {
  8707. $rows_r[$key]['rktype'] = '采购入库';
  8708. } else if ($value['rktype'] == 2) {
  8709. $rows_r[$key]['rktype'] = '盘盈调整';
  8710. } else if ($value['rktype'] == 3) {
  8711. $rows_r[$key]['rktype'] = '其他调整入库';
  8712. } else if ($value['rktype'] == 4) {
  8713. $rows_r[$key]['rktype'] = '其他调整入库';
  8714. } else if ($value['rktype'] == 5) {
  8715. $rows_r[$key]['rktype'] = '退库入库';
  8716. } else if ($value['rktype'] == 6) {
  8717. $rows_r[$key]['rktype'] = '退货可用入库';
  8718. } else if ($value['rktype'] == 7) {
  8719. $rows_r[$key]['rktype'] = '形态转换入库';
  8720. } else {
  8721. $rows_r[$key]['rktype'] = '';
  8722. }
  8723. $features = explode('-', trim($value['features'], '-'));
  8724. foreach ($features as $v) {
  8725. if (isset($typeclass[$v])) {
  8726. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8727. $pm[$typeclass[$v]['classid']] = $zh[0];
  8728. }
  8729. if (isset($typeclass[$v])) {
  8730. if (isset($jm[$typeclass[$v]['classid']])) {
  8731. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8732. }
  8733. }
  8734. }
  8735. $zh = implode(" ", $pm);
  8736. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8737. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8738. $rows_r[$key]['zh'] = $zh;
  8739. $jm = array_filter($jm);
  8740. $rows_r[$key]['features'] = implode("-", $jm);
  8741. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8742. }
  8743. $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');
  8744. foreach ($rows_c as $key => $value) {
  8745. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8746. $pm = $classid;
  8747. $jm = $classid;
  8748. $rows_c[$key]['time'] = $value['outk'];
  8749. $rows_c[$key]['outk'] = '出库';
  8750. if ($value['cktype'] == 1) {
  8751. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8752. } else if ($value['cktype'] == 2) {
  8753. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8754. } else if ($value['cktype'] == 3) {
  8755. $rows_c[$key]['cktype'] = '盘亏调整';
  8756. } else if ($value['cktype'] == 4) {
  8757. $rows_c[$key]['cktype'] = '其他调整出库';
  8758. } else if ($value['cktype'] == 5) {
  8759. $rows_c[$key]['cktype'] = '形态转换出库';
  8760. } else {
  8761. $rows_c[$key]['cktype'] = '';
  8762. }
  8763. unset($rows_c[$key]['state']);
  8764. $features = explode('-', trim($value['features'], '-'));
  8765. foreach ($features as $v) {
  8766. if (isset($typeclass[$v])) {
  8767. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8768. $pm[$typeclass[$v]['classid']] = $zh[0];
  8769. }
  8770. if (isset($typeclass[$v])) {
  8771. if (isset($jm[$typeclass[$v]['classid']])) {
  8772. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8773. }
  8774. }
  8775. }
  8776. $zh = implode(" ", $pm);
  8777. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8778. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8779. $rows_c[$key]['zh'] = $zh;
  8780. $jm = array_filter($jm);
  8781. $rows_c[$key]['features'] = implode("-", $jm);
  8782. $rows_c[$key]['number'] = 1;
  8783. }
  8784. $merged = $rows_r;
  8785. foreach ($rows_c as $key => $value) {
  8786. if (isset($merged[$key])) {
  8787. $merged[] = $value;
  8788. } else {
  8789. $merged[$key] = $value;
  8790. }
  8791. }
  8792. usort($merged, function ($a, $b) {
  8793. return $a['time'] - $b['time'];
  8794. });
  8795. foreach ($merged as $key => $value) {
  8796. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8797. }
  8798. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8799. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8800. $cols = [
  8801. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8802. ];
  8803. $final_list= [];
  8804. foreach($merged as $key => $value){
  8805. $final_list[] = array_values($value) ;
  8806. }
  8807. if(empty($merged)){
  8808. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8809. }
  8810. array_unshift($final_list, $first_row);
  8811. $end_list = [];
  8812. foreach ($final_list as $key => $value) {
  8813. $end_list[] = array_values($value);
  8814. }
  8815. $merges = [];
  8816. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8817. }
  8818. }
  8819. public function _errorexceljs()
  8820. {
  8821. $post = $this->input->post(NULL, TRUE);
  8822. if (isset($_GET['page'])) {
  8823. $page = $this->input->get('page', true);
  8824. $perpage = $this->input->get('perpage', true);
  8825. $sku = $this->input->get('sku', true);
  8826. $warehouse = $this->input->get('warehouse', true);
  8827. $ktime = $this->input->get('ktime', true);
  8828. $jtime = $this->input->get('jtime', true);
  8829. $ktime = strtotime($ktime);
  8830. $jtime = strtotime($jtime);
  8831. $where = "sku != 'Preset'";
  8832. $gj = '';
  8833. if ($sku) {
  8834. $where .= " and sku like '%$sku%'";
  8835. } else {
  8836. if ($ktime && $jtime) {
  8837. $gj = " and time > '$ktime' and time < '$jtime'";
  8838. }
  8839. }
  8840. if ($warehouse) {
  8841. $where .= " and warehouse = '$warehouse'";
  8842. }
  8843. //数据排序
  8844. $order_str = "id desc";
  8845. if (empty($page)) {
  8846. $start = 0;
  8847. $perpage = 1;
  8848. } else {
  8849. $start = ($page - 1) * $perpage;
  8850. }
  8851. //取得信息列表
  8852. $rows = array();
  8853. $list = array();
  8854. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  8855. foreach ($info_list as $value) {
  8856. $warehouse = $this->warehouse->read($value['warehouse']);
  8857. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  8858. $number = $value['number'];
  8859. $ftime = time() - 15 * 24 * 3600;
  8860. if ($c < 1) {
  8861. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  8862. }
  8863. }
  8864. $title = "0库存汇总";
  8865. $first_row = ["仓库","SKU","产品","当前库存"];
  8866. $cols = [
  8867. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  8868. ];
  8869. $final_list= [];
  8870. foreach($list as $key => $value){
  8871. $final_list[] = array_values($value) ;
  8872. }
  8873. if(empty($final_list)){
  8874. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8875. }
  8876. array_unshift($final_list, $first_row);
  8877. $merges = [];
  8878. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8879. }
  8880. }
  8881. }