Whlabel.php 300 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833
  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 == "w_t_cs"){
  204. $this->_w_t_cs(); //首页
  205. }else {
  206. $this->_index();
  207. }
  208. }
  209. public function _w_t_cs(){
  210. $vip = 0;
  211. if (isset($_SESSION['api'])) {
  212. $user = $this->user->get_api($_SESSION['api']);
  213. $fgshop = "";
  214. $sid = "";
  215. $usersp = explode('|', trim($user['shop'], '|'));
  216. foreach ($usersp as $value) {
  217. $fgshop .= " shop = " . $value . " or";
  218. $sid .= " id = " . $value . " or";
  219. }
  220. if ($user['vip'] == 1) {
  221. $vip = 1;
  222. }
  223. } else {
  224. header('Location: /');
  225. exit;
  226. }
  227. $prc = array();
  228. $purchase = $this->purchase->find_all();
  229. foreach ($purchase as $k => $v) {
  230. $prc[$v['id']] = $v['title'];
  231. }
  232. $company = array();
  233. $ct = $this->company->find_all();
  234. foreach ($ct as $k => $v) {
  235. $company[$v['id']] = $v['title'];
  236. }
  237. $sp = array();
  238. $s = $this->shop->find_all('1=1', 'id,shopname');
  239. foreach ($s as $v) {
  240. $sp[$v['id']] = $v['shopname'];
  241. }
  242. $wh = array();
  243. $w = $this->warehouse->find_all('1=1', 'id,title');
  244. foreach ($w as $v) {
  245. $wh[$v['id']] = $v['title'];
  246. }
  247. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  248. $this->data['shop'] = $wlshop;
  249. $this->data['vip'] = $vip;
  250. $this->_Template('whlabel_typejs', $this->data);
  251. }
  252. //管理
  253. public function _index()
  254. {
  255. $post = $this->input->post(NULL, TRUE);
  256. if (isset($post['page'])) {
  257. $page = $this->input->post('page', true);
  258. $perpage = $this->input->post('perpage', true);
  259. $sku = $this->input->post('sku', true);
  260. $number = $this->input->post('number', true);
  261. $warehouse = $this->input->post('warehouse', true);
  262. $purchase = $this->input->post('purchase', true);
  263. $orderinfo = $this->input->post('orderinfo', true);
  264. $waybill = $this->input->post('waybill', true);
  265. $category = $this->input->post('category', true);
  266. $size = $this->input->post('size', true);
  267. $grade = $this->input->post('grade', true);
  268. $color = $this->input->post('color', true);
  269. $lowe = $this->input->post('lowe', true);
  270. $state = $this->input->post('state', true);
  271. $label = $this->input->post('label', true);
  272. $timetk = $this->input->post('timetkk', true);
  273. $timetj = $this->input->post('timetjj', true);
  274. $timetk = strtotime($timetk);
  275. $timetj = strtotime($timetj);
  276. $where = "1=1 ";
  277. if ($timetk && $timetj) {
  278. $where .= " and time > '$timetk' and time < '$timetj'";
  279. }
  280. if ($sku) {
  281. $where .= " and sku = '$sku'";
  282. }
  283. if ($number) {
  284. $where .= " and number = '$number'";
  285. }
  286. if ($warehouse) {
  287. $where .= " and warehouse = '$warehouse'";
  288. }
  289. if ($purchase) {
  290. $where .= " and purchase = '$purchase'";
  291. }
  292. if ($orderinfo) {
  293. $where .= " and orderinfo = '$orderinfo'";
  294. }
  295. if ($waybill) {
  296. $where .= " and waybill = '$waybill'";
  297. }
  298. if ($category) {
  299. $where .= " and features like '%-$category-%'";
  300. }
  301. if ($size) {
  302. $where .= " and features like '%-$size-%'";
  303. }
  304. if ($grade) {
  305. $where .= " and features like '%-$grade-%'";
  306. }
  307. if ($color) {
  308. $where .= " and features like '%-$color-%'";
  309. }
  310. if ($lowe) {
  311. $where .= " and features like '%-$lowe-%'";
  312. }
  313. if ($label) {
  314. $where .= " and label = '$label'";
  315. }
  316. if ($state != '') {
  317. $where .= " and state = '$state'";
  318. }
  319. //数据排序
  320. $order_str = "time desc";
  321. if (empty($page)) {
  322. $start = 0;
  323. $perpage = 1;
  324. } else {
  325. $start = ($page - 1) * $perpage;
  326. }
  327. //取得信息列表
  328. $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);
  329. foreach ($info_list as $key => $value) {
  330. $warehouse = $this->warehouse->read($value['warehouse']);
  331. $info_list[$key]['warehouse'] = $warehouse['title'];
  332. $purchase = $this->purchase->read($value['purchase']);
  333. $info_list[$key]['purchase'] = $purchase['title'];
  334. if ($value['enter'] != 0) {
  335. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  336. } else {
  337. $info_list[$key]['enter'] = "";
  338. }
  339. if ($value['outk'] != 0) {
  340. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  341. } else {
  342. $info_list[$key]['outk'] = "";
  343. }
  344. if ($value['printing'] != 0) {
  345. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  346. } else {
  347. $info_list[$key]['printing'] = "";
  348. }
  349. if ($value['orderinfo'] == 0) {
  350. $info_list[$key]['orderinfo'] = "";
  351. }
  352. if ($value['waybill'] == 0) {
  353. $info_list[$key]['waybill'] = "";
  354. }
  355. if ($value['state'] == 0) {
  356. $info_list[$key]['state'] = "在库";
  357. } else if ($value['state'] == 1) {
  358. $info_list[$key]['state'] = "出库";
  359. } else if ($value['state'] == 2) {
  360. $info_list[$key]['state'] = "退库";
  361. } else if ($value['state'] == 3) {
  362. $info_list[$key]['state'] = "调拨中";
  363. } else if ($value['state'] == 4) {
  364. $info_list[$key]['state'] = "再加工";
  365. } else if ($value['state'] == 5) {
  366. $info_list[$key]['state'] = "维修中";
  367. } else if ($value['state'] == 6) {
  368. $info_list[$key]['state'] = "盘亏";
  369. } else if ($value['state'] == 7) {
  370. $info_list[$key]['state'] = "更换标签";
  371. } else if ($value['state'] == 8) {
  372. $info_list[$key]['state'] = "其它";
  373. } else if ($value['state'] == 9) {
  374. $info_list[$key]['state'] = "预设";
  375. } else if ($value['state'] == 10) {
  376. $info_list[$key]['state'] = "美店零售";
  377. }
  378. if ($value['text'] == "") {
  379. $info_list[$key]['text'] = "";
  380. }
  381. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  382. }
  383. $total = $this->whlabel->find_count($where);
  384. $pagenum = ceil($total / $perpage);
  385. $over = $total - ($start + $perpage);
  386. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  387. echo json_encode($rows);
  388. exit;
  389. }
  390. if (isset($post['outsku'])) {
  391. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  392. $cz = $this->input->post('cz', true);
  393. if ($cz == '1') {
  394. $sku = $this->input->post('outsku', true);
  395. if ($sku) {
  396. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  397. if (count($data) < 1) {
  398. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  399. exit;
  400. }
  401. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  402. echo json_encode(array('success' => true));
  403. exit;
  404. }
  405. } else {
  406. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  407. exit;
  408. $sku = $this->input->post('outsku', true);
  409. if ($sku) {
  410. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  411. if (count($data) < 1) {
  412. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  413. exit;
  414. }
  415. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  416. echo json_encode(array('success' => true));
  417. exit;
  418. }
  419. }
  420. }
  421. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  422. $this->_Template('whlabel', $this->data);
  423. }
  424. //在库标签
  425. public function _existence()
  426. {
  427. $post = $this->input->post(NULL, TRUE);
  428. if (isset($post['s'])) {
  429. $id_arr = $this->input->post('s');
  430. $id_arr = explode(',', $id_arr);
  431. if (!$id_arr) {
  432. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  433. exit;
  434. }
  435. //循环删除记录
  436. foreach ($id_arr as $v) {
  437. $sid = $this->whlabel->read($v);
  438. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  439. if ($count > 0) {
  440. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  441. exit;
  442. }
  443. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  444. if (count($zt) > 0) {
  445. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  446. exit;
  447. }
  448. $this->whlabel->remove($v);
  449. }
  450. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  451. exit;
  452. }
  453. if (isset($post['page'])) {
  454. $page = $this->input->post('page', true);
  455. $perpage = $this->input->post('perpage', true);
  456. $warehouse = $this->input->post('warehouse', true);
  457. $label = $this->input->post('label', true);
  458. $where = "1=1 and state = 0";
  459. if ($warehouse) {
  460. $where .= " and warehouse = '$warehouse'";
  461. }
  462. if ($label) {
  463. $where .= " and label = '$label'";
  464. }
  465. //数据排序
  466. $order_str = "time asc";
  467. if (empty($page)) {
  468. $start = 0;
  469. $perpage = 1;
  470. } else {
  471. $start = ($page - 1) * $perpage;
  472. }
  473. //取得信息列表
  474. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  475. foreach ($info_list as $key => $value) {
  476. if ($value['enter'] != 0) {
  477. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  478. } else {
  479. $info_list[$key]['enter'] = "";
  480. }
  481. if ($value['printing'] != 0) {
  482. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  483. } else {
  484. $info_list[$key]['printing'] = "";
  485. }
  486. }
  487. $total = $this->whlabel->find_count($where);
  488. $pagenum = ceil($total / $perpage);
  489. $over = $total - ($start + $perpage);
  490. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  491. echo json_encode($rows);
  492. exit;
  493. }
  494. $this->_Template('whlabel_existence', $this->data);
  495. }
  496. //进销存浏览
  497. public function _typedy($arg_array)
  498. {
  499. $prc = array();
  500. $purchase = $this->purchase->find_all();
  501. foreach ($purchase as $k => $v) {
  502. $prc[$v['id']] = $v['title'];
  503. }
  504. $post = $this->input->post(NULL, TRUE);
  505. if (isset($post['page'])) {
  506. $page = $this->input->post('page', true);
  507. $perpage = $this->input->post('perpage', true);
  508. $category = $this->input->post('category', true);
  509. $size = $this->input->post('size', true);
  510. $grade = $this->input->post('grade', true);
  511. $color = $this->input->post('color', true);
  512. $lowe = $this->input->post('lowe', true);
  513. $sku = $this->input->post('sku');
  514. $title = $this->input->post('title');
  515. $warehouse = $this->input->post('warehouse', true);
  516. $usa = $this->input->post('usa', true);
  517. $purchase = $this->input->post('purchase', true);
  518. $lacetype = $this->input->post('lacetype', true);
  519. $haircap = $this->input->post('haircap', true);
  520. $density = $this->input->post('density', true);
  521. $details = $this->input->post('details', true);
  522. $state = $this->input->post('state', true);
  523. $lacecolor = $this->input->post('lacecolor', true);
  524. $hairnumber = $this->input->post('hairnumber', true);
  525. $cklx = $this->input->post('cklx', true);
  526. $ktime = $this->input->post('ktime', true);
  527. $jtime = $this->input->post('jtime', true);
  528. $sm = $this->input->post('sm', true);
  529. $cpbz = $this->input->post('cpbz', true);
  530. $type = $this->input->post('type', true);
  531. $ktime = strtotime($ktime);
  532. $jtime = strtotime($jtime);
  533. $where = "1=1";
  534. $gj = "";
  535. $ck = "";
  536. if ($usa) {
  537. if (!$warehouse) {
  538. $where .= " and (warehouse = '5' or warehouse = '8')";
  539. }
  540. }
  541. if ($warehouse) {
  542. $where .= " and warehouse = '$warehouse'";
  543. }
  544. if ($details) {
  545. $where .= " and details = '$details'";
  546. }
  547. if ($purchase) {
  548. $where .= " and purchase = '$purchase'";
  549. }
  550. if (isset($state)) {
  551. if($state >-1){
  552. $where .= " and state = '$state'";
  553. }
  554. }
  555. if ($lacetype) {
  556. $where .= " and features like '%-$lacetype-%'";
  557. }
  558. if ($category) {
  559. $where .= " and features like '%-$category-%'";
  560. }
  561. if ($size) {
  562. $where .= " and features like '%-$size-%'";
  563. }
  564. if ($grade) {
  565. $where .= " and features like '%-$grade-%'";
  566. }
  567. if ($color) {
  568. $where .= " and features like '%-$color-%'";
  569. }
  570. if ($lowe) {
  571. $where .= " and features like '%-$lowe-%'";
  572. }
  573. if ($haircap) {
  574. $where .= " and features like '%-$haircap-%'";
  575. }
  576. if ($density) {
  577. $where .= " and features like '%-$density-%'";
  578. }
  579. if ($lacecolor) {
  580. $where .= " and features like '%-$lacecolor-%'";
  581. }
  582. if($sm){
  583. $where .= " and sm like '%".$sm."%'";
  584. }
  585. if($cpbz){
  586. $where .= " and cpbz like '%".$cpbz."%'";
  587. }
  588. if($type){
  589. $where .= " and type = ".$type."";
  590. }
  591. if (!empty($hairnumber)) {
  592. $where .= " and features like '%-128-%' ";
  593. if ($hairnumber < 0) {
  594. $class_list = $this->typeclass->find_all('classid = 43');
  595. foreach ($class_list as $v) {
  596. $where .= " and features not like '%-" . $v['id'] . "-%'";
  597. }
  598. } else {
  599. $where .= " and features like '%-$hairnumber-%'";
  600. }
  601. }
  602. $where_add = '';
  603. if ($cklx) {
  604. $shop = $this->shop->read($cklx);
  605. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  606. }
  607. if ($ktime && $jtime) {
  608. $gj = " and enter > '$ktime' and enter < '$jtime'";
  609. $ck = " and outk > '$ktime' and outk < '$jtime'";
  610. }
  611. //数据排序
  612. $order_str = "id desc";
  613. if (empty($page)) {
  614. $start = 0;
  615. $perpage = 1;
  616. } else {
  617. $start = ($page - 1) * $perpage;
  618. }
  619. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  620. if ($sku) {
  621. $sku = trim($sku, ' ');
  622. $sku = trim($sku, ' ');
  623. $where .= " and sku like '%$sku%'";
  624. $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);
  625. } else if ($title) {
  626. $title = trim($title, ' ');
  627. $title = trim($title, ' ');
  628. $where .= " and title like '%$title%'";
  629. $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);
  630. } else {
  631. //$where .= " and time > '$ktime' and time < '$jtime'";
  632. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  633. }
  634. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  635. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  636. foreach ($info_list as $k => $v) {
  637. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  638. unset($info_list[$k]['pm']);
  639. unset($info_list[$k]['jm']);
  640. unset($info_list[$k]['bm']);
  641. }
  642. //取得信息列表
  643. $rows = array();
  644. $list = array();
  645. foreach ($info_list as $key => $value) {
  646. $warehouse = $this->warehouse->read($value['warehouse']);
  647. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  648. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  649. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  650. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  651. $info_list[$key]['label'] = $value['sm'];
  652. $number = $value['number'];
  653. $ftime = time() - 15 * 24 * 3600;
  654. $info_list[$key]['warehouse'] = $warehouse['title'];
  655. $info_list[$key]['features'] = count($c);
  656. $z = count($z); //查看订单号
  657. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  658. $ztdata = '';
  659. if (count($zt) > 0) {
  660. foreach ($zt as $vv) {
  661. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  662. }
  663. }
  664. $info_list[$key]['number'] = $ztdata;
  665. $info_list[$key]['sm'] = $z;
  666. $details = array();
  667. $cpid = array();
  668. foreach ($c as $k => $v) {
  669. $details[$v['details']] = $v['details'];
  670. if ($v['cpid'] != 0) {
  671. $cpid[$v['cpid']] = $v['cpid'];
  672. }
  673. }
  674. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  675. if ($value['shop'] != '') {
  676. $shop = explode(',', trim($value['shop'], ','));
  677. $shop = $this->shop->read($shop[0]);
  678. $info_list[$key]['shop'] = $shop['shopname'];
  679. }
  680. }
  681. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  682. $pagenum = ceil($total / $perpage);
  683. $over = $total - ($start + $perpage);
  684. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  685. echo json_encode($rows);
  686. exit;
  687. }
  688. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  689. $this->_Template('whlabel_typedy', $this->data);
  690. }
  691. //进销存浏览
  692. public function _typedy_ck($arg_array)
  693. {
  694. $prc = array();
  695. $purchase = $this->purchase->find_all();
  696. foreach ($purchase as $k => $v) {
  697. $prc[$v['id']] = $v['title'];
  698. }
  699. $post = $this->input->post(NULL, TRUE);
  700. if (isset($post['page'])) {
  701. $page = $this->input->post('page', true);
  702. $perpage = $this->input->post('perpage', true);
  703. $category = $this->input->post('category', true);
  704. $size = $this->input->post('size', true);
  705. $grade = $this->input->post('grade', true);
  706. $color = $this->input->post('color', true);
  707. $lowe = $this->input->post('lowe', true);
  708. $sku = $this->input->post('sku');
  709. $title = $this->input->post('title');
  710. $warehouse = $this->input->post('warehouse', true);
  711. $usa = $this->input->post('usa', true);
  712. $purchase = $this->input->post('purchase', true);
  713. $lacetype = $this->input->post('lacetype', true);
  714. $haircap = $this->input->post('haircap', true);
  715. $density = $this->input->post('density', true);
  716. $details = $this->input->post('details', true);
  717. $state = $this->input->post('state', true);
  718. $lacecolor = $this->input->post('lacecolor', true);
  719. $cklx = $this->input->post('cklx', true);
  720. $ktime = $this->input->post('ktime', true);
  721. $jtime = $this->input->post('jtime', true);
  722. $ktime = strtotime($ktime);
  723. $jtime = strtotime($jtime);
  724. $where = "1=1";
  725. $gj = "";
  726. $ck = "";
  727. if ($lacetype) {
  728. $where .= " and features like '%-$lacetype-%'";
  729. }
  730. if ($category) {
  731. $where .= " and features like '%-$category-%'";
  732. }
  733. if ($size) {
  734. $where .= " and features like '%-$size-%'";
  735. }
  736. if ($grade) {
  737. $where .= " and features like '%-$grade-%'";
  738. }
  739. if ($color) {
  740. $where .= " and features like '%-$color-%'";
  741. }
  742. if ($lowe) {
  743. $where .= " and features like '%-$lowe-%'";
  744. }
  745. if ($haircap) {
  746. $where .= " and features like '%-$haircap-%'";
  747. }
  748. if ($density) {
  749. $where .= " and features like '%-$density-%'";
  750. }
  751. if ($lacecolor) {
  752. $where .= " and features like '%-$lacecolor-%'";
  753. }
  754. if ($usa) {
  755. if (!$warehouse) {
  756. $where .= " and (warehouse = '5' or warehouse = '8')";
  757. }
  758. }
  759. if ($warehouse) {
  760. $where .= " and warehouse = '$warehouse'";
  761. }
  762. if ($details) {
  763. $where .= " and details = '$details'";
  764. }
  765. if ($purchase) {
  766. $where .= " and purchase = '$purchase'";
  767. }
  768. if ($state) {
  769. $where .= " and state = '$state'";
  770. }
  771. $where_add = '';
  772. if ($cklx) {
  773. $shop = $this->shop->read($cklx);
  774. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  775. }
  776. if ($ktime && $jtime) {
  777. $gj = " and enter > '$ktime' and enter < '$jtime'";
  778. $ck = " and outk > '$ktime' and outk < '$jtime'";
  779. }
  780. //数据排序
  781. $order_str = "id desc";
  782. if (empty($page)) {
  783. $start = 0;
  784. $perpage = 1;
  785. } else {
  786. $start = ($page - 1) * $perpage;
  787. }
  788. if ($sku) {
  789. $sku = trim($sku, ' ');
  790. $sku = trim($sku, ' ');
  791. $where .= " and sku like '%$sku%'";
  792. $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);
  793. } else if ($title) {
  794. $title = trim($title, ' ');
  795. $title = trim($title, ' ');
  796. $where .= " and title like '%$title%'";
  797. $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);
  798. } else {
  799. //$where .= " and time > '$ktime' and time < '$jtime'";
  800. $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);
  801. }
  802. //取得信息列表
  803. $rows = array();
  804. $list = array();
  805. foreach ($info_list as $key => $value) {
  806. $warehouse = $this->warehouse->read($value['warehouse']);
  807. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  808. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  809. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  810. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  811. $ftime = time() - 15 * 24 * 3600;
  812. $info_list[$key]['warehouse'] = $warehouse['title'];
  813. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  814. //$z = count($z);//查看订单号
  815. //$info_list[$key]['zd'] = $z;
  816. $details = array();
  817. $cpid = array();
  818. foreach ($c as $k => $v) {
  819. $details[$v['details']] = $v['details'];
  820. if ($v['cpid'] != 0) {
  821. $cpid[$v['cpid']] = $v['cpid'];
  822. }
  823. }
  824. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  825. if ($value['shop'] != '') {
  826. $shop = explode(',', trim($value['shop'], ','));
  827. $shop = $this->shop->read($shop[0]);
  828. $info_list[$key]['shop'] = $shop['shopname'];
  829. }
  830. }
  831. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  832. $pagenum = ceil($total / $perpage);
  833. $over = $total - ($start + $perpage);
  834. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  835. echo json_encode($rows);
  836. exit;
  837. }
  838. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  839. $this->_Template('whlabel_typedy_ck', $this->data);
  840. }
  841. public function _typeck($arg_array)
  842. {
  843. $prc = array();
  844. $purchase = $this->purchase->find_all();
  845. foreach ($purchase as $k => $v) {
  846. $prc[$v['id']] = $v['title'];
  847. }
  848. $post = $this->input->post(NULL, TRUE);
  849. if (isset($post['page'])) {
  850. $page = $this->input->post('page', true);
  851. $perpage = $this->input->post('perpage', true);
  852. $category = $this->input->post('category', true);
  853. $size = $this->input->post('size', true);
  854. $grade = $this->input->post('grade', true);
  855. $color = $this->input->post('color', true);
  856. $lacecolor = $this->input->post('lacecolor', true);
  857. $lowe = $this->input->post('lowe', true);
  858. $sku = $this->input->post('sku');
  859. $title = $this->input->post('title');
  860. $warehouse = 13;
  861. $usa = $this->input->post('usa', true);
  862. $purchase = $this->input->post('purchase', true);
  863. $lacetype = $this->input->post('lacetype', true);
  864. $haircap = $this->input->post('haircap', true);
  865. $density = $this->input->post('density', true);
  866. $details = $this->input->post('details', true);
  867. $state = $this->input->post('state', true);
  868. $ktime = $this->input->post('ktime', true);
  869. $jtime = $this->input->post('jtime', true);
  870. $ktime = strtotime($ktime);
  871. $jtime = strtotime($jtime);
  872. $where = "1=1";
  873. $gj = "";
  874. $ck = "";
  875. if ($lacetype) {
  876. $where .= " and features like '%-$lacetype-%'";
  877. }
  878. if ($category) {
  879. $where .= " and features like '%-$category-%'";
  880. }
  881. if ($size) {
  882. $where .= " and features like '%-$size-%'";
  883. }
  884. if ($grade) {
  885. $where .= " and features like '%-$grade-%'";
  886. }
  887. if ($color) {
  888. $where .= " and features like '%-$color-%'";
  889. }
  890. if ($lacecolor) {
  891. $where .= " and features like '%-$lacecolor-%'";
  892. }
  893. if ($lowe) {
  894. $where .= " and features like '%-$lowe-%'";
  895. }
  896. if ($haircap) {
  897. $where .= " and features like '%-$haircap-%'";
  898. }
  899. if ($density) {
  900. $where .= " and features like '%-$density-%'";
  901. }
  902. if ($warehouse) {
  903. $where .= " and warehouse = '$warehouse'";
  904. }
  905. if ($details) {
  906. $where .= " and details = '$details'";
  907. }
  908. if ($purchase) {
  909. $where .= " and purchase = '$purchase'";
  910. }
  911. if ($state) {
  912. $where .= " and state = '$state'";
  913. }
  914. if ($ktime && $jtime) {
  915. $gj = " and enter > '$ktime' and enter < '$jtime'";
  916. $ck = " and outk > '$ktime' and outk < '$jtime'";
  917. }
  918. //数据排序
  919. $order_str = "id desc";
  920. if (empty($page)) {
  921. $start = 0;
  922. $perpage = 1;
  923. } else {
  924. $start = ($page - 1) * $perpage;
  925. }
  926. if ($sku) {
  927. $sku = trim($sku, ' ');
  928. $sku = trim($sku, ' ');
  929. $where .= " and sku like '%$sku%'";
  930. } else if ($title) {
  931. $title = trim($title, ' ');
  932. $title = trim($title, ' ');
  933. $where .= " and title like '%$title%'";
  934. }
  935. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  936. //取得信息列表
  937. $t = array();
  938. $typeclass = $this->typeclass->find_all();
  939. foreach ($typeclass as $v) {
  940. $t[$v['id']] = $v;
  941. }
  942. $rows = array();
  943. $list = array();
  944. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  945. foreach ($info_list as $key => $value) {
  946. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  947. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  948. $warehouse = $this->warehouse->read($value['warehouse']);
  949. $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');
  950. $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'] . '"');
  951. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  952. $number = $value['number'];
  953. $ftime = time() - 15 * 24 * 3600;
  954. $z = count($z); //查看订单号
  955. $info_list[$key]['warehouse'] = $warehouse['title'];
  956. $info_list[$key]['features'] = count($c);
  957. $info_list[$key]['number'] = $z;
  958. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  959. $details = array();
  960. $cpid = array();
  961. foreach ($c as $k => $v) {
  962. $details[$v['details']] = $v['details'];
  963. if ($v['cpid'] != 0) {
  964. $cpid[$v['cpid']] = $v['cpid'];
  965. }
  966. }
  967. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  968. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  969. unset($info_list[$key]['pm']);
  970. unset($info_list[$key]['jm']);
  971. unset($info_list[$key]['bm']);
  972. }
  973. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  974. $pagenum = ceil($total / $perpage);
  975. $over = $total - ($start + $perpage);
  976. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  977. echo json_encode($rows);
  978. exit;
  979. }
  980. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  981. $this->_Template('whlabel_typeck', $this->data);
  982. }
  983. //进销存导出
  984. public function _whlabeckdc()
  985. {
  986. $prc = array();
  987. $purchase = $this->purchase->find_all();
  988. foreach ($purchase as $k => $v) {
  989. $prc[$v['id']] = $v['title'];
  990. }
  991. if (isset($_GET['excel'])) {
  992. $where = "sku != 'Preset'";
  993. //数据排序
  994. $order_str = "id desc";
  995. if (empty($page)) {
  996. $start = 0;
  997. $perpage = 1;
  998. } else {
  999. $start = ($page - 1) * $perpage;
  1000. }
  1001. $category = $this->input->get('category', true);
  1002. $color = $this->input->get('color', true);
  1003. $lowe = $this->input->get('lowe', true);
  1004. $lacetype = $this->input->get('lacetype', true);
  1005. $size = $this->input->get('size', true);
  1006. $density = $this->input->get('density', true);
  1007. $haircap = $this->input->get('haircap', true);
  1008. $sku = $this->input->get('sku', true);
  1009. $details = $this->input->get('details', true);
  1010. $warehouse = 13;
  1011. $excelid = $this->input->get('sid', true);
  1012. if ($category) {
  1013. $where .= " and features like '%-$category-%'";
  1014. }
  1015. if ($color) {
  1016. $where .= " and features like '%-$color-%'";
  1017. }
  1018. if ($lowe) {
  1019. $where .= " and features like '%-$lowe-%'";
  1020. }
  1021. if ($lacetype) {
  1022. $where .= " and features like '%-$lacetype-%'";
  1023. }
  1024. if ($size) {
  1025. $where .= " and features like '%-$size-%'";
  1026. }
  1027. if ($density) {
  1028. $where .= " and features like '%-$density-%'";
  1029. }
  1030. if ($haircap) {
  1031. $where .= " and features like '%-$haircap-%'";
  1032. }
  1033. if ($warehouse) {
  1034. $where .= " and warehouse = '$warehouse'";
  1035. }
  1036. if ($sku) {
  1037. $where .= " and sku like '%$sku%'";
  1038. }
  1039. if ($details) {
  1040. $where .= " and details = '$details'";
  1041. }
  1042. $xzid = '';
  1043. if ($excelid) {
  1044. $excelid = explode(',', trim($excelid, ','));
  1045. foreach ($excelid as $key => $value) {
  1046. $xzid .= " id = " . $value . " or";
  1047. }
  1048. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1049. }
  1050. //取得信息列表
  1051. /**
  1052. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1053. $rows = array();$list = array();
  1054. foreach ($info_list as $key=>$value)
  1055. {
  1056. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1057. }
  1058. **/
  1059. $wh = array();
  1060. $w = $this->warehouse->find_all('1=1', 'id,title');
  1061. foreach ($w as $v) {
  1062. $wh[$v['id']] = $v['title'];
  1063. }
  1064. $tc = array();
  1065. $tcdata = array();
  1066. $list = array();
  1067. $classid = $this->classid->sku();
  1068. $tcall = $this->typeclass->find_all();
  1069. $typeclass = array();
  1070. foreach ($tcall as $v)
  1071. {
  1072. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1073. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1074. }
  1075. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1076. foreach ($rows as $key => $value) {
  1077. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1078. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1079. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1080. $rows[$key]['cpbz'] = $u9_info['bm'];
  1081. $rows[$key]['cs'] = $u9_info['jm'];
  1082. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1083. $details = array();
  1084. $cpid = array();
  1085. $cpbz = array();
  1086. $c = 0;
  1087. $g = 0;
  1088. $x = 0;
  1089. $t = 0;
  1090. $s = 0;
  1091. $q = 0;
  1092. foreach ($sd as $k => $v) {
  1093. if ($v['state'] == 0) {
  1094. $c++;
  1095. }
  1096. if ($v['state'] != 9) {
  1097. $g++;
  1098. }
  1099. if ($v['state'] == 1) {
  1100. $x++;
  1101. }
  1102. if ($v['state'] == 2) {
  1103. $t++;
  1104. }
  1105. if ($v['state'] == 8) {
  1106. $s++;
  1107. }
  1108. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1109. $q++;
  1110. }
  1111. $details[$v['details']] = $v['details'];
  1112. if ($v['cpid'] != 0) {
  1113. $cpid[$v['cpid']] = $v['cpid'];
  1114. }
  1115. if ($v['cpbz'] != '') {
  1116. $cpbz[$v['cpbz']] = $v['cpbz'];
  1117. }
  1118. }
  1119. $rows[$key]['details'] = implode("、", $details);
  1120. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1121. $number = $value['number'];
  1122. $ftime = time() - 15 * 24 * 3600;
  1123. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1124. $rows[$key]['number'] = $g;
  1125. $rows[$key]['features'] = $c;
  1126. $rows[$key]['x'] = $x;
  1127. $rows[$key]['t'] = $t;
  1128. $rows[$key]['s'] = $s;
  1129. $rows[$key]['q'] = $q;
  1130. $rows[$key]['wzsl'] = count($details);
  1131. }
  1132. $title = "进销存统计表" . date('Y-m-d', time());
  1133. $titlename = "<table border=1>
  1134. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1135. <tr align='center'>
  1136. <td>仓库</td>
  1137. <td>供应商</td>
  1138. <td>位置</td>
  1139. <td>库存编码</td>
  1140. <td>SKU</td>
  1141. <td>用友编码</td>
  1142. <td>用友料号</td>
  1143. <td>产品英文名</td>
  1144. <td>产品中文名</td>
  1145. <td>入库总量</td>
  1146. <td>库存数量</td>
  1147. <td>销售数量</td>
  1148. <td>退货数量</td>
  1149. <td>删除数量</td>
  1150. <td>其它操作</td>
  1151. <td>位置数量</td>
  1152. </tr>
  1153. </table>";
  1154. $filename = $title . ".xls";
  1155. $tail = "";
  1156. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1157. }
  1158. }
  1159. public function _type()
  1160. {
  1161. $vip = 0;
  1162. if (isset($_SESSION['api'])) {
  1163. $user = $this->user->get_api($_SESSION['api']);
  1164. $fgshop = "";
  1165. $sid = "";
  1166. $usersp = explode('|', trim($user['shop'], '|'));
  1167. foreach ($usersp as $value) {
  1168. $fgshop .= " shop = " . $value . " or";
  1169. $sid .= " id = " . $value . " or";
  1170. }
  1171. if ($user['vip'] == 1) {
  1172. $vip = 1;
  1173. }
  1174. } else {
  1175. header('Location: /');
  1176. exit;
  1177. }
  1178. $prc = array();
  1179. $purchase = $this->purchase->find_all();
  1180. foreach ($purchase as $k => $v) {
  1181. $prc[$v['id']] = $v['title'];
  1182. }
  1183. $company = array();
  1184. $ct = $this->company->find_all();
  1185. foreach ($ct as $k => $v) {
  1186. $company[$v['id']] = $v['title'];
  1187. }
  1188. $sp = array();
  1189. $s = $this->shop->find_all('1=1', 'id,shopname');
  1190. foreach ($s as $v) {
  1191. $sp[$v['id']] = $v['shopname'];
  1192. }
  1193. $wh = array();
  1194. $w = $this->warehouse->find_all('1=1', 'id,title');
  1195. foreach ($w as $v) {
  1196. $wh[$v['id']] = $v['title'];
  1197. }
  1198. $post = $this->input->post(NULL, TRUE);
  1199. if (isset($post['page'])) {
  1200. $page = $this->input->post('page', true);
  1201. $perpage = $this->input->post('perpage', true);
  1202. $category = $this->input->post('category', true);
  1203. $size = $this->input->post('size', true);
  1204. $grade = $this->input->post('grade', true);
  1205. $color = $this->input->post('color', true);
  1206. $lowe = $this->input->post('lowe', true);
  1207. $sku = $this->input->post('sku');
  1208. $title = $this->input->post('title');
  1209. $warehouse = $this->input->post('warehouse', true);
  1210. $usa = $this->input->post('usa', true);
  1211. $purchase = $this->input->post('purchase', true);
  1212. $lacetype = $this->input->post('lacetype', true);
  1213. $haircap = $this->input->post('haircap', true);
  1214. $density = $this->input->post('density', true);
  1215. $details = $this->input->post('details', true);
  1216. $state = $this->input->post('state', true);
  1217. $shop = $this->input->post('shop', true);
  1218. $lacecolor = $this->input->post('lacecolor', true);
  1219. $hairnumber = $this->input->post('hairnumber', true);
  1220. $type = $this->input->post('type', true);
  1221. $ktime = $this->input->post('ktime', true);
  1222. $jtime = $this->input->post('jtime', true);
  1223. $ktime = strtotime($ktime);
  1224. $jtime = strtotime($jtime);
  1225. $cpbz = $this->input->post('cpbz', true);
  1226. $sm = $this->input->post('sm', true);
  1227. $where = "1=1";
  1228. $gj = "";
  1229. $ck = "";
  1230. if ($usa) {
  1231. if (!$warehouse) {
  1232. $where .= " and (warehouse = '5' or warehouse = '8')";
  1233. }
  1234. }
  1235. if ($warehouse) {
  1236. $where .= " and warehouse = '$warehouse'";
  1237. }
  1238. if ($details) {
  1239. $where .= " and details = '$details'";
  1240. }
  1241. if ($purchase) {
  1242. $where .= " and purchase = '$purchase'";
  1243. }
  1244. if ($state) {
  1245. $where .= " and state = '$state'";
  1246. }
  1247. if ($shop) {
  1248. $where .= " and shop like '%$shop%'";
  1249. }
  1250. if ($type) {
  1251. $where .= " and type = '$type'";
  1252. }
  1253. if ($ktime && $jtime) {
  1254. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1255. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1256. }
  1257. if ($cpbz) {
  1258. $where .= " and cpbz like '%$cpbz%' ";
  1259. }
  1260. if ($sm) {
  1261. $where .= " and sm like '%$sm%' ";
  1262. }
  1263. if ($lacecolor) {
  1264. $where .= " and features like '%-$lacecolor-%'";
  1265. }
  1266. if ($lacetype) {
  1267. $where .= " and features like '%-$lacetype-%'";
  1268. }
  1269. if ($category) {
  1270. $where .= " and features like '%-$category-%'";
  1271. }
  1272. if ($size) {
  1273. $where .= " and features like '%-$size-%'";
  1274. }
  1275. if ($grade) {
  1276. $where .= " and features like '%-$grade-%'";
  1277. }
  1278. if ($color) {
  1279. $where .= " and features like '%-$color-%'";
  1280. }
  1281. if ($lowe) {
  1282. $where .= " and features like '%-$lowe-%'";
  1283. }
  1284. if ($haircap) {
  1285. $where .= " and features like '%-$haircap-%'";
  1286. }
  1287. if ($density) {
  1288. $where .= " and features like '%-$density-%'";
  1289. }
  1290. if (!empty($hairnumber)) {
  1291. $where .= " and features like '%-128-%' ";
  1292. if ($hairnumber < 0) {
  1293. $class_list = $this->typeclass->find_all('classid = 43');
  1294. foreach ($class_list as $v) {
  1295. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1296. }
  1297. } else {
  1298. $where .= " and features like '%-$hairnumber-%'";
  1299. }
  1300. }
  1301. //数据排序
  1302. $order_str = "id desc";
  1303. if (empty($page)) {
  1304. $start = 0;
  1305. $perpage = 1;
  1306. } else {
  1307. $start = ($page - 1) * $perpage;
  1308. }
  1309. $fjnr = '';
  1310. if ($sku) {
  1311. $sku = trim($sku, ' ');
  1312. $sku = trim($sku, ' ');
  1313. $fjnr .= " and sku like '%$sku%'";
  1314. }
  1315. if ($title) {
  1316. $title = trim($title, ' ');
  1317. $title = trim($title, ' ');
  1318. $fjnr .= " and title like '%$title%'";
  1319. }
  1320. $wt = array();
  1321. $whlabel_type = $this->whlabel_type->find_all();
  1322. foreach ($whlabel_type as $v) {
  1323. $wt[$v['id']] = $v['title'];
  1324. }
  1325. //$where .= " and time > '$ktime' and time < '$jtime'";
  1326. $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
  1327. //取得信息列表
  1328. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1329. $rows = array();
  1330. $list = array();
  1331. foreach ($info_list as $key => $value) {
  1332. if (isset($wt[$value['type']])) {
  1333. $info_list[$key]['type'] = $wt[$value['type']];
  1334. } else {
  1335. $info_list[$key]['type'] = '未设置';
  1336. }
  1337. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1338. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1339. $ztdata = '';
  1340. if (count($zt) > 0) {
  1341. foreach ($zt as $vv) {
  1342. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1343. }
  1344. }
  1345. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1346. $cdata = array_filter($qbdata, function ($item) {
  1347. return $item['state'] < 1;
  1348. });
  1349. $c = array_sum(array_column($cdata, 'jnum'));
  1350. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1351. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1352. });
  1353. $g = array_sum(array_column($gdata, 'jnum'));
  1354. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1355. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1356. });
  1357. $x = array_sum(array_column($xdata, 'jnum'));
  1358. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1359. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1360. });
  1361. $t = array_sum(array_column($tdata, 'jnum'));
  1362. // $zdata = array_filter($qbdata, function ($item) {
  1363. // return $item['zd'] != "" && $item['state'] < 1;
  1364. // });
  1365. // $z = array_sum(array_column($zdata, '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. //$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');
  1371. //$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'].'"');
  1372. //$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'].'"');
  1373. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1374. //$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'].'"');
  1375. $details = array();
  1376. $cpid = array();
  1377. $od = array();
  1378. $odid = '';
  1379. $companytitle = '';
  1380. $shop_list = [];
  1381. foreach ($qbdata as $v) {
  1382. if ($v['zd'] != "" && $v['state'] < 1) {
  1383. if (!isset($od[$v['zd']])) {
  1384. $od[$v['zd']] = 1; //所有数据sku
  1385. } else {
  1386. $od[$v['zd']] = $od[$v['zd']] + 1;
  1387. }
  1388. }
  1389. if ($v['state'] < 1) {
  1390. $details[$v['details']] = $v['details'];
  1391. if ($v['cpid'] != 0) {
  1392. $cpid[$v['cpid']] = $v['cpid'];
  1393. }
  1394. }
  1395. if($v['state'] == 0){
  1396. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1397. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1398. }
  1399. if ($v['shop'] != '') {
  1400. $shop = explode(',', trim($v['shop'], ','));
  1401. foreach ($shop as $vv) {
  1402. if (!in_array($vv, $shop_list)) {
  1403. $shop_list[] = $vv;
  1404. }
  1405. }
  1406. }
  1407. }
  1408. }
  1409. foreach ($od as $k => $vv) {
  1410. $odid .= $k . '数量' . $vv;
  1411. }
  1412. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1413. $info_list[$key]['label'] = $value['sm'];
  1414. $number = $value['number'];
  1415. $ftime = time() - 15 * 24 * 3600;
  1416. $z = $z . '(' . $odid . ')'; //查看订单号
  1417. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1418. $info_list[$key]['features'] = $c;
  1419. $info_list[$key]['number'] = $ztdata;
  1420. $info_list[$key]['sm'] = $g;
  1421. $info_list[$key]['x'] = $x;
  1422. $info_list[$key]['t'] = $t;
  1423. $info_list[$key]['z'] = $z;
  1424. /**
  1425. foreach ($cdata as $k=>$v)
  1426. {
  1427. $details[$v['details']] = $v['details'];
  1428. if($v['cpid'] != 0)
  1429. {
  1430. $cpid[$v['cpid']] = $v['cpid'];
  1431. }
  1432. }
  1433. **/
  1434. $info_list[$key]['shop'] = '';
  1435. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1436. // if ($value['shop'] != '') {
  1437. // $shop = explode(',', trim($value['shop'], ','));
  1438. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1439. // }
  1440. $shop_list = array_unique($shop_list);
  1441. $shop_str = '';
  1442. foreach ($shop_list as $v) {
  1443. if(isset($sp[$v])){
  1444. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1445. }
  1446. }
  1447. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1448. /**
  1449. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1450. if(isset($companytitle[0]))
  1451. {
  1452. foreach ($companytitle as $k=>$v)
  1453. {
  1454. if($v['companytitle'] != '')
  1455. {
  1456. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1457. }
  1458. }
  1459. }
  1460. **/
  1461. }
  1462. $final_all_list = [];
  1463. foreach ($info_list as $k => $v) {
  1464. $final_all_list[] = [
  1465. 'id' => $v['id'],
  1466. "warehouse" => $v["warehouse"],
  1467. "purchase" => $v["purchase"],
  1468. "sku" => $v["sku"],
  1469. "title" => $v["title"] . "<br/>" . $v["pm"],
  1470. "details" => $v["details"],
  1471. "shop" => $v["shop"],
  1472. "cpbz" => $v["cpbz"],
  1473. 'label' => $v['label'],
  1474. "type" => $v["type"],
  1475. "features" => $v["features"],
  1476. "number" => $v["number"],
  1477. "sm" => $v["sm"],
  1478. "x" => $v["x"],
  1479. "t" => $v["t"],
  1480. "z" => $v["z"]
  1481. ];
  1482. }
  1483. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1484. $pagenum = ceil($total / $perpage);
  1485. $over = $total - ($start + $perpage);
  1486. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1487. echo json_encode($rows);
  1488. exit;
  1489. }
  1490. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1491. $this->data['shop'] = $wlshop;
  1492. $this->data['vip'] = $vip;
  1493. $this->_Template('whlabel_type', $this->data);
  1494. }
  1495. //美仓进销存浏览
  1496. public function _usatype()
  1497. {
  1498. if (isset($_SESSION['api'])) {
  1499. $user = $this->user->get_api($_SESSION['api']);
  1500. $usp = $user;
  1501. $fgshop = "";
  1502. $sid = "";
  1503. $wid = "";
  1504. $wtype = "";
  1505. $userwh = explode('|', trim($user['warehouse'], '|'));
  1506. foreach ($userwh as $value) {
  1507. $wid .= " id = " . $value . " or";
  1508. $wtype .= " type = " . $value . " or";
  1509. }
  1510. }
  1511. $prc = array();
  1512. $purchase = $this->purchase->find_all();
  1513. foreach ($purchase as $k => $v) {
  1514. $prc[$v['id']] = $v['title'];
  1515. }
  1516. $post = $this->input->post(NULL, TRUE);
  1517. if (isset($post['page'])) {
  1518. $page = $this->input->post('page', true);
  1519. $perpage = $this->input->post('perpage', true);
  1520. $category = $this->input->post('category', true);
  1521. $size = $this->input->post('size', true);
  1522. $grade = $this->input->post('grade', true);
  1523. $color = $this->input->post('color', true);
  1524. $lowe = $this->input->post('lowe', true);
  1525. $sku = $this->input->post('sku');
  1526. $title = $this->input->post('title');
  1527. $warehouse = $this->input->post('warehouse', true);
  1528. $usa = $this->input->post('usa', true);
  1529. $purchase = $this->input->post('purchase', true);
  1530. $lacetype = $this->input->post('lacetype', true);
  1531. $haircap = $this->input->post('haircap', true);
  1532. $density = $this->input->post('density', true);
  1533. $details = $this->input->post('details', true);
  1534. $state = $this->input->post('state', true);
  1535. $lacecolor = $this->input->post('lacecolor', true);
  1536. $cklx = $this->input->post('cklx', true);
  1537. $ktime = $this->input->post('ktime', true);
  1538. $jtime = $this->input->post('jtime', true);
  1539. $ktime = strtotime($ktime);
  1540. $jtime = strtotime($jtime);
  1541. $where = "1=1";
  1542. $gj = "";
  1543. $ck = "";
  1544. if ($lacetype) {
  1545. $where .= " and features like '%-$lacetype-%'";
  1546. }
  1547. if ($category) {
  1548. $where .= " and features like '%-$category-%'";
  1549. }
  1550. if ($size) {
  1551. $where .= " and features like '%-$size-%'";
  1552. }
  1553. if ($grade) {
  1554. $where .= " and features like '%-$grade-%'";
  1555. }
  1556. if ($color) {
  1557. $where .= " and features like '%-$color-%'";
  1558. }
  1559. if ($lowe) {
  1560. $where .= " and features like '%-$lowe-%'";
  1561. }
  1562. if ($haircap) {
  1563. $where .= " and features like '%-$haircap-%'";
  1564. }
  1565. if ($density) {
  1566. $where .= " and features like '%-$density-%'";
  1567. }
  1568. if ($lacecolor) {
  1569. $where .= " and features like '%-$lacecolor-%'";
  1570. }
  1571. if ($usa) {
  1572. if (!$warehouse) {
  1573. $where .= " and (warehouse = '5' or warehouse = '8')";
  1574. }
  1575. }
  1576. if ($warehouse) {
  1577. $where .= " and warehouse = '$warehouse'";
  1578. }
  1579. if ($details) {
  1580. $where .= " and details = '$details'";
  1581. }
  1582. if ($purchase) {
  1583. $where .= " and purchase = '$purchase'";
  1584. }
  1585. if ($state) {
  1586. $where .= " and state = '$state'";
  1587. }
  1588. $where_add = '';
  1589. if ($cklx) {
  1590. $shop = $this->shop->read($cklx);
  1591. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1592. }
  1593. if ($ktime && $jtime) {
  1594. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1595. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1596. }
  1597. //数据排序
  1598. $order_str = "id desc";
  1599. if (empty($page)) {
  1600. $start = 0;
  1601. $perpage = 1;
  1602. } else {
  1603. $start = ($page - 1) * $perpage;
  1604. }
  1605. if ($sku) {
  1606. $sku = trim($sku, ' ');
  1607. $sku = trim($sku, ' ');
  1608. $where .= " and sku like '%$sku%'";
  1609. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1610. } else if ($title) {
  1611. $title = trim($title, ' ');
  1612. $title = trim($title, ' ');
  1613. $where .= " and title like '%$title%'";
  1614. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1615. } else {
  1616. //$where .= " and time > '$ktime' and time < '$jtime'";
  1617. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1618. }
  1619. //取得信息列表
  1620. $rows = array();
  1621. $list = array();
  1622. foreach ($info_list as $key => $value) {
  1623. $warehouse = $this->warehouse->read($value['warehouse']);
  1624. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1625. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1626. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1627. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1628. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1629. $od = array();
  1630. $odid = '';
  1631. foreach ($z as $v) {
  1632. if (!isset($od[$v['zd']])) {
  1633. $od[$v['zd']] = 1; //所有数据sku
  1634. } else {
  1635. $od[$v['zd']] = $od[$v['zd']] + 1;
  1636. }
  1637. }
  1638. foreach ($od as $k => $vv) {
  1639. $odid .= $k . '数量' . $vv . ' ';
  1640. }
  1641. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1642. $info_list[$key]['features'] = $c;
  1643. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1644. $ztdata = '';
  1645. if (count($zt) > 0) {
  1646. foreach ($zt as $vv) {
  1647. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1648. }
  1649. }
  1650. $info_list[$key]['warehouse'] = $ztdata;
  1651. $info_list[$key]['g'] = $g;
  1652. $info_list[$key]['x'] = $x;
  1653. $info_list[$key]['t'] = $t;
  1654. $info_list[$key]['z'] = $z;
  1655. }
  1656. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1657. $pagenum = ceil($total / $perpage);
  1658. $over = $total - ($start + $perpage);
  1659. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1660. echo json_encode($rows);
  1661. exit;
  1662. }
  1663. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1664. $this->data['warehouse'] = $warehouse;
  1665. $this->_Template('whlabel_typeusa', $this->data);
  1666. }
  1667. //美仓进销存浏览
  1668. public function _usatypeapp()
  1669. {
  1670. $post = $this->input->post(NULL, TRUE);
  1671. if (isset($post['page'])) {
  1672. $page = $this->input->post('page', true);
  1673. $perpage = $this->input->post('perpage', true);
  1674. $sku = $this->input->post('sku', true);
  1675. $warehouse = 5;
  1676. $title = $this->input->post('title', true);
  1677. $state = $this->input->post('state', true);
  1678. $ktime = $this->input->post('ktime', true);
  1679. $jtime = $this->input->post('jtime', true);
  1680. $ktime = strtotime($ktime);
  1681. $jtime = strtotime($jtime);
  1682. $where = "1=1";
  1683. $gj = "";
  1684. $ck = "";
  1685. if ($title) {
  1686. $st = explode(' ', trim($title, ' '));
  1687. foreach ($st as $v) {
  1688. $where .= " and title like '%$v%'";
  1689. }
  1690. }
  1691. if ($warehouse) {
  1692. $where .= " and warehouse = '$warehouse'";
  1693. }
  1694. if ($state) {
  1695. $where .= " and state = '$state'";
  1696. }
  1697. if ($sku) {
  1698. $where .= " and sku like '%$sku%'";
  1699. }
  1700. if ($ktime && $jtime) {
  1701. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1702. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1703. }
  1704. //数据排序
  1705. $order_str = "id desc";
  1706. if (empty($page)) {
  1707. $start = 0;
  1708. $perpage = 1;
  1709. } else {
  1710. $start = ($page - 1) * $perpage;
  1711. }
  1712. //取得信息列表
  1713. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1714. $rows = array();
  1715. $list = array();
  1716. foreach ($info_list as $key => $value) {
  1717. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1718. }
  1719. $rowsdq = array_slice($rows, $start, $perpage);
  1720. foreach ($rowsdq as $value) {
  1721. $warehouse = $this->warehouse->read($value['warehouse']);
  1722. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1723. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1724. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1725. $od = array();
  1726. $odid = '';
  1727. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1728. }
  1729. $total = count($rows);
  1730. $pagenum = ceil($total / $perpage);
  1731. $over = $total - ($start + $perpage);
  1732. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1733. echo json_encode($rows);
  1734. exit;
  1735. }
  1736. $this->_Template('phone/p_usatypeapp', $this->data);
  1737. }
  1738. //入库操作
  1739. public function _enteradd()
  1740. {
  1741. $dt = 0;
  1742. if (isset($_SESSION['api'])) {
  1743. $user = $this->user->get_api($_SESSION['api']);
  1744. $usp = $user;
  1745. $fgshop = "";
  1746. $sid = "";
  1747. $user = explode('|', trim($user['shop'], '|'));
  1748. foreach ($user as $value) {
  1749. $fgshop .= " shop = " . $value . " or";
  1750. $sid .= " id = " . $value . " or";
  1751. }
  1752. }
  1753. $tc = $this->typeclass->find_all();
  1754. $typeclass = array();
  1755. foreach ($tc as $v) {
  1756. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1757. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1758. }
  1759. $post = $this->input->post(NULL, TRUE);
  1760. if (isset($post['sku'])) {
  1761. $list = array();
  1762. $num = "";
  1763. $title = "";
  1764. $features = "";
  1765. $order = $this->input->post('order', true);
  1766. $shop = $this->input->post('shop', true);
  1767. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1768. $sku = $this->input->post('sku', true);
  1769. $post['sm'] = $this->input->post('sm', true);
  1770. $post['warehouse'] = $this->input->post('warehouse', true);
  1771. $post['purchase'] = $this->input->post('purchase', true);
  1772. $post['retreatwarehouse'] = $post['warehouse'];
  1773. $post['state'] = $this->input->post('state', true);
  1774. $post['rktype'] = $this->input->post('rktype', true);
  1775. $post['text'] = $this->input->post('text', true);
  1776. $category = $this->input->post('category', true);
  1777. $list['category'] = $category;
  1778. $list['hairtype'] = $this->input->post('hairtype', true);
  1779. $list['grade'] = $this->input->post('grade', true);
  1780. $size = $this->input->post('size', true);
  1781. $xzsku = $this->input->post('xzsku', true);
  1782. $list['size'] = rtrim($size, ',');
  1783. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1784. $list['extension'] = $this->input->post('extension', true);
  1785. if ($category == 1297) {
  1786. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1787. }
  1788. if ($category == 1702) {
  1789. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1790. $list['syother'] = $this->input->post('syother', true);
  1791. }
  1792. if ($category == 133) {
  1793. $list['fittype'] = $this->input->post('fittype', true);
  1794. $list['acother'] = $this->input->post('acother', true);
  1795. }
  1796. $list['color'] = $this->input->post('color', true);
  1797. $list['lowe'] = $this->input->post('lowe', true);
  1798. if (!$post['purchase']) {
  1799. $post['purchase'] = 1;
  1800. }
  1801. if ($category == 127) {
  1802. $list['type'] = $this->input->post('type', true);
  1803. $list['headroad'] = $this->input->post('headroad', true);
  1804. $list['density'] = $this->input->post('density', true);
  1805. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1806. $list['lacesize'] = $this->input->post('lacesize', true);
  1807. }
  1808. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1809. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1810. }
  1811. if ($category == 128) {
  1812. $list['lacetype'] = $this->input->post('lacetype', true);
  1813. $list['haircap'] = $this->input->post('haircap', true);
  1814. $list['density'] = $this->input->post('density', true);
  1815. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1816. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1817. $list['wigother'] = $this->input->post('wigother', true);
  1818. $list['wigother1'] = $this->input->post('wigother1', true);
  1819. $list['wigother2'] = $this->input->post('wigother2', true);
  1820. }
  1821. if ($category == 129) {
  1822. $list['wide'] = $this->input->post('wide', true);
  1823. }
  1824. if ($category == 131) {
  1825. $list['gifttype'] = $this->input->post('gifttype', true);
  1826. $list['giftother'] = $this->input->post('giftother', true);
  1827. }
  1828. if ($category == 134) {
  1829. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1830. }
  1831. if ($category == 1297) {
  1832. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1833. $list['sywigother'] = $this->input->post('sywigother', true);
  1834. }
  1835. if ($category == 130 || $category == 133 || $category == 1702) {
  1836. $list['items'] = $this->input->post('items', true);
  1837. $list['weight'] = $this->input->post('weight', true);
  1838. }
  1839. if ($category == 1702) {
  1840. $list['syhairther'] = $this->input->post('syhairther', true);
  1841. }
  1842. $classid = $this->classid->sku();
  1843. $scsku = $classid;
  1844. $pm = $classid;
  1845. foreach ($list as $k => $v) {
  1846. if ($v != 0) {
  1847. $num .= $v;
  1848. $features .= $v . '-';
  1849. $post[$k] = $v;
  1850. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1851. if ($k != 'size') {
  1852. $title .= $typeclass[$v]['title'] . " ";
  1853. }
  1854. if (isset($pm[$typeclass[$v]['classid']])) {
  1855. if ($typeclass[$v]['title'] == '9A') {
  1856. $pm[$typeclass[$v]['classid']] = '9A';
  1857. } else if ($typeclass[$v]['title'] == '10A') {
  1858. $pm[$typeclass[$v]['classid']] = '10A';
  1859. } else {
  1860. $clzh = $typeclass[$v]['zh'];
  1861. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1862. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1863. $clzh = $clzh[0];
  1864. }
  1865. $pm[$typeclass[$v]['classid']] = $clzh;
  1866. }
  1867. }
  1868. }
  1869. }
  1870. $zh = implode(" ", $pm);
  1871. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1872. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1873. if ($list['size']) {
  1874. $typeclass = $this->typeclass->read($list['size']);
  1875. $title .= $typeclass['title'];
  1876. }
  1877. $time = time();
  1878. if ($xzsku) {
  1879. $scsku = implode("-", $scsku);
  1880. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1881. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1882. $post['sku'] = trim($scsku, ' ');
  1883. } else {
  1884. $post['sku'] = $sku;
  1885. }
  1886. //$post['sku'] = trim($sku,' ');
  1887. $post['title'] = rtrim($title, ' ');
  1888. $post['number'] = $num;
  1889. $post['features'] = '-' . $features;
  1890. $post['enter'] = $time;
  1891. $post['time'] = $time; //操作时间
  1892. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1893. if ($yza) {
  1894. if ($post['features'] != $yza[0]['features']) {
  1895. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1896. exit;
  1897. }
  1898. }
  1899. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1900. if ($yzb) {
  1901. if ($post['sku'] != $yzb[0]['sku']) {
  1902. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1903. exit;
  1904. }
  1905. }
  1906. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1907. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1908. exit;
  1909. }
  1910. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1911. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1912. exit;
  1913. }
  1914. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1915. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1916. exit;
  1917. }
  1918. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1919. if (isset($yz[0]['type'])) {
  1920. $post['type'] = $yz[0]['type'];
  1921. }
  1922. if ($post['state'] == 9) //如果选择预设库存
  1923. {
  1924. $this->whlabel->insert($post);
  1925. } else {
  1926. /**
  1927. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1928. if($ljg == 1)
  1929. {
  1930. for($i=0;$i<$order;$i++)
  1931. {
  1932. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1933. $this->whlabel->insert($post);
  1934. }
  1935. }
  1936. **/
  1937. //if($post['warehouse'] == '5')
  1938. //{
  1939. //}
  1940. $yydata = $post;
  1941. $yydata['zh'] = $zh;
  1942. /**
  1943. $wl = $this->apiyy->get_cjlp($yydata);
  1944. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1945. {
  1946. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1947. }
  1948. if($wl['Data'][0]['m_isSucess'] != 1)
  1949. {
  1950. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1951. }
  1952. **/
  1953. for ($i = 0; $i < $order; $i++) {
  1954. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1955. $this->whlabel->insert($post);
  1956. }
  1957. }
  1958. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1959. exit;
  1960. }
  1961. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1962. $this->data['wlshop'] = $wlshop;
  1963. $this->_Template('whlabel_enteradd', $this->data);
  1964. }
  1965. //修改产品
  1966. public function _enteredit($arg_array)
  1967. {
  1968. $dt = 0;
  1969. if (isset($_SESSION['api'])) {
  1970. $user = $this->user->get_api($_SESSION['api']);
  1971. $usp = $user;
  1972. $fgshop = "";
  1973. $sid = "";
  1974. $user = explode('|', trim($user['shop'], '|'));
  1975. foreach ($user as $value) {
  1976. $fgshop .= " shop = " . $value . " or";
  1977. $sid .= " id = " . $value . " or";
  1978. }
  1979. }
  1980. $post = $this->input->post(NULL, TRUE);
  1981. if (isset($post['sku'])) {
  1982. $list = array();
  1983. $num = "";
  1984. $title = "";
  1985. $features = "";
  1986. $id = $this->input->post('id', true);
  1987. $order = $this->input->post('order', true);
  1988. $shop = $this->input->post('shop', true);
  1989. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1990. $post['sku'] = $this->input->post('sku', true);
  1991. $post['sm'] = $this->input->post('sm', true);
  1992. $post['warehouse'] = $this->input->post('warehouse', true);
  1993. $post['purchase'] = $this->input->post('purchase', true);
  1994. $post['retreatwarehouse'] = $post['warehouse'];
  1995. $category = $this->input->post('category', true);
  1996. $list['category'] = $category;
  1997. $list['hairtype'] = $this->input->post('hairtype', true);
  1998. $list['grade'] = $this->input->post('grade', true);
  1999. $size = $this->input->post('size', true);
  2000. $list['size'] = rtrim($size, ',');
  2001. $post['rktype'] = $this->input->post('rktype', true);
  2002. $post['text'] = $this->input->post('text', true);
  2003. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2004. $list['extension'] = $this->input->post('extension', true);
  2005. if ($category == 1297) {
  2006. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2007. }
  2008. if ($category == 1702) {
  2009. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2010. $list['syother'] = $this->input->post('syother', true);
  2011. }
  2012. if ($category == 133) {
  2013. $list['fittype'] = $this->input->post('fittype', true);
  2014. $list['acother'] = $this->input->post('acother', true);
  2015. }
  2016. $list['color'] = $this->input->post('color', true);
  2017. $list['lowe'] = $this->input->post('lowe', true);
  2018. if (!$post['purchase']) {
  2019. $post['purchase'] = 1;
  2020. }
  2021. if ($category == 127) {
  2022. $list['type'] = $this->input->post('type', true);
  2023. $list['headroad'] = $this->input->post('headroad', true);
  2024. $list['density'] = $this->input->post('density', true);
  2025. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2026. $list['lacesize'] = $this->input->post('lacesize', true);
  2027. }
  2028. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2029. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2030. }
  2031. if ($category == 128) {
  2032. $list['lacetype'] = $this->input->post('lacetype', true);
  2033. $list['haircap'] = $this->input->post('haircap', true);
  2034. $list['density'] = $this->input->post('density', true);
  2035. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2036. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2037. $list['wigother'] = $this->input->post('wigother', true);
  2038. $list['wigother1'] = $this->input->post('wigother1', true);
  2039. $list['wigother2'] = $this->input->post('wigother2', true);
  2040. }
  2041. if ($category == 129) {
  2042. $list['wide'] = $this->input->post('wide', true);
  2043. }
  2044. if ($category == 131) {
  2045. $list['gifttype'] = $this->input->post('gifttype', true);
  2046. $list['giftother'] = $this->input->post('giftother', true);
  2047. }
  2048. if ($category == 134) {
  2049. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2050. }
  2051. if ($category == 1297) {
  2052. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2053. $list['sywigother'] = $this->input->post('sywigother', true);
  2054. }
  2055. if ($category == 130 || $category == 133 || $category == 1702) {
  2056. $list['items'] = $this->input->post('items', true);
  2057. $list['weight'] = $this->input->post('weight', true);
  2058. }
  2059. if ($category == 1702) {
  2060. $list['syhairther'] = $this->input->post('syhairther', true);
  2061. }
  2062. foreach ($list as $k => $v) {
  2063. if ($v != 0) {
  2064. $num .= $v;
  2065. $features .= $v . '-';
  2066. $typeclass = $this->typeclass->read($v);
  2067. if ($k != 'size') {
  2068. $title .= $typeclass['title'] . " ";
  2069. }
  2070. }
  2071. }
  2072. $typeclass = $this->typeclass->read($list['size']);
  2073. $title .= $typeclass['title'];
  2074. $time = time();
  2075. $post['title'] = rtrim($title, ' ');
  2076. $post['number'] = $num;
  2077. $post['features'] = '-' . $features;
  2078. $post['time'] = $time; //操作时间
  2079. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2080. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2081. exit;
  2082. }
  2083. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2084. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2085. exit;
  2086. }
  2087. $uid = $this->whlabel->read($id);
  2088. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2089. if ($datanum > 0) {
  2090. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2091. exit;
  2092. }
  2093. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2094. {
  2095. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2096. if ($yza) {
  2097. if ($post['features'] != $yza[0]['features']) {
  2098. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2099. exit;
  2100. }
  2101. }
  2102. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2103. if ($yzb) {
  2104. if ($post['sku'] != $yzb[0]['sku']) {
  2105. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2106. exit;
  2107. }
  2108. }
  2109. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2110. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2111. exit;
  2112. }
  2113. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2114. foreach ($data as $v) {
  2115. $post['id'] = $v['id'];
  2116. $this->whlabel->save($post, $v['id']);
  2117. }
  2118. } else {
  2119. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2120. if ($data > 0) {
  2121. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2122. exit;
  2123. } else {
  2124. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2125. foreach ($data as $v) {
  2126. $post['id'] = $v['id'];
  2127. $this->whlabel->save($post, $v['id']);
  2128. }
  2129. }
  2130. }
  2131. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2132. exit;
  2133. }
  2134. $uid = $this->whlabel->read($arg_array[0]);
  2135. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2136. $this->data['enter'] = $uid;
  2137. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2138. $this->data['wlshop'] = $wlshop;
  2139. $this->_Template('whlabel_enteredit', $this->data);
  2140. }
  2141. //入库浏览
  2142. public function _enter()
  2143. {
  2144. $post = $this->input->post(NULL, TRUE);
  2145. if (isset($post['s'])) {
  2146. $id_arr = $this->input->post('s');
  2147. $id_arr = explode(',', $id_arr);
  2148. if (!$id_arr) {
  2149. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2150. exit;
  2151. }
  2152. //循环删除记录
  2153. foreach ($id_arr as $v) {
  2154. $sid = $this->whlabel->read($v);
  2155. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2156. if ($count > 0) {
  2157. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2158. exit;
  2159. }
  2160. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2161. foreach ($info_list as $va) {
  2162. $this->whlabel->remove($va['id']);
  2163. }
  2164. }
  2165. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2166. exit;
  2167. }
  2168. $sp = array();
  2169. $s = $this->shop->find_all('1=1', 'id,shopname');
  2170. foreach ($s as $v) {
  2171. $sp[$v['id']] = $v['shopname'];
  2172. }
  2173. $wh = array();
  2174. $w = $this->warehouse->find_all('1=1', 'id,title');
  2175. foreach ($w as $v) {
  2176. $wh[$v['id']] = $v['title'];
  2177. }
  2178. if (isset($post['page'])) {
  2179. $page = $this->input->post('page', true);
  2180. $perpage = $this->input->post('perpage', true);
  2181. $category = $this->input->post('category', true);
  2182. $size = $this->input->post('size', true);
  2183. $grade = $this->input->post('grade', true);
  2184. $color = $this->input->post('color', true);
  2185. $lowe = $this->input->post('lowe', true);
  2186. $sku = $this->input->post('sku', true);
  2187. $warehouse = $this->input->post('warehouse', true);
  2188. $purchase = $this->input->post('purchase', true);
  2189. $ktime = $this->input->post('ktime', true);
  2190. $jtime = $this->input->post('jtime', true);
  2191. $ktime = strtotime($ktime);
  2192. $jtime = strtotime($jtime);
  2193. $where = "1=1";
  2194. $gj = "";
  2195. $ck = "";
  2196. if ($category) {
  2197. $where .= " and features like '%-$category-%'";
  2198. }
  2199. if ($size) {
  2200. $where .= " and features like '%-$size-%'";
  2201. }
  2202. if ($grade) {
  2203. $where .= " and features like '%-$grade-%'";
  2204. }
  2205. if ($color) {
  2206. $where .= " and features like '%-$color-%'";
  2207. }
  2208. if ($lowe) {
  2209. $where .= " and features like '%-$lowe-%'";
  2210. }
  2211. if ($warehouse) {
  2212. $where .= " and warehouse = '$warehouse'";
  2213. }
  2214. if ($purchase) {
  2215. $where .= " and purchase = '$purchase'";
  2216. }
  2217. if ($sku) {
  2218. $where .= " and sku like '%$sku%'";
  2219. }
  2220. if ($ktime && $jtime) {
  2221. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2222. }
  2223. //数据排序
  2224. $order_str = "enter desc";
  2225. if (empty($page)) {
  2226. $start = 0;
  2227. $perpage = 1;
  2228. } else {
  2229. $start = ($page - 1) * $perpage;
  2230. }
  2231. //取得信息列表
  2232. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2233. foreach ($info_list as $k => $v) {
  2234. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2235. if ($v['shop'] == '') {
  2236. $s = '通用';
  2237. } else {
  2238. $info_list[$k]['shop'] = '';
  2239. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2240. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2241. }
  2242. }
  2243. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2244. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2245. $info_list[$k]['g'] = $g;
  2246. }
  2247. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2248. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2249. $pagenum = ceil($total / $perpage);
  2250. $over = $total - ($start + $perpage);
  2251. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2252. echo json_encode($rows);
  2253. exit;
  2254. }
  2255. $this->_Template('whlabel_enter', $this->data);
  2256. }
  2257. //出库浏览
  2258. public function _out()
  2259. {
  2260. $post = $this->input->post(NULL, TRUE);
  2261. if (isset($post['page'])) {
  2262. $page = $this->input->post('page', true);
  2263. $perpage = $this->input->post('perpage', true);
  2264. $category = $this->input->post('category', true);
  2265. $size = $this->input->post('size', true);
  2266. $grade = $this->input->post('grade', true);
  2267. $color = $this->input->post('color', true);
  2268. $lowe = $this->input->post('lowe', true);
  2269. $sku = $this->input->post('sku', true);
  2270. $warehouse = $this->input->post('warehouse', true);
  2271. $purchase = $this->input->post('purchase', true);
  2272. $state = $this->input->post('state', true);
  2273. $ktime = $this->input->post('ktime', true);
  2274. $jtime = $this->input->post('jtime', true);
  2275. $ktime = strtotime($ktime);
  2276. $jtime = strtotime($jtime);
  2277. $where = "state=3";
  2278. $gj = "";
  2279. $ck = "";
  2280. if ($category) {
  2281. $where .= " and features like '%-$category-%'";
  2282. }
  2283. if ($size) {
  2284. $where .= " and features like '%-$size-%'";
  2285. }
  2286. if ($grade) {
  2287. $where .= " and features like '%-$grade-%'";
  2288. }
  2289. if ($color) {
  2290. $where .= " and features like '%-$color-%'";
  2291. }
  2292. if ($lowe) {
  2293. $where .= " and features like '%-$lowe-%'";
  2294. }
  2295. if ($state) {
  2296. $where .= " and state = '$state'";
  2297. }
  2298. if ($warehouse) {
  2299. $where .= " and warehouse = '$warehouse'";
  2300. }
  2301. if ($purchase) {
  2302. $where .= " and purchase = '$purchase'";
  2303. }
  2304. if ($sku) {
  2305. $where .= " and sku = '$sku'";
  2306. }
  2307. if ($ktime && $jtime) {
  2308. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2309. }
  2310. //数据排序
  2311. $order_str = "id desc";
  2312. if (empty($page)) {
  2313. $start = 0;
  2314. $perpage = 1;
  2315. } else {
  2316. $start = ($page - 1) * $perpage;
  2317. }
  2318. //取得信息列表
  2319. $info_list = $this->whlabel->find_all($where, 'sku');
  2320. $rows = array();
  2321. $list = array();
  2322. foreach ($info_list as $key => $value) {
  2323. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2324. }
  2325. $rows = array_unique($rows); //删除重复记录
  2326. foreach ($rows as $key => $value) {
  2327. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2328. $ck = $this->warehouse->read($data['warehouse']);
  2329. $warehouse = $ck['title'];
  2330. $gy = $this->purchase->read($data['purchase']);
  2331. $purchase = $gy['purchase'];
  2332. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2333. $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);
  2334. }
  2335. $total = count($list);
  2336. $pagenum = ceil($total / $perpage);
  2337. $over = $total - ($start + $perpage);
  2338. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2339. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2340. echo json_encode($rows);
  2341. exit;
  2342. }
  2343. $this->_Template('whlabel_out', $this->data);
  2344. }
  2345. //出库标签浏览
  2346. public function _label()
  2347. {
  2348. $post = $this->input->post(NULL, TRUE);
  2349. if (isset($post['page'])) {
  2350. $page = $this->input->post('page', true);
  2351. $perpage = $this->input->post('perpage', true);
  2352. $sku = $this->input->post('sku', true);
  2353. $warehouse = $this->input->post('warehouse', true);
  2354. $purchase = $this->input->post('purchase', true);
  2355. $orderinfo = $this->input->post('orderinfo', true);
  2356. $waybill = $this->input->post('waybill', true);
  2357. $category = $this->input->post('category', true);
  2358. $size = $this->input->post('size', true);
  2359. $grade = $this->input->post('grade', true);
  2360. $color = $this->input->post('color', true);
  2361. $lowe = $this->input->post('lowe', true);
  2362. $where = "state=1";
  2363. if ($sku) {
  2364. $where .= " and sku = '$sku'";
  2365. }
  2366. if ($warehouse) {
  2367. $where .= " and warehouse = '$warehouse'";
  2368. }
  2369. if ($purchase) {
  2370. $where .= " and purchase = '$purchase'";
  2371. }
  2372. if ($orderinfo) {
  2373. $where .= " and orderinfo = '$orderinfo'";
  2374. }
  2375. if ($waybill) {
  2376. $where .= " and waybill = '$waybill'";
  2377. }
  2378. if ($category) {
  2379. $where .= " and features like '%-$category-%'";
  2380. }
  2381. if ($size) {
  2382. $where .= " and features like '%-$size-%'";
  2383. }
  2384. if ($grade) {
  2385. $where .= " and features like '%-$grade-%'";
  2386. }
  2387. if ($color) {
  2388. $where .= " and features like '%-$color-%'";
  2389. }
  2390. if ($lowe) {
  2391. $where .= " and features like '%-$lowe-%'";
  2392. }
  2393. //数据排序
  2394. $order_str = "outk desc";
  2395. if (empty($page)) {
  2396. $start = 0;
  2397. $perpage = 1;
  2398. } else {
  2399. $start = ($page - 1) * $perpage;
  2400. }
  2401. //取得信息列表
  2402. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2403. foreach ($info_list as $key => $value) {
  2404. $warehouse = $this->warehouse->read($value['warehouse']);
  2405. $info_list[$key]['warehouse'] = $warehouse['title'];
  2406. $purchase = $this->purchase->read($value['purchase']);
  2407. $info_list[$key]['purchase'] = $purchase['title'];
  2408. if ($value['outk'] != 0) {
  2409. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2410. } else {
  2411. $info_list[$key]['outk'] = "";
  2412. }
  2413. if ($value['orderinfo'] == 0) {
  2414. $info_list[$key]['orderinfo'] = "";
  2415. }
  2416. if ($value['waybill'] == 0) {
  2417. $info_list[$key]['waybill'] = "";
  2418. }
  2419. }
  2420. $total = $this->whlabel->find_count($where);
  2421. $pagenum = ceil($total / $perpage);
  2422. $over = $total - ($start + $perpage);
  2423. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2424. echo json_encode($rows);
  2425. exit;
  2426. }
  2427. $this->_Template('whlabel_label', $this->data);
  2428. }
  2429. //独立站出库订单
  2430. public function _outorder()
  2431. {
  2432. if (isset($_SESSION['api'])) {
  2433. $user = $this->user->get_api($_SESSION['api']);
  2434. $usp = $user;
  2435. $fgshop = "";
  2436. $sid = "";
  2437. $user = explode('|', trim($user['shop'], '|'));
  2438. foreach ($user as $value) {
  2439. $fgshop .= " shop = " . $value . " or";
  2440. $sid .= " id = " . $value . " or";
  2441. }
  2442. } else {
  2443. echo "请重新登录";
  2444. }
  2445. $post = $this->input->post(NULL, TRUE);
  2446. if (isset($post['page'])) {
  2447. $page = $this->input->post('page', true);
  2448. $perpage = $this->input->post('perpage', true);
  2449. $warehouse = $this->input->post('warehouse', true);
  2450. $xztime = $this->input->post('xztime', true);
  2451. $timetk = $this->input->post('timetkk', true);
  2452. $timetj = $this->input->post('timetjj', true);
  2453. $shop = $this->input->post('shop', true);
  2454. $source = $this->input->post('source', true);
  2455. $orderinfo = $this->input->post('orderinfo', true);
  2456. $number = $this->input->post('number', true);
  2457. $sfxh = $this->input->post('sfxh', true);
  2458. $express = $this->input->post('express', true);
  2459. $waybill = $this->input->post('waybill', true);
  2460. $library = $this->input->post('library', true);
  2461. $country = $this->input->post('country', true);
  2462. $so = $this->input->post('so', true);
  2463. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2464. $print = $this->input->post('print', true);
  2465. $state = $this->input->post('state', true);
  2466. $orderurl = $this->input->post('orderurl', true);
  2467. $productid = $this->input->post('productid', true);
  2468. $timetk = strtotime($timetk);
  2469. $timetj = strtotime($timetj);
  2470. /**
  2471. $sj = $this->input->post('sj',true);
  2472. if($sj)
  2473. {
  2474. $sj = $this->input->post('sj',true);
  2475. }
  2476. else
  2477. {
  2478. $sj = "fullorder";
  2479. }
  2480. **/
  2481. $sj = "fullorder";
  2482. $where = "1=1";
  2483. if ($warehouse) {
  2484. $where .= " and type = '$warehouse'";
  2485. }
  2486. if ($timetk && $timetj) {
  2487. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2488. }
  2489. if ($orderinfo) {
  2490. $where .= " and orderinfo = '$orderinfo'";
  2491. }
  2492. if ($number) {
  2493. $where .= " and number = '$number'";
  2494. }
  2495. if ($express) {
  2496. $where .= " and express = '$express'";
  2497. }
  2498. if ($waybill) {
  2499. $where .= " and waybill = '$waybill'";
  2500. }
  2501. if ($library) {
  2502. $where .= " and library = '$library'";
  2503. }
  2504. if ($print) {
  2505. $where .= " and print = '$print'";
  2506. }
  2507. if ($libraryconfirm) {
  2508. $where .= " and libraryconfirm = '$libraryconfirm'";
  2509. }
  2510. if ($state) {
  2511. $where .= " and state = '$state'";
  2512. }
  2513. if ($shop) {
  2514. $where .= " and shop = '$shop'";
  2515. }
  2516. if ($country) {
  2517. $where .= " and country = '$country'";
  2518. }
  2519. if ($sfxh != '') {
  2520. $where .= " and sfxh = '$sfxh'";
  2521. }
  2522. if ($so) {
  2523. $where .= " and shipremarks like '%$so%'";
  2524. }
  2525. if ($source) {
  2526. if ($source == '2d') {
  2527. $where .= " and source >= '2'";
  2528. } else {
  2529. $where .= " and source = '$source'";
  2530. }
  2531. }
  2532. if (isset($_SESSION['api'])) {
  2533. foreach ($user as $value) {
  2534. $fgshop .= " shop = " . $value . " or";
  2535. }
  2536. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2537. }
  2538. if ($orderurl) {
  2539. $url = $this->orderurl->read($orderurl);
  2540. $where .= " and link like '%" . $url['url'] . "%'";
  2541. }
  2542. if($productid){
  2543. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2544. }
  2545. //数据排序
  2546. $order_str = "librarytime desc";
  2547. if (empty($page)) {
  2548. $start = 0;
  2549. $perpage = 1;
  2550. } else {
  2551. $start = ($page - 1) * $perpage;
  2552. }
  2553. //取得信息列表
  2554. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2555. //格式化数据
  2556. foreach ($info_list as $key => $value) {
  2557. $shop = $this->shop->read($value['shop']);
  2558. $info_list[$key]['shop'] = $shop['shopname'];
  2559. $express = $this->express->read($value['express']);
  2560. $info_list[$key]['express'] = $express['servicename'];
  2561. $warehouse = $this->warehouse->read($value['type']);
  2562. $info_list[$key]['type'] = $warehouse['title'];
  2563. if ($value['librarytime'] == '0') {
  2564. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2565. } else {
  2566. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2567. }
  2568. }
  2569. $total = $this->$sj->find_count($where);
  2570. $pagenum = ceil($total / $perpage);
  2571. $over = $total - ($start + $perpage);
  2572. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2573. echo json_encode($rows);
  2574. exit;
  2575. }
  2576. $this->data['express'] = $this->express->find_all();
  2577. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2578. $this->data['wlshop'] = $wlshop;
  2579. $user = $this->user->get_api($_SESSION['api']);
  2580. $powerid = $this->power->read($user['power']);
  2581. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2582. $pid = '';
  2583. foreach ($powertext as $v) {
  2584. $pid .= " id = " . $v . " or";
  2585. }
  2586. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2587. $this->data['fullorderexcel'] = $fullorderexcel;
  2588. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2589. $this->data['orderurl'] = $orderurl;
  2590. $this->_Template('whlabel_outorder', $this->data);
  2591. }
  2592. //tt出库
  2593. public function _toutorder()
  2594. {
  2595. $fgshop = "";
  2596. $sid = "";
  2597. if (isset($_SESSION['api'])) {
  2598. $user = $this->user->get_api($_SESSION['api']);
  2599. $usp = $user;
  2600. $user = explode('|', trim($user['shop'], '|'));
  2601. foreach ($user as $value) {
  2602. $fgshop .= " shop = " . $value . " or";
  2603. $sid .= " id = " . $value . " or";
  2604. }
  2605. } else {
  2606. echo "请重新登录";
  2607. die;
  2608. }
  2609. $post = $this->input->post(NULL, TRUE);
  2610. if (isset($post['page'])) {
  2611. $page = $this->input->post('page', true);
  2612. $perpage = $this->input->post('perpage', true);
  2613. $warehouse = $this->input->post('warehouse', true);
  2614. $xztime = $this->input->post('xztime', true);
  2615. $timetk = $this->input->post('timetkk', true);
  2616. $timetj = $this->input->post('timetjj', true);
  2617. $shop = $this->input->post('shop', true);
  2618. $source = $this->input->post('source', true);
  2619. $orderinfo = $this->input->post('orderinfo', true);
  2620. $number = $this->input->post('number', true);
  2621. $sfxh = $this->input->post('sfxh', true);
  2622. $express = $this->input->post('express', true);
  2623. $waybill = $this->input->post('waybill', true);
  2624. $library = $this->input->post('library', true);
  2625. $country = $this->input->post('country', true);
  2626. $so = $this->input->post('so', true);
  2627. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2628. $print = $this->input->post('print', true);
  2629. $state = $this->input->post('state', true);
  2630. $orderurl = $this->input->post('orderurl', true);
  2631. $timetk = strtotime($timetk);
  2632. $timetj = strtotime($timetj);
  2633. /**
  2634. $sj = $this->input->post('sj',true);
  2635. if($sj)
  2636. {
  2637. $sj = $this->input->post('sj',true);
  2638. }
  2639. else
  2640. {
  2641. $sj = "fullorder";
  2642. }
  2643. **/
  2644. $sj = "fullordertt";
  2645. $where = "1=1";
  2646. if ($warehouse) {
  2647. $where .= " and type = '$warehouse'";
  2648. }
  2649. if ($timetk && $timetj) {
  2650. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2651. }
  2652. if ($orderinfo) {
  2653. $where .= " and orderinfo = '$orderinfo'";
  2654. }
  2655. if ($number) {
  2656. $where .= " and number = '$number'";
  2657. }
  2658. if ($express) {
  2659. $where .= " and express = '$express'";
  2660. }
  2661. if ($waybill) {
  2662. $where .= " and waybill = '$waybill'";
  2663. }
  2664. if ($library) {
  2665. $where .= " and library = '$library'";
  2666. }
  2667. if ($print) {
  2668. $where .= " and print = '$print'";
  2669. }
  2670. if ($libraryconfirm) {
  2671. $where .= " and libraryconfirm = '$libraryconfirm'";
  2672. }
  2673. if ($state) {
  2674. $where .= " and state = '$state'";
  2675. }
  2676. if ($shop) {
  2677. $where .= " and shop = '$shop'";
  2678. }
  2679. if ($country) {
  2680. $where .= " and country = '$country'";
  2681. }
  2682. if ($sfxh != '') {
  2683. $where .= " and sfxh = '$sfxh'";
  2684. }
  2685. if ($so) {
  2686. $where .= " and shipremarks like '%$so%'";
  2687. }
  2688. if ($source) {
  2689. if ($source == '2d') {
  2690. $where .= " and source >= '2'";
  2691. } else {
  2692. $where .= " and source = '$source'";
  2693. }
  2694. }
  2695. if (isset($_SESSION['api'])) {
  2696. foreach ($user as $value) {
  2697. $fgshop .= " shop = " . $value . " or";
  2698. }
  2699. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2700. }
  2701. if ($orderurl) {
  2702. $url = $this->orderurl->read($orderurl);
  2703. $where .= " and link like '%" . $url['url'] . "%'";
  2704. }
  2705. //数据排序
  2706. $order_str = "librarytime desc";
  2707. if (empty($page)) {
  2708. $start = 0;
  2709. $perpage = 1;
  2710. } else {
  2711. $start = ($page - 1) * $perpage;
  2712. }
  2713. //取得信息列表
  2714. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2715. //格式化数据
  2716. foreach ($info_list as $key => $value) {
  2717. $shop = $this->shop->read($value['shop']);
  2718. $info_list[$key]['shop'] = $shop['shopname'];
  2719. $express = $this->express->read($value['express']);
  2720. $info_list[$key]['express'] = $express['servicename'];
  2721. $warehouse = $this->warehouse->read($value['type']);
  2722. $info_list[$key]['type'] = $warehouse['title'];
  2723. if ($value['librarytime'] == '0') {
  2724. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2725. } else {
  2726. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2727. }
  2728. }
  2729. $total = $this->$sj->find_count($where);
  2730. $pagenum = ceil($total / $perpage);
  2731. $over = $total - ($start + $perpage);
  2732. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2733. echo json_encode($rows);
  2734. exit;
  2735. }
  2736. $this->data['express'] = $this->express->find_all();
  2737. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2738. $this->data['wlshop'] = $wlshop;
  2739. $user = $this->user->get_api($_SESSION['api']);
  2740. $powerid = $this->power->read($user['power']);
  2741. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2742. $pid = '';
  2743. foreach ($powertext as $v) {
  2744. $pid .= " id = " . $v . " or";
  2745. }
  2746. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2747. $this->data['fullorderexcel'] = $fullorderexcel;
  2748. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2749. $this->data['orderurl'] = $orderurl;
  2750. $this->_Template('whlabel_toutorder', $this->data);
  2751. }
  2752. //tt出库
  2753. public function _aoutorder()
  2754. {
  2755. if (isset($_SESSION['api'])) {
  2756. $user = $this->user->get_api($_SESSION['api']);
  2757. $usp = $user;
  2758. $fgshop = "";
  2759. $sid = "";
  2760. $user = explode('|', trim($user['shop'], '|'));
  2761. foreach ($user as $value) {
  2762. $fgshop .= " shop = " . $value . " or";
  2763. $sid .= " id = " . $value . " or";
  2764. }
  2765. } else {
  2766. echo "请重新登录";
  2767. }
  2768. $post = $this->input->post(NULL, TRUE);
  2769. if (isset($post['page'])) {
  2770. $page = $this->input->post('page', true);
  2771. $perpage = $this->input->post('perpage', true);
  2772. $warehouse = $this->input->post('warehouse', true);
  2773. $xztime = $this->input->post('xztime', true);
  2774. $timetk = $this->input->post('timetkk', true);
  2775. $timetj = $this->input->post('timetjj', true);
  2776. $shop = $this->input->post('shop', true);
  2777. $source = $this->input->post('source', true);
  2778. $orderinfo = $this->input->post('orderinfo', true);
  2779. $number = $this->input->post('number', true);
  2780. $sfxh = $this->input->post('sfxh', true);
  2781. $express = $this->input->post('express', true);
  2782. $waybill = $this->input->post('waybill', true);
  2783. $library = $this->input->post('library', true);
  2784. $country = $this->input->post('country', true);
  2785. $so = $this->input->post('so', true);
  2786. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2787. $print = $this->input->post('print', true);
  2788. $state = $this->input->post('state', true);
  2789. $orderurl = $this->input->post('orderurl', true);
  2790. $timetk = strtotime($timetk);
  2791. $timetj = strtotime($timetj);
  2792. /**
  2793. $sj = $this->input->post('sj',true);
  2794. if($sj)
  2795. {
  2796. $sj = $this->input->post('sj',true);
  2797. }
  2798. else
  2799. {
  2800. $sj = "fullorder";
  2801. }
  2802. **/
  2803. $sj = "fullorderamz";
  2804. $where = "1=1";
  2805. if ($warehouse) {
  2806. $where .= " and type = '$warehouse'";
  2807. }
  2808. if ($timetk && $timetj) {
  2809. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2810. }
  2811. if ($orderinfo) {
  2812. $where .= " and orderinfo = '$orderinfo'";
  2813. }
  2814. if ($number) {
  2815. $where .= " and number = '$number'";
  2816. }
  2817. if ($express) {
  2818. $where .= " and express = '$express'";
  2819. }
  2820. if ($waybill) {
  2821. $where .= " and waybill = '$waybill'";
  2822. }
  2823. if ($library) {
  2824. $where .= " and library = '$library'";
  2825. }
  2826. if ($print) {
  2827. $where .= " and print = '$print'";
  2828. }
  2829. if ($libraryconfirm) {
  2830. $where .= " and libraryconfirm = '$libraryconfirm'";
  2831. }
  2832. if ($state) {
  2833. $where .= " and state = '$state'";
  2834. }
  2835. if ($shop) {
  2836. $where .= " and shop = '$shop'";
  2837. }
  2838. if ($country) {
  2839. $where .= " and country = '$country'";
  2840. }
  2841. if ($sfxh != '') {
  2842. $where .= " and sfxh = '$sfxh'";
  2843. }
  2844. if ($so) {
  2845. $where .= " and shipremarks like '%$so%'";
  2846. }
  2847. if ($source) {
  2848. if ($source == '2d') {
  2849. $where .= " and source >= '2'";
  2850. } else {
  2851. $where .= " and source = '$source'";
  2852. }
  2853. }
  2854. if (isset($_SESSION['api'])) {
  2855. foreach ($user as $value) {
  2856. $fgshop .= " shop = " . $value . " or";
  2857. }
  2858. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2859. }
  2860. if ($orderurl) {
  2861. $url = $this->orderurl->read($orderurl);
  2862. $where .= " and link like '%" . $url['url'] . "%'";
  2863. }
  2864. //数据排序
  2865. $order_str = "librarytime desc";
  2866. if (empty($page)) {
  2867. $start = 0;
  2868. $perpage = 1;
  2869. } else {
  2870. $start = ($page - 1) * $perpage;
  2871. }
  2872. //取得信息列表
  2873. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2874. //格式化数据
  2875. foreach ($info_list as $key => $value) {
  2876. $shop = $this->shop->read($value['shop']);
  2877. $info_list[$key]['shop'] = $shop['shopname'];
  2878. $express = $this->express->read($value['express']);
  2879. $info_list[$key]['express'] = $express['servicename'];
  2880. $warehouse = $this->warehouse->read($value['type']);
  2881. $info_list[$key]['type'] = $warehouse['title'];
  2882. if ($value['librarytime'] == '0') {
  2883. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2884. } else {
  2885. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2886. }
  2887. }
  2888. $total = $this->$sj->find_count($where);
  2889. $pagenum = ceil($total / $perpage);
  2890. $over = $total - ($start + $perpage);
  2891. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2892. echo json_encode($rows);
  2893. exit;
  2894. }
  2895. $this->data['express'] = $this->express->find_all();
  2896. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2897. $this->data['wlshop'] = $wlshop;
  2898. $user = $this->user->get_api($_SESSION['api']);
  2899. $powerid = $this->power->read($user['power']);
  2900. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2901. $pid = '';
  2902. foreach ($powertext as $v) {
  2903. $pid .= " id = " . $v . " or";
  2904. }
  2905. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2906. $this->data['fullorderexcel'] = $fullorderexcel;
  2907. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2908. $this->data['orderurl'] = $orderurl;
  2909. $this->_Template('whlabel_aoutorder', $this->data);
  2910. }
  2911. //速卖通出库订单
  2912. public function _soutorder()
  2913. {
  2914. if (isset($_SESSION['api'])) {
  2915. $user = $this->user->get_api($_SESSION['api']);
  2916. $usp = $user;
  2917. $fgshop = "";
  2918. $sid = "";
  2919. $user = explode('|', trim($user['shop'], '|'));
  2920. foreach ($user as $value) {
  2921. $sid .= " id = " . $value . " or";
  2922. }
  2923. }
  2924. $post = $this->input->post(NULL, TRUE);
  2925. if (isset($post['page'])) {
  2926. $page = $this->input->post('page', true);
  2927. $perpage = $this->input->post('perpage', true);
  2928. $warehouse = $this->input->post('warehouse', true);
  2929. $xztime = $this->input->post('xztime', true);
  2930. $timetk = $this->input->post('timetkk', true);
  2931. $timetj = $this->input->post('timetjj', true);
  2932. $shop = $this->input->post('shop', true);
  2933. $source = $this->input->post('source', true);
  2934. $orderinfo = $this->input->post('orderinfo', true);
  2935. $number = $this->input->post('number', true);
  2936. $express = $this->input->post('express', true);
  2937. $waybill = $this->input->post('waybill', true);
  2938. $library = $this->input->post('library', true);
  2939. $country = $this->input->post('country', true);
  2940. $sfxh = $this->input->post('sfxh', true);
  2941. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2942. $print = $this->input->post('print', true);
  2943. $state = $this->input->post('state', true);
  2944. $so = $this->input->post('so', true);
  2945. $timetk = strtotime($timetk);
  2946. $timetj = strtotime($timetj);
  2947. /**
  2948. $sj = $this->input->post('sj',true);
  2949. if($sj)
  2950. {
  2951. $sj = $this->input->post('sj',true);
  2952. }
  2953. else
  2954. {
  2955. $sj = "fullorder";
  2956. }
  2957. **/
  2958. $sj = "fullordersmt";
  2959. $where = "1=1";
  2960. if ($warehouse) {
  2961. $where .= " and type = '$warehouse'";
  2962. }
  2963. if ($timetk && $timetj) {
  2964. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2965. }
  2966. if ($orderinfo) {
  2967. $where .= " and orderinfo = '$orderinfo'";
  2968. }
  2969. if ($number) {
  2970. $where .= " and number = '$number'";
  2971. }
  2972. if ($express) {
  2973. $where .= " and express = '$express'";
  2974. }
  2975. if ($waybill) {
  2976. $where .= " and waybill = '$waybill'";
  2977. }
  2978. if ($library) {
  2979. $where .= " and library = '$library'";
  2980. }
  2981. if ($print) {
  2982. $where .= " and print = '$print'";
  2983. }
  2984. if ($libraryconfirm) {
  2985. $where .= " and libraryconfirm = '$libraryconfirm'";
  2986. }
  2987. if ($state) {
  2988. $where .= " and state = '$state'";
  2989. }
  2990. if ($shop) {
  2991. $where .= " and shop = '$shop'";
  2992. }
  2993. if ($sfxh != '') {
  2994. $where .= " and sfxh = '$sfxh'";
  2995. }
  2996. if ($so) {
  2997. $where .= " and shipremarks like '%$so%'";
  2998. }
  2999. if ($source) {
  3000. $where .= " and source = '$source'";
  3001. }
  3002. if ($country) {
  3003. $where .= " and country = '$country'";
  3004. } else {
  3005. if (isset($_SESSION['api'])) {
  3006. foreach ($user as $value) {
  3007. $fgshop .= " shop = " . $value . " or";
  3008. }
  3009. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3010. }
  3011. }
  3012. //数据排序
  3013. $order_str = "librarytime desc";
  3014. if (empty($page)) {
  3015. $start = 0;
  3016. $perpage = 1;
  3017. } else {
  3018. $start = ($page - 1) * $perpage;
  3019. }
  3020. //取得信息列表
  3021. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3022. //格式化数据
  3023. foreach ($info_list as $key => $value) {
  3024. $shop = $this->shop->read($value['shop']);
  3025. $info_list[$key]['shop'] = $shop['shopname'];
  3026. $express = $this->express->read($value['express']);
  3027. $info_list[$key]['express'] = $express['servicename'];
  3028. $warehouse = $this->warehouse->read($value['type']);
  3029. $info_list[$key]['type'] = $warehouse['title'];
  3030. if ($value['librarytime'] == '0') {
  3031. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3032. } else {
  3033. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3034. }
  3035. }
  3036. $total = $this->$sj->find_count($where);
  3037. $pagenum = ceil($total / $perpage);
  3038. $over = $total - ($start + $perpage);
  3039. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3040. echo json_encode($rows);
  3041. exit;
  3042. }
  3043. $this->data['express'] = $this->express->find_all();
  3044. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3045. $this->data['wlshop'] = $wlshop;
  3046. $user = $this->user->get_api($_SESSION['api']);
  3047. $powerid = $this->power->read($user['power']);
  3048. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3049. $pid = '';
  3050. foreach ($powertext as $v) {
  3051. $pid .= " id = " . $v . " or";
  3052. }
  3053. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3054. $this->data['fullorderexcel'] = $fullorderexcel;
  3055. $this->_Template('whlabel_soutorder', $this->data);
  3056. }
  3057. //订单退库
  3058. public function _retreat()
  3059. {
  3060. $post = $this->input->post(NULL, TRUE);
  3061. if (isset($post['page'])) {
  3062. $page = $this->input->post('page', true);
  3063. $perpage = $this->input->post('perpage', true);
  3064. $warehouse = $this->input->post('warehouse', true);
  3065. $timetk = $this->input->post('timetk', true);
  3066. $timetj = $this->input->post('timetj', true);
  3067. $shop = $this->input->post('shop', true);
  3068. $source = $this->input->post('source', true);
  3069. $state = $this->input->post('state', true);
  3070. $review = $this->input->post('review', true);
  3071. $state = $this->input->post('state', true);
  3072. $express = $this->input->post('express', true);
  3073. $orderinfo = $this->input->post('orderinfo', true);
  3074. $user = $this->input->post('user', true);
  3075. $name = $this->input->post('name', true);
  3076. $waybill = $this->input->post('waybill', true);
  3077. $timetk = strtotime($timetk);
  3078. $timetj = strtotime($timetj);
  3079. $where = "(state=206 or state=210) and mergeid = 0";
  3080. if ($warehouse) {
  3081. $where .= " and state = '$warehouse'";
  3082. }
  3083. if ($timetk && $timetj) {
  3084. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3085. }
  3086. if ($shop) {
  3087. $where .= " and shop = '$shop'";
  3088. }
  3089. if ($source) {
  3090. $where .= " and source = '$source'";
  3091. }
  3092. if ($state) {
  3093. $where .= " and state = '$state'";
  3094. }
  3095. if ($review) {
  3096. $where .= " and review = '$review'";
  3097. }
  3098. if ($state) {
  3099. $where .= " and state = '$state'";
  3100. }
  3101. if ($express) {
  3102. $where .= " and express = '$express'";
  3103. }
  3104. if ($orderinfo) {
  3105. $where .= " and orderinfo = '$orderinfo'";
  3106. }
  3107. if ($user) {
  3108. $where .= " and user = '$user'";
  3109. }
  3110. if ($name) {
  3111. $where .= " and name = '$name'";
  3112. }
  3113. if ($waybill) {
  3114. $where .= " and waybill = '$waybill'";
  3115. }
  3116. //数据排序
  3117. $order_str = "id desc";
  3118. if (empty($page)) {
  3119. $start = 0;
  3120. $perpage = 1;
  3121. } else {
  3122. $start = ($page - 1) * $perpage;
  3123. }
  3124. //取得信息列表
  3125. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3126. //格式化数据
  3127. foreach ($info_list as $key => $value) {
  3128. $shop = $this->shop->read($value['shop']);
  3129. $info_list[$key]['shop'] = $shop['shopname'];
  3130. $warehouse = $this->warehouse->read($value['warehouse']);
  3131. $info_list[$key]['warehouse'] = $warehouse['title'];
  3132. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3133. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3134. if ($value['waybill'] == 0) {
  3135. $info_list[$key]['waybill'] = "";
  3136. }
  3137. $express = $this->express->read($value['express']);
  3138. $info_list[$key]['express'] = $express['title'];
  3139. $typeclass = $this->typeclass->read($value['state']);
  3140. $info_list[$key]['state'] = $typeclass['title'];
  3141. }
  3142. $total = $this->fullorder->find_count($where);
  3143. $pagenum = ceil($total / $perpage);
  3144. $over = $total - ($start + $perpage);
  3145. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3146. echo json_encode($rows);
  3147. exit;
  3148. }
  3149. $this->data['express'] = $this->express->find_all();
  3150. $this->_Template('whlabel_retreat', $this->data);
  3151. }
  3152. //退库标签浏览
  3153. public function _retreatlk()
  3154. {
  3155. $post = $this->input->post(NULL, TRUE);
  3156. if (isset($post['page'])) {
  3157. $page = $this->input->post('page', true);
  3158. $perpage = $this->input->post('perpage', true);
  3159. $timetk = $this->input->post('timetk', true);
  3160. $timetj = $this->input->post('timetj', true);
  3161. $sku = $this->input->post('sku', true);
  3162. $warehouse = $this->input->post('warehouse', true);
  3163. $purchase = $this->input->post('purchase', true);
  3164. $orderinfo = $this->input->post('orderinfo', true);
  3165. $waybill = $this->input->post('waybill', true);
  3166. $category = $this->input->post('category', true);
  3167. $size = $this->input->post('size', true);
  3168. $grade = $this->input->post('grade', true);
  3169. $color = $this->input->post('color', true);
  3170. $lowe = $this->input->post('lowe', true);
  3171. $state = $this->input->post('state', true);
  3172. $timetk = strtotime($timetk);
  3173. $timetj = strtotime($timetj);
  3174. $where = "state=2";
  3175. if ($timetk && $timetj) {
  3176. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3177. }
  3178. if ($sku) {
  3179. $where .= " and sku = '$sku'";
  3180. }
  3181. if ($warehouse) {
  3182. $where .= " and warehouse = '$warehouse'";
  3183. }
  3184. if ($purchase) {
  3185. $where .= " and purchase = '$purchase'";
  3186. }
  3187. if ($orderinfo) {
  3188. $where .= " and orderinfo = '$orderinfo'";
  3189. }
  3190. if ($waybill) {
  3191. $where .= " and waybill = '$waybill'";
  3192. }
  3193. if ($category) {
  3194. $where .= " and features like '%-$category-%'";
  3195. }
  3196. if ($size) {
  3197. $where .= " and features like '%-$size-%'";
  3198. }
  3199. if ($grade) {
  3200. $where .= " and features like '%-$grade-%'";
  3201. }
  3202. if ($color) {
  3203. $where .= " and features like '%-$color-%'";
  3204. }
  3205. if ($lowe) {
  3206. $where .= " and features like '%-$lowe-%'";
  3207. }
  3208. //数据排序
  3209. $order_str = "time desc";
  3210. if (empty($page)) {
  3211. $start = 0;
  3212. $perpage = 1;
  3213. } else {
  3214. $start = ($page - 1) * $perpage;
  3215. }
  3216. //取得信息列表
  3217. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3218. foreach ($info_list as $key => $value) {
  3219. $warehouse = $this->warehouse->read($value['warehouse']);
  3220. $info_list[$key]['warehouse'] = $warehouse['title'];
  3221. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3222. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3223. $purchase = $this->purchase->read($value['purchase']);
  3224. $info_list[$key]['purchase'] = $purchase['title'];
  3225. if ($value['outk'] != 0) {
  3226. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3227. } else {
  3228. $info_list[$key]['outk'] = "";
  3229. }
  3230. if ($value['retreat'] != 0) {
  3231. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3232. } else {
  3233. $info_list[$key]['retreat'] = "";
  3234. }
  3235. if ($value['orderinfo'] == 0) {
  3236. $info_list[$key]['orderinfo'] = "";
  3237. }
  3238. if ($value['waybill'] == 0) {
  3239. $info_list[$key]['waybill'] = "";
  3240. }
  3241. }
  3242. $total = $this->whlabel->find_count($where);
  3243. $pagenum = ceil($total / $perpage);
  3244. $over = $total - ($start + $perpage);
  3245. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3246. echo json_encode($rows);
  3247. exit;
  3248. }
  3249. $this->_Template('whlabel_retreatlk', $this->data);
  3250. }
  3251. //更换标签及浏览
  3252. public function _change()
  3253. {
  3254. $post = $this->input->post(NULL, TRUE);
  3255. if (isset($post['page'])) {
  3256. $page = $this->input->post('page', true);
  3257. $perpage = $this->input->post('perpage', true);
  3258. $timetk = $this->input->post('timetk', true);
  3259. $timetj = $this->input->post('timetj', true);
  3260. $label = $this->input->post('label', true);
  3261. $oldlabel = $this->input->post('oldlabel', true);
  3262. $timetk = strtotime($timetk);
  3263. $timetj = strtotime($timetj);
  3264. $where = "state=10 ";
  3265. if ($timetk && $timetj) {
  3266. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3267. }
  3268. if ($label) {
  3269. $where .= " and label = '$label'";
  3270. }
  3271. if ($oldlabel) {
  3272. $where .= " and oldlabel = '$oldlabel'";
  3273. }
  3274. //数据排序
  3275. $order_str = "time asc";
  3276. if (empty($page)) {
  3277. $start = 0;
  3278. $perpage = 1;
  3279. } else {
  3280. $start = ($page - 1) * $perpage;
  3281. }
  3282. //取得信息列表
  3283. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3284. foreach ($info_list as $key => $value) {
  3285. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3286. }
  3287. $total = $this->whlabel->find_count($where);
  3288. $pagenum = ceil($total / $perpage);
  3289. $over = $total - ($start + $perpage);
  3290. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3291. echo json_encode($rows);
  3292. exit;
  3293. }
  3294. $this->_Template('whlabel_change', $this->data);
  3295. }
  3296. //产品标签
  3297. public function _cpbqdc()
  3298. {
  3299. if (isset($_GET['excel'])) {
  3300. $where = "1=1";
  3301. //数据排序
  3302. $order_str = "id desc";
  3303. if (empty($page)) {
  3304. $start = 0;
  3305. $perpage = 1;
  3306. } else {
  3307. $start = ($page - 1) * $perpage;
  3308. }
  3309. $warehouse = $this->input->get('warehouse', true);
  3310. $state = $this->input->get('state', true);
  3311. $timetk = $this->input->get('timetkk', true);
  3312. $timetj = $this->input->get('timetjj', true);
  3313. $timetk = strtotime($timetk);
  3314. $timetj = strtotime($timetj);
  3315. if ($warehouse) {
  3316. $where .= " and warehouse = '$warehouse'";
  3317. }
  3318. if ($state || $state == 0) {
  3319. $where .= " and state = '$state'";
  3320. }
  3321. if ($timetk && $timetj) {
  3322. $where .= " and time > '$timetk' and time < '$timetj'";
  3323. }
  3324. //取得信息列表
  3325. $info_list = $this->whlabel->find_all($where, '*');
  3326. $rows = array();
  3327. $list = array();
  3328. foreach ($info_list as $key => $value) {
  3329. $rows[$value['time']] = $value; //所有数据sku
  3330. }
  3331. foreach ($rows as $value) {
  3332. $warehouse = $this->warehouse->read($value['warehouse']);
  3333. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3334. $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);
  3335. }
  3336. $title = "产品标签统计表";
  3337. $titlename = "<table border=1>
  3338. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3339. <tr align='center'>
  3340. <td>仓库</td>
  3341. <td>SKU</td>
  3342. <td>产品</td>
  3343. <td>入库时间</td>
  3344. <td>操作时间</td>
  3345. <td>备注</td>
  3346. <td>数量</td>
  3347. </tr>
  3348. </table>";
  3349. $filename = $title . ".xls";
  3350. $tail = "";
  3351. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3352. }
  3353. }
  3354. //进销存导出
  3355. public function _exceljxc()
  3356. {
  3357. $classid = $this->classid->sku();
  3358. $pm = $classid;
  3359. $typeclass = array();
  3360. $tc = $this->typeclass->find_all();
  3361. foreach ($tc as $v) {
  3362. $typeclass[$v['id']] = $v;
  3363. }
  3364. $prc = array();
  3365. $purchase = $this->purchase->find_all();
  3366. foreach ($purchase as $k => $v) {
  3367. $prc[$v['id']] = $v['title'];
  3368. }
  3369. if (isset($_GET['excel'])) {
  3370. $where = "sku != 'Preset'";
  3371. //数据排序
  3372. $order_str = "id desc";
  3373. if (empty($page)) {
  3374. $start = 0;
  3375. $perpage = 1;
  3376. } else {
  3377. $start = ($page - 1) * $perpage;
  3378. }
  3379. $category = $this->input->get('category', true);
  3380. $warehouse = $this->input->get('warehouse', true);
  3381. $excelid = $this->input->get('sid', true);
  3382. if ($category) {
  3383. $where .= " and features like '%-$category-%'";
  3384. }
  3385. if ($warehouse) {
  3386. $where .= " and warehouse = '$warehouse'";
  3387. }
  3388. $xzid = '';
  3389. if ($excelid) {
  3390. $excelid = explode(',', trim($excelid, ','));
  3391. foreach ($excelid as $key => $value) {
  3392. $xzid .= " id = " . $value . " or";
  3393. }
  3394. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3395. }
  3396. //取得信息列表
  3397. /**
  3398. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3399. $rows = array();$list = array();
  3400. foreach ($info_list as $key=>$value)
  3401. {
  3402. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3403. }
  3404. **/
  3405. $wt = array();
  3406. $whlabel_type = $this->whlabel_type->find_all();
  3407. foreach ($whlabel_type as $v) {
  3408. $wt[$v['id']] = $v['title'];
  3409. }
  3410. $wh = array();
  3411. $w = $this->warehouse->find_all('1=1', 'id,title');
  3412. foreach ($w as $v) {
  3413. $wh[$v['id']] = $v['title'];
  3414. }
  3415. $list = array();
  3416. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3417. foreach ($rows as $key => $value) {
  3418. if (isset($wt[$value['type']])) {
  3419. $rows[$key]['type'] = $wt[$value['type']];
  3420. } else {
  3421. $rows[$key]['type'] = '未设置';
  3422. }
  3423. $bm = '03';
  3424. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3425. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3426. $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');
  3427. $details = array();
  3428. $cpid = array();
  3429. $cpbz = array();
  3430. $c = 0;
  3431. $g = 0;
  3432. $x = 0;
  3433. $t = 0;
  3434. $s = 0;
  3435. $q = 0;
  3436. foreach ($sd as $k => $v) {
  3437. if ($v['state'] == 0) {
  3438. $c++;
  3439. if ($v['cpid'] != 0) {
  3440. $cpid[$v['cpid']] = $v['cpid'];
  3441. }
  3442. if ($v['cpbz'] != '') {
  3443. $cpbz[$v['cpbz']] = $v['cpbz'];
  3444. }
  3445. }
  3446. if ($v['state'] != 9) {
  3447. $g++;
  3448. }
  3449. if ($v['state'] == 1) {
  3450. $x++;
  3451. }
  3452. if ($v['state'] == 2) {
  3453. $t++;
  3454. }
  3455. if ($v['state'] == 8) {
  3456. $s++;
  3457. }
  3458. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3459. $q++;
  3460. }
  3461. $details[$v['details']] = $v['details'];
  3462. }
  3463. $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'] . '"');
  3464. $rows[$key]['details'] = implode("、", $details);
  3465. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3466. $number = $value['number'];
  3467. $ftime = time() - 15 * 24 * 3600;
  3468. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3469. $rows[$key]['number'] = $g;
  3470. $rows[$key]['c'] = $c;
  3471. $rows[$key]['x'] = $x;
  3472. $rows[$key]['t'] = $t;
  3473. $rows[$key]['s'] = $s;
  3474. $rows[$key]['q'] = $q;
  3475. $rows[$key]['z'] = $z;
  3476. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3477. $features = explode('-', trim($features, '-'));
  3478. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3479. // $pm = $classid;
  3480. // $jm = $classid;
  3481. // foreach($features as $k=>$v)
  3482. // {
  3483. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3484. // {
  3485. // if($typeclass[$v]['bm'] != '')
  3486. // {
  3487. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3488. // }
  3489. // }
  3490. // if($v != 0)
  3491. // {
  3492. // if(!isset($typeclass[$v]))
  3493. // {
  3494. // continue;
  3495. // }
  3496. // if(isset($pm[$typeclass[$v]['classid']]))
  3497. // {
  3498. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3499. // {
  3500. // $tz = explode('|',$typeclass[$v]['zh']);
  3501. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3502. // }
  3503. // else
  3504. // {
  3505. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3506. // }
  3507. // }
  3508. // if(isset($jm[$typeclass[$v]['classid']]))
  3509. // {
  3510. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3511. // }
  3512. // }
  3513. // }
  3514. // $jm = array_filter($jm);
  3515. // $rows[$key]['bs'] = implode("-",$jm);
  3516. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3517. // $zh = implode(" ",$pm);
  3518. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3519. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3520. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3521. // $rows[$key]['features'] = $zh;
  3522. }
  3523. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3524. $final_list = [];
  3525. foreach ($list as $k => $v) {
  3526. if (empty($v['sku'])) {
  3527. continue;
  3528. }
  3529. $final_list[] = [
  3530. "warehouse" => $v["warehouse"],
  3531. "purchase" => $v["purchase"],
  3532. "details" => $v["details"],
  3533. "cpid" => $v["cpid"],
  3534. "dbcontent" => $v["dbcontent"],
  3535. "sku" => $v["sku"],
  3536. "cs" => $v["bm"],
  3537. "bs" => $v["jm"],
  3538. "title" => $v["title"],
  3539. "features" => $v["pm"],
  3540. "cpbz" => $v["cpbz"],
  3541. "sm" => $v["sm"],
  3542. "type" => $v["type"],
  3543. "number" => $v["number"],
  3544. "c" => $v["c"],
  3545. "x" => $v["x"],
  3546. "t" => $v["t"],
  3547. "s" => $v["s"],
  3548. "q" => $v["q"],
  3549. "z" => $v["z"],
  3550. "weight" => $v['weight'],
  3551. ];
  3552. }
  3553. $title = "总进销存统计表";
  3554. $titlename = "<table border=1>
  3555. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3556. <tr align='center'>
  3557. <td>仓库</td>
  3558. <td>供应商</td>
  3559. <td>位置</td>
  3560. <td>库存编码</td>
  3561. <td>类目</td>
  3562. <td>SKU</td>
  3563. <td>用友编码</td>
  3564. <td>用友料号</td>
  3565. <td>商品名称</td>
  3566. <td>商品中文</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>重量(g)</td>
  3578. </tr>
  3579. </table>";
  3580. $filename = $title . ".xls";
  3581. $tail = "";
  3582. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3583. }
  3584. }
  3585. //入库导出
  3586. public function _excelr()
  3587. {
  3588. if (isset($_GET['excel'])) {
  3589. $category = $this->input->get('category', true);
  3590. $size = $this->input->get('size', true);
  3591. $grade = $this->input->get('grade', true);
  3592. $color = $this->input->get('color', true);
  3593. $lowe = $this->input->get('lowe', true);
  3594. $sku = $this->input->get('sku', true);
  3595. $warehouse = $this->input->get('warehouse', true);
  3596. $purchase = $this->input->get('purchase', true);
  3597. $ktime = $this->input->get('ktime', true);
  3598. $jtime = $this->input->get('jtime', true);
  3599. $ktime = strtotime($ktime);
  3600. $jtime = strtotime($jtime);
  3601. $where = "1=1";
  3602. $gj = "";
  3603. $ck = "";
  3604. if ($category) {
  3605. $where .= " and features like '%-$category-%'";
  3606. }
  3607. if ($size) {
  3608. $where .= " and features like '%-$size-%'";
  3609. }
  3610. if ($grade) {
  3611. $where .= " and features like '%-$grade-%'";
  3612. }
  3613. if ($color) {
  3614. $where .= " and features like '%-$color-%'";
  3615. }
  3616. if ($lowe) {
  3617. $where .= " and features like '%-$lowe-%'";
  3618. }
  3619. if ($warehouse) {
  3620. $where .= " and warehouse = '$warehouse'";
  3621. }
  3622. if ($purchase) {
  3623. $where .= " and purchase = '$purchase'";
  3624. }
  3625. if ($sku) {
  3626. $where .= " and sku = '$sku'";
  3627. }
  3628. if ($ktime && $jtime) {
  3629. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3630. }
  3631. //数据排序
  3632. $order_str = "id desc";
  3633. if (empty($page)) {
  3634. $start = 0;
  3635. $perpage = 1;
  3636. } else {
  3637. $start = ($page - 1) * $perpage;
  3638. }
  3639. $list = array();
  3640. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3641. foreach ($rows as $value) {
  3642. $ck = $this->warehouse->read($value['warehouse']);
  3643. $warehouse = $ck['title'];
  3644. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3645. $retreatwarehouse = $tkck['title'];
  3646. $gy = $this->purchase->read($value['purchase']);
  3647. $purchase = $gy['title'];
  3648. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3649. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3650. }
  3651. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3652. $titlename = "<table border=1>
  3653. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3654. <tr align='center'>
  3655. <td>仓库</td>
  3656. <td>SKU</td>
  3657. <td>产品</td>
  3658. <td>时间</td>
  3659. <td>数量</td>
  3660. </tr>
  3661. </table>";
  3662. $filename = $title . ".xls";
  3663. $tail = "";
  3664. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3665. }
  3666. }
  3667. //出库、退库导出
  3668. public function _excelct()
  3669. {
  3670. $classid = $this->classid->sku();
  3671. $pm = $classid;
  3672. $typeclass = array();
  3673. $tc = $this->typeclass->find_all();
  3674. foreach ($tc as $v) {
  3675. $typeclass[$v['id']] = $v;
  3676. }
  3677. $prc = array();
  3678. $purchase = $this->purchase->find_all();
  3679. foreach ($purchase as $k => $v) {
  3680. $prc[$v['id']] = $v['title'];
  3681. }
  3682. if (isset($_GET['excel'])) {
  3683. $wh = array();
  3684. $w = $this->warehouse->find_all('1=1', 'id,title');
  3685. foreach ($w as $v) {
  3686. $wh[$v['id']] = $v['title'];
  3687. }
  3688. $type = $this->input->get('excel', true);
  3689. $category = $this->input->get('category', true);
  3690. $size = $this->input->get('size', true);
  3691. $grade = $this->input->get('grade', true);
  3692. $color = $this->input->get('color', true);
  3693. $lowe = $this->input->get('lowe', true);
  3694. $sku = $this->input->get('sku', true);
  3695. $title = $this->input->get('title', true);
  3696. $warehouse = $this->input->get('warehouse', true);
  3697. $purchase = $this->input->get('purchase', true);
  3698. $lacetype = $this->input->get('lacetype', true);
  3699. $haircap = $this->input->get('haircap', true);
  3700. $lacecolor = $this->input->get('lacecolor', true);
  3701. $density = $this->input->get('density', true);
  3702. $details = $this->input->get('details', true);
  3703. $state = $this->input->get('state', true);
  3704. $shop = $this->input->get('shop', true);
  3705. $hairnumber = $this->input->get('hairnumber', true);
  3706. $type_leixi = $this->input->get('type', true);
  3707. $cpbz = $this->input->get('cpbz', true);
  3708. $sm = $this->input->get('sm', true);
  3709. $sid = $this->input->get('sid', true);
  3710. $ktime = $this->input->get('ktime', true);
  3711. $jtime = $this->input->get('jtime', true);
  3712. $ktime = strtotime($ktime);
  3713. $jtime = strtotime($jtime);
  3714. //$where = " 1=1 ";
  3715. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3716. $where = " sku != '' ";
  3717. $gj = "";
  3718. $ck = "";
  3719. if ($category) {
  3720. $where .= " and features like '%-$category-%'";
  3721. }
  3722. if ($size) {
  3723. $where .= " and features like '%-$size-%'";
  3724. }
  3725. if ($grade) {
  3726. $where .= " and features like '%-$grade-%'";
  3727. }
  3728. if ($color) {
  3729. $where .= " and features like '%-$color-%'";
  3730. }
  3731. if ($lowe) {
  3732. $where .= " and features like '%-$lowe-%'";
  3733. }
  3734. if ($warehouse) {
  3735. $where .= " and warehouse = '$warehouse'";
  3736. }
  3737. if ($purchase) {
  3738. $where .= " and purchase = '$purchase'";
  3739. }
  3740. if ($state) {
  3741. $where .= " and state = '$state'";
  3742. }
  3743. if ($lacetype) {
  3744. $where .= " and features like '%-$lacetype-%'";
  3745. }
  3746. if ($lacecolor) {
  3747. $where .= " and features like '%-$lacecolor-%'";
  3748. }
  3749. if ($density) {
  3750. $where .= " and features like '%-$density-%'";
  3751. }
  3752. if ($haircap) {
  3753. $where .= " and features like '%-$haircap-%'";
  3754. }
  3755. if ($details) {
  3756. $where .= " and details = '$details'";
  3757. }
  3758. if ($shop) {
  3759. $where .= " and shop like '%$shop%'";
  3760. }
  3761. if ($title) {
  3762. $title = trim($title, ' ');
  3763. $title = trim($title, ' ');
  3764. $where .= " and title like '%$title%'";
  3765. }
  3766. if (!empty($hairnumber)) {
  3767. $where .= " and features like '%-128-%' ";
  3768. if ($hairnumber < 0) {
  3769. $class_list = $this->typeclass->find_all('classid = 43');
  3770. foreach ($class_list as $v) {
  3771. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3772. }
  3773. } else {
  3774. $where .= " and features like '%-$hairnumber-%'";
  3775. }
  3776. }
  3777. if ($type_leixi) {
  3778. $where .= " and type = '$type_leixi'";
  3779. }
  3780. if ($cpbz) {
  3781. $where .= " and cpbz like '%$cpbz%' ";
  3782. }
  3783. if ($sm) {
  3784. $where .= " and sm like '%$sm%' ";
  3785. }
  3786. if ($sku) {
  3787. $sku = trim($sku, ' ');
  3788. $sku = trim($sku, ' ');
  3789. $where .= " and sku like '%$sku%'";
  3790. }
  3791. if ($ktime && $jtime) {
  3792. if ($type == 1) {
  3793. $tl = '出库';
  3794. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3795. } else if ($type == 2) {
  3796. $tl = '退库';
  3797. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3798. } else if ($type == 3) {
  3799. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3800. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3801. } else if ($type == 4) {
  3802. $tl = '出库+零售';
  3803. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3804. } else if ($type == 5) {
  3805. $tl = '零售';
  3806. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3807. }
  3808. }
  3809. $sidwhere = '';
  3810. if ($sid) {
  3811. $sd = "";
  3812. $s = explode(',', trim($sid, ','));
  3813. foreach ($s as $value) {
  3814. $sd .= " id = " . $value . " or";
  3815. }
  3816. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3817. }
  3818. //数据排序
  3819. $order_str = "time desc";
  3820. if (empty($page)) {
  3821. $start = 0;
  3822. $perpage = 1;
  3823. } else {
  3824. $start = ($page - 1) * $perpage;
  3825. }
  3826. //取得信息列表
  3827. if ($type != 3 && $type != 5) {
  3828. if ($type == 1 || $type == 4) {
  3829. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3830. foreach ($info_list as $key => $value) {
  3831. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3832. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3833. $warehouse = $this->warehouse->read($value['warehouse']);
  3834. $info_list[$key]['warehouse'] = $warehouse['title'];
  3835. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3836. $features = explode('-', trim($features, '-'));
  3837. $pm = $classid;
  3838. foreach ($features as $k => $v) {
  3839. if ($v != 0) {
  3840. if (!isset($typeclass[$v])) {
  3841. continue;
  3842. }
  3843. if (isset($pm[$typeclass[$v]['classid']])) {
  3844. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3845. $tz = explode('|', $typeclass[$v]['zh']);
  3846. $pm[$typeclass[$v]['classid']] = $tz[0];
  3847. } else {
  3848. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3849. }
  3850. }
  3851. }
  3852. }
  3853. $zh = implode(" ", $pm);
  3854. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3855. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3856. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3857. $info_list[$key]['features'] = $zh;
  3858. }
  3859. $final_list = [];
  3860. foreach($info_list as $k=>$v){
  3861. $number = "";
  3862. if(!empty($v['orderinfo'])){
  3863. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3864. if(!empty($tmp_info['number'])){
  3865. $number = $tmp_info['number'];
  3866. }
  3867. }
  3868. $final_list[] = [
  3869. 'warehouse'=>$v['warehouse'],
  3870. 'purchase'=>$v['purchase'],
  3871. 'sku'=>$v['sku'],
  3872. 'title'=>$v['title'],
  3873. 'features'=>$v['features'],
  3874. 'label'=>$v['label'],
  3875. 'orderinfo'=>$v['orderinfo'],
  3876. 'number'=>$number,
  3877. 'waybill'=>$v['waybill'],
  3878. 'outk'=>$v['outk'],
  3879. ];
  3880. }
  3881. } else {
  3882. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3883. foreach ($info_list as $key => $value) {
  3884. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3885. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3886. $warehouse = $this->warehouse->read($value['warehouse']);
  3887. $info_list[$key]['warehouse'] = $warehouse['title'];
  3888. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3889. $features = explode('-', trim($features, '-'));
  3890. $pm = $classid;
  3891. foreach ($features as $k => $v) {
  3892. if ($v != 0) {
  3893. if (!isset($typeclass[$v])) {
  3894. continue;
  3895. }
  3896. if (isset($pm[$typeclass[$v]['classid']])) {
  3897. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3898. $tz = explode('|', $typeclass[$v]['zh']);
  3899. $pm[$typeclass[$v]['classid']] = $tz[0];
  3900. } else {
  3901. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3902. }
  3903. }
  3904. }
  3905. }
  3906. $zh = implode(" ", $pm);
  3907. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3908. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3909. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3910. $info_list[$key]['features'] = $zh;
  3911. }
  3912. $final_list = [];
  3913. foreach($info_list as $k=>$v){
  3914. $number = "";
  3915. if(!empty($v['orderinfo'])){
  3916. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3917. if(!empty($tmp_info['number'])){
  3918. $number = $tmp_info['number'];
  3919. }
  3920. }
  3921. $final_list[] = [
  3922. 'warehouse'=>$v['warehouse'],
  3923. 'purchase'=>$v['purchase'],
  3924. 'sku'=>$v['sku'],
  3925. 'title'=>$v['title'],
  3926. 'features'=>$v['features'],
  3927. 'label'=>$v['label'],
  3928. 'orderinfo'=>$v['orderinfo'],
  3929. 'number'=>$number,
  3930. 'waybill'=>$v['waybill'],
  3931. 'retreat'=>$v['retreat'],
  3932. ];
  3933. }
  3934. }
  3935. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3936. $titlename = "<table border=1>
  3937. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3938. <tr align='center'>
  3939. <td>仓库</td>
  3940. <td>供应商</td>
  3941. <td>SKU</td>
  3942. <td>商品名称</td>
  3943. <td>商品中文</td>
  3944. <td>标签</td>
  3945. <td>订单号</td>
  3946. <td>订单编码</td>
  3947. <td>运单号</td>
  3948. <td>" . $tl . "时间(中国时间)</td>
  3949. </tr>
  3950. </table>";
  3951. $filename = $title . ".xls";
  3952. $tail = "";
  3953. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3954. } else if ($type == 5) {
  3955. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3956. foreach ($info_list as $key => $value) {
  3957. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3958. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3959. $warehouse = $this->warehouse->read($value['warehouse']);
  3960. $info_list[$key]['warehouse'] = $warehouse['title'];
  3961. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3962. $features = explode('-', trim($features, '-'));
  3963. $pm = $classid;
  3964. foreach ($features as $k => $v) {
  3965. if ($v != 0) {
  3966. if (!isset($typeclass[$v])) {
  3967. continue;
  3968. }
  3969. if (isset($pm[$typeclass[$v]['classid']])) {
  3970. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3971. $tz = explode('|', $typeclass[$v]['zh']);
  3972. $pm[$typeclass[$v]['classid']] = $tz[0];
  3973. } else {
  3974. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3975. }
  3976. }
  3977. }
  3978. }
  3979. $zh = implode(" ", $pm);
  3980. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3981. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3982. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3983. $info_list[$key]['features'] = $zh;
  3984. }
  3985. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3986. $titlename = "<table border=1>
  3987. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3988. <tr align='center'>
  3989. <td>仓库</td>
  3990. <td>供应商</td>
  3991. <td>SKU</td>
  3992. <td>商品名称</td>
  3993. <td>商品中文</td>
  3994. <td>标签</td>
  3995. <td>" . $tl . "时间(中国时间)</td>
  3996. </tr>
  3997. </table>";
  3998. $filename = $title . ".xls";
  3999. $tail = "";
  4000. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4001. } else {
  4002. /**
  4003. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4004. $rows = array();$list = array();
  4005. foreach ($info_list as $key=>$value)
  4006. {
  4007. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4008. }
  4009. **/
  4010. $wh = array();
  4011. $w = $this->warehouse->find_all('1=1', 'id,title');
  4012. foreach ($w as $v) {
  4013. $wh[$v['id']] = $v['title'];
  4014. }
  4015. $wt = array();
  4016. $whlabel_type = $this->whlabel_type->find_all();
  4017. foreach ($whlabel_type as $v) {
  4018. $wt[$v['id']] = $v['title'];
  4019. }
  4020. $classid = $this->classid->sku();
  4021. $list = array();
  4022. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4023. foreach ($rows as $key => $value) {
  4024. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4025. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4026. $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');
  4027. $details = array();
  4028. $cpid = array();
  4029. $cpbz = array();
  4030. $c = 0;
  4031. $g = 0;
  4032. $x = 0;
  4033. $t = 0;
  4034. $s = 0;
  4035. $q = 0;
  4036. foreach ($sd as $k => $v) {
  4037. if ($v['state'] == 0) {
  4038. $c++;
  4039. }
  4040. if ($v['state'] != 9) {
  4041. $g++;
  4042. }
  4043. if ($v['outk'] > 1) {
  4044. $x++;
  4045. }
  4046. if ($v['retreat'] > 0) {
  4047. $t++;
  4048. }
  4049. if ($v['state'] == 8) {
  4050. $s++;
  4051. }
  4052. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4053. $q++;
  4054. }
  4055. $details[$v['details']] = $v['details'];
  4056. if ($v['cpid'] != 0) {
  4057. $cpid[$v['cpid']] = $v['cpid'];
  4058. }
  4059. if ($v['cpbz'] != '') {
  4060. $cpbz[$v['cpbz']] = $v['cpbz'];
  4061. }
  4062. }
  4063. if (isset($wt[$value['type']])) {
  4064. $rows[$key]['type'] = $wt[$value['type']];
  4065. } else {
  4066. $rows[$key]['type'] = '未设置';
  4067. }
  4068. $rows[$key]['details'] = implode("、", $details);
  4069. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4070. $ftime = time() - 15 * 24 * 3600;
  4071. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4072. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4073. $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);
  4074. $rows[$key]['c'] = $c;
  4075. $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);
  4076. $rows[$key]['t'] = $t;
  4077. $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'] . '"');
  4078. $rows[$key]['z'] = $z;
  4079. // $jm = $classid;
  4080. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4081. $features = explode('-', trim($features, '-'));
  4082. // $pm = $classid;
  4083. // foreach ($features as $k => $v) {
  4084. // if ($v != 0) {
  4085. // if (!isset($typeclass[$v])) {
  4086. // continue;
  4087. // }
  4088. // if (isset($pm[$typeclass[$v]['classid']])) {
  4089. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4090. // $tz = explode('|', $typeclass[$v]['zh']);
  4091. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4092. // } else {
  4093. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4094. // }
  4095. // if (isset($jm[$typeclass[$v]['classid']])) {
  4096. // if ($typeclass[$v]['jm']) {
  4097. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4098. // }
  4099. // }
  4100. // }
  4101. // }
  4102. // }
  4103. // $zh = implode(" ", $pm);
  4104. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4105. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4106. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4107. // $rows[$key]['features'] = $zh;
  4108. // $jm = array_filter($jm); //去除空值
  4109. // $jm = implode("-", $jm);
  4110. // $rows[$key]['jm'] = $jm;
  4111. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4112. }
  4113. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4114. // echo "<pre>";
  4115. // print_r($tmp_list);
  4116. // die;
  4117. $final_list =[];
  4118. foreach($tmp_list as $k=>$v){
  4119. $final_list[] = [
  4120. "warehouse"=>$v['warehouse'],
  4121. "purchase"=>$v['purchase'],
  4122. "details"=>$v['details'],
  4123. "cpid"=>$v['cpid'],
  4124. "sku"=>$v['sku'],
  4125. "title"=>$v['title'],
  4126. "features"=>$v['pm'],
  4127. "cpbz"=>$v['cpbz'],
  4128. "sm"=>$v['sm'],
  4129. "type"=>$v['type'],
  4130. "g"=>$v["g"],
  4131. "c"=>$v["c"],
  4132. "x"=>$v["x"],
  4133. "t"=>$v["t"],
  4134. "z"=>$v["z"],
  4135. "jm"=>$v["jm"],
  4136. "weight"=>$v["weight"],
  4137. "asd"=>$v["asd"],
  4138. ];
  4139. }
  4140. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4141. $titlename = "<table border=1>
  4142. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4143. <tr align='center'>
  4144. <td>仓库</td>
  4145. <td>供应商</td>
  4146. <td>位置</td>
  4147. <td>库存编码</td>
  4148. <td>SKU</td>
  4149. <td>商品名称</td>
  4150. <td>商品中文</td>
  4151. <td>产品备注</td>
  4152. <td>说明</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. </tr>
  4163. </table>";
  4164. $filename = $title . ".xls";
  4165. $tail = "";
  4166. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4167. }
  4168. }
  4169. }
  4170. //出库+入库数据整合
  4171. public function _excelcr()
  4172. {
  4173. if (isset($_GET['excel'])) {
  4174. $type = $this->input->get('excel', true);
  4175. $category = $this->input->get('category', true);
  4176. $size = $this->input->get('size', true);
  4177. $grade = $this->input->get('grade', true);
  4178. $color = $this->input->get('color', true);
  4179. $lowe = $this->input->get('lowe', true);
  4180. $sku = $this->input->get('sku', true);
  4181. $warehouse = $this->input->get('warehouse', true);
  4182. $purchase = $this->input->get('purchase', true);
  4183. $state = $this->input->get('state', true);
  4184. $sid = $this->input->get('sid', true);
  4185. $ktime = $this->input->get('ktime', true);
  4186. $jtime = $this->input->get('jtime', true);
  4187. $ktime = strtotime($ktime);
  4188. $jtime = strtotime($jtime);
  4189. $where = "1=1";
  4190. $gj = "";
  4191. $ck = "";
  4192. if ($category) {
  4193. $where .= " and features like '%-$category-%'";
  4194. }
  4195. if ($size) {
  4196. $where .= " and features like '%-$size-%'";
  4197. }
  4198. if ($grade) {
  4199. $where .= " and features like '%-$grade-%'";
  4200. }
  4201. if ($color) {
  4202. $where .= " and features like '%-$color-%'";
  4203. }
  4204. if ($lowe) {
  4205. $where .= " and features like '%-$lowe-%'";
  4206. }
  4207. if ($warehouse) {
  4208. $where .= " and warehouse = '$warehouse'";
  4209. }
  4210. if ($purchase) {
  4211. $where .= " and purchase = '$purchase'";
  4212. }
  4213. if ($state) {
  4214. $where .= " and state = '$state'";
  4215. }
  4216. if ($sku) {
  4217. $where .= " and sku like '%$sku%'";
  4218. }
  4219. if ($ktime && $jtime) {
  4220. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4221. }
  4222. $sidwhere = '';
  4223. if ($sid) {
  4224. $sd = "";
  4225. $s = explode(',', trim($sid, ','));
  4226. foreach ($s as $value) {
  4227. $sd .= " id = " . $value . " or";
  4228. }
  4229. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4230. }
  4231. //取得信息列表
  4232. $timeread = $ktime;
  4233. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4234. $timelist = array();
  4235. for ($i = 0; $i < $timenum; $i++) {
  4236. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4237. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4238. }
  4239. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4240. //echo "<pre>";
  4241. //print_r($info_list);
  4242. //exit();
  4243. $rows = array();
  4244. $list = array();
  4245. foreach ($info_list as $key => $value) {
  4246. $thistime = $timelist;
  4247. if (isset($rows[strtolower($value['sku'])])) {
  4248. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4249. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4250. }
  4251. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4252. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4253. }
  4254. } else {
  4255. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4256. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4257. }
  4258. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4259. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4260. }
  4261. $rows[strtolower($value['sku'])] = $thistime;
  4262. }
  4263. }
  4264. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4265. <head>
  4266. <!--[if gte mso 9]><xml>
  4267. <x:ExcelWorkbook>
  4268. <x:ExcelWorksheets>
  4269. <x:ExcelWorksheet>
  4270. <x:Name>EXCEL</x:Name>
  4271. <x:WorksheetOptions>
  4272. <x:Print>
  4273. <x:ValidPrinterInfo />
  4274. </x:Print>
  4275. </x:WorksheetOptions>
  4276. </x:ExcelWorksheet>
  4277. </x:ExcelWorksheets>
  4278. </x:ExcelWorkbook>
  4279. </xml>
  4280. <![endif]-->
  4281. </head><body>";
  4282. $str .= "<table border=1><tr><td>SKU</td>";
  4283. foreach ($timelist as $k => $v) {
  4284. $str .= "<td>" . $k . "出库</td>";
  4285. $str .= "<td>" . $k . "入库</td>";
  4286. }
  4287. $str .= "</tr></table>";
  4288. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4289. foreach ($rows as $key => $val) {
  4290. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4291. foreach ($val as $k => $v) {
  4292. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4293. if ($val[$k]['r'] > 0) {
  4294. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4295. } else {
  4296. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4297. }
  4298. }
  4299. $str .= "</tr>";
  4300. }
  4301. $str .= "</table>";
  4302. $str .= "</body></html>";
  4303. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4304. header("Content-type: application/octet-stream");
  4305. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4306. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4307. header("Pragma: no-cache");
  4308. header("Expires: 0");
  4309. exit($str);
  4310. }
  4311. }
  4312. //数量调整模板导出
  4313. public function _presetout()
  4314. {
  4315. if (isset($_GET['excel'])) {
  4316. $where = "sku != 'Preset' and purchase != 0";
  4317. //数据排序
  4318. $order_str = "id desc";
  4319. if (empty($page)) {
  4320. $start = 0;
  4321. $perpage = 1;
  4322. } else {
  4323. $start = ($page - 1) * $perpage;
  4324. }
  4325. //取得信息列表
  4326. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4327. $rows = array();
  4328. $list = array();
  4329. foreach ($info_list as $value) {
  4330. $warehouse = $this->warehouse->read($value['warehouse']);
  4331. $number = $value['number'];
  4332. $ftime = time() - 15 * 24 * 3600;
  4333. $purchase = $this->purchase->read($value['purchase']);
  4334. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4335. }
  4336. $title = "库存模板";
  4337. $titlename = "<table border=1>
  4338. <tr align='center'>
  4339. <td>仓库</td>
  4340. <td>供应商编码</td>
  4341. <td>SKU</td>
  4342. <td>增减数量(正数或负数)</td>
  4343. <td>增减备注</td>
  4344. <td>扣减方式:0减少库存1删除库存</td>
  4345. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4346. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4347. </tr>
  4348. </table>";
  4349. $filename = $title . ".xls";
  4350. $tail = "";
  4351. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4352. }
  4353. }
  4354. //数量调整模板导入
  4355. public function _presetedit()
  4356. {
  4357. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4358. $config['upload_path'] = '.' . $dir;
  4359. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4360. $config['allowed_types'] = 'xls|xlsx|csv';
  4361. $config['max_size'] = 10240;
  4362. $this->load->library('upload', $config);
  4363. $this->upload->initialize($config);
  4364. if ($this->upload->do_upload('userfile')) {
  4365. $full_path = $dir . $this->upload->data('file_name');
  4366. $fileName = '.' . $full_path;
  4367. if (!file_exists($fileName)) {
  4368. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4369. exit;
  4370. } else {
  4371. require_once "./data/excel/PHPExcel/IOFactory.php";
  4372. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4373. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4374. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4375. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4376. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4377. ++$column; //如果列数大于26行
  4378. $list = array();
  4379. for ($i = 2; $i <= $row; $i++) // 行数循环
  4380. {
  4381. $data = array();
  4382. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4383. {
  4384. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4385. }
  4386. $list[] = $data;
  4387. }
  4388. }
  4389. $i = 0;
  4390. $j = 0;
  4391. $ed = array();
  4392. foreach ($list as $key => $value) {
  4393. $time = time();
  4394. if ($value['0'] == "") {
  4395. continue;
  4396. }
  4397. $warehouse = $this->warehouse->get_title($value['0']);
  4398. $purchase = $this->purchase->get_bm($value['1']);
  4399. $sku = $value['2'];
  4400. $num = $value['3']; //调整数量
  4401. $text = $value['4']; //扣减说明
  4402. $type = $value['5']; //调整方式0扣减1删除
  4403. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4404. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4405. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4406. if (!$purchase) //如果没有这个SKU
  4407. {
  4408. $ed[] = array($purchase . '-不存在此供应商编码');
  4409. $j++;
  4410. continue;
  4411. }
  4412. if (!$d) //如果没有这个SKU
  4413. {
  4414. $ed[] = array($sku . '-库存中不存在此SKU');
  4415. $j++;
  4416. continue;
  4417. }
  4418. if (!isset($warehouse['id'])) {
  4419. $ed[] = array($sku . '-仓库名错误!');
  4420. $j++;
  4421. continue;
  4422. }
  4423. if ($type != '0' && $type != '1') {
  4424. $ed[] = array($sku . '-扣减方式填写错误!');
  4425. $j++;
  4426. continue;
  4427. }
  4428. if ($num < 0) //扣减库存
  4429. {
  4430. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4431. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4432. $j++;
  4433. continue;
  4434. }
  4435. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4436. if (count($data) < abs($num)) {
  4437. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4438. $j++;
  4439. continue;
  4440. }
  4441. if ($type == 0) //如果扣减方式为 扣减库存
  4442. {
  4443. for ($i = 0; $i < abs($num); $i++) {
  4444. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4445. }
  4446. } else if ($type == 1) {
  4447. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4448. if (count($zt) > 0) {
  4449. $ed[] = array($sku . '-有在途库存无法删除!');
  4450. $j++;
  4451. continue;
  4452. }
  4453. for ($i = 0; $i < abs($num); $i++) {
  4454. $this->whlabel->remove($data[$i]['id']);
  4455. }
  4456. }
  4457. } else if ($num > 0) //增加库存
  4458. {
  4459. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4460. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4461. $j++;
  4462. continue;
  4463. }
  4464. $post['sku'] = $d['sku'];
  4465. $post['shop'] = $d['shop'];
  4466. $post['warehouse'] = $warehouse['id'];
  4467. $post['purchase'] = $purchase['id'];
  4468. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4469. $post['state'] = 0;
  4470. $post['title'] = $d['title'];
  4471. $post['number'] = $d['number'];
  4472. $post['features'] = $d['features'];
  4473. $post['enter'] = $time;
  4474. $post['time'] = $time; //操作时间
  4475. $post['rktype'] = $rktype;
  4476. for ($i = 0; $i < $num; $i++) {
  4477. $post['label'] = time() . rand(100, 999) . $i;
  4478. $this->whlabel->insert($post);
  4479. }
  4480. }
  4481. sleep(1); //防止入库时间一样,需要延迟1秒
  4482. }
  4483. if ($j > 0) {
  4484. $tt = date('Ymd', time());
  4485. $title = '库存导入错误信息-' . $tt;
  4486. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4487. $tail = "\n";
  4488. $filename = $title . ".xls";
  4489. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4490. $dir = '/data/excel/' . $time . '/';
  4491. $file_name = 'error_' . $time . rand(1000, 9999);
  4492. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4493. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4494. fwrite($myfile, $ecl);
  4495. fclose($myfile);
  4496. $error = $dir . $file_name . '.xls';
  4497. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4498. exit;
  4499. } else {
  4500. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4501. exit;
  4502. }
  4503. }
  4504. }
  4505. //笛卡儿积
  4506. function cp($ps, $sets, $list)
  4507. {
  4508. $result = array();
  4509. $j = 0;
  4510. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4511. if ($i == 0) {
  4512. $result = $sets[$i];
  4513. }
  4514. $tmp = array();
  4515. foreach ($result as $res) {
  4516. foreach ($sets[$i + 1] as $set) {
  4517. $tmp[] = $res . ',' . $set;
  4518. }
  4519. }
  4520. $result = $tmp;
  4521. }
  4522. $this->db->trans_begin();
  4523. foreach ($result as $v) {
  4524. $post = array();
  4525. $title = "";
  4526. $num = "";
  4527. $data = explode(',', $v);
  4528. for ($i = 0; $i < count($list); $i++) {
  4529. $post[$list[$i]] = $data[$i];
  4530. $typeclass = $this->typeclass->read($data[$i]);
  4531. $title = $title . $typeclass['title'] . " ";
  4532. if ($data[$i] != 0) {
  4533. $num .= $data[$i]; //所有数据ID拼接
  4534. }
  4535. }
  4536. foreach ($ps as $kp => $vp) {
  4537. $post[$kp] = $vp;
  4538. }
  4539. $post['number'] = $num;
  4540. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4541. if ($info_list) {
  4542. $j++;
  4543. } else {
  4544. $skunum = $this->whlabel->find_count();
  4545. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4546. $post['title'] = rtrim($title, ' ');
  4547. $this->whlabel->insert($post);
  4548. }
  4549. }
  4550. if ($this->db->trans_status() === FALSE) {
  4551. $this->db->trans_commit();
  4552. return NULL;
  4553. } else {
  4554. $this->db->trans_commit();
  4555. return $j;
  4556. }
  4557. }
  4558. public function _kj($arg_array)
  4559. {
  4560. if (isset($_POST['sku'])) {
  4561. $time = time();
  4562. $sku = $this->input->post('sku', true);
  4563. $warehouse = $this->input->post('warehouse', true);
  4564. $num = $this->input->post('num', true);
  4565. $text = $this->input->post('text', true);
  4566. $purchase = $this->input->post('purchase', true);
  4567. $cktype = $this->input->post('cktype', true);
  4568. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4569. if ($cktype != 1 && $text == '') {
  4570. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4571. exit;
  4572. }
  4573. if ($num > count($order)) {
  4574. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4575. exit;
  4576. } else {
  4577. for ($i = 0; $i < $num; $i++) {
  4578. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4579. }
  4580. }
  4581. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4582. exit;
  4583. }
  4584. $uid = $this->whlabel->read($arg_array[0]);
  4585. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4586. $this->data['data'] = $uid;
  4587. $this->_Template('whlabel_kj', $this->data);
  4588. }
  4589. public function _summary($arg_array)
  4590. {
  4591. $prc = array();
  4592. $purchase = $this->purchase->find_all();
  4593. foreach ($purchase as $k => $v) {
  4594. $prc[$v['id']] = $v['title'];
  4595. }
  4596. if (isset($_GET['excel'])) {
  4597. $ktime = $this->input->get('ktime', true);
  4598. $jtime = $this->input->get('jtime', true);
  4599. $ktime = strtotime($ktime);
  4600. $jtime = strtotime($jtime);
  4601. $where = "1=1";
  4602. if ($ktime && $jtime) {
  4603. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4604. }
  4605. //数据排序
  4606. $order_str = "time desc";
  4607. if (empty($page)) {
  4608. $start = 0;
  4609. $perpage = 1;
  4610. } else {
  4611. $start = ($page - 1) * $perpage;
  4612. }
  4613. //取得信息列表
  4614. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4615. foreach ($info_list as $key => $value) {
  4616. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4617. $warehouse = $this->warehouse->read($value['warehouse']);
  4618. $info_list[$key]['warehouse'] = $warehouse['title'];
  4619. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4620. $details = array();
  4621. $cpid = array();
  4622. foreach ($x as $k => $v) {
  4623. if ($v['details'] != '') {
  4624. $details[$v['details']] = $v['details'];
  4625. }
  4626. if ($v['cpid'] != 0) {
  4627. $cpid[$v['cpid']] = $v['cpid'];
  4628. }
  4629. }
  4630. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4631. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4632. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4633. $info_list[$key]['s'] = $s;
  4634. $info_list[$key]['x'] = count($x);
  4635. }
  4636. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4637. $titlename = "<table border=1>
  4638. <tr align='center'>
  4639. <td>仓库</td>
  4640. <td>供应商</td>
  4641. <td>出库位置</td>
  4642. <td>出库编码</td>
  4643. <td>SKU</td>
  4644. <td>产品名</td>
  4645. <td>总剩余库存</td>
  4646. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4647. </tr>
  4648. </table>";
  4649. $filename = $title . ".xls";
  4650. $tail = "";
  4651. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4652. }
  4653. }
  4654. //usps发货清单
  4655. public function _manifest()
  4656. {
  4657. if (isset($_POST['manifest'])) {
  4658. $wltext = $this->input->post('wltext', true);
  4659. $time = time() - 16 * 3600;
  4660. $ptime = strtotime(date('Y-m-d', $time));
  4661. $waybill = array();
  4662. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4663. foreach ($fullorder as $v) {
  4664. $waybill[$v['waybill']] = $v['waybill'];
  4665. }
  4666. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4667. foreach ($fullordersmt as $v) {
  4668. $waybill[$v['waybill']] = $v['waybill'];
  4669. }
  4670. $wltext = explode(';', $wltext);
  4671. foreach ($wltext as $v) {
  4672. if (isset($waybill[$v])) {
  4673. unset($waybill[$v]);
  4674. }
  4675. }
  4676. $data = $this->usps->get_manifest($waybill);
  4677. if (isset($data['Description'])) {
  4678. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4679. exit;
  4680. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4681. $bctime = date('Ymd', time());
  4682. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4683. echo json_encode(array('msg' => $pdf, 'success' => true));
  4684. exit;
  4685. } else {
  4686. echo json_encode(array('msg' => $data, 'success' => false));
  4687. exit;
  4688. }
  4689. }
  4690. }
  4691. public function _pdf($pdf, $title, $bctime)
  4692. {
  4693. $pdf_path = './data/pdf/' . $bctime . '/';
  4694. $file_base64 = $pdf;
  4695. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4696. $file_base64 = base64_decode($file_base64);
  4697. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4698. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4699. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4700. }
  4701. /**
  4702. *
  4703. *
  4704. *
  4705. 进销存占单异常索引
  4706. *
  4707. *
  4708. *
  4709. **/
  4710. public function _abnormal()
  4711. {
  4712. $post = $this->input->post(NULL, TRUE);
  4713. if (isset($post['page'])) {
  4714. $page = $this->input->post('page', true);
  4715. $perpage = $this->input->post('perpage', true);
  4716. $sku = $this->input->post('sku', true);
  4717. $where = "1=1";
  4718. //数据排序
  4719. $order_str = "id desc";
  4720. if (empty($page)) {
  4721. $start = 0;
  4722. $perpage = 1;
  4723. } else {
  4724. $start = ($page - 1) * $perpage;
  4725. }
  4726. //取得信息列表
  4727. $info_list = $this->whlabel->find_all($where, '*');
  4728. $rows = array();
  4729. $list = array();
  4730. foreach ($info_list as $key => $value) {
  4731. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4732. }
  4733. foreach ($rows as $value) {
  4734. $warehouse = $this->warehouse->read($value['warehouse']);
  4735. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4736. $number = $value['number'];
  4737. $ftime = time() - 15 * 24 * 3600;
  4738. if ($value['shop'] != '') {
  4739. $shop = $value['shop'];
  4740. $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');
  4741. $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');
  4742. $order = array_merge($orderdlz, $ordersmt);
  4743. $od = 0;
  4744. $a = '';
  4745. $orid = '';
  4746. foreach ($order as $v) {
  4747. $or = explode('|', ltrim($v['whlabel'], '|'));
  4748. for ($i = 0; $i < count($or); $i++) {
  4749. $orod = explode('-', $or[$i]);
  4750. if ($orod[0] == $number) {
  4751. $od += $orod[1];
  4752. }
  4753. }
  4754. $orid .= $v['number'] . '-';
  4755. }
  4756. } else {
  4757. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4758. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4759. $order = array_merge($orderdlz, $ordersmt);
  4760. $od = 0;
  4761. $a = '';
  4762. $orid = '';
  4763. $qt = array();
  4764. foreach ($order as $v) {
  4765. $or = explode('|', ltrim($v['whlabel'], '|'));
  4766. for ($i = 0; $i < count($or); $i++) {
  4767. $orod = explode('-', $or[$i]);
  4768. if ($orod[0] == $number) {
  4769. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4770. if ($czzs > 0) {
  4771. if (isset($qt[$v['shop']])) {
  4772. if ($qt[$v['shop']] < $orod[1]) {
  4773. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4774. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4775. } else {
  4776. $qt[$v['shop']] -= $orod[1];
  4777. }
  4778. } else {
  4779. $qt[$v['shop']] = $czzs;
  4780. }
  4781. } else {
  4782. $od += $orod[1];
  4783. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4784. }
  4785. }
  4786. }
  4787. }
  4788. }
  4789. $z = $od . '(' . $orid . ')'; //查看订单号
  4790. //$z = $od;
  4791. if ($od > $c) {
  4792. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4793. }
  4794. }
  4795. $listdata = array_slice($list, $start, $perpage);
  4796. $total = count($list);
  4797. $pagenum = ceil($total / $perpage);
  4798. $over = $total - ($start + $perpage);
  4799. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4800. echo json_encode($rows);
  4801. exit;
  4802. }
  4803. $this->_Template('whlabel_abnormal', $this->data);
  4804. }
  4805. /**
  4806. *
  4807. *
  4808. *
  4809. 进销存占单异常索引
  4810. *
  4811. *
  4812. *
  4813. **/
  4814. public function _error()
  4815. {
  4816. $post = $this->input->post(NULL, TRUE);
  4817. if (isset($post['page'])) {
  4818. $page = $this->input->post('page', true);
  4819. $perpage = $this->input->post('perpage', true);
  4820. $sku = $this->input->post('sku', true);
  4821. $warehouse = $this->input->post('warehouse', true);
  4822. $ktime = $this->input->post('ktime', true);
  4823. $jtime = $this->input->post('jtime', true);
  4824. $ktime = strtotime($ktime);
  4825. $jtime = strtotime($jtime);
  4826. $where = "sku != 'Preset'";
  4827. $gj = '';
  4828. if ($sku) {
  4829. $where .= " and sku like '%$sku%'";
  4830. } else {
  4831. if ($ktime && $jtime) {
  4832. $gj = " and time > '$ktime' and time < '$jtime'";
  4833. }
  4834. }
  4835. if ($warehouse) {
  4836. $where .= " and warehouse = '$warehouse'";
  4837. }
  4838. //数据排序
  4839. $order_str = "id desc";
  4840. if (empty($page)) {
  4841. $start = 0;
  4842. $perpage = 1;
  4843. } else {
  4844. $start = ($page - 1) * $perpage;
  4845. }
  4846. //取得信息列表
  4847. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4848. $rows = array();
  4849. $list = array();
  4850. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4851. // foreach ($info_list as $value)
  4852. // {
  4853. // $warehouse = $this->warehouse->read($value['warehouse']);
  4854. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4855. // $number = $value['number'];$ftime = time()-15*24*3600;
  4856. // if($c < 1)
  4857. // {
  4858. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4859. // }
  4860. // }
  4861. $warehouse_list = $this->warehouse->find_all();
  4862. $warehouse_list = array_column($warehouse_list, null, 'id');
  4863. foreach ($info_list as $value) {
  4864. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4865. 'title' => "",
  4866. ];
  4867. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4868. $number = $value['number'];
  4869. $ftime = time() - 15 * 24 * 3600;
  4870. if ($c < 1) {
  4871. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4872. }
  4873. }
  4874. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4875. // $query = $this->db->query($sql);
  4876. // $info_list = $query->result_array();
  4877. // $sql_two = "select title,id from crowd_warehouse";
  4878. // $query_two = $this->db->query($sql_two);
  4879. // $warehouse_list = $query_two->result_array();
  4880. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4881. // foreach ($info_list as $value)
  4882. // {
  4883. // if(isset($warehouse_arr[$value['warehouse']])){
  4884. // $warehouse = $warehouse_arr[$value['warehouse']];
  4885. // }else{
  4886. // $warehouse = [
  4887. // 'id'=>0,
  4888. // 'title'=>"异常",
  4889. // ];
  4890. // }
  4891. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4892. // $number = $value['number'];$ftime = time()-15*24*3600;
  4893. // if($c < 1)
  4894. // {
  4895. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4896. // }
  4897. // }
  4898. $listdata = array_slice($list, $start, $perpage);
  4899. $total = count($list);
  4900. $pagenum = ceil($total / $perpage);
  4901. $over = $total - ($start + $perpage);
  4902. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4903. echo json_encode($rows);
  4904. exit;
  4905. }
  4906. if (isset($post['s'])) {
  4907. $id_arr = $this->input->post('s');
  4908. $id_arr = explode(',', trim($id_arr, ','));
  4909. if (!$id_arr) {
  4910. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4911. exit;
  4912. }
  4913. //循环删除记录
  4914. foreach ($id_arr as $v) {
  4915. $dd = $this->whlabel->read($v);
  4916. if (!isset($dd['id'])) {
  4917. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4918. exit;
  4919. }
  4920. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4921. if (isset($zt[0])) {
  4922. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4923. exit;
  4924. }
  4925. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4926. foreach ($deldd as $vv) {
  4927. $this->whlabel->remove($vv['id']);
  4928. }
  4929. }
  4930. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4931. exit;
  4932. }
  4933. $this->_Template('whlabel_error', $this->data);
  4934. }
  4935. public function _errorexcel()
  4936. {
  4937. $post = $this->input->post(NULL, TRUE);
  4938. if (isset($_GET['page'])) {
  4939. $page = $this->input->get('page', true);
  4940. $perpage = $this->input->get('perpage', true);
  4941. $sku = $this->input->get('sku', true);
  4942. $warehouse = $this->input->get('warehouse', true);
  4943. $ktime = $this->input->get('ktime', true);
  4944. $jtime = $this->input->get('jtime', true);
  4945. $ktime = strtotime($ktime);
  4946. $jtime = strtotime($jtime);
  4947. $where = "sku != 'Preset'";
  4948. $gj = '';
  4949. if ($sku) {
  4950. $where .= " and sku like '%$sku%'";
  4951. } else {
  4952. if ($ktime && $jtime) {
  4953. $gj = " and time > '$ktime' and time < '$jtime'";
  4954. }
  4955. }
  4956. if ($warehouse) {
  4957. $where .= " and warehouse = '$warehouse'";
  4958. }
  4959. //数据排序
  4960. $order_str = "id desc";
  4961. if (empty($page)) {
  4962. $start = 0;
  4963. $perpage = 1;
  4964. } else {
  4965. $start = ($page - 1) * $perpage;
  4966. }
  4967. //取得信息列表
  4968. $rows = array();
  4969. $list = array();
  4970. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4971. foreach ($info_list as $value) {
  4972. $warehouse = $this->warehouse->read($value['warehouse']);
  4973. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4974. $number = $value['number'];
  4975. $ftime = time() - 15 * 24 * 3600;
  4976. if ($c < 1) {
  4977. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4978. }
  4979. }
  4980. $title = "0库存汇总";
  4981. $titlename = "<table border=1>
  4982. <tr align='center'>
  4983. <td>仓库</td>
  4984. <td>SKU</td>
  4985. <td>产品</td>
  4986. <td>当前库存</td>
  4987. </tr>
  4988. </table>";
  4989. $filename = $title . ".xls";
  4990. $tail = "";
  4991. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4992. }
  4993. }
  4994. /**
  4995. *
  4996. *
  4997. * 占单
  4998. *
  4999. *
  5000. **/
  5001. public function _kcyz()
  5002. {
  5003. $post = $this->input->post(NULL, TRUE);
  5004. if (isset($post['warehouse'])) {
  5005. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5006. exit; //不再使用
  5007. $warehouse = $this->input->post('warehouse', true);
  5008. $whlabel = $this->input->post('whlabel', true);
  5009. $id = $this->input->post('id', true);
  5010. $shop = $this->input->post('shop', true);
  5011. $number = $this->input->post('number', true);
  5012. if (!$whlabel || $whlabel == '|') {
  5013. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5014. exit;
  5015. }
  5016. $pp = explode('|', trim($whlabel, '|'));
  5017. $x = 0;
  5018. $save = array();
  5019. foreach ($pp as $va) {
  5020. $num = explode('-', $va);
  5021. if ($number) {
  5022. $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 = '')"); //通用
  5023. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5024. } else {
  5025. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5026. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5027. }
  5028. $x++;
  5029. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5030. $save[] = $x - 1;
  5031. continue; //提前先加X不然出错,所以要减1
  5032. }
  5033. }
  5034. if (isset($save[0])) {
  5035. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5036. exit;
  5037. } else {
  5038. echo json_encode(array('success' => true));
  5039. exit;
  5040. }
  5041. }
  5042. }
  5043. public function _db()
  5044. {
  5045. $post = $this->input->post(NULL, TRUE);
  5046. if (isset($post['page'])) {
  5047. $page = $this->input->post('page', true);
  5048. $perpage = $this->input->post('perpage', true);
  5049. $sku = $this->input->post('sku', true);
  5050. $number = $this->input->post('number', true);
  5051. $warehouse = $this->input->post('warehouse', true);
  5052. $purchase = $this->input->post('purchase', true);
  5053. $orderinfo = $this->input->post('orderinfo', true);
  5054. $waybill = $this->input->post('waybill', true);
  5055. $category = $this->input->post('category', true);
  5056. $size = $this->input->post('size', true);
  5057. $grade = $this->input->post('grade', true);
  5058. $color = $this->input->post('color', true);
  5059. $lowe = $this->input->post('lowe', true);
  5060. $state = $this->input->post('state', true);
  5061. $label = $this->input->post('label', true);
  5062. $timetk = $this->input->post('timetkk', true);
  5063. $timetj = $this->input->post('timetjj', true);
  5064. $timetk = strtotime($timetk);
  5065. $timetj = strtotime($timetj);
  5066. $where = "dbtime > 0";
  5067. if ($timetk && $timetj) {
  5068. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5069. }
  5070. if ($sku) {
  5071. $where .= " and sku = '$sku'";
  5072. }
  5073. if ($warehouse) {
  5074. $where .= " and warehouse = '$warehouse'";
  5075. if ($warehouse == 12) {
  5076. $w = 'specialstock';
  5077. } else {
  5078. $w = 'whlabel';
  5079. }
  5080. }
  5081. if ($purchase) {
  5082. $where .= " and purchase = '$purchase'";
  5083. }
  5084. if ($category) {
  5085. $where .= " and features like '%-$category-%'";
  5086. }
  5087. if ($size) {
  5088. $where .= " and features like '%-$size-%'";
  5089. }
  5090. if ($grade) {
  5091. $where .= " and features like '%-$grade-%'";
  5092. }
  5093. if ($color) {
  5094. $where .= " and features like '%-$color-%'";
  5095. }
  5096. if ($lowe) {
  5097. $where .= " and features like '%-$lowe-%'";
  5098. }
  5099. if ($state != '') {
  5100. $where .= " and state = '$state'";
  5101. }
  5102. //数据排序
  5103. $order_str = "dbtime desc";
  5104. if (empty($page)) {
  5105. $start = 0;
  5106. $perpage = 1;
  5107. } else {
  5108. $start = ($page - 1) * $perpage;
  5109. }
  5110. //取得信息列表
  5111. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5112. foreach ($info_list as $key => $value) {
  5113. $warehouse = $this->$w->read($value['warehouse']);
  5114. $info_list[$key]['warehouse'] = $warehouse['title'];
  5115. $purchase = $this->purchase->read($value['purchase']);
  5116. $info_list[$key]['purchase'] = $purchase['title'];
  5117. if ($value['enter'] != 0) {
  5118. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5119. } else {
  5120. $info_list[$key]['enter'] = "";
  5121. }
  5122. if ($value['dbtime'] != 0) {
  5123. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5124. } else {
  5125. $info_list[$key]['dbtime'] = "";
  5126. }
  5127. if ($value['state'] == 0) {
  5128. $info_list[$key]['state'] = "在库";
  5129. } else if ($value['state'] == 1) {
  5130. $info_list[$key]['state'] = "出库";
  5131. } else if ($value['state'] == 2) {
  5132. $info_list[$key]['state'] = "退库";
  5133. } else if ($value['state'] == 3) {
  5134. $info_list[$key]['state'] = "调拨中";
  5135. } else if ($value['state'] == 4) {
  5136. $info_list[$key]['state'] = "再加工";
  5137. } else if ($value['state'] == 5) {
  5138. $info_list[$key]['state'] = "维修中";
  5139. } else if ($value['state'] == 6) {
  5140. $info_list[$key]['state'] = "盘亏";
  5141. } else if ($value['state'] == 7) {
  5142. $info_list[$key]['state'] = "更换标签";
  5143. } else if ($value['state'] == 8) {
  5144. $info_list[$key]['state'] = "其它";
  5145. } else if ($value['state'] == 9) {
  5146. $info_list[$key]['state'] = "预设";
  5147. }
  5148. }
  5149. $total = $this->whlabel->find_count($where);
  5150. $pagenum = ceil($total / $perpage);
  5151. $over = $total - ($start + $perpage);
  5152. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5153. echo json_encode($rows);
  5154. exit;
  5155. }
  5156. if (isset($post['outsku'])) {
  5157. $time = time();
  5158. $cz = $this->input->post('cz', true);
  5159. $label = $this->input->post('outsku', true);
  5160. $sl = $this->input->post('sl', true);
  5161. $num = $this->input->post('num', true);
  5162. //$warehouse = $this->input->post('warehouse',true);
  5163. if (!$sl) {
  5164. $sl = 1;
  5165. }
  5166. if (!$warehouse) {
  5167. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5168. exit;
  5169. }
  5170. $dblabel = $this->whlabellabel->get_label($label);
  5171. if ($dblabel) {
  5172. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5173. if (count($data) < 1) {
  5174. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5175. exit;
  5176. }
  5177. if (count($data) < $num) {
  5178. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5179. exit;
  5180. }
  5181. for ($i = 0; $i < $sl; $i++) {
  5182. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5183. }
  5184. echo json_encode(array('success' => true));
  5185. exit;
  5186. } else {
  5187. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5188. exit;
  5189. }
  5190. }
  5191. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5192. $this->_Template('whlabel_db', $this->data);
  5193. }
  5194. public function _dbrk()
  5195. {
  5196. $post = $this->input->post(NULL, TRUE);
  5197. if (isset($post['page'])) {
  5198. $page = $this->input->post('page', true);
  5199. $perpage = $this->input->post('perpage', true);
  5200. $sku = $this->input->post('sku', true);
  5201. $number = $this->input->post('number', true);
  5202. $warehouse = $this->input->post('warehouse', true);
  5203. $purchase = $this->input->post('purchase', true);
  5204. $orderinfo = $this->input->post('orderinfo', true);
  5205. $waybill = $this->input->post('waybill', true);
  5206. $category = $this->input->post('category', true);
  5207. $size = $this->input->post('size', true);
  5208. $grade = $this->input->post('grade', true);
  5209. $color = $this->input->post('color', true);
  5210. $lowe = $this->input->post('lowe', true);
  5211. $state = $this->input->post('state', true);
  5212. $label = $this->input->post('label', true);
  5213. $ctime = $this->input->post('ctime', true);
  5214. $timetk = $this->input->post('timetkk', true);
  5215. $timetj = $this->input->post('timetjj', true);
  5216. $timetk = strtotime($timetk);
  5217. $timetj = strtotime($timetj);
  5218. $where = "dbtime > 0";
  5219. if ($timetk && $timetj) {
  5220. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5221. }
  5222. if ($sku) {
  5223. $where .= " and sku = '$sku'";
  5224. }
  5225. if ($warehouse) {
  5226. $where .= " and warehouse = '$warehouse'";
  5227. }
  5228. if ($purchase) {
  5229. $where .= " and purchase = '$purchase'";
  5230. }
  5231. if ($category) {
  5232. $where .= " and features like '%-$category-%'";
  5233. }
  5234. if ($size) {
  5235. $where .= " and features like '%-$size-%'";
  5236. }
  5237. if ($grade) {
  5238. $where .= " and features like '%-$grade-%'";
  5239. }
  5240. if ($color) {
  5241. $where .= " and features like '%-$color-%'";
  5242. }
  5243. if ($lowe) {
  5244. $where .= " and features like '%-$lowe-%'";
  5245. }
  5246. if ($state != '') {
  5247. $where .= " and state = '$state'";
  5248. }
  5249. //数据排序
  5250. $order_str = "dbtime desc";
  5251. if (empty($page)) {
  5252. $start = 0;
  5253. $perpage = 1;
  5254. } else {
  5255. $start = ($page - 1) * $perpage;
  5256. }
  5257. //取得信息列表
  5258. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5259. foreach ($info_list as $key => $value) {
  5260. $warehouse = $this->warehouse->read($value['warehouse']);
  5261. $info_list[$key]['warehouse'] = $warehouse['title'];
  5262. $purchase = $this->purchase->read($value['purchase']);
  5263. $info_list[$key]['purchase'] = $purchase['title'];
  5264. if ($value['enter'] != 0) {
  5265. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5266. } else {
  5267. $info_list[$key]['enter'] = "";
  5268. }
  5269. if ($value['dbtime'] != 0) {
  5270. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5271. } else {
  5272. $info_list[$key]['dbtime'] = "";
  5273. }
  5274. if ($value['state'] == 0) {
  5275. $info_list[$key]['state'] = "在库";
  5276. } else if ($value['state'] == 1) {
  5277. $info_list[$key]['state'] = "出库";
  5278. } else if ($value['state'] == 2) {
  5279. $info_list[$key]['state'] = "退库";
  5280. } else if ($value['state'] == 3) {
  5281. $info_list[$key]['state'] = "调拨中";
  5282. } else if ($value['state'] == 4) {
  5283. $info_list[$key]['state'] = "再加工";
  5284. } else if ($value['state'] == 5) {
  5285. $info_list[$key]['state'] = "维修中";
  5286. } else if ($value['state'] == 6) {
  5287. $info_list[$key]['state'] = "盘亏";
  5288. } else if ($value['state'] == 7) {
  5289. $info_list[$key]['state'] = "更换标签";
  5290. } else if ($value['state'] == 8) {
  5291. $info_list[$key]['state'] = "其它";
  5292. } else if ($value['state'] == 9) {
  5293. $info_list[$key]['state'] = "预设";
  5294. }
  5295. }
  5296. $total = $this->whlabel->find_count($where);
  5297. $pagenum = ceil($total / $perpage);
  5298. $over = $total - ($start + $perpage);
  5299. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5300. echo json_encode($rows);
  5301. exit;
  5302. }
  5303. if (isset($post['rsku'])) {
  5304. $cz = $this->input->post('cz', true);
  5305. $label = $this->input->post('rsku', true);
  5306. $sl = $this->input->post('sl', true);
  5307. $warehouse = $this->input->post('warehouse', true);
  5308. if (!$sl) {
  5309. $sl = 1;
  5310. }
  5311. if (!$warehouse) {
  5312. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5313. exit;
  5314. }
  5315. $dblabel = $this->whlabellabel->get_label($label);
  5316. if ($dblabel) {
  5317. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5318. if (count($data) < 1) {
  5319. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5320. exit;
  5321. }
  5322. if ($sl > count($data)) {
  5323. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5324. exit;
  5325. }
  5326. $time = time();
  5327. for ($i = 0; $i < $sl; $i++) {
  5328. $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']);
  5329. }
  5330. echo json_encode(array('success' => true));
  5331. exit;
  5332. } else {
  5333. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5334. exit;
  5335. }
  5336. }
  5337. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5338. $this->_Template('whlabel_dbrk', $this->data);
  5339. }
  5340. public function _whlabelczdc()
  5341. {
  5342. if (isset($_GET['excel'])) {
  5343. //数据排序
  5344. $order_str = "id desc";
  5345. if (empty($page)) {
  5346. $start = 0;
  5347. $perpage = 1;
  5348. } else {
  5349. $start = ($page - 1) * $perpage;
  5350. }
  5351. $state = $this->input->get('state', true);
  5352. $sku = $this->input->get('sku', true);
  5353. $ctime = $this->input->get('ctime', true);
  5354. $category = $this->input->get('category', true);
  5355. $size = $this->input->get('size', true);
  5356. $grade = $this->input->get('grade', true);
  5357. $color = $this->input->get('color', true);
  5358. $lowe = $this->input->get('lowe', true);
  5359. $timetk = $this->input->get('timetkk', true);
  5360. $timetj = $this->input->get('timetjj', true);
  5361. $timetk = strtotime($timetk);
  5362. $timetj = strtotime($timetj);
  5363. $where = "dbtime > 0";
  5364. if ($timetk && $timetj) {
  5365. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5366. }
  5367. if ($category) {
  5368. $where .= " and features like '%-$category-%'";
  5369. }
  5370. if ($size) {
  5371. $where .= " and features like '%-$size-%'";
  5372. }
  5373. if ($grade) {
  5374. $where .= " and features like '%-$grade-%'";
  5375. }
  5376. if ($color) {
  5377. $where .= " and features like '%-$color-%'";
  5378. }
  5379. if ($lowe) {
  5380. $where .= " and features like '%-$lowe-%'";
  5381. }
  5382. //取得信息列表
  5383. $info_list = $this->whlabel->find_all($where, '*');
  5384. $rows = array();
  5385. $list = array();
  5386. foreach ($info_list as $key => $value) {
  5387. $rows[$value['sku']] = $value; //所有数据sku
  5388. }
  5389. foreach ($rows as $value) {
  5390. $warehouse = $this->warehouse->read($value['warehouse']);
  5391. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5392. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5393. if ($value['orderinfo'] == 0) {
  5394. $info_list[$key]['orderinfo'] = "";
  5395. }
  5396. if ($value['waybill'] == 0) {
  5397. $info_list[$key]['waybill'] = "";
  5398. }
  5399. if ($value['state'] == 0) {
  5400. $value['state'] = "在库";
  5401. } else if ($value['state'] == 3) {
  5402. $value['state'] = "调拨中";
  5403. }
  5404. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5405. }
  5406. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5407. $titlename = "<table border=1>
  5408. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5409. <tr align='center'>
  5410. <td>SKU</td>
  5411. <td>产品</td>
  5412. <td>调拨数量</td>
  5413. <td>入库数量</td>
  5414. </tr>
  5415. </table>";
  5416. $filename = $title . ".xls";
  5417. $tail = "";
  5418. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5419. }
  5420. }
  5421. public function _print($arg_array)
  5422. {
  5423. if (isset($_SESSION['api'])) {
  5424. $user = $this->user->get_api($_SESSION['api']);
  5425. $usp = $user;
  5426. $fgshop = "";
  5427. $sid = "";
  5428. $wid = "";
  5429. $wtype = "";
  5430. $usersp = explode('|', trim($user['shop'], '|'));
  5431. $userwh = explode('|', trim($user['warehouse'], '|'));
  5432. foreach ($usersp as $value) {
  5433. $fgshop .= " shop = " . $value . " or";
  5434. $sid .= " id = " . $value . " or";
  5435. }
  5436. foreach ($userwh as $value) {
  5437. $wid .= " id = " . $value . " or";
  5438. $wtype .= " type = " . $value . " or";
  5439. }
  5440. }
  5441. $post = $this->input->post(NULL, TRUE);
  5442. if (isset($post['tmsku'])) {
  5443. $tmsku = $this->input->post('tmsku', true);
  5444. if (is_numeric($tmsku)) {
  5445. $yyh = $this->whlabellabel->get_label($tmsku);
  5446. } else {
  5447. $yyh = $this->whlabellabel->get_sku($tmsku);
  5448. }
  5449. if ($yyh) {
  5450. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5451. exit;
  5452. } else {
  5453. echo json_encode(array('success' => false));
  5454. exit;
  5455. }
  5456. }
  5457. $classid = $this->classid->sku();
  5458. $pm = $classid;
  5459. $scsku = $classid;
  5460. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5461. if (isset($post['warehouse'])) {
  5462. if ($post['warehouse']) {
  5463. $list = array();
  5464. $num = "";
  5465. $title = "";
  5466. $features = "";
  5467. $order = 0;
  5468. $post['shop'] = '';
  5469. $brand = $this->input->post('brand', true);
  5470. if ($brand != '0,') {
  5471. $b = $this->brand->read(rtrim($brand, ','));
  5472. if ($b) {
  5473. $post['shop'] = str_replace('|', ',', $b['shop']);
  5474. }
  5475. }
  5476. $post['details'] = $this->input->post('details', true); //打印数量
  5477. $xbqnum = $this->input->post('xbqnum', true);
  5478. $post['purchase'] = $this->input->post('purchase', true);
  5479. $post['warehouse'] = $this->input->post('warehouse', true);
  5480. $post['purchase'] = $this->input->post('purchase', true);
  5481. $post['retreatwarehouse'] = $post['warehouse'];
  5482. $post['cpbz'] = $this->input->post('cpbz', true);
  5483. $post['state'] = 9;
  5484. $category = $this->input->post('category', true);
  5485. $list['category'] = $category;
  5486. $list['hairtype'] = $this->input->post('hairtype', true);
  5487. $list['grade'] = $this->input->post('grade', true);
  5488. $size = $this->input->post('size', true);
  5489. $list['size'] = rtrim($size, ',');
  5490. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5491. $list['extension'] = $this->input->post('extension', true);
  5492. if ($category == 1297) {
  5493. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5494. }
  5495. if ($category == 1702) {
  5496. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5497. $list['syother'] = $this->input->post('syother', true);
  5498. }
  5499. if ($category == 133) {
  5500. $list['fittype'] = $this->input->post('fittype', true);
  5501. $list['acother'] = $this->input->post('acother', true);
  5502. }
  5503. $list['color'] = $this->input->post('color', true);
  5504. $list['lowe'] = $this->input->post('lowe', true);
  5505. if ($category == 127) {
  5506. $list['type'] = $this->input->post('type', true);
  5507. $list['headroad'] = $this->input->post('headroad', true);
  5508. $list['density'] = $this->input->post('density', true);
  5509. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5510. $list['lacesize'] = $this->input->post('lacesize', true);
  5511. }
  5512. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5513. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5514. }
  5515. if ($category == 128) {
  5516. $list['lacetype'] = $this->input->post('lacetype', true);
  5517. $list['haircap'] = $this->input->post('haircap', true);
  5518. $list['density'] = $this->input->post('density', true);
  5519. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5520. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5521. $list['wigother'] = $this->input->post('wigother', true);
  5522. $list['wigother1'] = $this->input->post('wigother1', true);
  5523. $list['wigother2'] = $this->input->post('wigother2', true);
  5524. }
  5525. if ($category == 129) {
  5526. $list['wide'] = $this->input->post('wide', true);
  5527. }
  5528. if ($category == 131) {
  5529. $list['gifttype'] = $this->input->post('gifttype', true);
  5530. $list['giftother'] = $this->input->post('giftother', true);
  5531. }
  5532. if ($category == 134) {
  5533. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5534. }
  5535. if ($category == 1297) {
  5536. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5537. $list['sywigother'] = $this->input->post('sywigother', true);
  5538. }
  5539. if ($category == 130 || $category == 133 || $category == 1702) {
  5540. $list['items'] = $this->input->post('items', true);
  5541. $list['weight'] = $this->input->post('weight', true);
  5542. }
  5543. if ($category == 1702) {
  5544. $list['syhairther'] = $this->input->post('syhairther', true);
  5545. }
  5546. foreach ($list as $k => $v) {
  5547. if ($v != 0) {
  5548. $num .= $v;
  5549. $features .= $v . '-';
  5550. $post[$k] = $v;
  5551. $typeclass = $this->typeclass->read($v);
  5552. if (isset($pm[$typeclass['classid']])) {
  5553. if (stripos($typeclass['zh'], '|') !== false) {
  5554. $exzh = explode('|', $typeclass['zh']);
  5555. $pm[$typeclass['classid']] = $exzh[0];
  5556. } else {
  5557. $pm[$typeclass['classid']] = $typeclass['zh'];
  5558. }
  5559. }
  5560. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5561. if ($k != 'size') {
  5562. $title .= $typeclass['title'] . " ";
  5563. }
  5564. }
  5565. }
  5566. $typeclass = $this->typeclass->read($list['size']);
  5567. $title .= $typeclass['title'];
  5568. $time = time();
  5569. $post['title'] = rtrim($title, ' ');
  5570. $post['number'] = $num;
  5571. $post['features'] = '-' . $features;
  5572. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5573. $featurespp = explode('-', trim($featurespp, '-'));
  5574. if (isset($featurespp[5])) {
  5575. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5576. } else {
  5577. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5578. }
  5579. $post['enter'] = $time;
  5580. $post['time'] = $time; //操作时间
  5581. $scsku = implode("-", $scsku);
  5582. $zh = implode(" ", $pm);
  5583. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5584. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5585. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5586. $post['sku'] = $bqsku;
  5587. $label = time() . rand(0, 9);
  5588. $post['label'] = $label;
  5589. $cpid = $this->whlabellabel->find_count();
  5590. $post['cpid'] = $cpid + 1;
  5591. $cpid = $post['cpid'];
  5592. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5593. //if($whlabelbarcode)
  5594. //{
  5595. //$post['label'] = $whlabelbarcode['label'];
  5596. //if(!$this->whlabellabel->insert($post))
  5597. //{
  5598. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5599. //}
  5600. //}
  5601. //else
  5602. //{
  5603. $this->db->trans_begin();
  5604. $this->whlabellabel->insert($post);
  5605. //$this->whlabelbarcode->insert($post);
  5606. if ($this->db->trans_status() === TRUE) {
  5607. $this->db->trans_commit();
  5608. } else {
  5609. $this->db->trans_rollback();
  5610. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5611. exit;
  5612. }
  5613. //}
  5614. $warehouse_name = "";
  5615. $warehouse = $post['warehouse'];
  5616. if($warehouse == 12){
  5617. $warehouse_name = "特殊库存库";
  5618. }
  5619. // if($warehouse == 13){
  5620. // $warehouse_name = "许昌仓";
  5621. // }
  5622. // if($warehouse == 5){
  5623. // $warehouse_name = "美国店";
  5624. // }
  5625. // if($warehouse == 16){
  5626. // $warehouse_name = "定制头套仓";
  5627. // }
  5628. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5629. if(!empty($warehouse_name)){
  5630. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5631. }
  5632. $purchase = $this->purchase->read($post['purchase']);
  5633. 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));
  5634. exit; //特殊仓目前不需要仓库选项
  5635. }
  5636. }
  5637. if (isset($_SESSION['api'])) {
  5638. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5639. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5640. $this->data['wlshop'] = $wlshop;
  5641. $this->data['warehouse'] = $warehouse;
  5642. }
  5643. $whlabelwz = $this->whlabelwz->find_all();
  5644. $this->data['whlabelwz'] = $whlabelwz;
  5645. $this->_Template('whlabel_print', $this->data);
  5646. }
  5647. public function _usaprint($arg_array)
  5648. {
  5649. if (isset($_SESSION['api'])) {
  5650. $user = $this->user->get_api($_SESSION['api']);
  5651. $usp = $user;
  5652. $fgshop = "";
  5653. $sid = "";
  5654. $wid = "";
  5655. $wtype = "";
  5656. $usersp = explode('|', trim($user['shop'], '|'));
  5657. $userwh = explode('|', trim($user['warehouse'], '|'));
  5658. foreach ($usersp as $value) {
  5659. $fgshop .= " shop = " . $value . " or";
  5660. $sid .= " id = " . $value . " or";
  5661. }
  5662. foreach ($userwh as $value) {
  5663. $wid .= " id = " . $value . " or";
  5664. $wtype .= " type = " . $value . " or";
  5665. }
  5666. }
  5667. $post = $this->input->post(NULL, TRUE);
  5668. if (isset($post['tmsku'])) {
  5669. $tmsku = $this->input->post('tmsku', true);
  5670. if (is_numeric($tmsku)) {
  5671. $yyh = $this->whlabellabel->get_label($tmsku);
  5672. } else {
  5673. $yyh = $this->whlabellabel->get_sku($tmsku);
  5674. }
  5675. if ($yyh) {
  5676. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5677. exit;
  5678. } else {
  5679. echo json_encode(array('success' => false));
  5680. exit;
  5681. }
  5682. }
  5683. $classid = $this->classid->sku();
  5684. $pm = $classid;
  5685. $scsku = $classid;
  5686. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5687. if (isset($post['warehouse'])) {
  5688. if ($post['warehouse']) {
  5689. $list = array();
  5690. $num = "";
  5691. $title = "";
  5692. $features = "";
  5693. $order = 0;
  5694. $post['shop'] = '';
  5695. $brand = $this->input->post('brand', true);
  5696. if ($brand != '0,') {
  5697. $b = $this->brand->read(rtrim($brand, ','));
  5698. if ($b) {
  5699. $post['shop'] = str_replace('|', ',', $b['shop']);
  5700. }
  5701. }
  5702. $post['details'] = $this->input->post('details', true); //打印数量
  5703. $xbqnum = $this->input->post('xbqnum', true);
  5704. $post['purchase'] = $this->input->post('purchase', true);
  5705. $post['warehouse'] = $this->input->post('warehouse', true);
  5706. $post['purchase'] = $this->input->post('purchase', true);
  5707. $post['retreatwarehouse'] = $post['warehouse'];
  5708. $post['cpbz'] = $this->input->post('cpbz', true);
  5709. $post['state'] = 9;
  5710. $category = $this->input->post('category', true);
  5711. $list['category'] = $category;
  5712. $list['hairtype'] = $this->input->post('hairtype', true);
  5713. $list['grade'] = $this->input->post('grade', true);
  5714. $size = $this->input->post('size', true);
  5715. $list['size'] = rtrim($size, ',');
  5716. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5717. $list['extension'] = $this->input->post('extension', true);
  5718. if ($category == 1297) {
  5719. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5720. }
  5721. if ($category == 1702) {
  5722. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5723. $list['syother'] = $this->input->post('syother', true);
  5724. }
  5725. if ($category == 133) {
  5726. $list['fittype'] = $this->input->post('fittype', true);
  5727. $list['acother'] = $this->input->post('acother', true);
  5728. }
  5729. $list['color'] = $this->input->post('color', true);
  5730. $list['lowe'] = $this->input->post('lowe', true);
  5731. if ($category == 127) {
  5732. $list['type'] = $this->input->post('type', true);
  5733. $list['headroad'] = $this->input->post('headroad', true);
  5734. $list['density'] = $this->input->post('density', true);
  5735. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5736. $list['lacesize'] = $this->input->post('lacesize', true);
  5737. }
  5738. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5739. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5740. }
  5741. if ($category == 128) {
  5742. $list['lacetype'] = $this->input->post('lacetype', true);
  5743. $list['haircap'] = $this->input->post('haircap', true);
  5744. $list['density'] = $this->input->post('density', true);
  5745. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5746. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5747. $list['wigother'] = $this->input->post('wigother', true);
  5748. $list['wigother1'] = $this->input->post('wigother1', true);
  5749. $list['wigother2'] = $this->input->post('wigother2', true);
  5750. }
  5751. if ($category == 129) {
  5752. $list['wide'] = $this->input->post('wide', true);
  5753. }
  5754. if ($category == 131) {
  5755. $list['gifttype'] = $this->input->post('gifttype', true);
  5756. $list['giftother'] = $this->input->post('giftother', true);
  5757. }
  5758. if ($category == 134) {
  5759. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5760. }
  5761. if ($category == 1297) {
  5762. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5763. $list['sywigother'] = $this->input->post('sywigother', true);
  5764. }
  5765. if ($category == 130 || $category == 133 || $category == 1702) {
  5766. $list['items'] = $this->input->post('items', true);
  5767. $list['weight'] = $this->input->post('weight', true);
  5768. }
  5769. if ($category == 1702) {
  5770. $list['syhairther'] = $this->input->post('syhairther', true);
  5771. }
  5772. foreach ($list as $k => $v) {
  5773. if ($v != 0) {
  5774. $num .= $v;
  5775. $features .= $v . '-';
  5776. $post[$k] = $v;
  5777. $typeclass = $this->typeclass->read($v);
  5778. if (isset($pm[$typeclass['classid']])) {
  5779. if (stripos($typeclass['zh'], '|') !== false) {
  5780. $exzh = explode('|', $typeclass['zh']);
  5781. $pm[$typeclass['classid']] = $exzh[0];
  5782. } else {
  5783. $pm[$typeclass['classid']] = $typeclass['zh'];
  5784. }
  5785. }
  5786. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5787. if ($k != 'size') {
  5788. $title .= $typeclass['title'] . " ";
  5789. }
  5790. }
  5791. }
  5792. $typeclass = $this->typeclass->read($list['size']);
  5793. $title .= $typeclass['title'];
  5794. $time = time();
  5795. $post['title'] = rtrim($title, ' ');
  5796. $post['number'] = $num;
  5797. $post['features'] = '-' . $features;
  5798. $fp = $this->whlabel->get_features($post['features']);
  5799. if (!$fp) {
  5800. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5801. exit;
  5802. }
  5803. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5804. $featurespp = explode('-', trim($featurespp, '-'));
  5805. if (isset($featurespp[5])) {
  5806. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5807. } else {
  5808. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5809. }
  5810. $post['enter'] = $time;
  5811. $post['time'] = $time; //操作时间
  5812. $scsku = implode("-", $scsku);
  5813. $zh = implode(" ", $pm);
  5814. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5815. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5816. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5817. $post['sku'] = $fp['sku'];
  5818. $post['label'] = $fp['sku'];
  5819. $cpid = $this->whlabellabel->find_count();
  5820. $post['cpid'] = $cpid + 1;
  5821. $cpid = $post['cpid'];
  5822. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5823. //if($whlabelbarcode)
  5824. //{
  5825. //$post['label'] = $whlabelbarcode['label'];
  5826. //if(!$this->whlabellabel->insert($post))
  5827. //{
  5828. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5829. //}
  5830. //}
  5831. //else
  5832. //{
  5833. $this->db->trans_begin();
  5834. $this->whlabellabel->insert($post);
  5835. //$this->whlabelbarcode->insert($post);
  5836. if ($this->db->trans_status() === TRUE) {
  5837. $this->db->trans_commit();
  5838. } else {
  5839. $this->db->trans_rollback();
  5840. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5841. exit;
  5842. }
  5843. //}
  5844. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5845. $purchase = $this->purchase->read($post['purchase']);
  5846. 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));
  5847. exit; //特殊仓目前不需要仓库选项
  5848. }
  5849. }
  5850. if (isset($_SESSION['api'])) {
  5851. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5852. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5853. $this->data['wlshop'] = $wlshop;
  5854. $this->data['warehouse'] = $warehouse;
  5855. }
  5856. $whlabelwz = $this->whlabelwz->find_all();
  5857. $this->data['whlabelwz'] = $whlabelwz;
  5858. $this->_Template('whlabel_usaprint', $this->data);
  5859. }
  5860. public function _printrk($arg_array)
  5861. {
  5862. $prc = array();
  5863. $purchase = $this->purchase->find_all();
  5864. foreach ($purchase as $k => $v) {
  5865. $prc[$v['id']] = $v['title'];
  5866. }
  5867. $post = $this->input->post(NULL, TRUE);
  5868. if (isset($post['page'])) {
  5869. $page = $this->input->post('page', true);
  5870. $perpage = $this->input->post('perpage', true);
  5871. $sku = $this->input->post('sku', true);
  5872. $bs = $this->input->post('bs', true);
  5873. $number = $this->input->post('number', true);
  5874. $warehouse = $this->input->post('warehouse', true);
  5875. $purchase = $this->input->post('purchase', true);
  5876. $orderinfo = $this->input->post('orderinfo', true);
  5877. $waybill = $this->input->post('waybill', true);
  5878. $category = $this->input->post('category', true);
  5879. $size = $this->input->post('size', true);
  5880. $grade = $this->input->post('grade', true);
  5881. $color = $this->input->post('color', true);
  5882. $lowe = $this->input->post('lowe', true);
  5883. $state = $this->input->post('state', true);
  5884. $label = $this->input->post('label', true);
  5885. $timetk = $this->input->post('ktime', true);
  5886. $timetj = $this->input->post('jtime', true);
  5887. $timetk = strtotime($timetk);
  5888. $timetj = strtotime($timetj);
  5889. $where = "1=1 ";
  5890. if ($timetk && $timetj) {
  5891. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5892. }
  5893. if ($sku) {
  5894. $where .= " and sku = '$sku'";
  5895. }
  5896. if ($bs != '') {
  5897. $where .= " and bs = '$bs'";
  5898. }
  5899. if ($number) {
  5900. $where .= " and number = '$number'";
  5901. }
  5902. if ($warehouse) {
  5903. $where .= " and warehouse = '$warehouse'";
  5904. }
  5905. if ($purchase) {
  5906. $where .= " and purchase = '$purchase'";
  5907. }
  5908. if ($orderinfo) {
  5909. $where .= " and orderinfo = '$orderinfo'";
  5910. }
  5911. if ($waybill) {
  5912. $where .= " and waybill = '$waybill'";
  5913. }
  5914. if ($category) {
  5915. $where .= " and features like '%-$category-%'";
  5916. }
  5917. if ($size) {
  5918. $where .= " and features like '%-$size-%'";
  5919. }
  5920. if ($grade) {
  5921. $where .= " and features like '%-$grade-%'";
  5922. }
  5923. if ($color) {
  5924. $where .= " and features like '%-$color-%'";
  5925. }
  5926. if ($lowe) {
  5927. $where .= " and features like '%-$lowe-%'";
  5928. }
  5929. if ($label) {
  5930. $where .= " and label = '$label'";
  5931. }
  5932. if ($state || $state == 0) {
  5933. $where .= " and state = '$state'";
  5934. }
  5935. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5936. //数据排序
  5937. $order_str = "enter desc";
  5938. if (empty($page)) {
  5939. $start = 0;
  5940. $perpage = 1;
  5941. } else {
  5942. $start = ($page - 1) * $perpage;
  5943. }
  5944. //取得信息列表
  5945. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5946. foreach ($info_list as $key => $value) {
  5947. $warehouse = $this->warehouse->read($value['warehouse']);
  5948. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5949. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5950. if ($value['state'] == 0) {
  5951. $info_list[$key]['state'] = "在库";
  5952. } else if ($value['state'] == 1) {
  5953. $info_list[$key]['state'] = "出库";
  5954. } else if ($value['state'] == 2) {
  5955. $info_list[$key]['state'] = "退库";
  5956. } else if ($value['state'] == 3) {
  5957. $info_list[$key]['state'] = "调拨中";
  5958. } else if ($value['state'] == 4) {
  5959. $info_list[$key]['state'] = "再加工";
  5960. } else if ($value['state'] == 5) {
  5961. $info_list[$key]['state'] = "维修中";
  5962. } else if ($value['state'] == 6) {
  5963. $info_list[$key]['state'] = "盘亏";
  5964. } else if ($value['state'] == 7) {
  5965. $info_list[$key]['state'] = "更换标签";
  5966. } else if ($value['state'] == 8) {
  5967. $info_list[$key]['state'] = "其它";
  5968. } else if ($value['state'] == 9) {
  5969. $info_list[$key]['state'] = "预设";
  5970. } else if ($value['state'] == 10) {
  5971. $info_list[$key]['state'] = "美店零售";
  5972. }
  5973. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5974. }
  5975. $total = $this->$ck->find_count($where);
  5976. $pagenum = ceil($total / $perpage);
  5977. $over = $total - ($start + $perpage);
  5978. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5979. echo json_encode($rows);
  5980. exit;
  5981. }
  5982. if (isset($post['tmsku'])) {
  5983. $time = time();
  5984. $tmsku = $this->input->post('tmsku', true);
  5985. //$post['shop'] = $this->input->post('shop',true);
  5986. $num = $this->input->post('num', true);
  5987. $rktype = $this->input->post('rktype', true);
  5988. if ($num > 200) {
  5989. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5990. exit;
  5991. }
  5992. if (!$rktype) {
  5993. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5994. }
  5995. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5996. /**
  5997. $wz = array();
  5998. foreach ($rk as $key=>$value)
  5999. {
  6000. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6001. }
  6002. if(count($wz) > 1)
  6003. {
  6004. $wz = array_values($wz);
  6005. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6006. }
  6007. **/
  6008. if (isset($rk[0]['purchase'])) {
  6009. $rk = $rk[0];
  6010. $j = 0;
  6011. $post['purchase'] = $rk['purchase'];
  6012. $post['warehouse'] = $rk['warehouse'];
  6013. $post['retreatwarehouse'] = $rk['warehouse'];
  6014. $post['sku'] = $rk['sku'];
  6015. $post['number'] = $rk['number'];
  6016. $post['features'] = $rk['features'];
  6017. $post['title'] = $rk['title'];
  6018. $post['enter'] = $time;
  6019. $post['time'] = $time;
  6020. $post['bs'] = 1;
  6021. $post['shop'] = $rk['shop'];
  6022. $post['details'] = $rk['details'];
  6023. $post['cpid'] = $rk['cpid'];
  6024. $post['cpbz'] = $rk['cpbz'];
  6025. //$post['rktype'] = $rktype;
  6026. $warehouse = $this->warehouse->read($rk['warehouse']);
  6027. if ($warehouse['bdck'] == '') {
  6028. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6029. exit;
  6030. } else {
  6031. $bdck = $warehouse['bdck'];
  6032. }
  6033. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6034. if (isset($pdwz['details'])) {
  6035. if ($pdwz['details'] != $post['details']) {
  6036. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6037. exit;
  6038. }
  6039. }
  6040. $post['featurespp'] = $rk['featurespp'];
  6041. if ($post['warehouse'] == '5') {
  6042. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6043. if ($yza) {
  6044. if ($post['features'] != $yza[0]['features']) {
  6045. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6046. exit;
  6047. }
  6048. }
  6049. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6050. if ($yzb) {
  6051. if ($post['sku'] != $yzb[0]['sku']) {
  6052. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6053. exit;
  6054. }
  6055. }
  6056. }
  6057. for ($i = 0; $i < $num; $i++) {
  6058. $post['label'] = time() . rand(100, 999) . $i;
  6059. if ($this->$bdck->insert($post)) {
  6060. $j++;
  6061. }
  6062. }
  6063. /**
  6064. if($post['warehouse'] != 12)
  6065. {
  6066. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6067. }
  6068. **/
  6069. if ($j == $num) {
  6070. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6071. exit;
  6072. } else {
  6073. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6074. exit;
  6075. }
  6076. } else {
  6077. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6078. exit;
  6079. }
  6080. }
  6081. $this->_Template('whlabel_printrk', $this->data);
  6082. }
  6083. public function _printxzrk($arg_array)
  6084. {
  6085. $post = $this->input->post(NULL, TRUE);
  6086. if (isset($post['wzid'])) {
  6087. $time = time();
  6088. $id = $this->input->post('wzid', true);
  6089. //$post['shop'] = $this->input->post('shop',true);
  6090. $num = 1;
  6091. $rk = $this->whlabellabel->read($id);
  6092. if (isset($rk['purchase'])) {
  6093. $x = 0;
  6094. $post['purchase'] = $rk['purchase'];
  6095. $post['warehouse'] = $rk['warehouse'];
  6096. $post['retreatwarehouse'] = $rk['warehouse'];
  6097. $post['sku'] = $rk['sku'];
  6098. $post['number'] = $rk['number'];
  6099. $post['features'] = $rk['features'];
  6100. $post['title'] = $rk['title'];
  6101. $post['enter'] = $time;
  6102. $post['time'] = $time;
  6103. $post['bs'] = 1;
  6104. $post['shop'] = $rk['shop'];
  6105. $post['details'] = $rk['details'];
  6106. $post['cpid'] = $rk['cpid'];
  6107. $post['cpbz'] = $rk['cpbz'];
  6108. $warehouse = $this->warehouse->read($rk['warehouse']);
  6109. if ($warehouse['bdck'] == '') {
  6110. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6111. exit;
  6112. } else {
  6113. $bdck = $warehouse['bdck'];
  6114. }
  6115. $post['featurespp'] = $rk['featurespp'];
  6116. $this->db->trans_begin();
  6117. for ($i = 0; $i < $num; $i++) {
  6118. $post['label'] = time() . rand(100, 999) . $i;
  6119. $this->$bdck->insert($post);
  6120. }
  6121. /**
  6122. if($post['warehouse'] != 12)
  6123. {
  6124. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6125. }
  6126. **/
  6127. if ($this->db->trans_status() === TRUE) {
  6128. $this->db->trans_commit();
  6129. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6130. exit;
  6131. } else {
  6132. $this->db->trans_rollback();
  6133. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6134. exit;
  6135. }
  6136. } else {
  6137. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6138. exit;
  6139. }
  6140. }
  6141. }
  6142. public function _printck($arg_array)
  6143. {
  6144. $prc = array();
  6145. $purchase = $this->purchase->find_all();
  6146. foreach ($purchase as $k => $v) {
  6147. $prc[$v['id']] = $v['title'];
  6148. }
  6149. $post = $this->input->post(NULL, TRUE);
  6150. if (isset($post['page'])) {
  6151. $page = $this->input->post('page', true);
  6152. $perpage = $this->input->post('perpage', true);
  6153. $sku = $this->input->post('sku', true);
  6154. $bs = $this->input->post('bs', true);
  6155. $number = $this->input->post('number', true);
  6156. $warehouse = $this->input->post('warehouse', true);
  6157. $purchase = $this->input->post('purchase', true);
  6158. $orderinfo = $this->input->post('orderinfo', true);
  6159. $waybill = $this->input->post('waybill', true);
  6160. $category = $this->input->post('category', true);
  6161. $size = $this->input->post('size', true);
  6162. $grade = $this->input->post('grade', true);
  6163. $color = $this->input->post('color', true);
  6164. $lowe = $this->input->post('lowe', true);
  6165. $state = $this->input->post('state', true);
  6166. $label = $this->input->post('label', true);
  6167. $timetk = $this->input->post('ktime', true);
  6168. $timetj = $this->input->post('jtime', true);
  6169. $timetk = strtotime($timetk);
  6170. $timetj = strtotime($timetj);
  6171. $where = "state=1 ";
  6172. if ($timetk && $timetj) {
  6173. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6174. }
  6175. if ($sku) {
  6176. $where .= " and sku = '$sku'";
  6177. }
  6178. if ($bs != '') {
  6179. $where .= " and bs = '$bs'";
  6180. }
  6181. if ($number) {
  6182. $where .= " and number = '$number'";
  6183. }
  6184. if ($warehouse) {
  6185. $where .= " and warehouse = '$warehouse'";
  6186. }
  6187. if ($purchase) {
  6188. $where .= " and purchase = '$purchase'";
  6189. }
  6190. if ($orderinfo) {
  6191. $where .= " and orderinfo = '$orderinfo'";
  6192. }
  6193. if ($waybill) {
  6194. $where .= " and waybill = '$waybill'";
  6195. }
  6196. if ($category) {
  6197. $where .= " and features like '%-$category-%'";
  6198. }
  6199. if ($size) {
  6200. $where .= " and features like '%-$size-%'";
  6201. }
  6202. if ($grade) {
  6203. $where .= " and features like '%-$grade-%'";
  6204. }
  6205. if ($color) {
  6206. $where .= " and features like '%-$color-%'";
  6207. }
  6208. if ($lowe) {
  6209. $where .= " and features like '%-$lowe-%'";
  6210. }
  6211. if ($label) {
  6212. $where .= " and label = '$label'";
  6213. }
  6214. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6215. //数据排序
  6216. $order_str = "outk desc";
  6217. if (empty($page)) {
  6218. $start = 0;
  6219. $perpage = 1;
  6220. } else {
  6221. $start = ($page - 1) * $perpage;
  6222. }
  6223. //取得信息列表
  6224. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6225. foreach ($info_list as $key => $value) {
  6226. $warehouse = $this->warehouse->read($value['warehouse']);
  6227. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6228. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6229. if ($value['state'] == 0) {
  6230. $info_list[$key]['state'] = "在库";
  6231. } else if ($value['state'] == 1) {
  6232. $info_list[$key]['state'] = "出库";
  6233. } else if ($value['state'] == 2) {
  6234. $info_list[$key]['state'] = "退库";
  6235. } else if ($value['state'] == 3) {
  6236. $info_list[$key]['state'] = "调拨中";
  6237. } else if ($value['state'] == 4) {
  6238. $info_list[$key]['state'] = "再加工";
  6239. } else if ($value['state'] == 5) {
  6240. $info_list[$key]['state'] = "维修中";
  6241. } else if ($value['state'] == 6) {
  6242. $info_list[$key]['state'] = "盘亏";
  6243. } else if ($value['state'] == 7) {
  6244. $info_list[$key]['state'] = "更换标签";
  6245. } else if ($value['state'] == 8) {
  6246. $info_list[$key]['state'] = "其它";
  6247. } else if ($value['state'] == 9) {
  6248. $info_list[$key]['state'] = "预设";
  6249. } else if ($value['state'] == 10) {
  6250. $info_list[$key]['state'] = "美店零售";
  6251. }
  6252. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6253. }
  6254. $total = $this->$ck->find_count($where);
  6255. $pagenum = ceil($total / $perpage);
  6256. $over = $total - ($start + $perpage);
  6257. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6258. echo json_encode($rows);
  6259. exit;
  6260. }
  6261. if (isset($post['tmsku'])) {
  6262. $time = time();
  6263. $tmsku = $this->input->post('tmsku', true);
  6264. //$post['shop'] = $this->input->post('shop',true);
  6265. $num = $this->input->post('num', true);
  6266. $cktype = $this->input->post('cktype', true);
  6267. $label = $this->whlabellabel->get_label($tmsku);
  6268. if (!$cktype) {
  6269. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6270. }
  6271. if (!isset($label['warehouse'])) {
  6272. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6273. exit;
  6274. }
  6275. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6276. if (stripos($label['features'], '-126-') !== false) {
  6277. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6278. } else {
  6279. $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 = ''");
  6280. }
  6281. $j = 0;
  6282. if (count($ck) >= $num) {
  6283. for ($i = 0; $i < $num; $i++) {
  6284. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6285. {
  6286. $j++;
  6287. }
  6288. }
  6289. if ($j == $num) {
  6290. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6291. exit;
  6292. } else {
  6293. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6294. exit;
  6295. }
  6296. } else {
  6297. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6298. exit;
  6299. }
  6300. }
  6301. if(isset($_SESSION['api']))
  6302. {
  6303. $user = $this->user->get_api($_SESSION['api']);
  6304. if(in_array($user['power'],[1,27])){
  6305. $vip = 1;
  6306. }
  6307. }
  6308. else
  6309. {
  6310. $vip = 0;
  6311. header('Location: /');exit;
  6312. }
  6313. $this->data['vip'] = $vip;
  6314. $this->_Template('whlabel_printck', $this->data);
  6315. }
  6316. public function _printexcel()
  6317. {
  6318. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6319. $config['upload_path'] = '.' . $dir;
  6320. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6321. $config['allowed_types'] = 'xls|xlsx|csv';
  6322. $config['max_size'] = 10240;
  6323. $this->load->library('upload', $config);
  6324. $this->upload->initialize($config);
  6325. if ($this->upload->do_upload('userfile')) {
  6326. $full_path = $dir . $this->upload->data('file_name');
  6327. $fileName = '.' . $full_path;
  6328. if (!file_exists($fileName)) {
  6329. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6330. exit;
  6331. } else {
  6332. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6333. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6334. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6335. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6336. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6337. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6338. ++$column; //如果列数大于26行
  6339. $list = array();
  6340. for ($i = 2; $i <= $row; $i++) // 行数循环
  6341. {
  6342. $data = array();
  6343. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6344. {
  6345. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6346. }
  6347. $list[] = $data;
  6348. }
  6349. }
  6350. $ed = array();
  6351. $i = 0;
  6352. $j = 0;
  6353. $dcdata = array();
  6354. $yc = '';
  6355. $cmf_arr = array_column($list, '1');
  6356. array_multisort($cmf_arr, SORT_ASC, $list);
  6357. foreach ($list as $key => $value) {
  6358. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6359. if ($typeclass) {
  6360. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6361. } else {
  6362. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6363. $i++;
  6364. continue;
  6365. }
  6366. }
  6367. if ($i > 0) {
  6368. $yc = $i . '条异常';
  6369. }
  6370. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6371. exit;
  6372. }
  6373. }
  6374. public function _uck()
  6375. {
  6376. if (isset($_GET['excel'])) {
  6377. $tc = array();
  6378. $typeclass = $this->typeclass->find_all();
  6379. foreach ($typeclass as $v) {
  6380. $tc[$v['id']] = $v['zh'];
  6381. }
  6382. $data = array();
  6383. $t = array();
  6384. $rq = '';
  6385. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6386. $ts = $ts / (24 * 3600);
  6387. for ($i = 0; $i < $ts; $i++) {
  6388. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6389. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6390. }
  6391. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6392. foreach ($info_list as $k => $v) {
  6393. $features = explode('-', trim($v['features'], '-'));
  6394. if (!isset($features[3]) || !isset($features[4])) {
  6395. continue;
  6396. }
  6397. $data[$k][0] = $tc[$features[0]]; //类型
  6398. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6399. $data[$k][2] = $tc[$features[4]]; //曲度
  6400. $data[$k][3] = '';
  6401. if (isset($data[$k][1])) {
  6402. $data[$k][3] .= $data[$k][1];
  6403. }
  6404. if (isset($data[$k][2])) {
  6405. $data[$k][3] .= $data[$k][2];
  6406. }
  6407. if (isset($features[5])) {
  6408. $data[$k][3] .= $tc[$features[5]];
  6409. }
  6410. if (isset($features[2])) {
  6411. $data[$k][3] .= $tc[$features[2]];
  6412. }
  6413. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6414. $data[$k][4] = $v['sku'];
  6415. $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())) . '))'); //月初库存
  6416. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6417. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6418. $ztrq = '';
  6419. $ztsl = '';
  6420. if (count($zt) > 0) {
  6421. foreach ($zt as $vv) {
  6422. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6423. $ztsl .= $vv['num'] . '<br>';
  6424. }
  6425. }
  6426. $data[$k][] = trim($ztsl, '<br>');
  6427. $data[$k][] = trim($ztrq, '<br>');
  6428. $byck = 0;
  6429. foreach ($t as $vv) {
  6430. $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));
  6431. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6432. $byck += $sl;
  6433. }
  6434. $data[$k][] = ($byck > 0) ? $byck : '';
  6435. }
  6436. $title = "详情 " . date("Y-m-d", time());
  6437. $titlename = "<table border=1>
  6438. <tr align='center'>
  6439. <td>类别</td>
  6440. <td>颜色</td>
  6441. <td>曲度</td>
  6442. <td>名称</td>
  6443. <td>SKU</td>
  6444. <td>月初库存</td>
  6445. <td>剩余库存</td>
  6446. <td>在途数量</td>
  6447. <td>预达日期</td>" .
  6448. $rq
  6449. . "<td>本月出库</td></tr>
  6450. </table>";
  6451. $filename = $title . ".xls";
  6452. $tail = "";
  6453. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6454. }
  6455. }
  6456. public function _whlabelexcelzh()
  6457. {
  6458. if (isset($_GET['excel'])) {
  6459. $where = "sku != 'Preset'";
  6460. //数据排序
  6461. $order_str = "id desc";
  6462. if (empty($page)) {
  6463. $start = 0;
  6464. $perpage = 1;
  6465. } else {
  6466. $start = ($page - 1) * $perpage;
  6467. }
  6468. $category = $this->input->get('category', true);
  6469. $warehouse = $this->input->get('warehouse', true);
  6470. $excelid = $this->input->get('sid', true);
  6471. if ($category) {
  6472. $where .= " and features like '%-$category-%'";
  6473. }
  6474. if ($warehouse) {
  6475. $where .= " and warehouse = '$warehouse'";
  6476. }
  6477. $xzid = '';
  6478. if ($excelid) {
  6479. $excelid = explode(',', trim($excelid, ','));
  6480. foreach ($excelid as $key => $value) {
  6481. $xzid .= " id = " . $value . " or";
  6482. }
  6483. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6484. }
  6485. //取得信息列表
  6486. /**
  6487. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6488. $rows = array();$list = array();
  6489. foreach ($info_list as $key=>$value)
  6490. {
  6491. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6492. }
  6493. **/
  6494. $list = array();
  6495. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6496. foreach ($rows as $key => $value) {
  6497. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6498. $zh = '';
  6499. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6500. foreach ($zt as $v) {
  6501. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6502. }
  6503. $zt = array_sum(array_column($zt, 'num'));
  6504. $number = $value['number'];
  6505. $ftime = time() - 15 * 24 * 3600;
  6506. $warehouse = $this->warehouse->read($value['warehouse']);
  6507. $rows[$key]['warehouse'] = $warehouse['title'];
  6508. $rows[$key]['number'] = $c;
  6509. $rows[$key]['features'] = $zh;
  6510. $rows[$key]['hb'] = $c + $zt;
  6511. }
  6512. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6513. $titlename = "<table border=1>
  6514. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6515. <tr align='center'>
  6516. <td>仓库</td>
  6517. <td>SKU</td>
  6518. <td>产品</td>
  6519. <td>库存数量</td>
  6520. <td>在途数量及预达日期</td>
  6521. <td>在途+库存数量</td>
  6522. </tr>
  6523. </table>";
  6524. $filename = $title . ".xls";
  6525. $tail = "";
  6526. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6527. }
  6528. if (isset($_GET['excel'])) {
  6529. $warehouse = $this->input->get('warehouse', true);
  6530. $sku = $this->input->get('sku', true);
  6531. $cz = $this->input->get('cz', true);
  6532. $text = $this->input->post('text', true);
  6533. $xztime = $this->input->get('xztime', true);
  6534. $timetk = $this->input->get('timetk', true);
  6535. $timetj = $this->input->get('timetj', true);
  6536. $timetk = strtotime($timetk);
  6537. $timetj = strtotime($timetj);
  6538. $where = "time = '0' ";
  6539. if ($warehouse) {
  6540. $where .= " and warehouse = '$warehouse'";
  6541. }
  6542. if ($sku) {
  6543. $where .= " and sku = '$sku'";
  6544. }
  6545. if ($text) {
  6546. $where .= " and text like '%$text%'";
  6547. }
  6548. if ($cz != '') {
  6549. $where .= " and cz = '$cz'";
  6550. }
  6551. if ($timetk && $timetj) {
  6552. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6553. }
  6554. //数据排序
  6555. $order_str = $xztime . " desc";
  6556. //取得信息列表
  6557. $zh = array();
  6558. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6559. foreach ($info_list as $v) {
  6560. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6561. $warehouse = $this->warehouse->read($v['warehouse']);
  6562. $v['warehouse'] = $warehouse['title'];
  6563. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6564. $v['stime'] = date('Y-m-d', $v['stime']);
  6565. if (isset($zh[$v['features']])) {
  6566. $zh[$v['features']]['num'] += $v['num'];
  6567. } else {
  6568. $zh[$v['features']] = $v;
  6569. }
  6570. $zh[$v['features']]['features'] = $c;
  6571. }
  6572. $title = "在途数据" . date('Y-m-d', time());
  6573. $titlename = "<table border=1>
  6574. <tr align='center'>
  6575. <td>仓库</td>
  6576. <td>SKU</td>
  6577. <td>名称</td>
  6578. <td>在途数量</td>
  6579. <td>库存数量</td>
  6580. <td>添加在途日期</td>
  6581. <td>预达日期</td>
  6582. <td>备注</td>
  6583. </tr>
  6584. </table>";
  6585. $filename = $title . ".xls";
  6586. $tail = "";
  6587. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6588. }
  6589. }
  6590. public function _fc()
  6591. {
  6592. $vip = 0;
  6593. if (isset($_SESSION['api'])) {
  6594. $user = $this->user->get_api($_SESSION['api']);
  6595. if ($user['vip'] == 1) {
  6596. $vip = 1;
  6597. }
  6598. } else {
  6599. header('Location: /');
  6600. exit;
  6601. }
  6602. $post = $this->input->post(NULL, TRUE);
  6603. if (isset($post['page'])) {
  6604. $page = $this->input->post('page', true);
  6605. $perpage = $this->input->post('perpage', true);
  6606. $category = $this->input->post('category', true);
  6607. $size = $this->input->post('size', true);
  6608. $grade = $this->input->post('grade', true);
  6609. $color = $this->input->post('color', true);
  6610. $lowe = $this->input->post('lowe', true);
  6611. $sku = $this->input->post('sku');
  6612. $title = $this->input->post('title');
  6613. $warehouse = $this->input->post('warehouse', true);
  6614. $usa = $this->input->post('usa', true);
  6615. $purchase = $this->input->post('purchase', true);
  6616. $lacetype = $this->input->post('lacetype', true);
  6617. $haircap = $this->input->post('haircap', true);
  6618. $density = $this->input->post('density', true);
  6619. $details = $this->input->post('details', true);
  6620. $state = $this->input->post('state', true);
  6621. $ktime = $this->input->post('ktime', true);
  6622. $jtime = $this->input->post('jtime', true);
  6623. $ktime = strtotime($ktime);
  6624. $jtime = strtotime($jtime);
  6625. $where = "state = '11'";
  6626. $gj = "";
  6627. $ck = "";
  6628. if ($lacetype) {
  6629. $where .= " and features like '%-$lacetype-%'";
  6630. }
  6631. if ($category) {
  6632. $where .= " and features like '%-$category-%'";
  6633. }
  6634. if ($size) {
  6635. $where .= " and features like '%-$size-%'";
  6636. }
  6637. if ($grade) {
  6638. $where .= " and features like '%-$grade-%'";
  6639. }
  6640. if ($color) {
  6641. $where .= " and features like '%-$color-%'";
  6642. }
  6643. if ($lowe) {
  6644. $where .= " and features like '%-$lowe-%'";
  6645. }
  6646. if ($haircap) {
  6647. $where .= " and features like '%-$haircap-%'";
  6648. }
  6649. if ($density) {
  6650. $where .= " and features like '%-$density-%'";
  6651. }
  6652. if ($usa) {
  6653. if (!$warehouse) {
  6654. $where .= " and (warehouse = '5' or warehouse = '8')";
  6655. }
  6656. }
  6657. if ($warehouse) {
  6658. $where .= " and warehouse = '$warehouse'";
  6659. }
  6660. if ($details) {
  6661. $where .= " and details = '$details'";
  6662. }
  6663. if ($purchase) {
  6664. $where .= " and purchase = '$purchase'";
  6665. }
  6666. if ($state) {
  6667. $where .= " and state = '$state'";
  6668. }
  6669. if ($ktime && $jtime) {
  6670. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6671. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6672. }
  6673. //数据排序
  6674. $order_str = "id desc";
  6675. if (empty($page)) {
  6676. $start = 0;
  6677. $perpage = 1;
  6678. } else {
  6679. $start = ($page - 1) * $perpage;
  6680. }
  6681. if ($sku) {
  6682. $sku = trim($sku, ' ');
  6683. $sku = trim($sku, ' ');
  6684. $where .= " and sku like '%$sku%'";
  6685. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6686. } else if ($title) {
  6687. $title = trim($title, ' ');
  6688. $title = trim($title, ' ');
  6689. $where .= " and title like '%$title%'";
  6690. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6691. } else {
  6692. //$where .= " and time > '$ktime' and time < '$jtime'";
  6693. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6694. }
  6695. //取得信息列表
  6696. $rows = array();
  6697. $list = array();
  6698. foreach ($info_list as $key => $value) {
  6699. $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'] . '"');
  6700. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6701. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6702. $warehouse = $this->warehouse->read($value['warehouse']);
  6703. $info_list[$key]['warehouse'] = $warehouse['title'];
  6704. $info_list[$key]['number'] = $g;
  6705. $info_list[$key]['features'] = $x;
  6706. $info_list[$key]['x'] = $s;
  6707. }
  6708. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6709. $pagenum = ceil($total / $perpage);
  6710. $over = $total - ($start + $perpage);
  6711. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6712. echo json_encode($rows);
  6713. exit;
  6714. }
  6715. $this->data['vip'] = $vip;
  6716. $this->_Template('whlabel_fc', $this->data);
  6717. }
  6718. public function _fcmb()
  6719. {
  6720. $where = "sku != 'Preset'";
  6721. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6722. foreach ($rows as $k => $v) {
  6723. $warehouse = $this->warehouse->read($v['warehouse']);
  6724. $rows[$k]['warehouse'] = $warehouse['title'];
  6725. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6726. $rows[$k]['t'] = '';
  6727. $rows[$k]['n'] = '';
  6728. }
  6729. $title = "封货产品数据导入模板";
  6730. $titlename = "<table border=1>
  6731. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6732. <tr align='center'>
  6733. <td>仓库</td>
  6734. <td>SKU</td>
  6735. <td>产品</td>
  6736. <td>封存产品总数量</td>
  6737. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6738. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6739. </tr>
  6740. </table>";
  6741. $filename = $title . ".xls";
  6742. $tail = "";
  6743. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6744. }
  6745. public function _fcexcel()
  6746. {
  6747. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6748. $config['upload_path'] = '.' . $dir;
  6749. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6750. $config['allowed_types'] = 'xls|xlsx|csv';
  6751. $config['max_size'] = 10240;
  6752. $this->load->library('upload', $config);
  6753. $this->upload->initialize($config);
  6754. if ($this->upload->do_upload('userfile')) {
  6755. $full_path = $dir . $this->upload->data('file_name');
  6756. $fileName = '.' . $full_path;
  6757. if (!file_exists($fileName)) {
  6758. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6759. exit;
  6760. } else {
  6761. libxml_use_internal_errors(true);
  6762. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6763. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6764. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6765. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6766. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6767. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6768. ++$column; //如果列数大于26行
  6769. $list = array();
  6770. for ($i = 2; $i <= $row; $i++) // 行数循环
  6771. {
  6772. $data = array();
  6773. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6774. {
  6775. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6776. }
  6777. $list[] = $data;
  6778. }
  6779. }
  6780. $i = 0;
  6781. $j = 0;
  6782. $ed = array();
  6783. foreach ($list as $key => $value) {
  6784. $time = time();
  6785. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6786. continue;
  6787. }
  6788. $warehouse = $this->warehouse->get_title($value['0']);
  6789. $sku = $value['1'];
  6790. $type = $value['4']; //调整方式0扣减1删除
  6791. $num = $value['5']; //调整数量
  6792. //$text = $value['4'];//扣减说明
  6793. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6794. if (!$d) //如果没有这个SKU
  6795. {
  6796. $ed[] = array($sku . '-库存中不存在此SKU');
  6797. $j++;
  6798. continue;
  6799. }
  6800. if (!isset($warehouse['id'])) {
  6801. $ed[] = array($sku . '-仓库名错误!');
  6802. $j++;
  6803. continue;
  6804. }
  6805. if ($type == 1 || $type == 2) //扣减库存
  6806. {
  6807. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6808. if (count($data) < abs($num)) {
  6809. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6810. $j++;
  6811. continue;
  6812. }
  6813. if ($type == 1) //转入库存
  6814. {
  6815. for ($i = 0; $i < abs($num); $i++) {
  6816. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6817. }
  6818. } else if ($type == 2) //删除
  6819. {
  6820. for ($i = 0; $i < abs($num); $i++) {
  6821. $this->whlabel->remove($data[$i]['id']);
  6822. }
  6823. }
  6824. } else if ($type == 0) //增加库存
  6825. {
  6826. $post['sku'] = $d['sku'];
  6827. $post['shop'] = '';
  6828. $post['warehouse'] = $warehouse['id'];
  6829. $post['purchase'] = $d['purchase'];
  6830. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6831. $post['state'] = 11;
  6832. $post['title'] = $d['title'];
  6833. $post['number'] = $d['number'];
  6834. $post['features'] = $d['features'];
  6835. $post['enter'] = $time;
  6836. $post['time'] = $time; //操作时间
  6837. for ($i = 0; $i < $num; $i++) {
  6838. $post['label'] = time() . rand(100, 999) . $i;
  6839. $this->whlabel->insert($post);
  6840. }
  6841. }
  6842. sleep(1); //防止入库时间一样,需要延迟1秒
  6843. }
  6844. if ($j > 0) {
  6845. $tt = date('Ymd', time());
  6846. $title = '库存导入错误信息-' . $tt;
  6847. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6848. $tail = "\n";
  6849. $filename = $title . ".xls";
  6850. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6851. $dir = '/data/excel/' . $time . '/';
  6852. $file_name = 'error_' . $time . rand(1000, 9999);
  6853. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6854. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6855. fwrite($myfile, $ecl);
  6856. fclose($myfile);
  6857. $error = $dir . $file_name . '.xls';
  6858. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6859. exit;
  6860. } else {
  6861. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6862. exit;
  6863. }
  6864. }
  6865. }
  6866. public function _fcjxc($arg_array)
  6867. {
  6868. if (isset($_GET['excel'])) {
  6869. $category = $this->input->get('category', true);
  6870. $size = $this->input->get('size', true);
  6871. $grade = $this->input->get('grade', true);
  6872. $color = $this->input->get('color', true);
  6873. $lowe = $this->input->get('lowe', true);
  6874. $sku = $this->input->get('sku');
  6875. $title = $this->input->get('title');
  6876. $warehouse = $arg_array[0];
  6877. $usa = $this->input->get('usa', true);
  6878. $purchase = $this->input->get('purchase', true);
  6879. $lacetype = $this->input->get('lacetype', true);
  6880. $haircap = $this->input->get('haircap', true);
  6881. $density = $this->input->get('density', true);
  6882. $title = $this->input->get('title', true);
  6883. $state = $this->input->get('state', true);
  6884. $ktime = $this->input->get('ktime', true);
  6885. $jtime = $this->input->get('jtime', true);
  6886. $where = "state=11";
  6887. $gj = "";
  6888. $ck = "";
  6889. if ($lacetype) {
  6890. $where .= " and features like '%-$lacetype-%'";
  6891. }
  6892. if ($category) {
  6893. $where .= " and features like '%-$category-%'";
  6894. }
  6895. if ($size) {
  6896. $where .= " and features like '%-$size-%'";
  6897. }
  6898. if ($grade) {
  6899. $where .= " and features like '%-$grade-%'";
  6900. }
  6901. if ($color) {
  6902. $where .= " and features like '%-$color-%'";
  6903. }
  6904. if ($lowe) {
  6905. $where .= " and features like '%-$lowe-%'";
  6906. }
  6907. if ($haircap) {
  6908. $where .= " and features like '%-$haircap-%'";
  6909. }
  6910. if ($density) {
  6911. $where .= " and features like '%-$density-%'";
  6912. }
  6913. if ($usa) {
  6914. if (!$warehouse) {
  6915. $where .= " and (warehouse = '5' or warehouse = '8')";
  6916. }
  6917. }
  6918. if ($warehouse) {
  6919. $where .= " and warehouse = '$warehouse'";
  6920. }
  6921. if ($purchase) {
  6922. $where .= " and purchase = '$purchase'";
  6923. }
  6924. if ($state) {
  6925. $where .= " and state = '$state'";
  6926. }
  6927. $order_str = "id desc";
  6928. if ($sku) {
  6929. $sku = trim($sku, ' ');
  6930. $sku = trim($sku, ' ');
  6931. $where .= " and sku like '%$sku%'";
  6932. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6933. } else if ($title) {
  6934. $title = trim($title, ' ');
  6935. $title = trim($title, ' ');
  6936. $where .= " and title like '%$title%'";
  6937. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6938. } else {
  6939. //$where .= " and time > '$ktime' and time < '$jtime'";
  6940. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6941. }
  6942. //取得信息列表
  6943. $rows = array();
  6944. $list = array();
  6945. foreach ($info_list as $key => $value) {
  6946. $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'] . '"');
  6947. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6948. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6949. $rows[$key] = $value;
  6950. $warehouse = $this->warehouse->read($value['warehouse']);
  6951. $rows[$key]['warehouse'] = $warehouse['title'];
  6952. $rows[$key]['features'] = $g;
  6953. $rows[$key]['a'] = $x;
  6954. $rows[$key]['b'] = $s;
  6955. }
  6956. $title = "总统计表";
  6957. $titlename = "<table border=1>
  6958. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6959. <tr align='center'>
  6960. <td>仓库</td>
  6961. <td>SKU</td>
  6962. <td>产品名称</td>
  6963. <td>录入总量</td>
  6964. <td>取出总量</td>
  6965. <td>剩余总量</td>
  6966. </tr>
  6967. </table>";
  6968. $filename = $title . ".xls";
  6969. $tail = "";
  6970. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6971. }
  6972. $vip = 0;
  6973. if (isset($_SESSION['api'])) {
  6974. $user = $this->user->get_api($_SESSION['api']);
  6975. if ($user['vip'] == 1) {
  6976. $vip = 1;
  6977. }
  6978. } else {
  6979. header('Location: /');
  6980. exit;
  6981. }
  6982. $post = $this->input->post(NULL, TRUE);
  6983. if (isset($post['page'])) {
  6984. $page = $this->input->post('page', true);
  6985. $perpage = $this->input->post('perpage', true);
  6986. $category = $this->input->post('category', true);
  6987. $size = $this->input->post('size', true);
  6988. $grade = $this->input->post('grade', true);
  6989. $color = $this->input->post('color', true);
  6990. $lowe = $this->input->post('lowe', true);
  6991. $sku = $this->input->post('sku');
  6992. $title = $this->input->post('title');
  6993. $warehouse = $arg_array[0];
  6994. $usa = $this->input->post('usa', true);
  6995. $purchase = $this->input->post('purchase', true);
  6996. $lacetype = $this->input->post('lacetype', true);
  6997. $haircap = $this->input->post('haircap', true);
  6998. $density = $this->input->post('density', true);
  6999. $title = $this->input->post('title', true);
  7000. $state = $this->input->post('state', true);
  7001. $ktime = $this->input->post('ktime', true);
  7002. $jtime = $this->input->post('jtime', true);
  7003. $ktime = strtotime($ktime);
  7004. $jtime = strtotime($jtime);
  7005. $where = "state=11";
  7006. $gj = "";
  7007. $ck = "";
  7008. if ($lacetype) {
  7009. $where .= " and features like '%-$lacetype-%'";
  7010. }
  7011. if ($category) {
  7012. $where .= " and features like '%-$category-%'";
  7013. }
  7014. if ($size) {
  7015. $where .= " and features like '%-$size-%'";
  7016. }
  7017. if ($grade) {
  7018. $where .= " and features like '%-$grade-%'";
  7019. }
  7020. if ($color) {
  7021. $where .= " and features like '%-$color-%'";
  7022. }
  7023. if ($lowe) {
  7024. $where .= " and features like '%-$lowe-%'";
  7025. }
  7026. if ($haircap) {
  7027. $where .= " and features like '%-$haircap-%'";
  7028. }
  7029. if ($density) {
  7030. $where .= " and features like '%-$density-%'";
  7031. }
  7032. if ($usa) {
  7033. if (!$warehouse) {
  7034. $where .= " and (warehouse = '5' or warehouse = '8')";
  7035. }
  7036. }
  7037. if ($warehouse) {
  7038. $where .= " and warehouse = '$warehouse'";
  7039. }
  7040. if ($purchase) {
  7041. $where .= " and purchase = '$purchase'";
  7042. }
  7043. if ($state) {
  7044. $where .= " and state = '$state'";
  7045. }
  7046. if ($ktime && $jtime) {
  7047. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7048. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7049. }
  7050. //数据排序
  7051. $order_str = "id desc";
  7052. $xs = 0;
  7053. $rows = array();
  7054. $list = array();
  7055. if (empty($page)) {
  7056. $start = 0;
  7057. $perpage = 1;
  7058. } else {
  7059. $start = ($page - 1) * $perpage;
  7060. }
  7061. if ($sku || $title) {
  7062. if ($title) {
  7063. $title = trim($title, ' ');
  7064. $title = trim($title, ' ');
  7065. $where .= " and title like '%$title%'";
  7066. } else {
  7067. $sku = trim($sku, ' ');
  7068. $sku = trim($sku, ' ');
  7069. $where .= " and sku like '%$sku%'";
  7070. }
  7071. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7072. foreach ($info_list as $key => $value) {
  7073. $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'] . '"');
  7074. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7075. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7076. $rows[$key] = $value;
  7077. $warehouse = $this->warehouse->read($value['warehouse']);
  7078. $rows[$key]['warehouse'] = $warehouse['title'];
  7079. $rows[$key]['features'] = $g;
  7080. $rows[$key]['a'] = $x;
  7081. $rows[$key]['b'] = $s;
  7082. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7083. $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天销量
  7084. $yj = $c / ($xl / 30);
  7085. if ($yj < 7) {
  7086. $rows[$key]['y'] = round($yj) . '天销量';
  7087. } else {
  7088. $rows[$key]['y'] = '正常';
  7089. }
  7090. }
  7091. } else {
  7092. //$where .= " and time > '$ktime' and time < '$jtime'";
  7093. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7094. foreach ($info_list as $key => $value) {
  7095. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  7096. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7097. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7098. $zs[$key] = $value;
  7099. $warehouse = $this->warehouse->read($value['warehouse']);
  7100. $zs[$key]['warehouse'] = $warehouse['title'];
  7101. $zs[$key]['features'] = $g;
  7102. $zs[$key]['a'] = $x;
  7103. $zs[$key]['b'] = $s;
  7104. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7105. $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天销量
  7106. $yj = $c / ($xl / 30);
  7107. if ($yj < 7) {
  7108. $zs[$key]['y'] = round($yj) . '天销量';
  7109. $rows[$key] = $zs[$key];
  7110. }
  7111. }
  7112. }
  7113. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7114. $pagenum = ceil($total / $perpage);
  7115. $over = $total - ($start + $perpage);
  7116. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7117. echo json_encode($rows);
  7118. exit;
  7119. }
  7120. $this->data['arg_array'] = $arg_array[0];
  7121. $this->_Template('whlabel_fcjxc', $this->data);
  7122. }
  7123. public function _0kcdel()
  7124. {
  7125. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7126. $config['upload_path'] = '.' . $dir;
  7127. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7128. $config['allowed_types'] = 'xls|xlsx|csv';
  7129. $config['max_size'] = 10240;
  7130. $this->load->library('upload', $config);
  7131. $this->upload->initialize($config);
  7132. if ($this->upload->do_upload('userfile')) {
  7133. $full_path = $dir . $this->upload->data('file_name');
  7134. $fileName = '.' . $full_path;
  7135. if (!file_exists($fileName)) {
  7136. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7137. exit;
  7138. } else {
  7139. require_once "./data/excel/PHPExcel/IOFactory.php";
  7140. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7141. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7142. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7143. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7144. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7145. ++$column; //如果列数大于26行
  7146. $list = array();
  7147. for ($i = 2; $i <= $row; $i++) // 行数循环
  7148. {
  7149. $data = array();
  7150. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7151. {
  7152. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7153. }
  7154. $list[] = $data;
  7155. }
  7156. }
  7157. $i = 0;
  7158. $j = 0;
  7159. $ed = array();
  7160. foreach ($list as $key => $value) {
  7161. $time = time();
  7162. if ($value['0'] == "" || $value['1'] == "") {
  7163. continue;
  7164. }
  7165. $warehouse = $this->warehouse->get_title($value['0']);
  7166. $sku = $value['1'];
  7167. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7168. if (!$d) //如果没有这个SKU
  7169. {
  7170. $ed[] = array($sku . '-库存中不存在此SKU');
  7171. $j++;
  7172. continue;
  7173. }
  7174. if (!isset($warehouse['id'])) {
  7175. $ed[] = array($sku . '-仓库名错误!');
  7176. $j++;
  7177. continue;
  7178. }
  7179. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7180. if ($z < 1) {
  7181. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7182. foreach ($z as $v) {
  7183. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7184. if (count($zt) > 0) {
  7185. $ed[] = array($sku . '-有在途库存无法删除!');
  7186. $j++;
  7187. continue;
  7188. }
  7189. $this->whlabel->remove($v['id']);
  7190. }
  7191. } else {
  7192. $ed[] = array($sku . '-非0库存!');
  7193. $j++;
  7194. continue;
  7195. }
  7196. }
  7197. if ($j > 0) {
  7198. $tt = date('Ymd', time());
  7199. $title = '删除0库存错误信息-' . $tt;
  7200. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7201. $tail = "\n";
  7202. $filename = $title . ".xls";
  7203. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7204. $dir = '/data/excel/' . $time . '/';
  7205. $file_name = 'error_' . $time . rand(1000, 9999);
  7206. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7207. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7208. fwrite($myfile, $ecl);
  7209. fclose($myfile);
  7210. $error = $dir . $file_name . '.xls';
  7211. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7212. exit;
  7213. } else {
  7214. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7215. exit;
  7216. }
  7217. }
  7218. }
  7219. public function _gbhtype()
  7220. {
  7221. $post = $this->input->post(NULL, TRUE);
  7222. if (isset($post['s'])) {
  7223. $n = $this->input->post('n');
  7224. $d = $this->input->post('s');
  7225. if (!$d) {
  7226. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7227. exit;
  7228. }
  7229. $d = explode(',', trim($d, ','));
  7230. $t = $this->whlabel_type->read($n);
  7231. //循环删除记录
  7232. foreach ($d as $v) {
  7233. $u = $this->whlabel->read($v);
  7234. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7235. foreach ($data as $val) {
  7236. $this->whlabel->save(array('type' => $n), $val['id']);
  7237. }
  7238. }
  7239. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7240. }
  7241. }
  7242. //出库、退库导出
  7243. public function _dccrtype()
  7244. {
  7245. $classid = $this->classid->sku();
  7246. $pm = $classid;
  7247. $typeclass = array();
  7248. $tc = $this->typeclass->find_all();
  7249. foreach ($tc as $v) {
  7250. $typeclass[$v['id']] = $v;
  7251. }
  7252. $prc = array();
  7253. $purchase = $this->purchase->find_all();
  7254. foreach ($purchase as $k => $v) {
  7255. $prc[$v['id']] = $v['title'];
  7256. }
  7257. if (isset($_GET['sid'])) {
  7258. $wh = array();
  7259. $w = $this->warehouse->find_all('1=1', 'id,title');
  7260. foreach ($w as $v) {
  7261. $wh[$v['id']] = $v['title'];
  7262. }
  7263. $type = $this->input->get('excel', true);
  7264. $category = $this->input->get('category', true);
  7265. $size = $this->input->get('size', true);
  7266. $grade = $this->input->get('grade', true);
  7267. $color = $this->input->get('color', true);
  7268. $lowe = $this->input->get('lowe', true);
  7269. $sku = $this->input->get('sku', true);
  7270. $warehouse = $this->input->get('warehouse', true);
  7271. $lacetype = $this->input->get('lacetype', true);
  7272. $lacecolor = $this->input->get('lacecolor', true);
  7273. $density = $this->input->get('density', true);
  7274. $haircap = $this->input->get('haircap', true);
  7275. $purchase = $this->input->get('purchase', true);
  7276. $title = $this->input->get('title', true);
  7277. $state = $this->input->get('state', true);
  7278. $sid = $this->input->get('sid', true);
  7279. $ktime = $this->input->get('ktime', true);
  7280. $jtime = $this->input->get('jtime', true);
  7281. $ktime = strtotime($ktime);
  7282. $jtime = strtotime($jtime);
  7283. $where = "1=1";
  7284. $gj = "";
  7285. $ck = "";
  7286. if ($category) {
  7287. $where .= " and features like '%-$category-%'";
  7288. }
  7289. if ($size) {
  7290. $where .= " and features like '%-$size-%'";
  7291. }
  7292. if ($grade) {
  7293. $where .= " and features like '%-$grade-%'";
  7294. }
  7295. if ($color) {
  7296. $where .= " and features like '%-$color-%'";
  7297. }
  7298. if ($lowe) {
  7299. $where .= " and features like '%-$lowe-%'";
  7300. }
  7301. if ($warehouse) {
  7302. $where .= " and warehouse = '$warehouse'";
  7303. }
  7304. if ($purchase) {
  7305. $where .= " and purchase = '$purchase'";
  7306. }
  7307. if ($state) {
  7308. $where .= " and state = '$state'";
  7309. }
  7310. if ($lacetype) {
  7311. $where .= " and features like '%-$lacetype-%'";
  7312. }
  7313. if ($lacecolor) {
  7314. $where .= " and features like '%-$lacecolor-%'";
  7315. }
  7316. if ($density) {
  7317. $where .= " and features like '%-$density-%'";
  7318. }
  7319. if ($haircap) {
  7320. $where .= " and features like '%-$haircap-%'";
  7321. }
  7322. if ($title) {
  7323. $title = trim($title, ' ');
  7324. $title = trim($title, ' ');
  7325. $where .= " and title like '%$title%'";
  7326. }
  7327. if ($sku) {
  7328. $sku = trim($sku, ' ');
  7329. $sku = trim($sku, ' ');
  7330. $where .= " and sku like '%$sku%'";
  7331. }
  7332. if ($ktime && $jtime) {
  7333. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7334. }
  7335. $sidwhere = '';
  7336. if ($sid) {
  7337. $sd = "";
  7338. $s = explode(',', trim($sid, ','));
  7339. foreach ($s as $value) {
  7340. $sd .= " id = " . $value . " or";
  7341. }
  7342. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7343. }
  7344. //数据排序
  7345. $order_str = "time desc";
  7346. if (empty($page)) {
  7347. $start = 0;
  7348. $perpage = 1;
  7349. } else {
  7350. $start = ($page - 1) * $perpage;
  7351. }
  7352. $wh = array();
  7353. $w = $this->warehouse->find_all('1=1', 'id,title');
  7354. foreach ($w as $v) {
  7355. $wh[$v['id']] = $v['title'];
  7356. }
  7357. $wt = array();
  7358. $whlabel_type = $this->whlabel_type->find_all();
  7359. foreach ($whlabel_type as $v) {
  7360. $wt[$v['id']] = $v['title'];
  7361. }
  7362. $classid = $this->classid->sku();
  7363. $list = array();
  7364. $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');
  7365. foreach ($rows_r as $key => $value) {
  7366. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7367. $pm = $classid;
  7368. $jm = $classid;
  7369. $rows_r[$key]['enter'] = '入库';
  7370. $rows_r[$key]['time'] = $value['enter'];
  7371. if ($value['rktype'] == 1) {
  7372. $rows_r[$key]['rktype'] = '采购入库';
  7373. } else if ($value['rktype'] == 2) {
  7374. $rows_r[$key]['rktype'] = '盘盈调整';
  7375. } else if ($value['rktype'] == 3) {
  7376. $rows_r[$key]['rktype'] = '其他调整入库';
  7377. } else if ($value['rktype'] == 4) {
  7378. $rows_r[$key]['rktype'] = '其他调整入库';
  7379. } else if ($value['rktype'] == 5) {
  7380. $rows_r[$key]['rktype'] = '退库入库';
  7381. } else if ($value['rktype'] == 6) {
  7382. $rows_r[$key]['rktype'] = '退货可用入库';
  7383. } else if ($value['rktype'] == 7) {
  7384. $rows_r[$key]['rktype'] = '形态转换入库';
  7385. } else {
  7386. $rows_r[$key]['rktype'] = '';
  7387. }
  7388. $features = explode('-', trim($value['features'], '-'));
  7389. foreach ($features as $v) {
  7390. if (isset($typeclass[$v])) {
  7391. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7392. $pm[$typeclass[$v]['classid']] = $zh[0];
  7393. }
  7394. if (isset($typeclass[$v])) {
  7395. if (isset($jm[$typeclass[$v]['classid']])) {
  7396. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7397. }
  7398. }
  7399. }
  7400. $zh = implode(" ", $pm);
  7401. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7402. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7403. $rows_r[$key]['zh'] = $zh;
  7404. $jm = array_filter($jm);
  7405. $rows_r[$key]['features'] = implode("-", $jm);
  7406. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7407. }
  7408. $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');
  7409. foreach ($rows_c as $key => $value) {
  7410. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7411. $pm = $classid;
  7412. $jm = $classid;
  7413. $rows_c[$key]['time'] = $value['outk'];
  7414. $rows_c[$key]['outk'] = '出库';
  7415. if ($value['cktype'] == 1) {
  7416. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7417. } else if ($value['cktype'] == 2) {
  7418. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7419. } else if ($value['cktype'] == 3) {
  7420. $rows_c[$key]['cktype'] = '盘亏调整';
  7421. } else if ($value['cktype'] == 4) {
  7422. $rows_c[$key]['cktype'] = '其他调整出库';
  7423. } else if ($value['cktype'] == 5) {
  7424. $rows_c[$key]['cktype'] = '形态转换出库';
  7425. } else {
  7426. $rows_c[$key]['cktype'] = '';
  7427. }
  7428. unset($rows_c[$key]['state']);
  7429. $features = explode('-', trim($value['features'], '-'));
  7430. foreach ($features as $v) {
  7431. if (isset($typeclass[$v])) {
  7432. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7433. $pm[$typeclass[$v]['classid']] = $zh[0];
  7434. }
  7435. if (isset($typeclass[$v])) {
  7436. if (isset($jm[$typeclass[$v]['classid']])) {
  7437. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7438. }
  7439. }
  7440. }
  7441. $zh = implode(" ", $pm);
  7442. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7443. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7444. $rows_c[$key]['zh'] = $zh;
  7445. $jm = array_filter($jm);
  7446. $rows_c[$key]['features'] = implode("-", $jm);
  7447. $rows_c[$key]['number'] = 1;
  7448. }
  7449. $merged = $rows_r;
  7450. foreach ($rows_c as $key => $value) {
  7451. if (isset($merged[$key])) {
  7452. $merged[] = $value;
  7453. } else {
  7454. $merged[$key] = $value;
  7455. }
  7456. }
  7457. usort($merged, function ($a, $b) {
  7458. return $a['time'] - $b['time'];
  7459. });
  7460. foreach ($merged as $key => $value) {
  7461. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7462. }
  7463. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7464. $titlename = "<table border=1>
  7465. <tr align='center'>
  7466. <td>仓库</td>
  7467. <td>SKU</td>
  7468. <td>商品名称</td>
  7469. <td>仓库品名</td>
  7470. <td>料号</td>
  7471. <td>时间</td>
  7472. <td>操作</td>
  7473. <td>类型</td>
  7474. <td>数量</td>
  7475. <td>备注</td>
  7476. </tr>
  7477. </table>";
  7478. $filename = $title . ".xlsx";
  7479. $tail = "";
  7480. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7481. }
  7482. }
  7483. /*************************************处理exceljs导出****************************************************/
  7484. public function _excelrjs(){
  7485. if (isset($_GET['excel'])) {
  7486. $category = $this->input->get('category', true);
  7487. $size = $this->input->get('size', true);
  7488. $grade = $this->input->get('grade', true);
  7489. $color = $this->input->get('color', true);
  7490. $lowe = $this->input->get('lowe', true);
  7491. $sku = $this->input->get('sku', true);
  7492. $warehouse = $this->input->get('warehouse', true);
  7493. $purchase = $this->input->get('purchase', true);
  7494. $ktime = $this->input->get('ktime', true);
  7495. $jtime = $this->input->get('jtime', true);
  7496. $ktime = strtotime($ktime);
  7497. $jtime = strtotime($jtime);
  7498. $where = "1=1";
  7499. $gj = "";
  7500. $ck = "";
  7501. if ($category) {
  7502. $where .= " and features like '%-$category-%'";
  7503. }
  7504. if ($size) {
  7505. $where .= " and features like '%-$size-%'";
  7506. }
  7507. if ($grade) {
  7508. $where .= " and features like '%-$grade-%'";
  7509. }
  7510. if ($color) {
  7511. $where .= " and features like '%-$color-%'";
  7512. }
  7513. if ($lowe) {
  7514. $where .= " and features like '%-$lowe-%'";
  7515. }
  7516. if ($warehouse) {
  7517. $where .= " and warehouse = '$warehouse'";
  7518. }
  7519. if ($purchase) {
  7520. $where .= " and purchase = '$purchase'";
  7521. }
  7522. if ($sku) {
  7523. $where .= " and sku = '$sku'";
  7524. }
  7525. if ($ktime && $jtime) {
  7526. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7527. }
  7528. //数据排序
  7529. $order_str = "id desc";
  7530. if (empty($page)) {
  7531. $start = 0;
  7532. $perpage = 1;
  7533. } else {
  7534. $start = ($page - 1) * $perpage;
  7535. }
  7536. $list = array();
  7537. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7538. foreach ($rows as $value) {
  7539. $ck = $this->warehouse->read($value['warehouse']);
  7540. $warehouse = $ck['title'];
  7541. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7542. $retreatwarehouse = $tkck['title'];
  7543. $gy = $this->purchase->read($value['purchase']);
  7544. $purchase = $gy['title'];
  7545. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7546. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7547. }
  7548. if(empty($list)){
  7549. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7550. }else{
  7551. $final_list = [];
  7552. foreach($list as $v){
  7553. $final_list[] = array_values($v);
  7554. }
  7555. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7556. array_unshift($final_list,[
  7557. "仓库","SKU","商品名称","时间","数量"
  7558. ]);
  7559. array_unshift($final_list,[
  7560. $title,"","","",""
  7561. ]);
  7562. $merges = [
  7563. [
  7564. "s"=>["r"=>0,"c"=>0],
  7565. "e"=>["r"=>0,"c"=>4]
  7566. ]
  7567. ];
  7568. $cols = [
  7569. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7570. ];
  7571. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7572. }
  7573. }
  7574. }
  7575. //出库、退库导出
  7576. public function _excelctjs()
  7577. {
  7578. $classid = $this->classid->sku();
  7579. $pm = $classid;
  7580. $typeclass = array();
  7581. $tc = $this->typeclass->find_all();
  7582. foreach ($tc as $v) {
  7583. $typeclass[$v['id']] = $v;
  7584. }
  7585. $prc = array();
  7586. $purchase = $this->purchase->find_all();
  7587. foreach ($purchase as $k => $v) {
  7588. $prc[$v['id']] = $v['title'];
  7589. }
  7590. if (isset($_GET['excel'])) {
  7591. $wh = array();
  7592. $w = $this->warehouse->find_all('1=1', 'id,title');
  7593. foreach ($w as $v) {
  7594. $wh[$v['id']] = $v['title'];
  7595. }
  7596. $type = $this->input->get('excel', true);
  7597. $category = $this->input->get('category', true);
  7598. $size = $this->input->get('size', true);
  7599. $grade = $this->input->get('grade', true);
  7600. $color = $this->input->get('color', true);
  7601. $lowe = $this->input->get('lowe', true);
  7602. $sku = $this->input->get('sku', true);
  7603. $title = $this->input->get('title', true);
  7604. $warehouse = $this->input->get('warehouse', true);
  7605. $purchase = $this->input->get('purchase', true);
  7606. $lacetype = $this->input->get('lacetype', true);
  7607. $haircap = $this->input->get('haircap', true);
  7608. $lacecolor = $this->input->get('lacecolor', true);
  7609. $density = $this->input->get('density', true);
  7610. $details = $this->input->get('details', true);
  7611. $state = $this->input->get('state', true);
  7612. $shop = $this->input->get('shop', true);
  7613. $hairnumber = $this->input->get('hairnumber', true);
  7614. $type_leixi = $this->input->get('type', true);
  7615. $cpbz = $this->input->get('cpbz', true);
  7616. $sm = $this->input->get('sm', true);
  7617. $sid = $this->input->get('sid', true);
  7618. $ktime = $this->input->get('ktime', true);
  7619. $jtime = $this->input->get('jtime', true);
  7620. $ktime = strtotime($ktime);
  7621. $jtime = strtotime($jtime);
  7622. //$where = " 1=1 ";
  7623. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7624. $where = " sku != '' ";
  7625. $gj = "";
  7626. $ck = "";
  7627. if ($category) {
  7628. $where .= " and features like '%-$category-%'";
  7629. }
  7630. if ($size) {
  7631. $where .= " and features like '%-$size-%'";
  7632. }
  7633. if ($grade) {
  7634. $where .= " and features like '%-$grade-%'";
  7635. }
  7636. if ($color) {
  7637. $where .= " and features like '%-$color-%'";
  7638. }
  7639. if ($lowe) {
  7640. $where .= " and features like '%-$lowe-%'";
  7641. }
  7642. if ($warehouse) {
  7643. $where .= " and warehouse = '$warehouse'";
  7644. }
  7645. if ($purchase) {
  7646. $where .= " and purchase = '$purchase'";
  7647. }
  7648. if ($state) {
  7649. $where .= " and state = '$state'";
  7650. }
  7651. if ($lacetype) {
  7652. $where .= " and features like '%-$lacetype-%'";
  7653. }
  7654. if ($lacecolor) {
  7655. $where .= " and features like '%-$lacecolor-%'";
  7656. }
  7657. if ($density) {
  7658. $where .= " and features like '%-$density-%'";
  7659. }
  7660. if ($haircap) {
  7661. $where .= " and features like '%-$haircap-%'";
  7662. }
  7663. if ($details) {
  7664. $where .= " and details = '$details'";
  7665. }
  7666. if ($shop) {
  7667. $where .= " and shop like '%$shop%'";
  7668. }
  7669. if ($title) {
  7670. $title = trim($title, ' ');
  7671. $title = trim($title, ' ');
  7672. $where .= " and title like '%$title%'";
  7673. }
  7674. if (!empty($hairnumber)) {
  7675. $where .= " and features like '%-128-%' ";
  7676. if ($hairnumber < 0) {
  7677. $class_list = $this->typeclass->find_all('classid = 43');
  7678. foreach ($class_list as $v) {
  7679. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7680. }
  7681. } else {
  7682. $where .= " and features like '%-$hairnumber-%'";
  7683. }
  7684. }
  7685. if ($type_leixi) {
  7686. $where .= " and type = '$type_leixi'";
  7687. }
  7688. if ($cpbz) {
  7689. $where .= " and cpbz like '%$cpbz%' ";
  7690. }
  7691. if ($sm) {
  7692. $where .= " and sm like '%$sm%' ";
  7693. }
  7694. if ($sku) {
  7695. $sku = trim($sku, ' ');
  7696. $sku = trim($sku, ' ');
  7697. $where .= " and sku like '%$sku%'";
  7698. }
  7699. if ($ktime && $jtime) {
  7700. if ($type == 1) {
  7701. $tl = '出库';
  7702. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7703. } else if ($type == 2) {
  7704. $tl = '退库';
  7705. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7706. } else if ($type == 3) {
  7707. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7708. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7709. } else if ($type == 4) {
  7710. $tl = '出库+零售';
  7711. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7712. } else if ($type == 5) {
  7713. $tl = '零售';
  7714. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7715. }
  7716. }
  7717. $sidwhere = '';
  7718. if ($sid) {
  7719. $sd = "";
  7720. $s = explode(',', trim($sid, ','));
  7721. foreach ($s as $value) {
  7722. $sd .= " id = " . $value . " or";
  7723. }
  7724. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7725. }
  7726. //数据排序
  7727. $order_str = "time desc";
  7728. if (empty($page)) {
  7729. $start = 0;
  7730. $perpage = 1;
  7731. } else {
  7732. $start = ($page - 1) * $perpage;
  7733. }
  7734. //取得信息列表
  7735. if ($type != 3 && $type != 5) {
  7736. if ($type == 1 || $type == 4) {
  7737. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7738. foreach ($info_list as $key => $value) {
  7739. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7740. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7741. $warehouse = $this->warehouse->read($value['warehouse']);
  7742. $info_list[$key]['warehouse'] = $warehouse['title'];
  7743. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7744. $features = explode('-', trim($features, '-'));
  7745. $pm = $classid;
  7746. foreach ($features as $k => $v) {
  7747. if ($v != 0) {
  7748. if (!isset($typeclass[$v])) {
  7749. continue;
  7750. }
  7751. if (isset($pm[$typeclass[$v]['classid']])) {
  7752. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7753. $tz = explode('|', $typeclass[$v]['zh']);
  7754. $pm[$typeclass[$v]['classid']] = $tz[0];
  7755. } else {
  7756. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7757. }
  7758. }
  7759. }
  7760. }
  7761. $zh = implode(" ", $pm);
  7762. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7763. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7764. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7765. $info_list[$key]['features'] = $zh;
  7766. }
  7767. $final_list = [];
  7768. foreach($info_list as $k=>$v){
  7769. $number = "";
  7770. if(!empty($v['orderinfo'])){
  7771. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7772. if(!empty($tmp_info['number'])){
  7773. $number = $tmp_info['number'];
  7774. }
  7775. }
  7776. $final_list[] = [
  7777. 'warehouse'=>$v['warehouse'],
  7778. 'purchase'=>$v['purchase'],
  7779. 'sku'=>$v['sku'],
  7780. 'title'=>$v['title'],
  7781. 'features'=>$v['features'],
  7782. 'label'=>$v['label'],
  7783. 'orderinfo'=>$v['orderinfo'],
  7784. 'number'=>$number,
  7785. 'waybill'=>$v['waybill'],
  7786. 'outk'=>$v['outk'],
  7787. ];
  7788. }
  7789. } else {
  7790. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7791. foreach ($info_list as $key => $value) {
  7792. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7793. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7794. $warehouse = $this->warehouse->read($value['warehouse']);
  7795. $info_list[$key]['warehouse'] = $warehouse['title'];
  7796. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7797. $features = explode('-', trim($features, '-'));
  7798. $pm = $classid;
  7799. foreach ($features as $k => $v) {
  7800. if ($v != 0) {
  7801. if (!isset($typeclass[$v])) {
  7802. continue;
  7803. }
  7804. if (isset($pm[$typeclass[$v]['classid']])) {
  7805. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7806. $tz = explode('|', $typeclass[$v]['zh']);
  7807. $pm[$typeclass[$v]['classid']] = $tz[0];
  7808. } else {
  7809. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7810. }
  7811. }
  7812. }
  7813. }
  7814. $zh = implode(" ", $pm);
  7815. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7816. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7817. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7818. $info_list[$key]['features'] = $zh;
  7819. }
  7820. $final_list = [];
  7821. foreach($info_list as $k=>$v){
  7822. $number = "";
  7823. if(!empty($v['orderinfo'])){
  7824. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7825. if(!empty($tmp_info['number'])){
  7826. $number = $tmp_info['number'];
  7827. }
  7828. }
  7829. $final_list[] = [
  7830. 'warehouse'=>$v['warehouse'],
  7831. 'purchase'=>$v['purchase'],
  7832. 'sku'=>$v['sku'],
  7833. 'title'=>$v['title'],
  7834. 'features'=>$v['features'],
  7835. 'label'=>$v['label'],
  7836. 'orderinfo'=>$v['orderinfo'],
  7837. 'number'=>$number,
  7838. 'waybill'=>$v['waybill'],
  7839. 'retreat'=>$v['retreat'],
  7840. ];
  7841. }
  7842. }
  7843. if(empty($final_list)){
  7844. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7845. }else{
  7846. $end_list = [];
  7847. foreach($final_list as $v){
  7848. $end_list[] = array_values($v);
  7849. }
  7850. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7851. array_unshift($end_list,[
  7852. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7853. ]);
  7854. array_unshift($end_list,[
  7855. $title,"","","","","","","","",""
  7856. ]);
  7857. $merges = [
  7858. [
  7859. "s"=>["r"=>0,"c"=>0],
  7860. "e"=>["r"=>0,"c"=>9]
  7861. ]
  7862. ];
  7863. $cols = [
  7864. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  7865. ];
  7866. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  7867. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  7868. ] )));
  7869. }
  7870. } else if ($type == 5) {
  7871. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  7872. foreach ($info_list as $key => $value) {
  7873. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7874. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7875. $warehouse = $this->warehouse->read($value['warehouse']);
  7876. $info_list[$key]['warehouse'] = $warehouse['title'];
  7877. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7878. $features = explode('-', trim($features, '-'));
  7879. $pm = $classid;
  7880. foreach ($features as $k => $v) {
  7881. if ($v != 0) {
  7882. if (!isset($typeclass[$v])) {
  7883. continue;
  7884. }
  7885. if (isset($pm[$typeclass[$v]['classid']])) {
  7886. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7887. $tz = explode('|', $typeclass[$v]['zh']);
  7888. $pm[$typeclass[$v]['classid']] = $tz[0];
  7889. } else {
  7890. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7891. }
  7892. }
  7893. }
  7894. }
  7895. $zh = implode(" ", $pm);
  7896. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7897. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7898. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7899. $info_list[$key]['features'] = $zh;
  7900. }
  7901. if(empty($info_list)){
  7902. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7903. }else{
  7904. $final_list = [];
  7905. foreach($info_list as $v){
  7906. $final_list[] = array_values($v);
  7907. }
  7908. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  7909. array_unshift($final_list,[
  7910. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  7911. ]);
  7912. array_unshift($final_list,[
  7913. $title,"","","","","","",
  7914. ]);
  7915. $merges = [
  7916. [
  7917. "s"=>["r"=>0,"c"=>0],
  7918. "e"=>["r"=>0,"c"=>6]
  7919. ]
  7920. ];
  7921. $cols = [
  7922. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  7923. ];
  7924. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  7925. }
  7926. } else {
  7927. $wh = array();
  7928. $w = $this->warehouse->find_all('1=1', 'id,title');
  7929. foreach ($w as $v) {
  7930. $wh[$v['id']] = $v['title'];
  7931. }
  7932. $wt = array();
  7933. $whlabel_type = $this->whlabel_type->find_all();
  7934. foreach ($whlabel_type as $v) {
  7935. $wt[$v['id']] = $v['title'];
  7936. }
  7937. $classid = $this->classid->sku();
  7938. $list = array();
  7939. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  7940. foreach ($rows as $key => $value) {
  7941. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7942. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7943. $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');
  7944. $details = array();
  7945. $cpid = array();
  7946. $cpbz = array();
  7947. $c = 0;
  7948. $g = 0;
  7949. $x = 0;
  7950. $t = 0;
  7951. $s = 0;
  7952. $q = 0;
  7953. foreach ($sd as $k => $v) {
  7954. if ($v['state'] == 0) {
  7955. $c++;
  7956. }
  7957. if ($v['state'] != 9) {
  7958. $g++;
  7959. }
  7960. if ($v['outk'] > 1) {
  7961. $x++;
  7962. }
  7963. if ($v['retreat'] > 0) {
  7964. $t++;
  7965. }
  7966. if ($v['state'] == 8) {
  7967. $s++;
  7968. }
  7969. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  7970. $q++;
  7971. }
  7972. $details[$v['details']] = $v['details'];
  7973. if ($v['cpid'] != 0) {
  7974. $cpid[$v['cpid']] = $v['cpid'];
  7975. }
  7976. if ($v['cpbz'] != '') {
  7977. $cpbz[$v['cpbz']] = $v['cpbz'];
  7978. }
  7979. }
  7980. if (isset($wt[$value['type']])) {
  7981. $rows[$key]['type'] = $wt[$value['type']];
  7982. } else {
  7983. $rows[$key]['type'] = '未设置';
  7984. }
  7985. $rows[$key]['details'] = implode("、", $details);
  7986. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  7987. $ftime = time() - 15 * 24 * 3600;
  7988. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  7989. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  7990. $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);
  7991. $rows[$key]['c'] = $c;
  7992. $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);
  7993. $rows[$key]['t'] = $t;
  7994. $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'] . '"');
  7995. $rows[$key]['z'] = $z;
  7996. // $jm = $classid;
  7997. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7998. $features = explode('-', trim($features, '-'));
  7999. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8000. }
  8001. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8002. $final_list =[];
  8003. foreach($tmp_list as $k=>$v){
  8004. $final_list[] = [
  8005. "warehouse"=>$v['warehouse'],
  8006. "purchase"=>$v['purchase'],
  8007. "details"=>$v['details'],
  8008. "cpid"=>$v['cpid'],
  8009. "sku"=>$v['sku'],
  8010. "title"=>$v['title'],
  8011. "features"=>$v['pm'],
  8012. "cpbz"=>$v['cpbz'],
  8013. "sm"=>$v['sm'],
  8014. "type"=>$v['type'],
  8015. "g"=>$v["g"],
  8016. "c"=>$v["c"],
  8017. "x"=>$v["x"],
  8018. "t"=>$v["t"],
  8019. "z"=>$v["z"],
  8020. "jm"=>$v["jm"],
  8021. "weight"=>$v["weight"],
  8022. "asd"=>$v["asd"],
  8023. ];
  8024. }
  8025. if(empty($final_list)){
  8026. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8027. }else{
  8028. $end_list = [];
  8029. foreach($final_list as $v){
  8030. $end_list[] = array_values($v);
  8031. }
  8032. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8033. array_unshift($end_list,[
  8034. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8035. ]);
  8036. array_unshift($end_list,[
  8037. $title,"","","","","","","","","","","","","","","","","",""
  8038. ]);
  8039. $merges = [
  8040. [
  8041. "s"=>["r"=>0,"c"=>0],
  8042. "e"=>["r"=>0,"c"=>6]
  8043. ]
  8044. ];
  8045. $cols = [
  8046. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8047. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8048. ];
  8049. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8050. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8051. ])));
  8052. }
  8053. }
  8054. }
  8055. }
  8056. public function _exceljxcjs(){
  8057. $classid = $this->classid->sku();
  8058. $pm = $classid;
  8059. $typeclass = array();
  8060. $tc = $this->typeclass->find_all();
  8061. foreach ($tc as $v) {
  8062. $typeclass[$v['id']] = $v;
  8063. }
  8064. $prc = array();
  8065. $purchase = $this->purchase->find_all();
  8066. foreach ($purchase as $k => $v) {
  8067. $prc[$v['id']] = $v['title'];
  8068. }
  8069. if(!isset($_GET['excel'])){
  8070. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8071. }
  8072. $where = "sku != 'Preset'";
  8073. //数据排序
  8074. $order_str = "id desc";
  8075. if (empty($page)) {
  8076. $start = 0;
  8077. $perpage = 1;
  8078. } else {
  8079. $start = ($page - 1) * $perpage;
  8080. }
  8081. $category = $this->input->get('category', true);
  8082. $warehouse = $this->input->get('warehouse', true);
  8083. $excelid = $this->input->get('sid', true);
  8084. if ($category) {
  8085. $where .= " and features like '%-$category-%'";
  8086. }
  8087. if ($warehouse) {
  8088. $where .= " and warehouse = '$warehouse'";
  8089. }
  8090. $xzid = '';
  8091. if ($excelid) {
  8092. $excelid = explode(',', trim($excelid, ','));
  8093. foreach ($excelid as $key => $value) {
  8094. $xzid .= " id = " . $value . " or";
  8095. }
  8096. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8097. }
  8098. $wt = array();
  8099. $whlabel_type = $this->whlabel_type->find_all();
  8100. foreach ($whlabel_type as $v) {
  8101. $wt[$v['id']] = $v['title'];
  8102. }
  8103. $wh = array();
  8104. $w = $this->warehouse->find_all('1=1', 'id,title');
  8105. foreach ($w as $v) {
  8106. $wh[$v['id']] = $v['title'];
  8107. }
  8108. $list = array();
  8109. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8110. foreach ($rows as $key => $value) {
  8111. if (isset($wt[$value['type']])) {
  8112. $rows[$key]['type'] = $wt[$value['type']];
  8113. } else {
  8114. $rows[$key]['type'] = '未设置';
  8115. }
  8116. $bm = '03';
  8117. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8118. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8119. $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');
  8120. $details = array();
  8121. $cpid = array();
  8122. $cpbz = array();
  8123. $c = 0;
  8124. $g = 0;
  8125. $x = 0;
  8126. $t = 0;
  8127. $s = 0;
  8128. $q = 0;
  8129. foreach ($sd as $k => $v) {
  8130. if ($v['state'] == 0) {
  8131. $c++;
  8132. if ($v['cpid'] != 0) {
  8133. $cpid[$v['cpid']] = $v['cpid'];
  8134. }
  8135. if ($v['cpbz'] != '') {
  8136. $cpbz[$v['cpbz']] = $v['cpbz'];
  8137. }
  8138. }
  8139. if ($v['state'] != 9) {
  8140. $g++;
  8141. }
  8142. if ($v['state'] == 1) {
  8143. $x++;
  8144. }
  8145. if ($v['state'] == 2) {
  8146. $t++;
  8147. }
  8148. if ($v['state'] == 8) {
  8149. $s++;
  8150. }
  8151. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8152. $q++;
  8153. }
  8154. $details[$v['details']] = $v['details'];
  8155. }
  8156. $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'] . '"');
  8157. $rows[$key]['details'] = implode("、", $details);
  8158. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8159. $number = $value['number'];
  8160. $ftime = time() - 15 * 24 * 3600;
  8161. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8162. $rows[$key]['number'] = $g;
  8163. $rows[$key]['c'] = $c;
  8164. $rows[$key]['x'] = $x;
  8165. $rows[$key]['t'] = $t;
  8166. $rows[$key]['s'] = $s;
  8167. $rows[$key]['q'] = $q;
  8168. $rows[$key]['z'] = $z;
  8169. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8170. $features = explode('-', trim($features, '-'));
  8171. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8172. }
  8173. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8174. $final_list = [];
  8175. foreach ($list as $k => $v) {
  8176. if (empty($v['sku'])) {
  8177. continue;
  8178. }
  8179. $final_list[] = [
  8180. $v["warehouse"],
  8181. $v["purchase"],
  8182. $v["details"],
  8183. $v["cpid"],
  8184. $v["dbcontent"],
  8185. $v["sku"],
  8186. $v["bm"],
  8187. $v["jm"],
  8188. $v["title"],
  8189. $v["pm"],
  8190. $v["cpbz"],
  8191. $v["sm"],
  8192. $v["type"],
  8193. $v["number"],
  8194. $v["c"],
  8195. $v["x"],
  8196. $v["t"],
  8197. $v["s"],
  8198. $v["q"],
  8199. $v["z"],
  8200. $v['weight'],
  8201. ];
  8202. }
  8203. if(empty($final_list)){
  8204. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8205. }
  8206. $title = "总进销存统计表";
  8207. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8208. $merges = [
  8209. [
  8210. "s"=>["r"=>0,"c"=>0],
  8211. "e"=>["r"=>0,"c"=>21]
  8212. ]
  8213. ];
  8214. $cols = [
  8215. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8216. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8217. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8218. ];
  8219. array_unshift($final_list, $first_row);
  8220. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8221. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8222. }
  8223. public function _summaryjs($arg_array)
  8224. {
  8225. $prc = array();
  8226. $purchase = $this->purchase->find_all();
  8227. foreach ($purchase as $k => $v) {
  8228. $prc[$v['id']] = $v['title'];
  8229. }
  8230. if (isset($_GET['excel'])) {
  8231. $ktime = $this->input->get('ktime', true);
  8232. $jtime = $this->input->get('jtime', true);
  8233. $ktime = strtotime($ktime);
  8234. $jtime = strtotime($jtime);
  8235. $where = "1=1";
  8236. if ($ktime && $jtime) {
  8237. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8238. }
  8239. //数据排序
  8240. $order_str = "time desc";
  8241. if (empty($page)) {
  8242. $start = 0;
  8243. $perpage = 1;
  8244. } else {
  8245. $start = ($page - 1) * $perpage;
  8246. }
  8247. //取得信息列表
  8248. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8249. foreach ($info_list as $key => $value) {
  8250. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8251. $warehouse = $this->warehouse->read($value['warehouse']);
  8252. $info_list[$key]['warehouse'] = $warehouse['title'];
  8253. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8254. $details = array();
  8255. $cpid = array();
  8256. foreach ($x as $k => $v) {
  8257. if ($v['details'] != '') {
  8258. $details[$v['details']] = $v['details'];
  8259. }
  8260. if ($v['cpid'] != 0) {
  8261. $cpid[$v['cpid']] = $v['cpid'];
  8262. }
  8263. }
  8264. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8265. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8266. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8267. $info_list[$key]['s'] = $s;
  8268. $info_list[$key]['x'] = count($x);
  8269. }
  8270. if(empty($info_list)){
  8271. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8272. }
  8273. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8274. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8275. $merges = [
  8276. [
  8277. "s"=>["r"=>0,"c"=>0],
  8278. "e"=>["r"=>0,"c"=>7]
  8279. ]
  8280. ];
  8281. $cols = [
  8282. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8283. ];
  8284. $final_list = [];
  8285. foreach($info_list as $k => $v){
  8286. $final_list[] = array_values($v);
  8287. }
  8288. array_unshift($final_list, $first_row);
  8289. array_unshift($final_list,[
  8290. $title,"","","","","","","","",
  8291. ]);
  8292. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8293. $titlename = "<table border=1>
  8294. <tr align='center'>
  8295. <td>仓库</td>
  8296. <td>供应商</td>
  8297. <td>出库位置</td>
  8298. <td>出库编码</td>
  8299. <td>SKU</td>
  8300. <td>产品名</td>
  8301. <td>总剩余库存</td>
  8302. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8303. </tr>
  8304. </table>";
  8305. $filename = $title . ".xls";
  8306. $tail = "";
  8307. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8308. }
  8309. }
  8310. public function _uckjs()
  8311. {
  8312. if (isset($_GET['excel'])) {
  8313. $tc = array();
  8314. $typeclass = $this->typeclass->find_all();
  8315. foreach ($typeclass as $v) {
  8316. $tc[$v['id']] = $v['zh'];
  8317. }
  8318. $first_row = [
  8319. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8320. ];
  8321. $t = array();
  8322. $rq = '';
  8323. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8324. $ts = $ts / (24 * 3600);
  8325. for ($i = 0; $i < $ts; $i++) {
  8326. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8327. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8328. }
  8329. $day_len = count($t);
  8330. $first_row[] = "本月出库";
  8331. $merges = [
  8332. ];
  8333. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8334. $excel_key = 1;
  8335. $final_list = [];
  8336. foreach ($info_list as $k => $v) {
  8337. $features = explode('-', trim($v['features'], '-'));
  8338. if (!isset($features[3]) || !isset($features[4])) {
  8339. continue;
  8340. }
  8341. $tmp = [];
  8342. $tmp[0] = $tc[$features[0]]; //类型
  8343. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8344. $tmp[2] = $tc[$features[4]]; //曲度
  8345. $tmp[3] = '';
  8346. if (isset($data[$k][1])) {
  8347. $tmp[3] .=$tmp[1];
  8348. }
  8349. if (isset($data[$k][2])) {
  8350. $tmp[3] .= $tmp[2];
  8351. }
  8352. if (isset($features[5])) {
  8353. $tmp[3] .= $tc[$features[5]];
  8354. }
  8355. if (isset($features[2])) {
  8356. $tmp[3] .= $tc[$features[2]];
  8357. }
  8358. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8359. $tmp[4] = $v['sku'];
  8360. $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())) . '))'); //月初库存
  8361. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8362. $tmp[7] ="";
  8363. $tmp[8] ="";
  8364. $byck = 0;
  8365. foreach ($t as $vv) {
  8366. $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));
  8367. $tmp[] = ($sl > 0) ? $sl : '';
  8368. $byck += $sl;
  8369. }
  8370. $tmp[] = ($byck > 0) ? $byck : '';
  8371. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8372. // $ztrq = '';
  8373. // $ztsl = '';
  8374. // if (count($zt) > 0) {
  8375. // foreach ($zt as $vv) {
  8376. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8377. // $ztsl .= $vv['num'] . '<br>';
  8378. // }
  8379. // }
  8380. if(empty($zt)){
  8381. $final_list[] = $tmp;
  8382. $excel_key = $excel_key + 1;
  8383. }else{
  8384. $len = count($zt);
  8385. if($len == 1){
  8386. $tmp[7] = $zt[0]['num'] ;
  8387. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8388. $final_list[] = $tmp;
  8389. $excel_key = $excel_key + 1;
  8390. }else{
  8391. foreach($zt as $vv){
  8392. $tmp[7] = "";
  8393. $tmp[8] = "";
  8394. $tmp[7] = $vv['num'];
  8395. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8396. $final_list[] = $tmp;
  8397. }
  8398. $merges[] = [
  8399. "s"=>["r"=>$excel_key,"c"=>0],
  8400. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8401. ];
  8402. $merges[] = [
  8403. "s"=>["r"=>$excel_key,"c"=>1],
  8404. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8405. ];
  8406. $merges[] = [
  8407. "s"=>["r"=>$excel_key,"c"=>2],
  8408. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8409. ];
  8410. $merges[] = [
  8411. "s"=>["r"=>$excel_key,"c"=>3],
  8412. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8413. ];
  8414. $merges[] = [
  8415. "s"=>["r"=>$excel_key,"c"=>4],
  8416. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8417. ];
  8418. $merges[] = [
  8419. "s"=>["r"=>$excel_key,"c"=>5],
  8420. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8421. ];
  8422. $merges[] = [
  8423. "s"=>["r"=>$excel_key,"c"=>6],
  8424. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8425. ];
  8426. for($i=1;$i<=$day_len;$i++){
  8427. $merges[] = [
  8428. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8429. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8430. ];
  8431. }
  8432. $merges[] = [
  8433. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8434. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8435. ];
  8436. $excel_key = $excel_key + $len;
  8437. }
  8438. }
  8439. }
  8440. $title = "详情 " . date("Y-m-d", time());
  8441. if(empty($final_list)){
  8442. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8443. }
  8444. $cols = [
  8445. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8446. ];
  8447. array_unshift($final_list, $first_row);
  8448. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8449. }
  8450. }
  8451. public function _whlabelexcelzhjs(){
  8452. if(empty($_GET['excel'])){
  8453. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8454. }
  8455. $where = "sku != 'Preset' and sku != '' ";
  8456. //数据排序
  8457. $order_str = "id desc";
  8458. if (empty($page)) {
  8459. $start = 0;
  8460. $perpage = 1;
  8461. } else {
  8462. $start = ($page - 1) * $perpage;
  8463. }
  8464. $category = $this->input->get('category', true);
  8465. $warehouse = $this->input->get('warehouse', true);
  8466. $excelid = $this->input->get('sid', true);
  8467. if ($category) {
  8468. $where .= " and features like '%-$category-%'";
  8469. }
  8470. if ($warehouse) {
  8471. $where .= " and warehouse = '$warehouse'";
  8472. }
  8473. $xzid = '';
  8474. if ($excelid) {
  8475. $excelid = explode(',', trim($excelid, ','));
  8476. foreach ($excelid as $key => $value) {
  8477. $xzid .= " id = " . $value . " or";
  8478. }
  8479. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8480. }
  8481. $merges = [
  8482. [
  8483. "s"=>["r"=>0,"c"=>0],
  8484. "e"=>["r"=>0,"c"=>6]
  8485. ]
  8486. ];
  8487. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8488. $excel_index = 2;
  8489. $final_list = [];
  8490. foreach ($rows as $key => $value) {
  8491. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8492. $zh = '';
  8493. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8494. // foreach ($zt_list as $v) {
  8495. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8496. // }
  8497. $zt = array_sum(array_column($zt_list, 'num'));
  8498. $number = $value['number'];
  8499. $ftime = time() - 15 * 24 * 3600;
  8500. $warehouse = $this->warehouse->read($value['warehouse']);
  8501. // $rows[$key]['warehouse'] = $warehouse['title'];
  8502. // $rows[$key]['number'] = $c;
  8503. // $rows[$key]['features'] = $zh;
  8504. //$rows[$key]['hb'] = $c + $zt;
  8505. $tmp = [];
  8506. $tmp[0] = $warehouse['title'];
  8507. $tmp[1] = $value['sku'];
  8508. $tmp[2] = $value['title'];
  8509. $tmp[3] = $c;
  8510. $tmp[4] = "";
  8511. $tmp[5] = $c + $zt;
  8512. if(empty($zt_list)){
  8513. $tmp[4] = "";
  8514. $final_list[] = $tmp;
  8515. $excel_index = $excel_index + 1;
  8516. }else{
  8517. if(count($zt_list) == 1){
  8518. $tmp[4] = "";
  8519. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8520. $final_list[] = $tmp;
  8521. $excel_index = $excel_index + 1;
  8522. }else{
  8523. $len = count($zt_list);
  8524. foreach ($zt_list as $v){
  8525. $tmp[4] = "";
  8526. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8527. $final_list[] = $tmp;
  8528. }
  8529. $merges[] = [
  8530. "s"=>["r"=>$excel_index,"c"=>0],
  8531. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8532. ];
  8533. $merges[] = [
  8534. "s"=>["r"=>$excel_index,"c"=>1],
  8535. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8536. ];
  8537. $merges[] = [
  8538. "s"=>["r"=>$excel_index,"c"=>2],
  8539. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8540. ];
  8541. $merges[] = [
  8542. "s"=>["r"=>$excel_index,"c"=>3],
  8543. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8544. ];
  8545. $merges[] = [
  8546. "s"=>["r"=>$excel_index,"c"=>5],
  8547. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8548. ];
  8549. $excel_index = $excel_index + $len;
  8550. }
  8551. }
  8552. }
  8553. $first_row = [
  8554. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8555. ];
  8556. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8557. if(empty($final_list)){
  8558. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8559. }
  8560. $cols = [
  8561. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8562. ];
  8563. array_unshift($final_list, $first_row);
  8564. array_unshift($final_list, [
  8565. $title,"","","","",""
  8566. ]);
  8567. $end_list = [];
  8568. foreach ($final_list as $key => $value) {
  8569. $end_list[] = array_values($value);
  8570. }
  8571. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8572. }
  8573. }