Whlabel.php 296 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722
  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 == "w_t_cs"){
  202. $this->_w_t_cs(); //首页
  203. }else {
  204. $this->_index();
  205. }
  206. }
  207. public function _w_t_cs(){
  208. $vip = 0;
  209. if (isset($_SESSION['api'])) {
  210. $user = $this->user->get_api($_SESSION['api']);
  211. $fgshop = "";
  212. $sid = "";
  213. $usersp = explode('|', trim($user['shop'], '|'));
  214. foreach ($usersp as $value) {
  215. $fgshop .= " shop = " . $value . " or";
  216. $sid .= " id = " . $value . " or";
  217. }
  218. if ($user['vip'] == 1) {
  219. $vip = 1;
  220. }
  221. } else {
  222. header('Location: /');
  223. exit;
  224. }
  225. $prc = array();
  226. $purchase = $this->purchase->find_all();
  227. foreach ($purchase as $k => $v) {
  228. $prc[$v['id']] = $v['title'];
  229. }
  230. $company = array();
  231. $ct = $this->company->find_all();
  232. foreach ($ct as $k => $v) {
  233. $company[$v['id']] = $v['title'];
  234. }
  235. $sp = array();
  236. $s = $this->shop->find_all('1=1', 'id,shopname');
  237. foreach ($s as $v) {
  238. $sp[$v['id']] = $v['shopname'];
  239. }
  240. $wh = array();
  241. $w = $this->warehouse->find_all('1=1', 'id,title');
  242. foreach ($w as $v) {
  243. $wh[$v['id']] = $v['title'];
  244. }
  245. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  246. $this->data['shop'] = $wlshop;
  247. $this->data['vip'] = $vip;
  248. $this->_Template('whlabel_typejs', $this->data);
  249. }
  250. //管理
  251. public function _index()
  252. {
  253. $post = $this->input->post(NULL, TRUE);
  254. if (isset($post['page'])) {
  255. $page = $this->input->post('page', true);
  256. $perpage = $this->input->post('perpage', true);
  257. $sku = $this->input->post('sku', true);
  258. $number = $this->input->post('number', true);
  259. $warehouse = $this->input->post('warehouse', true);
  260. $purchase = $this->input->post('purchase', true);
  261. $orderinfo = $this->input->post('orderinfo', true);
  262. $waybill = $this->input->post('waybill', true);
  263. $category = $this->input->post('category', true);
  264. $size = $this->input->post('size', true);
  265. $grade = $this->input->post('grade', true);
  266. $color = $this->input->post('color', true);
  267. $lowe = $this->input->post('lowe', true);
  268. $state = $this->input->post('state', true);
  269. $label = $this->input->post('label', true);
  270. $timetk = $this->input->post('timetkk', true);
  271. $timetj = $this->input->post('timetjj', true);
  272. $timetk = strtotime($timetk);
  273. $timetj = strtotime($timetj);
  274. $where = "1=1 ";
  275. if ($timetk && $timetj) {
  276. $where .= " and time > '$timetk' and time < '$timetj'";
  277. }
  278. if ($sku) {
  279. $where .= " and sku = '$sku'";
  280. }
  281. if ($number) {
  282. $where .= " and number = '$number'";
  283. }
  284. if ($warehouse) {
  285. $where .= " and warehouse = '$warehouse'";
  286. }
  287. if ($purchase) {
  288. $where .= " and purchase = '$purchase'";
  289. }
  290. if ($orderinfo) {
  291. $where .= " and orderinfo = '$orderinfo'";
  292. }
  293. if ($waybill) {
  294. $where .= " and waybill = '$waybill'";
  295. }
  296. if ($category) {
  297. $where .= " and features like '%-$category-%'";
  298. }
  299. if ($size) {
  300. $where .= " and features like '%-$size-%'";
  301. }
  302. if ($grade) {
  303. $where .= " and features like '%-$grade-%'";
  304. }
  305. if ($color) {
  306. $where .= " and features like '%-$color-%'";
  307. }
  308. if ($lowe) {
  309. $where .= " and features like '%-$lowe-%'";
  310. }
  311. if ($label) {
  312. $where .= " and label = '$label'";
  313. }
  314. if ($state != '') {
  315. $where .= " and state = '$state'";
  316. }
  317. //数据排序
  318. $order_str = "time desc";
  319. if (empty($page)) {
  320. $start = 0;
  321. $perpage = 1;
  322. } else {
  323. $start = ($page - 1) * $perpage;
  324. }
  325. //取得信息列表
  326. $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);
  327. foreach ($info_list as $key => $value) {
  328. $warehouse = $this->warehouse->read($value['warehouse']);
  329. $info_list[$key]['warehouse'] = $warehouse['title'];
  330. $purchase = $this->purchase->read($value['purchase']);
  331. $info_list[$key]['purchase'] = $purchase['title'];
  332. if ($value['enter'] != 0) {
  333. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  334. } else {
  335. $info_list[$key]['enter'] = "";
  336. }
  337. if ($value['outk'] != 0) {
  338. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  339. } else {
  340. $info_list[$key]['outk'] = "";
  341. }
  342. if ($value['printing'] != 0) {
  343. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  344. } else {
  345. $info_list[$key]['printing'] = "";
  346. }
  347. if ($value['orderinfo'] == 0) {
  348. $info_list[$key]['orderinfo'] = "";
  349. }
  350. if ($value['waybill'] == 0) {
  351. $info_list[$key]['waybill'] = "";
  352. }
  353. if ($value['state'] == 0) {
  354. $info_list[$key]['state'] = "在库";
  355. } else if ($value['state'] == 1) {
  356. $info_list[$key]['state'] = "出库";
  357. } else if ($value['state'] == 2) {
  358. $info_list[$key]['state'] = "退库";
  359. } else if ($value['state'] == 3) {
  360. $info_list[$key]['state'] = "调拨中";
  361. } else if ($value['state'] == 4) {
  362. $info_list[$key]['state'] = "再加工";
  363. } else if ($value['state'] == 5) {
  364. $info_list[$key]['state'] = "维修中";
  365. } else if ($value['state'] == 6) {
  366. $info_list[$key]['state'] = "盘亏";
  367. } else if ($value['state'] == 7) {
  368. $info_list[$key]['state'] = "更换标签";
  369. } else if ($value['state'] == 8) {
  370. $info_list[$key]['state'] = "其它";
  371. } else if ($value['state'] == 9) {
  372. $info_list[$key]['state'] = "预设";
  373. } else if ($value['state'] == 10) {
  374. $info_list[$key]['state'] = "美店零售";
  375. }
  376. if ($value['text'] == "") {
  377. $info_list[$key]['text'] = "";
  378. }
  379. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  380. }
  381. $total = $this->whlabel->find_count($where);
  382. $pagenum = ceil($total / $perpage);
  383. $over = $total - ($start + $perpage);
  384. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  385. echo json_encode($rows);
  386. exit;
  387. }
  388. if (isset($post['outsku'])) {
  389. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  390. $cz = $this->input->post('cz', true);
  391. if ($cz == '1') {
  392. $sku = $this->input->post('outsku', true);
  393. if ($sku) {
  394. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  395. if (count($data) < 1) {
  396. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  397. exit;
  398. }
  399. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  400. echo json_encode(array('success' => true));
  401. exit;
  402. }
  403. } else {
  404. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  405. exit;
  406. $sku = $this->input->post('outsku', true);
  407. if ($sku) {
  408. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  409. if (count($data) < 1) {
  410. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  411. exit;
  412. }
  413. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  414. echo json_encode(array('success' => true));
  415. exit;
  416. }
  417. }
  418. }
  419. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  420. $this->_Template('whlabel', $this->data);
  421. }
  422. //在库标签
  423. public function _existence()
  424. {
  425. $post = $this->input->post(NULL, TRUE);
  426. if (isset($post['s'])) {
  427. $id_arr = $this->input->post('s');
  428. $id_arr = explode(',', $id_arr);
  429. if (!$id_arr) {
  430. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  431. exit;
  432. }
  433. //循环删除记录
  434. foreach ($id_arr as $v) {
  435. $sid = $this->whlabel->read($v);
  436. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  437. if ($count > 0) {
  438. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  439. exit;
  440. }
  441. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  442. if (count($zt) > 0) {
  443. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  444. exit;
  445. }
  446. $this->whlabel->remove($v);
  447. }
  448. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  449. exit;
  450. }
  451. if (isset($post['page'])) {
  452. $page = $this->input->post('page', true);
  453. $perpage = $this->input->post('perpage', true);
  454. $warehouse = $this->input->post('warehouse', true);
  455. $label = $this->input->post('label', true);
  456. $where = "1=1 and state = 0";
  457. if ($warehouse) {
  458. $where .= " and warehouse = '$warehouse'";
  459. }
  460. if ($label) {
  461. $where .= " and label = '$label'";
  462. }
  463. //数据排序
  464. $order_str = "time asc";
  465. if (empty($page)) {
  466. $start = 0;
  467. $perpage = 1;
  468. } else {
  469. $start = ($page - 1) * $perpage;
  470. }
  471. //取得信息列表
  472. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  473. foreach ($info_list as $key => $value) {
  474. if ($value['enter'] != 0) {
  475. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  476. } else {
  477. $info_list[$key]['enter'] = "";
  478. }
  479. if ($value['printing'] != 0) {
  480. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  481. } else {
  482. $info_list[$key]['printing'] = "";
  483. }
  484. }
  485. $total = $this->whlabel->find_count($where);
  486. $pagenum = ceil($total / $perpage);
  487. $over = $total - ($start + $perpage);
  488. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  489. echo json_encode($rows);
  490. exit;
  491. }
  492. $this->_Template('whlabel_existence', $this->data);
  493. }
  494. //进销存浏览
  495. public function _typedy($arg_array)
  496. {
  497. $prc = array();
  498. $purchase = $this->purchase->find_all();
  499. foreach ($purchase as $k => $v) {
  500. $prc[$v['id']] = $v['title'];
  501. }
  502. $post = $this->input->post(NULL, TRUE);
  503. if (isset($post['page'])) {
  504. $page = $this->input->post('page', true);
  505. $perpage = $this->input->post('perpage', true);
  506. $category = $this->input->post('category', true);
  507. $size = $this->input->post('size', true);
  508. $grade = $this->input->post('grade', true);
  509. $color = $this->input->post('color', true);
  510. $lowe = $this->input->post('lowe', true);
  511. $sku = $this->input->post('sku');
  512. $title = $this->input->post('title');
  513. $warehouse = $this->input->post('warehouse', true);
  514. $usa = $this->input->post('usa', true);
  515. $purchase = $this->input->post('purchase', true);
  516. $lacetype = $this->input->post('lacetype', true);
  517. $haircap = $this->input->post('haircap', true);
  518. $density = $this->input->post('density', true);
  519. $details = $this->input->post('details', true);
  520. $state = $this->input->post('state', true);
  521. $lacecolor = $this->input->post('lacecolor', true);
  522. $hairnumber = $this->input->post('hairnumber', true);
  523. $cklx = $this->input->post('cklx', true);
  524. $ktime = $this->input->post('ktime', true);
  525. $jtime = $this->input->post('jtime', true);
  526. $sm = $this->input->post('sm', true);
  527. $cpbz = $this->input->post('cpbz', true);
  528. $type = $this->input->post('type', true);
  529. $ktime = strtotime($ktime);
  530. $jtime = strtotime($jtime);
  531. $where = "1=1";
  532. $gj = "";
  533. $ck = "";
  534. if ($usa) {
  535. if (!$warehouse) {
  536. $where .= " and (warehouse = '5' or warehouse = '8')";
  537. }
  538. }
  539. if ($warehouse) {
  540. $where .= " and warehouse = '$warehouse'";
  541. }
  542. if ($details) {
  543. $where .= " and details = '$details'";
  544. }
  545. if ($purchase) {
  546. $where .= " and purchase = '$purchase'";
  547. }
  548. if (isset($state)) {
  549. if($state >-1){
  550. $where .= " and state = '$state'";
  551. }
  552. }
  553. if ($lacetype) {
  554. $where .= " and features like '%-$lacetype-%'";
  555. }
  556. if ($category) {
  557. $where .= " and features like '%-$category-%'";
  558. }
  559. if ($size) {
  560. $where .= " and features like '%-$size-%'";
  561. }
  562. if ($grade) {
  563. $where .= " and features like '%-$grade-%'";
  564. }
  565. if ($color) {
  566. $where .= " and features like '%-$color-%'";
  567. }
  568. if ($lowe) {
  569. $where .= " and features like '%-$lowe-%'";
  570. }
  571. if ($haircap) {
  572. $where .= " and features like '%-$haircap-%'";
  573. }
  574. if ($density) {
  575. $where .= " and features like '%-$density-%'";
  576. }
  577. if ($lacecolor) {
  578. $where .= " and features like '%-$lacecolor-%'";
  579. }
  580. if($sm){
  581. $where .= " and sm like '%".$sm."%'";
  582. }
  583. if($cpbz){
  584. $where .= " and cpbz like '%".$cpbz."%'";
  585. }
  586. if($type){
  587. $where .= " and type = ".$type."";
  588. }
  589. if (!empty($hairnumber)) {
  590. $where .= " and features like '%-128-%' ";
  591. if ($hairnumber < 0) {
  592. $class_list = $this->typeclass->find_all('classid = 43');
  593. foreach ($class_list as $v) {
  594. $where .= " and features not like '%-" . $v['id'] . "-%'";
  595. }
  596. } else {
  597. $where .= " and features like '%-$hairnumber-%'";
  598. }
  599. }
  600. $where_add = '';
  601. if ($cklx) {
  602. $shop = $this->shop->read($cklx);
  603. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  604. }
  605. if ($ktime && $jtime) {
  606. $gj = " and enter > '$ktime' and enter < '$jtime'";
  607. $ck = " and outk > '$ktime' and outk < '$jtime'";
  608. }
  609. //数据排序
  610. $order_str = "id desc";
  611. if (empty($page)) {
  612. $start = 0;
  613. $perpage = 1;
  614. } else {
  615. $start = ($page - 1) * $perpage;
  616. }
  617. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  618. if ($sku) {
  619. $sku = trim($sku, ' ');
  620. $sku = trim($sku, ' ');
  621. $where .= " and sku like '%$sku%'";
  622. $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);
  623. } else if ($title) {
  624. $title = trim($title, ' ');
  625. $title = trim($title, ' ');
  626. $where .= " and title like '%$title%'";
  627. $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);
  628. } else {
  629. //$where .= " and time > '$ktime' and time < '$jtime'";
  630. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  631. }
  632. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  633. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  634. foreach ($info_list as $k => $v) {
  635. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  636. unset($info_list[$k]['pm']);
  637. unset($info_list[$k]['jm']);
  638. unset($info_list[$k]['bm']);
  639. }
  640. //取得信息列表
  641. $rows = array();
  642. $list = array();
  643. foreach ($info_list as $key => $value) {
  644. $warehouse = $this->warehouse->read($value['warehouse']);
  645. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  646. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  647. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  648. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  649. $info_list[$key]['label'] = $value['sm'];
  650. $number = $value['number'];
  651. $ftime = time() - 15 * 24 * 3600;
  652. $info_list[$key]['warehouse'] = $warehouse['title'];
  653. $info_list[$key]['features'] = count($c);
  654. $z = count($z); //查看订单号
  655. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  656. $ztdata = '';
  657. if (count($zt) > 0) {
  658. foreach ($zt as $vv) {
  659. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  660. }
  661. }
  662. $info_list[$key]['number'] = $ztdata;
  663. $info_list[$key]['sm'] = $z;
  664. $details = array();
  665. $cpid = array();
  666. foreach ($c as $k => $v) {
  667. $details[$v['details']] = $v['details'];
  668. if ($v['cpid'] != 0) {
  669. $cpid[$v['cpid']] = $v['cpid'];
  670. }
  671. }
  672. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  673. if ($value['shop'] != '') {
  674. $shop = explode(',', trim($value['shop'], ','));
  675. $shop = $this->shop->read($shop[0]);
  676. $info_list[$key]['shop'] = $shop['shopname'];
  677. }
  678. }
  679. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  680. $pagenum = ceil($total / $perpage);
  681. $over = $total - ($start + $perpage);
  682. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  683. echo json_encode($rows);
  684. exit;
  685. }
  686. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  687. $this->_Template('whlabel_typedy', $this->data);
  688. }
  689. //进销存浏览
  690. public function _typedy_ck($arg_array)
  691. {
  692. $prc = array();
  693. $purchase = $this->purchase->find_all();
  694. foreach ($purchase as $k => $v) {
  695. $prc[$v['id']] = $v['title'];
  696. }
  697. $post = $this->input->post(NULL, TRUE);
  698. if (isset($post['page'])) {
  699. $page = $this->input->post('page', true);
  700. $perpage = $this->input->post('perpage', true);
  701. $category = $this->input->post('category', true);
  702. $size = $this->input->post('size', true);
  703. $grade = $this->input->post('grade', true);
  704. $color = $this->input->post('color', true);
  705. $lowe = $this->input->post('lowe', true);
  706. $sku = $this->input->post('sku');
  707. $title = $this->input->post('title');
  708. $warehouse = $this->input->post('warehouse', true);
  709. $usa = $this->input->post('usa', true);
  710. $purchase = $this->input->post('purchase', true);
  711. $lacetype = $this->input->post('lacetype', true);
  712. $haircap = $this->input->post('haircap', true);
  713. $density = $this->input->post('density', true);
  714. $details = $this->input->post('details', true);
  715. $state = $this->input->post('state', true);
  716. $lacecolor = $this->input->post('lacecolor', true);
  717. $cklx = $this->input->post('cklx', true);
  718. $ktime = $this->input->post('ktime', true);
  719. $jtime = $this->input->post('jtime', true);
  720. $ktime = strtotime($ktime);
  721. $jtime = strtotime($jtime);
  722. $where = "1=1";
  723. $gj = "";
  724. $ck = "";
  725. if ($lacetype) {
  726. $where .= " and features like '%-$lacetype-%'";
  727. }
  728. if ($category) {
  729. $where .= " and features like '%-$category-%'";
  730. }
  731. if ($size) {
  732. $where .= " and features like '%-$size-%'";
  733. }
  734. if ($grade) {
  735. $where .= " and features like '%-$grade-%'";
  736. }
  737. if ($color) {
  738. $where .= " and features like '%-$color-%'";
  739. }
  740. if ($lowe) {
  741. $where .= " and features like '%-$lowe-%'";
  742. }
  743. if ($haircap) {
  744. $where .= " and features like '%-$haircap-%'";
  745. }
  746. if ($density) {
  747. $where .= " and features like '%-$density-%'";
  748. }
  749. if ($lacecolor) {
  750. $where .= " and features like '%-$lacecolor-%'";
  751. }
  752. if ($usa) {
  753. if (!$warehouse) {
  754. $where .= " and (warehouse = '5' or warehouse = '8')";
  755. }
  756. }
  757. if ($warehouse) {
  758. $where .= " and warehouse = '$warehouse'";
  759. }
  760. if ($details) {
  761. $where .= " and details = '$details'";
  762. }
  763. if ($purchase) {
  764. $where .= " and purchase = '$purchase'";
  765. }
  766. if ($state) {
  767. $where .= " and state = '$state'";
  768. }
  769. $where_add = '';
  770. if ($cklx) {
  771. $shop = $this->shop->read($cklx);
  772. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  773. }
  774. if ($ktime && $jtime) {
  775. $gj = " and enter > '$ktime' and enter < '$jtime'";
  776. $ck = " and outk > '$ktime' and outk < '$jtime'";
  777. }
  778. //数据排序
  779. $order_str = "id desc";
  780. if (empty($page)) {
  781. $start = 0;
  782. $perpage = 1;
  783. } else {
  784. $start = ($page - 1) * $perpage;
  785. }
  786. if ($sku) {
  787. $sku = trim($sku, ' ');
  788. $sku = trim($sku, ' ');
  789. $where .= " and sku like '%$sku%'";
  790. $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);
  791. } else if ($title) {
  792. $title = trim($title, ' ');
  793. $title = trim($title, ' ');
  794. $where .= " and title like '%$title%'";
  795. $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);
  796. } else {
  797. //$where .= " and time > '$ktime' and time < '$jtime'";
  798. $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);
  799. }
  800. //取得信息列表
  801. $rows = array();
  802. $list = array();
  803. foreach ($info_list as $key => $value) {
  804. $warehouse = $this->warehouse->read($value['warehouse']);
  805. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  806. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  807. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  808. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  809. $ftime = time() - 15 * 24 * 3600;
  810. $info_list[$key]['warehouse'] = $warehouse['title'];
  811. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  812. //$z = count($z);//查看订单号
  813. //$info_list[$key]['zd'] = $z;
  814. $details = array();
  815. $cpid = array();
  816. foreach ($c as $k => $v) {
  817. $details[$v['details']] = $v['details'];
  818. if ($v['cpid'] != 0) {
  819. $cpid[$v['cpid']] = $v['cpid'];
  820. }
  821. }
  822. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  823. if ($value['shop'] != '') {
  824. $shop = explode(',', trim($value['shop'], ','));
  825. $shop = $this->shop->read($shop[0]);
  826. $info_list[$key]['shop'] = $shop['shopname'];
  827. }
  828. }
  829. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  830. $pagenum = ceil($total / $perpage);
  831. $over = $total - ($start + $perpage);
  832. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  833. echo json_encode($rows);
  834. exit;
  835. }
  836. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  837. $this->_Template('whlabel_typedy_ck', $this->data);
  838. }
  839. public function _typeck($arg_array)
  840. {
  841. $prc = array();
  842. $purchase = $this->purchase->find_all();
  843. foreach ($purchase as $k => $v) {
  844. $prc[$v['id']] = $v['title'];
  845. }
  846. $post = $this->input->post(NULL, TRUE);
  847. if (isset($post['page'])) {
  848. $page = $this->input->post('page', true);
  849. $perpage = $this->input->post('perpage', true);
  850. $category = $this->input->post('category', true);
  851. $size = $this->input->post('size', true);
  852. $grade = $this->input->post('grade', true);
  853. $color = $this->input->post('color', true);
  854. $lacecolor = $this->input->post('lacecolor', true);
  855. $lowe = $this->input->post('lowe', true);
  856. $sku = $this->input->post('sku');
  857. $title = $this->input->post('title');
  858. $warehouse = 13;
  859. $usa = $this->input->post('usa', true);
  860. $purchase = $this->input->post('purchase', true);
  861. $lacetype = $this->input->post('lacetype', true);
  862. $haircap = $this->input->post('haircap', true);
  863. $density = $this->input->post('density', true);
  864. $details = $this->input->post('details', true);
  865. $state = $this->input->post('state', true);
  866. $ktime = $this->input->post('ktime', true);
  867. $jtime = $this->input->post('jtime', true);
  868. $ktime = strtotime($ktime);
  869. $jtime = strtotime($jtime);
  870. $where = "1=1";
  871. $gj = "";
  872. $ck = "";
  873. if ($lacetype) {
  874. $where .= " and features like '%-$lacetype-%'";
  875. }
  876. if ($category) {
  877. $where .= " and features like '%-$category-%'";
  878. }
  879. if ($size) {
  880. $where .= " and features like '%-$size-%'";
  881. }
  882. if ($grade) {
  883. $where .= " and features like '%-$grade-%'";
  884. }
  885. if ($color) {
  886. $where .= " and features like '%-$color-%'";
  887. }
  888. if ($lacecolor) {
  889. $where .= " and features like '%-$lacecolor-%'";
  890. }
  891. if ($lowe) {
  892. $where .= " and features like '%-$lowe-%'";
  893. }
  894. if ($haircap) {
  895. $where .= " and features like '%-$haircap-%'";
  896. }
  897. if ($density) {
  898. $where .= " and features like '%-$density-%'";
  899. }
  900. if ($warehouse) {
  901. $where .= " and warehouse = '$warehouse'";
  902. }
  903. if ($details) {
  904. $where .= " and details = '$details'";
  905. }
  906. if ($purchase) {
  907. $where .= " and purchase = '$purchase'";
  908. }
  909. if ($state) {
  910. $where .= " and state = '$state'";
  911. }
  912. if ($ktime && $jtime) {
  913. $gj = " and enter > '$ktime' and enter < '$jtime'";
  914. $ck = " and outk > '$ktime' and outk < '$jtime'";
  915. }
  916. //数据排序
  917. $order_str = "id desc";
  918. if (empty($page)) {
  919. $start = 0;
  920. $perpage = 1;
  921. } else {
  922. $start = ($page - 1) * $perpage;
  923. }
  924. if ($sku) {
  925. $sku = trim($sku, ' ');
  926. $sku = trim($sku, ' ');
  927. $where .= " and sku like '%$sku%'";
  928. } else if ($title) {
  929. $title = trim($title, ' ');
  930. $title = trim($title, ' ');
  931. $where .= " and title like '%$title%'";
  932. }
  933. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  934. //取得信息列表
  935. $t = array();
  936. $typeclass = $this->typeclass->find_all();
  937. foreach ($typeclass as $v) {
  938. $t[$v['id']] = $v;
  939. }
  940. $rows = array();
  941. $list = array();
  942. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  943. foreach ($info_list as $key => $value) {
  944. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  945. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  946. $warehouse = $this->warehouse->read($value['warehouse']);
  947. $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');
  948. $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'] . '"');
  949. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  950. $number = $value['number'];
  951. $ftime = time() - 15 * 24 * 3600;
  952. $z = count($z); //查看订单号
  953. $info_list[$key]['warehouse'] = $warehouse['title'];
  954. $info_list[$key]['features'] = count($c);
  955. $info_list[$key]['number'] = $z;
  956. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  957. $details = array();
  958. $cpid = array();
  959. foreach ($c as $k => $v) {
  960. $details[$v['details']] = $v['details'];
  961. if ($v['cpid'] != 0) {
  962. $cpid[$v['cpid']] = $v['cpid'];
  963. }
  964. }
  965. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  966. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  967. unset($info_list[$key]['pm']);
  968. unset($info_list[$key]['jm']);
  969. unset($info_list[$key]['bm']);
  970. }
  971. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  972. $pagenum = ceil($total / $perpage);
  973. $over = $total - ($start + $perpage);
  974. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  975. echo json_encode($rows);
  976. exit;
  977. }
  978. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  979. $this->_Template('whlabel_typeck', $this->data);
  980. }
  981. //进销存导出
  982. public function _whlabeckdc()
  983. {
  984. $prc = array();
  985. $purchase = $this->purchase->find_all();
  986. foreach ($purchase as $k => $v) {
  987. $prc[$v['id']] = $v['title'];
  988. }
  989. if (isset($_GET['excel'])) {
  990. $where = "sku != 'Preset'";
  991. //数据排序
  992. $order_str = "id desc";
  993. if (empty($page)) {
  994. $start = 0;
  995. $perpage = 1;
  996. } else {
  997. $start = ($page - 1) * $perpage;
  998. }
  999. $category = $this->input->get('category', true);
  1000. $color = $this->input->get('color', true);
  1001. $lowe = $this->input->get('lowe', true);
  1002. $lacetype = $this->input->get('lacetype', true);
  1003. $size = $this->input->get('size', true);
  1004. $density = $this->input->get('density', true);
  1005. $haircap = $this->input->get('haircap', true);
  1006. $sku = $this->input->get('sku', true);
  1007. $details = $this->input->get('details', true);
  1008. $warehouse = 13;
  1009. $excelid = $this->input->get('sid', true);
  1010. if ($category) {
  1011. $where .= " and features like '%-$category-%'";
  1012. }
  1013. if ($color) {
  1014. $where .= " and features like '%-$color-%'";
  1015. }
  1016. if ($lowe) {
  1017. $where .= " and features like '%-$lowe-%'";
  1018. }
  1019. if ($lacetype) {
  1020. $where .= " and features like '%-$lacetype-%'";
  1021. }
  1022. if ($size) {
  1023. $where .= " and features like '%-$size-%'";
  1024. }
  1025. if ($density) {
  1026. $where .= " and features like '%-$density-%'";
  1027. }
  1028. if ($haircap) {
  1029. $where .= " and features like '%-$haircap-%'";
  1030. }
  1031. if ($warehouse) {
  1032. $where .= " and warehouse = '$warehouse'";
  1033. }
  1034. if ($sku) {
  1035. $where .= " and sku like '%$sku%'";
  1036. }
  1037. if ($details) {
  1038. $where .= " and details = '$details'";
  1039. }
  1040. $xzid = '';
  1041. if ($excelid) {
  1042. $excelid = explode(',', trim($excelid, ','));
  1043. foreach ($excelid as $key => $value) {
  1044. $xzid .= " id = " . $value . " or";
  1045. }
  1046. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1047. }
  1048. //取得信息列表
  1049. /**
  1050. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1051. $rows = array();$list = array();
  1052. foreach ($info_list as $key=>$value)
  1053. {
  1054. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1055. }
  1056. **/
  1057. $wh = array();
  1058. $w = $this->warehouse->find_all('1=1', 'id,title');
  1059. foreach ($w as $v) {
  1060. $wh[$v['id']] = $v['title'];
  1061. }
  1062. $tc = array();
  1063. $tcdata = array();
  1064. $list = array();
  1065. $classid = $this->classid->sku();
  1066. $tcall = $this->typeclass->find_all();
  1067. $typeclass = array();
  1068. foreach ($tcall as $v)
  1069. {
  1070. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1071. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1072. }
  1073. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1074. foreach ($rows as $key => $value) {
  1075. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1076. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1077. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1078. $rows[$key]['cpbz'] = $u9_info['bm'];
  1079. $rows[$key]['cs'] = $u9_info['jm'];
  1080. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1081. $details = array();
  1082. $cpid = array();
  1083. $cpbz = array();
  1084. $c = 0;
  1085. $g = 0;
  1086. $x = 0;
  1087. $t = 0;
  1088. $s = 0;
  1089. $q = 0;
  1090. foreach ($sd as $k => $v) {
  1091. if ($v['state'] == 0) {
  1092. $c++;
  1093. }
  1094. if ($v['state'] != 9) {
  1095. $g++;
  1096. }
  1097. if ($v['state'] == 1) {
  1098. $x++;
  1099. }
  1100. if ($v['state'] == 2) {
  1101. $t++;
  1102. }
  1103. if ($v['state'] == 8) {
  1104. $s++;
  1105. }
  1106. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1107. $q++;
  1108. }
  1109. $details[$v['details']] = $v['details'];
  1110. if ($v['cpid'] != 0) {
  1111. $cpid[$v['cpid']] = $v['cpid'];
  1112. }
  1113. if ($v['cpbz'] != '') {
  1114. $cpbz[$v['cpbz']] = $v['cpbz'];
  1115. }
  1116. }
  1117. $rows[$key]['details'] = implode("、", $details);
  1118. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1119. $number = $value['number'];
  1120. $ftime = time() - 15 * 24 * 3600;
  1121. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1122. $rows[$key]['number'] = $g;
  1123. $rows[$key]['features'] = $c;
  1124. $rows[$key]['x'] = $x;
  1125. $rows[$key]['t'] = $t;
  1126. $rows[$key]['s'] = $s;
  1127. $rows[$key]['q'] = $q;
  1128. $rows[$key]['wzsl'] = count($details);
  1129. }
  1130. $title = "进销存统计表" . date('Y-m-d', time());
  1131. $titlename = "<table border=1>
  1132. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1133. <tr align='center'>
  1134. <td>仓库</td>
  1135. <td>供应商</td>
  1136. <td>位置</td>
  1137. <td>库存编码</td>
  1138. <td>SKU</td>
  1139. <td>用友编码</td>
  1140. <td>用友料号</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. </tr>
  1151. </table>";
  1152. $filename = $title . ".xls";
  1153. $tail = "";
  1154. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1155. }
  1156. }
  1157. public function _type()
  1158. {
  1159. $vip = 0;
  1160. if (isset($_SESSION['api'])) {
  1161. $user = $this->user->get_api($_SESSION['api']);
  1162. $fgshop = "";
  1163. $sid = "";
  1164. $usersp = explode('|', trim($user['shop'], '|'));
  1165. foreach ($usersp as $value) {
  1166. $fgshop .= " shop = " . $value . " or";
  1167. $sid .= " id = " . $value . " or";
  1168. }
  1169. if ($user['vip'] == 1) {
  1170. $vip = 1;
  1171. }
  1172. } else {
  1173. header('Location: /');
  1174. exit;
  1175. }
  1176. $prc = array();
  1177. $purchase = $this->purchase->find_all();
  1178. foreach ($purchase as $k => $v) {
  1179. $prc[$v['id']] = $v['title'];
  1180. }
  1181. $company = array();
  1182. $ct = $this->company->find_all();
  1183. foreach ($ct as $k => $v) {
  1184. $company[$v['id']] = $v['title'];
  1185. }
  1186. $sp = array();
  1187. $s = $this->shop->find_all('1=1', 'id,shopname');
  1188. foreach ($s as $v) {
  1189. $sp[$v['id']] = $v['shopname'];
  1190. }
  1191. $wh = array();
  1192. $w = $this->warehouse->find_all('1=1', 'id,title');
  1193. foreach ($w as $v) {
  1194. $wh[$v['id']] = $v['title'];
  1195. }
  1196. $post = $this->input->post(NULL, TRUE);
  1197. if (isset($post['page'])) {
  1198. $page = $this->input->post('page', true);
  1199. $perpage = $this->input->post('perpage', true);
  1200. $category = $this->input->post('category', true);
  1201. $size = $this->input->post('size', true);
  1202. $grade = $this->input->post('grade', true);
  1203. $color = $this->input->post('color', true);
  1204. $lowe = $this->input->post('lowe', true);
  1205. $sku = $this->input->post('sku');
  1206. $title = $this->input->post('title');
  1207. $warehouse = $this->input->post('warehouse', true);
  1208. $usa = $this->input->post('usa', true);
  1209. $purchase = $this->input->post('purchase', true);
  1210. $lacetype = $this->input->post('lacetype', true);
  1211. $haircap = $this->input->post('haircap', true);
  1212. $density = $this->input->post('density', true);
  1213. $details = $this->input->post('details', true);
  1214. $state = $this->input->post('state', true);
  1215. $shop = $this->input->post('shop', true);
  1216. $lacecolor = $this->input->post('lacecolor', true);
  1217. $hairnumber = $this->input->post('hairnumber', true);
  1218. $type = $this->input->post('type', true);
  1219. $ktime = $this->input->post('ktime', true);
  1220. $jtime = $this->input->post('jtime', true);
  1221. $ktime = strtotime($ktime);
  1222. $jtime = strtotime($jtime);
  1223. $cpbz = $this->input->post('cpbz', true);
  1224. $sm = $this->input->post('sm', true);
  1225. $where = "1=1";
  1226. $gj = "";
  1227. $ck = "";
  1228. if ($usa) {
  1229. if (!$warehouse) {
  1230. $where .= " and (warehouse = '5' or warehouse = '8')";
  1231. }
  1232. }
  1233. if ($warehouse) {
  1234. $where .= " and warehouse = '$warehouse'";
  1235. }
  1236. if ($details) {
  1237. $where .= " and details = '$details'";
  1238. }
  1239. if ($purchase) {
  1240. $where .= " and purchase = '$purchase'";
  1241. }
  1242. if ($state) {
  1243. $where .= " and state = '$state'";
  1244. }
  1245. if ($shop) {
  1246. $where .= " and shop like '%$shop%'";
  1247. }
  1248. if ($type) {
  1249. $where .= " and type = '$type'";
  1250. }
  1251. if ($ktime && $jtime) {
  1252. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1253. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1254. }
  1255. if ($cpbz) {
  1256. $where .= " and cpbz like '%$cpbz%' ";
  1257. }
  1258. if ($sm) {
  1259. $where .= " and sm like '%$sm%' ";
  1260. }
  1261. if ($lacecolor) {
  1262. $where .= " and features like '%-$lacecolor-%'";
  1263. }
  1264. if ($lacetype) {
  1265. $where .= " and features like '%-$lacetype-%'";
  1266. }
  1267. if ($category) {
  1268. $where .= " and features like '%-$category-%'";
  1269. }
  1270. if ($size) {
  1271. $where .= " and features like '%-$size-%'";
  1272. }
  1273. if ($grade) {
  1274. $where .= " and features like '%-$grade-%'";
  1275. }
  1276. if ($color) {
  1277. $where .= " and features like '%-$color-%'";
  1278. }
  1279. if ($lowe) {
  1280. $where .= " and features like '%-$lowe-%'";
  1281. }
  1282. if ($haircap) {
  1283. $where .= " and features like '%-$haircap-%'";
  1284. }
  1285. if ($density) {
  1286. $where .= " and features like '%-$density-%'";
  1287. }
  1288. if (!empty($hairnumber)) {
  1289. $where .= " and features like '%-128-%' ";
  1290. if ($hairnumber < 0) {
  1291. $class_list = $this->typeclass->find_all('classid = 43');
  1292. foreach ($class_list as $v) {
  1293. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1294. }
  1295. } else {
  1296. $where .= " and features like '%-$hairnumber-%'";
  1297. }
  1298. }
  1299. //数据排序
  1300. $order_str = "id desc";
  1301. if (empty($page)) {
  1302. $start = 0;
  1303. $perpage = 1;
  1304. } else {
  1305. $start = ($page - 1) * $perpage;
  1306. }
  1307. $fjnr = '';
  1308. if ($sku) {
  1309. $sku = trim($sku, ' ');
  1310. $sku = trim($sku, ' ');
  1311. $fjnr .= " and sku like '%$sku%'";
  1312. }
  1313. if ($title) {
  1314. $title = trim($title, ' ');
  1315. $title = trim($title, ' ');
  1316. $fjnr .= " and title like '%$title%'";
  1317. }
  1318. $wt = array();
  1319. $whlabel_type = $this->whlabel_type->find_all();
  1320. foreach ($whlabel_type as $v) {
  1321. $wt[$v['id']] = $v['title'];
  1322. }
  1323. //$where .= " and time > '$ktime' and time < '$jtime'";
  1324. $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
  1325. //取得信息列表
  1326. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1327. $rows = array();
  1328. $list = array();
  1329. foreach ($info_list as $key => $value) {
  1330. if (isset($wt[$value['type']])) {
  1331. $info_list[$key]['type'] = $wt[$value['type']];
  1332. } else {
  1333. $info_list[$key]['type'] = '未设置';
  1334. }
  1335. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1336. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1337. $ztdata = '';
  1338. if (count($zt) > 0) {
  1339. foreach ($zt as $vv) {
  1340. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1341. }
  1342. }
  1343. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1344. $cdata = array_filter($qbdata, function ($item) {
  1345. return $item['state'] < 1;
  1346. });
  1347. $c = array_sum(array_column($cdata, 'jnum'));
  1348. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1349. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1350. });
  1351. $g = array_sum(array_column($gdata, 'jnum'));
  1352. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1353. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1354. });
  1355. $x = array_sum(array_column($xdata, 'jnum'));
  1356. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1357. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1358. });
  1359. $t = array_sum(array_column($tdata, 'jnum'));
  1360. // $zdata = array_filter($qbdata, function ($item) {
  1361. // return $item['zd'] != "" && $item['state'] < 1;
  1362. // });
  1363. // $z = array_sum(array_column($zdata, 'jnum'));
  1364. $zdata = array_filter($qbdata, function ($item) {
  1365. return $item['zd'] != "" && $item['state'] < 1;
  1366. });
  1367. $z = array_sum(array_column($zdata, 'jnum'));
  1368. //$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');
  1369. //$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'].'"');
  1370. //$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'].'"');
  1371. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1372. //$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'].'"');
  1373. $details = array();
  1374. $cpid = array();
  1375. $od = array();
  1376. $odid = '';
  1377. $companytitle = '';
  1378. $shop_list = [];
  1379. foreach ($qbdata as $v) {
  1380. if ($v['zd'] != "" && $v['state'] < 1) {
  1381. if (!isset($od[$v['zd']])) {
  1382. $od[$v['zd']] = 1; //所有数据sku
  1383. } else {
  1384. $od[$v['zd']] = $od[$v['zd']] + 1;
  1385. }
  1386. }
  1387. if ($v['state'] < 1) {
  1388. $details[$v['details']] = $v['details'];
  1389. if ($v['cpid'] != 0) {
  1390. $cpid[$v['cpid']] = $v['cpid'];
  1391. }
  1392. }
  1393. if($v['state'] == 0){
  1394. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1395. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1396. }
  1397. if ($v['shop'] != '') {
  1398. $shop = explode(',', trim($v['shop'], ','));
  1399. foreach ($shop as $vv) {
  1400. if (!in_array($vv, $shop_list)) {
  1401. $shop_list[] = $vv;
  1402. }
  1403. }
  1404. }
  1405. }
  1406. }
  1407. foreach ($od as $k => $vv) {
  1408. $odid .= $k . '数量' . $vv;
  1409. }
  1410. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1411. $info_list[$key]['label'] = $value['sm'];
  1412. $number = $value['number'];
  1413. $ftime = time() - 15 * 24 * 3600;
  1414. $z = $z . '(' . $odid . ')'; //查看订单号
  1415. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1416. $info_list[$key]['features'] = $c;
  1417. $info_list[$key]['number'] = $ztdata;
  1418. $info_list[$key]['sm'] = $g;
  1419. $info_list[$key]['x'] = $x;
  1420. $info_list[$key]['t'] = $t;
  1421. $info_list[$key]['z'] = $z;
  1422. /**
  1423. foreach ($cdata as $k=>$v)
  1424. {
  1425. $details[$v['details']] = $v['details'];
  1426. if($v['cpid'] != 0)
  1427. {
  1428. $cpid[$v['cpid']] = $v['cpid'];
  1429. }
  1430. }
  1431. **/
  1432. $info_list[$key]['shop'] = '';
  1433. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1434. // if ($value['shop'] != '') {
  1435. // $shop = explode(',', trim($value['shop'], ','));
  1436. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1437. // }
  1438. $shop_list = array_unique($shop_list);
  1439. $shop_str = '';
  1440. foreach ($shop_list as $v) {
  1441. if(isset($sp[$v])){
  1442. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1443. }
  1444. }
  1445. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1446. /**
  1447. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1448. if(isset($companytitle[0]))
  1449. {
  1450. foreach ($companytitle as $k=>$v)
  1451. {
  1452. if($v['companytitle'] != '')
  1453. {
  1454. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1455. }
  1456. }
  1457. }
  1458. **/
  1459. }
  1460. $final_all_list = [];
  1461. foreach ($info_list as $k => $v) {
  1462. $final_all_list[] = [
  1463. 'id' => $v['id'],
  1464. "warehouse" => $v["warehouse"],
  1465. "purchase" => $v["purchase"],
  1466. "sku" => $v["sku"],
  1467. "title" => $v["title"] . "<br/>" . $v["pm"],
  1468. "details" => $v["details"],
  1469. "shop" => $v["shop"],
  1470. "cpbz" => $v["cpbz"],
  1471. 'label' => $v['label'],
  1472. "type" => $v["type"],
  1473. "features" => $v["features"],
  1474. "number" => $v["number"],
  1475. "sm" => $v["sm"],
  1476. "x" => $v["x"],
  1477. "t" => $v["t"],
  1478. "z" => $v["z"]
  1479. ];
  1480. }
  1481. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1482. $pagenum = ceil($total / $perpage);
  1483. $over = $total - ($start + $perpage);
  1484. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1485. echo json_encode($rows);
  1486. exit;
  1487. }
  1488. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1489. $this->data['shop'] = $wlshop;
  1490. $this->data['vip'] = $vip;
  1491. $this->_Template('whlabel_type', $this->data);
  1492. }
  1493. //美仓进销存浏览
  1494. public function _usatype()
  1495. {
  1496. if (isset($_SESSION['api'])) {
  1497. $user = $this->user->get_api($_SESSION['api']);
  1498. $usp = $user;
  1499. $fgshop = "";
  1500. $sid = "";
  1501. $wid = "";
  1502. $wtype = "";
  1503. $userwh = explode('|', trim($user['warehouse'], '|'));
  1504. foreach ($userwh as $value) {
  1505. $wid .= " id = " . $value . " or";
  1506. $wtype .= " type = " . $value . " or";
  1507. }
  1508. }
  1509. $prc = array();
  1510. $purchase = $this->purchase->find_all();
  1511. foreach ($purchase as $k => $v) {
  1512. $prc[$v['id']] = $v['title'];
  1513. }
  1514. $post = $this->input->post(NULL, TRUE);
  1515. if (isset($post['page'])) {
  1516. $page = $this->input->post('page', true);
  1517. $perpage = $this->input->post('perpage', true);
  1518. $category = $this->input->post('category', true);
  1519. $size = $this->input->post('size', true);
  1520. $grade = $this->input->post('grade', true);
  1521. $color = $this->input->post('color', true);
  1522. $lowe = $this->input->post('lowe', true);
  1523. $sku = $this->input->post('sku');
  1524. $title = $this->input->post('title');
  1525. $warehouse = $this->input->post('warehouse', true);
  1526. $usa = $this->input->post('usa', true);
  1527. $purchase = $this->input->post('purchase', true);
  1528. $lacetype = $this->input->post('lacetype', true);
  1529. $haircap = $this->input->post('haircap', true);
  1530. $density = $this->input->post('density', true);
  1531. $details = $this->input->post('details', true);
  1532. $state = $this->input->post('state', true);
  1533. $lacecolor = $this->input->post('lacecolor', true);
  1534. $cklx = $this->input->post('cklx', true);
  1535. $ktime = $this->input->post('ktime', true);
  1536. $jtime = $this->input->post('jtime', true);
  1537. $ktime = strtotime($ktime);
  1538. $jtime = strtotime($jtime);
  1539. $where = "1=1";
  1540. $gj = "";
  1541. $ck = "";
  1542. if ($lacetype) {
  1543. $where .= " and features like '%-$lacetype-%'";
  1544. }
  1545. if ($category) {
  1546. $where .= " and features like '%-$category-%'";
  1547. }
  1548. if ($size) {
  1549. $where .= " and features like '%-$size-%'";
  1550. }
  1551. if ($grade) {
  1552. $where .= " and features like '%-$grade-%'";
  1553. }
  1554. if ($color) {
  1555. $where .= " and features like '%-$color-%'";
  1556. }
  1557. if ($lowe) {
  1558. $where .= " and features like '%-$lowe-%'";
  1559. }
  1560. if ($haircap) {
  1561. $where .= " and features like '%-$haircap-%'";
  1562. }
  1563. if ($density) {
  1564. $where .= " and features like '%-$density-%'";
  1565. }
  1566. if ($lacecolor) {
  1567. $where .= " and features like '%-$lacecolor-%'";
  1568. }
  1569. if ($usa) {
  1570. if (!$warehouse) {
  1571. $where .= " and (warehouse = '5' or warehouse = '8')";
  1572. }
  1573. }
  1574. if ($warehouse) {
  1575. $where .= " and warehouse = '$warehouse'";
  1576. }
  1577. if ($details) {
  1578. $where .= " and details = '$details'";
  1579. }
  1580. if ($purchase) {
  1581. $where .= " and purchase = '$purchase'";
  1582. }
  1583. if ($state) {
  1584. $where .= " and state = '$state'";
  1585. }
  1586. $where_add = '';
  1587. if ($cklx) {
  1588. $shop = $this->shop->read($cklx);
  1589. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1590. }
  1591. if ($ktime && $jtime) {
  1592. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1593. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1594. }
  1595. //数据排序
  1596. $order_str = "id desc";
  1597. if (empty($page)) {
  1598. $start = 0;
  1599. $perpage = 1;
  1600. } else {
  1601. $start = ($page - 1) * $perpage;
  1602. }
  1603. if ($sku) {
  1604. $sku = trim($sku, ' ');
  1605. $sku = trim($sku, ' ');
  1606. $where .= " and sku like '%$sku%'";
  1607. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1608. } else if ($title) {
  1609. $title = trim($title, ' ');
  1610. $title = trim($title, ' ');
  1611. $where .= " and title like '%$title%'";
  1612. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1613. } else {
  1614. //$where .= " and time > '$ktime' and time < '$jtime'";
  1615. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1616. }
  1617. //取得信息列表
  1618. $rows = array();
  1619. $list = array();
  1620. foreach ($info_list as $key => $value) {
  1621. $warehouse = $this->warehouse->read($value['warehouse']);
  1622. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1623. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1624. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1625. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1626. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1627. $od = array();
  1628. $odid = '';
  1629. foreach ($z as $v) {
  1630. if (!isset($od[$v['zd']])) {
  1631. $od[$v['zd']] = 1; //所有数据sku
  1632. } else {
  1633. $od[$v['zd']] = $od[$v['zd']] + 1;
  1634. }
  1635. }
  1636. foreach ($od as $k => $vv) {
  1637. $odid .= $k . '数量' . $vv . ' ';
  1638. }
  1639. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1640. $info_list[$key]['features'] = $c;
  1641. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1642. $ztdata = '';
  1643. if (count($zt) > 0) {
  1644. foreach ($zt as $vv) {
  1645. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1646. }
  1647. }
  1648. $info_list[$key]['warehouse'] = $ztdata;
  1649. $info_list[$key]['g'] = $g;
  1650. $info_list[$key]['x'] = $x;
  1651. $info_list[$key]['t'] = $t;
  1652. $info_list[$key]['z'] = $z;
  1653. }
  1654. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1655. $pagenum = ceil($total / $perpage);
  1656. $over = $total - ($start + $perpage);
  1657. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1658. echo json_encode($rows);
  1659. exit;
  1660. }
  1661. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1662. $this->data['warehouse'] = $warehouse;
  1663. $this->_Template('whlabel_typeusa', $this->data);
  1664. }
  1665. //美仓进销存浏览
  1666. public function _usatypeapp()
  1667. {
  1668. $post = $this->input->post(NULL, TRUE);
  1669. if (isset($post['page'])) {
  1670. $page = $this->input->post('page', true);
  1671. $perpage = $this->input->post('perpage', true);
  1672. $sku = $this->input->post('sku', true);
  1673. $warehouse = 5;
  1674. $title = $this->input->post('title', true);
  1675. $state = $this->input->post('state', true);
  1676. $ktime = $this->input->post('ktime', true);
  1677. $jtime = $this->input->post('jtime', true);
  1678. $ktime = strtotime($ktime);
  1679. $jtime = strtotime($jtime);
  1680. $where = "1=1";
  1681. $gj = "";
  1682. $ck = "";
  1683. if ($title) {
  1684. $st = explode(' ', trim($title, ' '));
  1685. foreach ($st as $v) {
  1686. $where .= " and title like '%$v%'";
  1687. }
  1688. }
  1689. if ($warehouse) {
  1690. $where .= " and warehouse = '$warehouse'";
  1691. }
  1692. if ($state) {
  1693. $where .= " and state = '$state'";
  1694. }
  1695. if ($sku) {
  1696. $where .= " and sku like '%$sku%'";
  1697. }
  1698. if ($ktime && $jtime) {
  1699. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1700. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1701. }
  1702. //数据排序
  1703. $order_str = "id desc";
  1704. if (empty($page)) {
  1705. $start = 0;
  1706. $perpage = 1;
  1707. } else {
  1708. $start = ($page - 1) * $perpage;
  1709. }
  1710. //取得信息列表
  1711. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1712. $rows = array();
  1713. $list = array();
  1714. foreach ($info_list as $key => $value) {
  1715. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1716. }
  1717. $rowsdq = array_slice($rows, $start, $perpage);
  1718. foreach ($rowsdq as $value) {
  1719. $warehouse = $this->warehouse->read($value['warehouse']);
  1720. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1721. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1722. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1723. $od = array();
  1724. $odid = '';
  1725. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1726. }
  1727. $total = count($rows);
  1728. $pagenum = ceil($total / $perpage);
  1729. $over = $total - ($start + $perpage);
  1730. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1731. echo json_encode($rows);
  1732. exit;
  1733. }
  1734. $this->_Template('phone/p_usatypeapp', $this->data);
  1735. }
  1736. //入库操作
  1737. public function _enteradd()
  1738. {
  1739. $dt = 0;
  1740. if (isset($_SESSION['api'])) {
  1741. $user = $this->user->get_api($_SESSION['api']);
  1742. $usp = $user;
  1743. $fgshop = "";
  1744. $sid = "";
  1745. $user = explode('|', trim($user['shop'], '|'));
  1746. foreach ($user as $value) {
  1747. $fgshop .= " shop = " . $value . " or";
  1748. $sid .= " id = " . $value . " or";
  1749. }
  1750. }
  1751. $tc = $this->typeclass->find_all();
  1752. $typeclass = array();
  1753. foreach ($tc as $v) {
  1754. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1755. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1756. }
  1757. $post = $this->input->post(NULL, TRUE);
  1758. if (isset($post['sku'])) {
  1759. $list = array();
  1760. $num = "";
  1761. $title = "";
  1762. $features = "";
  1763. $order = $this->input->post('order', true);
  1764. $shop = $this->input->post('shop', true);
  1765. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1766. $sku = $this->input->post('sku', true);
  1767. $post['sm'] = $this->input->post('sm', true);
  1768. $post['warehouse'] = $this->input->post('warehouse', true);
  1769. $post['purchase'] = $this->input->post('purchase', true);
  1770. $post['retreatwarehouse'] = $post['warehouse'];
  1771. $post['state'] = $this->input->post('state', true);
  1772. $post['rktype'] = $this->input->post('rktype', true);
  1773. $post['text'] = $this->input->post('text', true);
  1774. $category = $this->input->post('category', true);
  1775. $list['category'] = $category;
  1776. $list['hairtype'] = $this->input->post('hairtype', true);
  1777. $list['grade'] = $this->input->post('grade', true);
  1778. $size = $this->input->post('size', true);
  1779. $xzsku = $this->input->post('xzsku', true);
  1780. $list['size'] = rtrim($size, ',');
  1781. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1782. $list['extension'] = $this->input->post('extension', true);
  1783. if ($category == 1297) {
  1784. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1785. }
  1786. if ($category == 1702) {
  1787. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1788. $list['syother'] = $this->input->post('syother', true);
  1789. }
  1790. if ($category == 133) {
  1791. $list['fittype'] = $this->input->post('fittype', true);
  1792. $list['acother'] = $this->input->post('acother', true);
  1793. }
  1794. $list['color'] = $this->input->post('color', true);
  1795. $list['lowe'] = $this->input->post('lowe', true);
  1796. if (!$post['purchase']) {
  1797. $post['purchase'] = 1;
  1798. }
  1799. if ($category == 127) {
  1800. $list['type'] = $this->input->post('type', true);
  1801. $list['headroad'] = $this->input->post('headroad', true);
  1802. $list['density'] = $this->input->post('density', true);
  1803. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1804. $list['lacesize'] = $this->input->post('lacesize', true);
  1805. }
  1806. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1807. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1808. }
  1809. if ($category == 128) {
  1810. $list['lacetype'] = $this->input->post('lacetype', true);
  1811. $list['haircap'] = $this->input->post('haircap', true);
  1812. $list['density'] = $this->input->post('density', true);
  1813. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1814. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1815. $list['wigother'] = $this->input->post('wigother', true);
  1816. $list['wigother1'] = $this->input->post('wigother1', true);
  1817. $list['wigother2'] = $this->input->post('wigother2', true);
  1818. }
  1819. if ($category == 129) {
  1820. $list['wide'] = $this->input->post('wide', true);
  1821. }
  1822. if ($category == 131) {
  1823. $list['gifttype'] = $this->input->post('gifttype', true);
  1824. $list['giftother'] = $this->input->post('giftother', true);
  1825. }
  1826. if ($category == 134) {
  1827. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1828. }
  1829. if ($category == 1297) {
  1830. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1831. $list['sywigother'] = $this->input->post('sywigother', true);
  1832. }
  1833. if ($category == 130 || $category == 133 || $category == 1702) {
  1834. $list['items'] = $this->input->post('items', true);
  1835. $list['weight'] = $this->input->post('weight', true);
  1836. }
  1837. if ($category == 1702) {
  1838. $list['syhairther'] = $this->input->post('syhairther', true);
  1839. }
  1840. $classid = $this->classid->sku();
  1841. $scsku = $classid;
  1842. $pm = $classid;
  1843. foreach ($list as $k => $v) {
  1844. if ($v != 0) {
  1845. $num .= $v;
  1846. $features .= $v . '-';
  1847. $post[$k] = $v;
  1848. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1849. if ($k != 'size') {
  1850. $title .= $typeclass[$v]['title'] . " ";
  1851. }
  1852. if (isset($pm[$typeclass[$v]['classid']])) {
  1853. if ($typeclass[$v]['title'] == '9A') {
  1854. $pm[$typeclass[$v]['classid']] = '9A';
  1855. } else if ($typeclass[$v]['title'] == '10A') {
  1856. $pm[$typeclass[$v]['classid']] = '10A';
  1857. } else {
  1858. $clzh = $typeclass[$v]['zh'];
  1859. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1860. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1861. $clzh = $clzh[0];
  1862. }
  1863. $pm[$typeclass[$v]['classid']] = $clzh;
  1864. }
  1865. }
  1866. }
  1867. }
  1868. $zh = implode(" ", $pm);
  1869. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1870. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1871. if ($list['size']) {
  1872. $typeclass = $this->typeclass->read($list['size']);
  1873. $title .= $typeclass['title'];
  1874. }
  1875. $time = time();
  1876. if ($xzsku) {
  1877. $scsku = implode("-", $scsku);
  1878. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1879. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1880. $post['sku'] = trim($scsku, ' ');
  1881. } else {
  1882. $post['sku'] = $sku;
  1883. }
  1884. //$post['sku'] = trim($sku,' ');
  1885. $post['title'] = rtrim($title, ' ');
  1886. $post['number'] = $num;
  1887. $post['features'] = '-' . $features;
  1888. $post['enter'] = $time;
  1889. $post['time'] = $time; //操作时间
  1890. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1891. if ($yza) {
  1892. if ($post['features'] != $yza[0]['features']) {
  1893. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1894. exit;
  1895. }
  1896. }
  1897. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1898. if ($yzb) {
  1899. if ($post['sku'] != $yzb[0]['sku']) {
  1900. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1901. exit;
  1902. }
  1903. }
  1904. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1905. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1906. exit;
  1907. }
  1908. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1909. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1910. exit;
  1911. }
  1912. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1913. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1914. exit;
  1915. }
  1916. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1917. if (isset($yz[0]['type'])) {
  1918. $post['type'] = $yz[0]['type'];
  1919. }
  1920. if ($post['state'] == 9) //如果选择预设库存
  1921. {
  1922. $this->whlabel->insert($post);
  1923. } else {
  1924. /**
  1925. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1926. if($ljg == 1)
  1927. {
  1928. for($i=0;$i<$order;$i++)
  1929. {
  1930. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1931. $this->whlabel->insert($post);
  1932. }
  1933. }
  1934. **/
  1935. //if($post['warehouse'] == '5')
  1936. //{
  1937. //}
  1938. $yydata = $post;
  1939. $yydata['zh'] = $zh;
  1940. /**
  1941. $wl = $this->apiyy->get_cjlp($yydata);
  1942. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1943. {
  1944. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1945. }
  1946. if($wl['Data'][0]['m_isSucess'] != 1)
  1947. {
  1948. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1949. }
  1950. **/
  1951. for ($i = 0; $i < $order; $i++) {
  1952. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1953. $this->whlabel->insert($post);
  1954. }
  1955. }
  1956. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1957. exit;
  1958. }
  1959. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1960. $this->data['wlshop'] = $wlshop;
  1961. $this->_Template('whlabel_enteradd', $this->data);
  1962. }
  1963. //修改产品
  1964. public function _enteredit($arg_array)
  1965. {
  1966. $dt = 0;
  1967. if (isset($_SESSION['api'])) {
  1968. $user = $this->user->get_api($_SESSION['api']);
  1969. $usp = $user;
  1970. $fgshop = "";
  1971. $sid = "";
  1972. $user = explode('|', trim($user['shop'], '|'));
  1973. foreach ($user as $value) {
  1974. $fgshop .= " shop = " . $value . " or";
  1975. $sid .= " id = " . $value . " or";
  1976. }
  1977. }
  1978. $post = $this->input->post(NULL, TRUE);
  1979. if (isset($post['sku'])) {
  1980. $list = array();
  1981. $num = "";
  1982. $title = "";
  1983. $features = "";
  1984. $id = $this->input->post('id', true);
  1985. $order = $this->input->post('order', true);
  1986. $shop = $this->input->post('shop', true);
  1987. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1988. $post['sku'] = $this->input->post('sku', true);
  1989. $post['sm'] = $this->input->post('sm', true);
  1990. $post['warehouse'] = $this->input->post('warehouse', true);
  1991. $post['purchase'] = $this->input->post('purchase', true);
  1992. $post['retreatwarehouse'] = $post['warehouse'];
  1993. $category = $this->input->post('category', true);
  1994. $list['category'] = $category;
  1995. $list['hairtype'] = $this->input->post('hairtype', true);
  1996. $list['grade'] = $this->input->post('grade', true);
  1997. $size = $this->input->post('size', true);
  1998. $list['size'] = rtrim($size, ',');
  1999. $post['rktype'] = $this->input->post('rktype', true);
  2000. $post['text'] = $this->input->post('text', true);
  2001. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2002. $list['extension'] = $this->input->post('extension', true);
  2003. if ($category == 1297) {
  2004. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2005. }
  2006. if ($category == 1702) {
  2007. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2008. $list['syother'] = $this->input->post('syother', true);
  2009. }
  2010. if ($category == 133) {
  2011. $list['fittype'] = $this->input->post('fittype', true);
  2012. $list['acother'] = $this->input->post('acother', true);
  2013. }
  2014. $list['color'] = $this->input->post('color', true);
  2015. $list['lowe'] = $this->input->post('lowe', true);
  2016. if (!$post['purchase']) {
  2017. $post['purchase'] = 1;
  2018. }
  2019. if ($category == 127) {
  2020. $list['type'] = $this->input->post('type', true);
  2021. $list['headroad'] = $this->input->post('headroad', true);
  2022. $list['density'] = $this->input->post('density', true);
  2023. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2024. $list['lacesize'] = $this->input->post('lacesize', true);
  2025. }
  2026. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2027. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2028. }
  2029. if ($category == 128) {
  2030. $list['lacetype'] = $this->input->post('lacetype', true);
  2031. $list['haircap'] = $this->input->post('haircap', true);
  2032. $list['density'] = $this->input->post('density', true);
  2033. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2034. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2035. $list['wigother'] = $this->input->post('wigother', true);
  2036. $list['wigother1'] = $this->input->post('wigother1', true);
  2037. $list['wigother2'] = $this->input->post('wigother2', true);
  2038. }
  2039. if ($category == 129) {
  2040. $list['wide'] = $this->input->post('wide', true);
  2041. }
  2042. if ($category == 131) {
  2043. $list['gifttype'] = $this->input->post('gifttype', true);
  2044. $list['giftother'] = $this->input->post('giftother', true);
  2045. }
  2046. if ($category == 134) {
  2047. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2048. }
  2049. if ($category == 1297) {
  2050. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2051. $list['sywigother'] = $this->input->post('sywigother', true);
  2052. }
  2053. if ($category == 130 || $category == 133 || $category == 1702) {
  2054. $list['items'] = $this->input->post('items', true);
  2055. $list['weight'] = $this->input->post('weight', true);
  2056. }
  2057. if ($category == 1702) {
  2058. $list['syhairther'] = $this->input->post('syhairther', true);
  2059. }
  2060. foreach ($list as $k => $v) {
  2061. if ($v != 0) {
  2062. $num .= $v;
  2063. $features .= $v . '-';
  2064. $typeclass = $this->typeclass->read($v);
  2065. if ($k != 'size') {
  2066. $title .= $typeclass['title'] . " ";
  2067. }
  2068. }
  2069. }
  2070. $typeclass = $this->typeclass->read($list['size']);
  2071. $title .= $typeclass['title'];
  2072. $time = time();
  2073. $post['title'] = rtrim($title, ' ');
  2074. $post['number'] = $num;
  2075. $post['features'] = '-' . $features;
  2076. $post['time'] = $time; //操作时间
  2077. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2078. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2079. exit;
  2080. }
  2081. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2082. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2083. exit;
  2084. }
  2085. $uid = $this->whlabel->read($id);
  2086. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2087. if ($datanum > 0) {
  2088. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2089. exit;
  2090. }
  2091. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2092. {
  2093. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2094. if ($yza) {
  2095. if ($post['features'] != $yza[0]['features']) {
  2096. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2097. exit;
  2098. }
  2099. }
  2100. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2101. if ($yzb) {
  2102. if ($post['sku'] != $yzb[0]['sku']) {
  2103. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2104. exit;
  2105. }
  2106. }
  2107. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2108. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2109. exit;
  2110. }
  2111. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2112. foreach ($data as $v) {
  2113. $post['id'] = $v['id'];
  2114. $this->whlabel->save($post, $v['id']);
  2115. }
  2116. } else {
  2117. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2118. if ($data > 0) {
  2119. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2120. exit;
  2121. } else {
  2122. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2123. foreach ($data as $v) {
  2124. $post['id'] = $v['id'];
  2125. $this->whlabel->save($post, $v['id']);
  2126. }
  2127. }
  2128. }
  2129. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2130. exit;
  2131. }
  2132. $uid = $this->whlabel->read($arg_array[0]);
  2133. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2134. $this->data['enter'] = $uid;
  2135. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2136. $this->data['wlshop'] = $wlshop;
  2137. $this->_Template('whlabel_enteredit', $this->data);
  2138. }
  2139. //入库浏览
  2140. public function _enter()
  2141. {
  2142. $post = $this->input->post(NULL, TRUE);
  2143. if (isset($post['s'])) {
  2144. $id_arr = $this->input->post('s');
  2145. $id_arr = explode(',', $id_arr);
  2146. if (!$id_arr) {
  2147. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2148. exit;
  2149. }
  2150. //循环删除记录
  2151. foreach ($id_arr as $v) {
  2152. $sid = $this->whlabel->read($v);
  2153. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2154. if ($count > 0) {
  2155. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2156. exit;
  2157. }
  2158. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2159. foreach ($info_list as $va) {
  2160. $this->whlabel->remove($va['id']);
  2161. }
  2162. }
  2163. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2164. exit;
  2165. }
  2166. $sp = array();
  2167. $s = $this->shop->find_all('1=1', 'id,shopname');
  2168. foreach ($s as $v) {
  2169. $sp[$v['id']] = $v['shopname'];
  2170. }
  2171. $wh = array();
  2172. $w = $this->warehouse->find_all('1=1', 'id,title');
  2173. foreach ($w as $v) {
  2174. $wh[$v['id']] = $v['title'];
  2175. }
  2176. if (isset($post['page'])) {
  2177. $page = $this->input->post('page', true);
  2178. $perpage = $this->input->post('perpage', true);
  2179. $category = $this->input->post('category', true);
  2180. $size = $this->input->post('size', true);
  2181. $grade = $this->input->post('grade', true);
  2182. $color = $this->input->post('color', true);
  2183. $lowe = $this->input->post('lowe', true);
  2184. $sku = $this->input->post('sku', true);
  2185. $warehouse = $this->input->post('warehouse', true);
  2186. $purchase = $this->input->post('purchase', true);
  2187. $ktime = $this->input->post('ktime', true);
  2188. $jtime = $this->input->post('jtime', true);
  2189. $ktime = strtotime($ktime);
  2190. $jtime = strtotime($jtime);
  2191. $where = "1=1";
  2192. $gj = "";
  2193. $ck = "";
  2194. if ($category) {
  2195. $where .= " and features like '%-$category-%'";
  2196. }
  2197. if ($size) {
  2198. $where .= " and features like '%-$size-%'";
  2199. }
  2200. if ($grade) {
  2201. $where .= " and features like '%-$grade-%'";
  2202. }
  2203. if ($color) {
  2204. $where .= " and features like '%-$color-%'";
  2205. }
  2206. if ($lowe) {
  2207. $where .= " and features like '%-$lowe-%'";
  2208. }
  2209. if ($warehouse) {
  2210. $where .= " and warehouse = '$warehouse'";
  2211. }
  2212. if ($purchase) {
  2213. $where .= " and purchase = '$purchase'";
  2214. }
  2215. if ($sku) {
  2216. $where .= " and sku like '%$sku%'";
  2217. }
  2218. if ($ktime && $jtime) {
  2219. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2220. }
  2221. //数据排序
  2222. $order_str = "enter desc";
  2223. if (empty($page)) {
  2224. $start = 0;
  2225. $perpage = 1;
  2226. } else {
  2227. $start = ($page - 1) * $perpage;
  2228. }
  2229. //取得信息列表
  2230. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2231. foreach ($info_list as $k => $v) {
  2232. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2233. if ($v['shop'] == '') {
  2234. $s = '通用';
  2235. } else {
  2236. $info_list[$k]['shop'] = '';
  2237. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2238. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2239. }
  2240. }
  2241. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2242. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2243. $info_list[$k]['g'] = $g;
  2244. }
  2245. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2246. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2247. $pagenum = ceil($total / $perpage);
  2248. $over = $total - ($start + $perpage);
  2249. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2250. echo json_encode($rows);
  2251. exit;
  2252. }
  2253. $this->_Template('whlabel_enter', $this->data);
  2254. }
  2255. //出库浏览
  2256. public function _out()
  2257. {
  2258. $post = $this->input->post(NULL, TRUE);
  2259. if (isset($post['page'])) {
  2260. $page = $this->input->post('page', true);
  2261. $perpage = $this->input->post('perpage', true);
  2262. $category = $this->input->post('category', true);
  2263. $size = $this->input->post('size', true);
  2264. $grade = $this->input->post('grade', true);
  2265. $color = $this->input->post('color', true);
  2266. $lowe = $this->input->post('lowe', true);
  2267. $sku = $this->input->post('sku', true);
  2268. $warehouse = $this->input->post('warehouse', true);
  2269. $purchase = $this->input->post('purchase', true);
  2270. $state = $this->input->post('state', true);
  2271. $ktime = $this->input->post('ktime', true);
  2272. $jtime = $this->input->post('jtime', true);
  2273. $ktime = strtotime($ktime);
  2274. $jtime = strtotime($jtime);
  2275. $where = "state=3";
  2276. $gj = "";
  2277. $ck = "";
  2278. if ($category) {
  2279. $where .= " and features like '%-$category-%'";
  2280. }
  2281. if ($size) {
  2282. $where .= " and features like '%-$size-%'";
  2283. }
  2284. if ($grade) {
  2285. $where .= " and features like '%-$grade-%'";
  2286. }
  2287. if ($color) {
  2288. $where .= " and features like '%-$color-%'";
  2289. }
  2290. if ($lowe) {
  2291. $where .= " and features like '%-$lowe-%'";
  2292. }
  2293. if ($state) {
  2294. $where .= " and state = '$state'";
  2295. }
  2296. if ($warehouse) {
  2297. $where .= " and warehouse = '$warehouse'";
  2298. }
  2299. if ($purchase) {
  2300. $where .= " and purchase = '$purchase'";
  2301. }
  2302. if ($sku) {
  2303. $where .= " and sku = '$sku'";
  2304. }
  2305. if ($ktime && $jtime) {
  2306. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2307. }
  2308. //数据排序
  2309. $order_str = "id desc";
  2310. if (empty($page)) {
  2311. $start = 0;
  2312. $perpage = 1;
  2313. } else {
  2314. $start = ($page - 1) * $perpage;
  2315. }
  2316. //取得信息列表
  2317. $info_list = $this->whlabel->find_all($where, 'sku');
  2318. $rows = array();
  2319. $list = array();
  2320. foreach ($info_list as $key => $value) {
  2321. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2322. }
  2323. $rows = array_unique($rows); //删除重复记录
  2324. foreach ($rows as $key => $value) {
  2325. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2326. $ck = $this->warehouse->read($data['warehouse']);
  2327. $warehouse = $ck['title'];
  2328. $gy = $this->purchase->read($data['purchase']);
  2329. $purchase = $gy['purchase'];
  2330. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2331. $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);
  2332. }
  2333. $total = count($list);
  2334. $pagenum = ceil($total / $perpage);
  2335. $over = $total - ($start + $perpage);
  2336. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2337. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2338. echo json_encode($rows);
  2339. exit;
  2340. }
  2341. $this->_Template('whlabel_out', $this->data);
  2342. }
  2343. //出库标签浏览
  2344. public function _label()
  2345. {
  2346. $post = $this->input->post(NULL, TRUE);
  2347. if (isset($post['page'])) {
  2348. $page = $this->input->post('page', true);
  2349. $perpage = $this->input->post('perpage', true);
  2350. $sku = $this->input->post('sku', true);
  2351. $warehouse = $this->input->post('warehouse', true);
  2352. $purchase = $this->input->post('purchase', true);
  2353. $orderinfo = $this->input->post('orderinfo', true);
  2354. $waybill = $this->input->post('waybill', true);
  2355. $category = $this->input->post('category', true);
  2356. $size = $this->input->post('size', true);
  2357. $grade = $this->input->post('grade', true);
  2358. $color = $this->input->post('color', true);
  2359. $lowe = $this->input->post('lowe', true);
  2360. $where = "state=1";
  2361. if ($sku) {
  2362. $where .= " and sku = '$sku'";
  2363. }
  2364. if ($warehouse) {
  2365. $where .= " and warehouse = '$warehouse'";
  2366. }
  2367. if ($purchase) {
  2368. $where .= " and purchase = '$purchase'";
  2369. }
  2370. if ($orderinfo) {
  2371. $where .= " and orderinfo = '$orderinfo'";
  2372. }
  2373. if ($waybill) {
  2374. $where .= " and waybill = '$waybill'";
  2375. }
  2376. if ($category) {
  2377. $where .= " and features like '%-$category-%'";
  2378. }
  2379. if ($size) {
  2380. $where .= " and features like '%-$size-%'";
  2381. }
  2382. if ($grade) {
  2383. $where .= " and features like '%-$grade-%'";
  2384. }
  2385. if ($color) {
  2386. $where .= " and features like '%-$color-%'";
  2387. }
  2388. if ($lowe) {
  2389. $where .= " and features like '%-$lowe-%'";
  2390. }
  2391. //数据排序
  2392. $order_str = "outk desc";
  2393. if (empty($page)) {
  2394. $start = 0;
  2395. $perpage = 1;
  2396. } else {
  2397. $start = ($page - 1) * $perpage;
  2398. }
  2399. //取得信息列表
  2400. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2401. foreach ($info_list as $key => $value) {
  2402. $warehouse = $this->warehouse->read($value['warehouse']);
  2403. $info_list[$key]['warehouse'] = $warehouse['title'];
  2404. $purchase = $this->purchase->read($value['purchase']);
  2405. $info_list[$key]['purchase'] = $purchase['title'];
  2406. if ($value['outk'] != 0) {
  2407. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2408. } else {
  2409. $info_list[$key]['outk'] = "";
  2410. }
  2411. if ($value['orderinfo'] == 0) {
  2412. $info_list[$key]['orderinfo'] = "";
  2413. }
  2414. if ($value['waybill'] == 0) {
  2415. $info_list[$key]['waybill'] = "";
  2416. }
  2417. }
  2418. $total = $this->whlabel->find_count($where);
  2419. $pagenum = ceil($total / $perpage);
  2420. $over = $total - ($start + $perpage);
  2421. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2422. echo json_encode($rows);
  2423. exit;
  2424. }
  2425. $this->_Template('whlabel_label', $this->data);
  2426. }
  2427. //独立站出库订单
  2428. public function _outorder()
  2429. {
  2430. if (isset($_SESSION['api'])) {
  2431. $user = $this->user->get_api($_SESSION['api']);
  2432. $usp = $user;
  2433. $fgshop = "";
  2434. $sid = "";
  2435. $user = explode('|', trim($user['shop'], '|'));
  2436. foreach ($user as $value) {
  2437. $fgshop .= " shop = " . $value . " or";
  2438. $sid .= " id = " . $value . " or";
  2439. }
  2440. } else {
  2441. echo "请重新登录";
  2442. }
  2443. $post = $this->input->post(NULL, TRUE);
  2444. if (isset($post['page'])) {
  2445. $page = $this->input->post('page', true);
  2446. $perpage = $this->input->post('perpage', true);
  2447. $warehouse = $this->input->post('warehouse', true);
  2448. $xztime = $this->input->post('xztime', true);
  2449. $timetk = $this->input->post('timetkk', true);
  2450. $timetj = $this->input->post('timetjj', true);
  2451. $shop = $this->input->post('shop', true);
  2452. $source = $this->input->post('source', true);
  2453. $orderinfo = $this->input->post('orderinfo', true);
  2454. $number = $this->input->post('number', true);
  2455. $sfxh = $this->input->post('sfxh', true);
  2456. $express = $this->input->post('express', true);
  2457. $waybill = $this->input->post('waybill', true);
  2458. $library = $this->input->post('library', true);
  2459. $country = $this->input->post('country', true);
  2460. $so = $this->input->post('so', true);
  2461. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2462. $print = $this->input->post('print', true);
  2463. $state = $this->input->post('state', true);
  2464. $orderurl = $this->input->post('orderurl', true);
  2465. $productid = $this->input->post('productid', true);
  2466. $timetk = strtotime($timetk);
  2467. $timetj = strtotime($timetj);
  2468. /**
  2469. $sj = $this->input->post('sj',true);
  2470. if($sj)
  2471. {
  2472. $sj = $this->input->post('sj',true);
  2473. }
  2474. else
  2475. {
  2476. $sj = "fullorder";
  2477. }
  2478. **/
  2479. $sj = "fullorder";
  2480. $where = "1=1";
  2481. if ($warehouse) {
  2482. $where .= " and type = '$warehouse'";
  2483. }
  2484. if ($timetk && $timetj) {
  2485. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2486. }
  2487. if ($orderinfo) {
  2488. $where .= " and orderinfo = '$orderinfo'";
  2489. }
  2490. if ($number) {
  2491. $where .= " and number = '$number'";
  2492. }
  2493. if ($express) {
  2494. $where .= " and express = '$express'";
  2495. }
  2496. if ($waybill) {
  2497. $where .= " and waybill = '$waybill'";
  2498. }
  2499. if ($library) {
  2500. $where .= " and library = '$library'";
  2501. }
  2502. if ($print) {
  2503. $where .= " and print = '$print'";
  2504. }
  2505. if ($libraryconfirm) {
  2506. $where .= " and libraryconfirm = '$libraryconfirm'";
  2507. }
  2508. if ($state) {
  2509. $where .= " and state = '$state'";
  2510. }
  2511. if ($shop) {
  2512. $where .= " and shop = '$shop'";
  2513. }
  2514. if ($country) {
  2515. $where .= " and country = '$country'";
  2516. }
  2517. if ($sfxh != '') {
  2518. $where .= " and sfxh = '$sfxh'";
  2519. }
  2520. if ($so) {
  2521. $where .= " and shipremarks like '%$so%'";
  2522. }
  2523. if ($source) {
  2524. if ($source == '2d') {
  2525. $where .= " and source >= '2'";
  2526. } else {
  2527. $where .= " and source = '$source'";
  2528. }
  2529. }
  2530. if (isset($_SESSION['api'])) {
  2531. foreach ($user as $value) {
  2532. $fgshop .= " shop = " . $value . " or";
  2533. }
  2534. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2535. }
  2536. if ($orderurl) {
  2537. $url = $this->orderurl->read($orderurl);
  2538. $where .= " and link like '%" . $url['url'] . "%'";
  2539. }
  2540. if($productid){
  2541. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2542. }
  2543. //数据排序
  2544. $order_str = "librarytime desc";
  2545. if (empty($page)) {
  2546. $start = 0;
  2547. $perpage = 1;
  2548. } else {
  2549. $start = ($page - 1) * $perpage;
  2550. }
  2551. //取得信息列表
  2552. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2553. //格式化数据
  2554. foreach ($info_list as $key => $value) {
  2555. $shop = $this->shop->read($value['shop']);
  2556. $info_list[$key]['shop'] = $shop['shopname'];
  2557. $express = $this->express->read($value['express']);
  2558. $info_list[$key]['express'] = $express['servicename'];
  2559. $warehouse = $this->warehouse->read($value['type']);
  2560. $info_list[$key]['type'] = $warehouse['title'];
  2561. if ($value['librarytime'] == '0') {
  2562. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2563. } else {
  2564. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2565. }
  2566. }
  2567. $total = $this->$sj->find_count($where);
  2568. $pagenum = ceil($total / $perpage);
  2569. $over = $total - ($start + $perpage);
  2570. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2571. echo json_encode($rows);
  2572. exit;
  2573. }
  2574. $this->data['express'] = $this->express->find_all();
  2575. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2576. $this->data['wlshop'] = $wlshop;
  2577. $user = $this->user->get_api($_SESSION['api']);
  2578. $powerid = $this->power->read($user['power']);
  2579. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2580. $pid = '';
  2581. foreach ($powertext as $v) {
  2582. $pid .= " id = " . $v . " or";
  2583. }
  2584. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2585. $this->data['fullorderexcel'] = $fullorderexcel;
  2586. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2587. $this->data['orderurl'] = $orderurl;
  2588. $this->_Template('whlabel_outorder', $this->data);
  2589. }
  2590. //tt出库
  2591. public function _toutorder()
  2592. {
  2593. $fgshop = "";
  2594. $sid = "";
  2595. if (isset($_SESSION['api'])) {
  2596. $user = $this->user->get_api($_SESSION['api']);
  2597. $usp = $user;
  2598. $user = explode('|', trim($user['shop'], '|'));
  2599. foreach ($user as $value) {
  2600. $fgshop .= " shop = " . $value . " or";
  2601. $sid .= " id = " . $value . " or";
  2602. }
  2603. } else {
  2604. echo "请重新登录";
  2605. die;
  2606. }
  2607. $post = $this->input->post(NULL, TRUE);
  2608. if (isset($post['page'])) {
  2609. $page = $this->input->post('page', true);
  2610. $perpage = $this->input->post('perpage', true);
  2611. $warehouse = $this->input->post('warehouse', true);
  2612. $xztime = $this->input->post('xztime', true);
  2613. $timetk = $this->input->post('timetkk', true);
  2614. $timetj = $this->input->post('timetjj', true);
  2615. $shop = $this->input->post('shop', true);
  2616. $source = $this->input->post('source', true);
  2617. $orderinfo = $this->input->post('orderinfo', true);
  2618. $number = $this->input->post('number', true);
  2619. $sfxh = $this->input->post('sfxh', true);
  2620. $express = $this->input->post('express', true);
  2621. $waybill = $this->input->post('waybill', true);
  2622. $library = $this->input->post('library', true);
  2623. $country = $this->input->post('country', true);
  2624. $so = $this->input->post('so', true);
  2625. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2626. $print = $this->input->post('print', true);
  2627. $state = $this->input->post('state', true);
  2628. $orderurl = $this->input->post('orderurl', true);
  2629. $timetk = strtotime($timetk);
  2630. $timetj = strtotime($timetj);
  2631. /**
  2632. $sj = $this->input->post('sj',true);
  2633. if($sj)
  2634. {
  2635. $sj = $this->input->post('sj',true);
  2636. }
  2637. else
  2638. {
  2639. $sj = "fullorder";
  2640. }
  2641. **/
  2642. $sj = "fullordertt";
  2643. $where = "1=1";
  2644. if ($warehouse) {
  2645. $where .= " and type = '$warehouse'";
  2646. }
  2647. if ($timetk && $timetj) {
  2648. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2649. }
  2650. if ($orderinfo) {
  2651. $where .= " and orderinfo = '$orderinfo'";
  2652. }
  2653. if ($number) {
  2654. $where .= " and number = '$number'";
  2655. }
  2656. if ($express) {
  2657. $where .= " and express = '$express'";
  2658. }
  2659. if ($waybill) {
  2660. $where .= " and waybill = '$waybill'";
  2661. }
  2662. if ($library) {
  2663. $where .= " and library = '$library'";
  2664. }
  2665. if ($print) {
  2666. $where .= " and print = '$print'";
  2667. }
  2668. if ($libraryconfirm) {
  2669. $where .= " and libraryconfirm = '$libraryconfirm'";
  2670. }
  2671. if ($state) {
  2672. $where .= " and state = '$state'";
  2673. }
  2674. if ($shop) {
  2675. $where .= " and shop = '$shop'";
  2676. }
  2677. if ($country) {
  2678. $where .= " and country = '$country'";
  2679. }
  2680. if ($sfxh != '') {
  2681. $where .= " and sfxh = '$sfxh'";
  2682. }
  2683. if ($so) {
  2684. $where .= " and shipremarks like '%$so%'";
  2685. }
  2686. if ($source) {
  2687. if ($source == '2d') {
  2688. $where .= " and source >= '2'";
  2689. } else {
  2690. $where .= " and source = '$source'";
  2691. }
  2692. }
  2693. if (isset($_SESSION['api'])) {
  2694. foreach ($user as $value) {
  2695. $fgshop .= " shop = " . $value . " or";
  2696. }
  2697. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2698. }
  2699. if ($orderurl) {
  2700. $url = $this->orderurl->read($orderurl);
  2701. $where .= " and link like '%" . $url['url'] . "%'";
  2702. }
  2703. //数据排序
  2704. $order_str = "librarytime desc";
  2705. if (empty($page)) {
  2706. $start = 0;
  2707. $perpage = 1;
  2708. } else {
  2709. $start = ($page - 1) * $perpage;
  2710. }
  2711. //取得信息列表
  2712. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2713. //格式化数据
  2714. foreach ($info_list as $key => $value) {
  2715. $shop = $this->shop->read($value['shop']);
  2716. $info_list[$key]['shop'] = $shop['shopname'];
  2717. $express = $this->express->read($value['express']);
  2718. $info_list[$key]['express'] = $express['servicename'];
  2719. $warehouse = $this->warehouse->read($value['type']);
  2720. $info_list[$key]['type'] = $warehouse['title'];
  2721. if ($value['librarytime'] == '0') {
  2722. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2723. } else {
  2724. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2725. }
  2726. }
  2727. $total = $this->$sj->find_count($where);
  2728. $pagenum = ceil($total / $perpage);
  2729. $over = $total - ($start + $perpage);
  2730. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2731. echo json_encode($rows);
  2732. exit;
  2733. }
  2734. $this->data['express'] = $this->express->find_all();
  2735. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2736. $this->data['wlshop'] = $wlshop;
  2737. $user = $this->user->get_api($_SESSION['api']);
  2738. $powerid = $this->power->read($user['power']);
  2739. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2740. $pid = '';
  2741. foreach ($powertext as $v) {
  2742. $pid .= " id = " . $v . " or";
  2743. }
  2744. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2745. $this->data['fullorderexcel'] = $fullorderexcel;
  2746. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2747. $this->data['orderurl'] = $orderurl;
  2748. $this->_Template('whlabel_toutorder', $this->data);
  2749. }
  2750. //tt出库
  2751. public function _aoutorder()
  2752. {
  2753. if (isset($_SESSION['api'])) {
  2754. $user = $this->user->get_api($_SESSION['api']);
  2755. $usp = $user;
  2756. $fgshop = "";
  2757. $sid = "";
  2758. $user = explode('|', trim($user['shop'], '|'));
  2759. foreach ($user as $value) {
  2760. $fgshop .= " shop = " . $value . " or";
  2761. $sid .= " id = " . $value . " or";
  2762. }
  2763. } else {
  2764. echo "请重新登录";
  2765. }
  2766. $post = $this->input->post(NULL, TRUE);
  2767. if (isset($post['page'])) {
  2768. $page = $this->input->post('page', true);
  2769. $perpage = $this->input->post('perpage', true);
  2770. $warehouse = $this->input->post('warehouse', true);
  2771. $xztime = $this->input->post('xztime', true);
  2772. $timetk = $this->input->post('timetkk', true);
  2773. $timetj = $this->input->post('timetjj', true);
  2774. $shop = $this->input->post('shop', true);
  2775. $source = $this->input->post('source', true);
  2776. $orderinfo = $this->input->post('orderinfo', true);
  2777. $number = $this->input->post('number', true);
  2778. $sfxh = $this->input->post('sfxh', true);
  2779. $express = $this->input->post('express', true);
  2780. $waybill = $this->input->post('waybill', true);
  2781. $library = $this->input->post('library', true);
  2782. $country = $this->input->post('country', true);
  2783. $so = $this->input->post('so', true);
  2784. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2785. $print = $this->input->post('print', true);
  2786. $state = $this->input->post('state', true);
  2787. $orderurl = $this->input->post('orderurl', true);
  2788. $timetk = strtotime($timetk);
  2789. $timetj = strtotime($timetj);
  2790. /**
  2791. $sj = $this->input->post('sj',true);
  2792. if($sj)
  2793. {
  2794. $sj = $this->input->post('sj',true);
  2795. }
  2796. else
  2797. {
  2798. $sj = "fullorder";
  2799. }
  2800. **/
  2801. $sj = "fullorderamz";
  2802. $where = "1=1";
  2803. if ($warehouse) {
  2804. $where .= " and type = '$warehouse'";
  2805. }
  2806. if ($timetk && $timetj) {
  2807. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2808. }
  2809. if ($orderinfo) {
  2810. $where .= " and orderinfo = '$orderinfo'";
  2811. }
  2812. if ($number) {
  2813. $where .= " and number = '$number'";
  2814. }
  2815. if ($express) {
  2816. $where .= " and express = '$express'";
  2817. }
  2818. if ($waybill) {
  2819. $where .= " and waybill = '$waybill'";
  2820. }
  2821. if ($library) {
  2822. $where .= " and library = '$library'";
  2823. }
  2824. if ($print) {
  2825. $where .= " and print = '$print'";
  2826. }
  2827. if ($libraryconfirm) {
  2828. $where .= " and libraryconfirm = '$libraryconfirm'";
  2829. }
  2830. if ($state) {
  2831. $where .= " and state = '$state'";
  2832. }
  2833. if ($shop) {
  2834. $where .= " and shop = '$shop'";
  2835. }
  2836. if ($country) {
  2837. $where .= " and country = '$country'";
  2838. }
  2839. if ($sfxh != '') {
  2840. $where .= " and sfxh = '$sfxh'";
  2841. }
  2842. if ($so) {
  2843. $where .= " and shipremarks like '%$so%'";
  2844. }
  2845. if ($source) {
  2846. if ($source == '2d') {
  2847. $where .= " and source >= '2'";
  2848. } else {
  2849. $where .= " and source = '$source'";
  2850. }
  2851. }
  2852. if (isset($_SESSION['api'])) {
  2853. foreach ($user as $value) {
  2854. $fgshop .= " shop = " . $value . " or";
  2855. }
  2856. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2857. }
  2858. if ($orderurl) {
  2859. $url = $this->orderurl->read($orderurl);
  2860. $where .= " and link like '%" . $url['url'] . "%'";
  2861. }
  2862. //数据排序
  2863. $order_str = "librarytime desc";
  2864. if (empty($page)) {
  2865. $start = 0;
  2866. $perpage = 1;
  2867. } else {
  2868. $start = ($page - 1) * $perpage;
  2869. }
  2870. //取得信息列表
  2871. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2872. //格式化数据
  2873. foreach ($info_list as $key => $value) {
  2874. $shop = $this->shop->read($value['shop']);
  2875. $info_list[$key]['shop'] = $shop['shopname'];
  2876. $express = $this->express->read($value['express']);
  2877. $info_list[$key]['express'] = $express['servicename'];
  2878. $warehouse = $this->warehouse->read($value['type']);
  2879. $info_list[$key]['type'] = $warehouse['title'];
  2880. if ($value['librarytime'] == '0') {
  2881. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2882. } else {
  2883. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2884. }
  2885. }
  2886. $total = $this->$sj->find_count($where);
  2887. $pagenum = ceil($total / $perpage);
  2888. $over = $total - ($start + $perpage);
  2889. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2890. echo json_encode($rows);
  2891. exit;
  2892. }
  2893. $this->data['express'] = $this->express->find_all();
  2894. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2895. $this->data['wlshop'] = $wlshop;
  2896. $user = $this->user->get_api($_SESSION['api']);
  2897. $powerid = $this->power->read($user['power']);
  2898. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2899. $pid = '';
  2900. foreach ($powertext as $v) {
  2901. $pid .= " id = " . $v . " or";
  2902. }
  2903. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2904. $this->data['fullorderexcel'] = $fullorderexcel;
  2905. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2906. $this->data['orderurl'] = $orderurl;
  2907. $this->_Template('whlabel_aoutorder', $this->data);
  2908. }
  2909. //速卖通出库订单
  2910. public function _soutorder()
  2911. {
  2912. if (isset($_SESSION['api'])) {
  2913. $user = $this->user->get_api($_SESSION['api']);
  2914. $usp = $user;
  2915. $fgshop = "";
  2916. $sid = "";
  2917. $user = explode('|', trim($user['shop'], '|'));
  2918. foreach ($user as $value) {
  2919. $sid .= " id = " . $value . " or";
  2920. }
  2921. }
  2922. $post = $this->input->post(NULL, TRUE);
  2923. if (isset($post['page'])) {
  2924. $page = $this->input->post('page', true);
  2925. $perpage = $this->input->post('perpage', true);
  2926. $warehouse = $this->input->post('warehouse', true);
  2927. $xztime = $this->input->post('xztime', true);
  2928. $timetk = $this->input->post('timetkk', true);
  2929. $timetj = $this->input->post('timetjj', true);
  2930. $shop = $this->input->post('shop', true);
  2931. $source = $this->input->post('source', true);
  2932. $orderinfo = $this->input->post('orderinfo', true);
  2933. $number = $this->input->post('number', true);
  2934. $express = $this->input->post('express', true);
  2935. $waybill = $this->input->post('waybill', true);
  2936. $library = $this->input->post('library', true);
  2937. $country = $this->input->post('country', true);
  2938. $sfxh = $this->input->post('sfxh', true);
  2939. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2940. $print = $this->input->post('print', true);
  2941. $state = $this->input->post('state', true);
  2942. $so = $this->input->post('so', true);
  2943. $timetk = strtotime($timetk);
  2944. $timetj = strtotime($timetj);
  2945. /**
  2946. $sj = $this->input->post('sj',true);
  2947. if($sj)
  2948. {
  2949. $sj = $this->input->post('sj',true);
  2950. }
  2951. else
  2952. {
  2953. $sj = "fullorder";
  2954. }
  2955. **/
  2956. $sj = "fullordersmt";
  2957. $where = "1=1";
  2958. if ($warehouse) {
  2959. $where .= " and type = '$warehouse'";
  2960. }
  2961. if ($timetk && $timetj) {
  2962. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2963. }
  2964. if ($orderinfo) {
  2965. $where .= " and orderinfo = '$orderinfo'";
  2966. }
  2967. if ($number) {
  2968. $where .= " and number = '$number'";
  2969. }
  2970. if ($express) {
  2971. $where .= " and express = '$express'";
  2972. }
  2973. if ($waybill) {
  2974. $where .= " and waybill = '$waybill'";
  2975. }
  2976. if ($library) {
  2977. $where .= " and library = '$library'";
  2978. }
  2979. if ($print) {
  2980. $where .= " and print = '$print'";
  2981. }
  2982. if ($libraryconfirm) {
  2983. $where .= " and libraryconfirm = '$libraryconfirm'";
  2984. }
  2985. if ($state) {
  2986. $where .= " and state = '$state'";
  2987. }
  2988. if ($shop) {
  2989. $where .= " and shop = '$shop'";
  2990. }
  2991. if ($sfxh != '') {
  2992. $where .= " and sfxh = '$sfxh'";
  2993. }
  2994. if ($so) {
  2995. $where .= " and shipremarks like '%$so%'";
  2996. }
  2997. if ($source) {
  2998. $where .= " and source = '$source'";
  2999. }
  3000. if ($country) {
  3001. $where .= " and country = '$country'";
  3002. } else {
  3003. if (isset($_SESSION['api'])) {
  3004. foreach ($user as $value) {
  3005. $fgshop .= " shop = " . $value . " or";
  3006. }
  3007. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3008. }
  3009. }
  3010. //数据排序
  3011. $order_str = "librarytime desc";
  3012. if (empty($page)) {
  3013. $start = 0;
  3014. $perpage = 1;
  3015. } else {
  3016. $start = ($page - 1) * $perpage;
  3017. }
  3018. //取得信息列表
  3019. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3020. //格式化数据
  3021. foreach ($info_list as $key => $value) {
  3022. $shop = $this->shop->read($value['shop']);
  3023. $info_list[$key]['shop'] = $shop['shopname'];
  3024. $express = $this->express->read($value['express']);
  3025. $info_list[$key]['express'] = $express['servicename'];
  3026. $warehouse = $this->warehouse->read($value['type']);
  3027. $info_list[$key]['type'] = $warehouse['title'];
  3028. if ($value['librarytime'] == '0') {
  3029. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3030. } else {
  3031. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3032. }
  3033. }
  3034. $total = $this->$sj->find_count($where);
  3035. $pagenum = ceil($total / $perpage);
  3036. $over = $total - ($start + $perpage);
  3037. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3038. echo json_encode($rows);
  3039. exit;
  3040. }
  3041. $this->data['express'] = $this->express->find_all();
  3042. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3043. $this->data['wlshop'] = $wlshop;
  3044. $user = $this->user->get_api($_SESSION['api']);
  3045. $powerid = $this->power->read($user['power']);
  3046. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3047. $pid = '';
  3048. foreach ($powertext as $v) {
  3049. $pid .= " id = " . $v . " or";
  3050. }
  3051. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3052. $this->data['fullorderexcel'] = $fullorderexcel;
  3053. $this->_Template('whlabel_soutorder', $this->data);
  3054. }
  3055. //订单退库
  3056. public function _retreat()
  3057. {
  3058. $post = $this->input->post(NULL, TRUE);
  3059. if (isset($post['page'])) {
  3060. $page = $this->input->post('page', true);
  3061. $perpage = $this->input->post('perpage', true);
  3062. $warehouse = $this->input->post('warehouse', true);
  3063. $timetk = $this->input->post('timetk', true);
  3064. $timetj = $this->input->post('timetj', true);
  3065. $shop = $this->input->post('shop', true);
  3066. $source = $this->input->post('source', true);
  3067. $state = $this->input->post('state', true);
  3068. $review = $this->input->post('review', true);
  3069. $state = $this->input->post('state', true);
  3070. $express = $this->input->post('express', true);
  3071. $orderinfo = $this->input->post('orderinfo', true);
  3072. $user = $this->input->post('user', true);
  3073. $name = $this->input->post('name', true);
  3074. $waybill = $this->input->post('waybill', true);
  3075. $timetk = strtotime($timetk);
  3076. $timetj = strtotime($timetj);
  3077. $where = "(state=206 or state=210) and mergeid = 0";
  3078. if ($warehouse) {
  3079. $where .= " and state = '$warehouse'";
  3080. }
  3081. if ($timetk && $timetj) {
  3082. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3083. }
  3084. if ($shop) {
  3085. $where .= " and shop = '$shop'";
  3086. }
  3087. if ($source) {
  3088. $where .= " and source = '$source'";
  3089. }
  3090. if ($state) {
  3091. $where .= " and state = '$state'";
  3092. }
  3093. if ($review) {
  3094. $where .= " and review = '$review'";
  3095. }
  3096. if ($state) {
  3097. $where .= " and state = '$state'";
  3098. }
  3099. if ($express) {
  3100. $where .= " and express = '$express'";
  3101. }
  3102. if ($orderinfo) {
  3103. $where .= " and orderinfo = '$orderinfo'";
  3104. }
  3105. if ($user) {
  3106. $where .= " and user = '$user'";
  3107. }
  3108. if ($name) {
  3109. $where .= " and name = '$name'";
  3110. }
  3111. if ($waybill) {
  3112. $where .= " and waybill = '$waybill'";
  3113. }
  3114. //数据排序
  3115. $order_str = "id desc";
  3116. if (empty($page)) {
  3117. $start = 0;
  3118. $perpage = 1;
  3119. } else {
  3120. $start = ($page - 1) * $perpage;
  3121. }
  3122. //取得信息列表
  3123. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3124. //格式化数据
  3125. foreach ($info_list as $key => $value) {
  3126. $shop = $this->shop->read($value['shop']);
  3127. $info_list[$key]['shop'] = $shop['shopname'];
  3128. $warehouse = $this->warehouse->read($value['warehouse']);
  3129. $info_list[$key]['warehouse'] = $warehouse['title'];
  3130. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3131. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3132. if ($value['waybill'] == 0) {
  3133. $info_list[$key]['waybill'] = "";
  3134. }
  3135. $express = $this->express->read($value['express']);
  3136. $info_list[$key]['express'] = $express['title'];
  3137. $typeclass = $this->typeclass->read($value['state']);
  3138. $info_list[$key]['state'] = $typeclass['title'];
  3139. }
  3140. $total = $this->fullorder->find_count($where);
  3141. $pagenum = ceil($total / $perpage);
  3142. $over = $total - ($start + $perpage);
  3143. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3144. echo json_encode($rows);
  3145. exit;
  3146. }
  3147. $this->data['express'] = $this->express->find_all();
  3148. $this->_Template('whlabel_retreat', $this->data);
  3149. }
  3150. //退库标签浏览
  3151. public function _retreatlk()
  3152. {
  3153. $post = $this->input->post(NULL, TRUE);
  3154. if (isset($post['page'])) {
  3155. $page = $this->input->post('page', true);
  3156. $perpage = $this->input->post('perpage', true);
  3157. $timetk = $this->input->post('timetk', true);
  3158. $timetj = $this->input->post('timetj', true);
  3159. $sku = $this->input->post('sku', true);
  3160. $warehouse = $this->input->post('warehouse', true);
  3161. $purchase = $this->input->post('purchase', true);
  3162. $orderinfo = $this->input->post('orderinfo', true);
  3163. $waybill = $this->input->post('waybill', true);
  3164. $category = $this->input->post('category', true);
  3165. $size = $this->input->post('size', true);
  3166. $grade = $this->input->post('grade', true);
  3167. $color = $this->input->post('color', true);
  3168. $lowe = $this->input->post('lowe', true);
  3169. $state = $this->input->post('state', true);
  3170. $timetk = strtotime($timetk);
  3171. $timetj = strtotime($timetj);
  3172. $where = "state=2";
  3173. if ($timetk && $timetj) {
  3174. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3175. }
  3176. if ($sku) {
  3177. $where .= " and sku = '$sku'";
  3178. }
  3179. if ($warehouse) {
  3180. $where .= " and warehouse = '$warehouse'";
  3181. }
  3182. if ($purchase) {
  3183. $where .= " and purchase = '$purchase'";
  3184. }
  3185. if ($orderinfo) {
  3186. $where .= " and orderinfo = '$orderinfo'";
  3187. }
  3188. if ($waybill) {
  3189. $where .= " and waybill = '$waybill'";
  3190. }
  3191. if ($category) {
  3192. $where .= " and features like '%-$category-%'";
  3193. }
  3194. if ($size) {
  3195. $where .= " and features like '%-$size-%'";
  3196. }
  3197. if ($grade) {
  3198. $where .= " and features like '%-$grade-%'";
  3199. }
  3200. if ($color) {
  3201. $where .= " and features like '%-$color-%'";
  3202. }
  3203. if ($lowe) {
  3204. $where .= " and features like '%-$lowe-%'";
  3205. }
  3206. //数据排序
  3207. $order_str = "time desc";
  3208. if (empty($page)) {
  3209. $start = 0;
  3210. $perpage = 1;
  3211. } else {
  3212. $start = ($page - 1) * $perpage;
  3213. }
  3214. //取得信息列表
  3215. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3216. foreach ($info_list as $key => $value) {
  3217. $warehouse = $this->warehouse->read($value['warehouse']);
  3218. $info_list[$key]['warehouse'] = $warehouse['title'];
  3219. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3220. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3221. $purchase = $this->purchase->read($value['purchase']);
  3222. $info_list[$key]['purchase'] = $purchase['title'];
  3223. if ($value['outk'] != 0) {
  3224. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3225. } else {
  3226. $info_list[$key]['outk'] = "";
  3227. }
  3228. if ($value['retreat'] != 0) {
  3229. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3230. } else {
  3231. $info_list[$key]['retreat'] = "";
  3232. }
  3233. if ($value['orderinfo'] == 0) {
  3234. $info_list[$key]['orderinfo'] = "";
  3235. }
  3236. if ($value['waybill'] == 0) {
  3237. $info_list[$key]['waybill'] = "";
  3238. }
  3239. }
  3240. $total = $this->whlabel->find_count($where);
  3241. $pagenum = ceil($total / $perpage);
  3242. $over = $total - ($start + $perpage);
  3243. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3244. echo json_encode($rows);
  3245. exit;
  3246. }
  3247. $this->_Template('whlabel_retreatlk', $this->data);
  3248. }
  3249. //更换标签及浏览
  3250. public function _change()
  3251. {
  3252. $post = $this->input->post(NULL, TRUE);
  3253. if (isset($post['page'])) {
  3254. $page = $this->input->post('page', true);
  3255. $perpage = $this->input->post('perpage', true);
  3256. $timetk = $this->input->post('timetk', true);
  3257. $timetj = $this->input->post('timetj', true);
  3258. $label = $this->input->post('label', true);
  3259. $oldlabel = $this->input->post('oldlabel', true);
  3260. $timetk = strtotime($timetk);
  3261. $timetj = strtotime($timetj);
  3262. $where = "state=10 ";
  3263. if ($timetk && $timetj) {
  3264. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3265. }
  3266. if ($label) {
  3267. $where .= " and label = '$label'";
  3268. }
  3269. if ($oldlabel) {
  3270. $where .= " and oldlabel = '$oldlabel'";
  3271. }
  3272. //数据排序
  3273. $order_str = "time asc";
  3274. if (empty($page)) {
  3275. $start = 0;
  3276. $perpage = 1;
  3277. } else {
  3278. $start = ($page - 1) * $perpage;
  3279. }
  3280. //取得信息列表
  3281. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3282. foreach ($info_list as $key => $value) {
  3283. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3284. }
  3285. $total = $this->whlabel->find_count($where);
  3286. $pagenum = ceil($total / $perpage);
  3287. $over = $total - ($start + $perpage);
  3288. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3289. echo json_encode($rows);
  3290. exit;
  3291. }
  3292. $this->_Template('whlabel_change', $this->data);
  3293. }
  3294. //产品标签
  3295. public function _cpbqdc()
  3296. {
  3297. if (isset($_GET['excel'])) {
  3298. $where = "1=1";
  3299. //数据排序
  3300. $order_str = "id desc";
  3301. if (empty($page)) {
  3302. $start = 0;
  3303. $perpage = 1;
  3304. } else {
  3305. $start = ($page - 1) * $perpage;
  3306. }
  3307. $warehouse = $this->input->get('warehouse', true);
  3308. $state = $this->input->get('state', true);
  3309. $timetk = $this->input->get('timetkk', true);
  3310. $timetj = $this->input->get('timetjj', true);
  3311. $timetk = strtotime($timetk);
  3312. $timetj = strtotime($timetj);
  3313. if ($warehouse) {
  3314. $where .= " and warehouse = '$warehouse'";
  3315. }
  3316. if ($state || $state == 0) {
  3317. $where .= " and state = '$state'";
  3318. }
  3319. if ($timetk && $timetj) {
  3320. $where .= " and time > '$timetk' and time < '$timetj'";
  3321. }
  3322. //取得信息列表
  3323. $info_list = $this->whlabel->find_all($where, '*');
  3324. $rows = array();
  3325. $list = array();
  3326. foreach ($info_list as $key => $value) {
  3327. $rows[$value['time']] = $value; //所有数据sku
  3328. }
  3329. foreach ($rows as $value) {
  3330. $warehouse = $this->warehouse->read($value['warehouse']);
  3331. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3332. $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);
  3333. }
  3334. $title = "产品标签统计表";
  3335. $titlename = "<table border=1>
  3336. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3337. <tr align='center'>
  3338. <td>仓库</td>
  3339. <td>SKU</td>
  3340. <td>产品</td>
  3341. <td>入库时间</td>
  3342. <td>操作时间</td>
  3343. <td>备注</td>
  3344. <td>数量</td>
  3345. </tr>
  3346. </table>";
  3347. $filename = $title . ".xls";
  3348. $tail = "";
  3349. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3350. }
  3351. }
  3352. //进销存导出
  3353. public function _exceljxc()
  3354. {
  3355. $classid = $this->classid->sku();
  3356. $pm = $classid;
  3357. $typeclass = array();
  3358. $tc = $this->typeclass->find_all();
  3359. foreach ($tc as $v) {
  3360. $typeclass[$v['id']] = $v;
  3361. }
  3362. $prc = array();
  3363. $purchase = $this->purchase->find_all();
  3364. foreach ($purchase as $k => $v) {
  3365. $prc[$v['id']] = $v['title'];
  3366. }
  3367. if (isset($_GET['excel'])) {
  3368. $where = "sku != 'Preset'";
  3369. //数据排序
  3370. $order_str = "id desc";
  3371. if (empty($page)) {
  3372. $start = 0;
  3373. $perpage = 1;
  3374. } else {
  3375. $start = ($page - 1) * $perpage;
  3376. }
  3377. $category = $this->input->get('category', true);
  3378. $warehouse = $this->input->get('warehouse', true);
  3379. $excelid = $this->input->get('sid', true);
  3380. if ($category) {
  3381. $where .= " and features like '%-$category-%'";
  3382. }
  3383. if ($warehouse) {
  3384. $where .= " and warehouse = '$warehouse'";
  3385. }
  3386. $xzid = '';
  3387. if ($excelid) {
  3388. $excelid = explode(',', trim($excelid, ','));
  3389. foreach ($excelid as $key => $value) {
  3390. $xzid .= " id = " . $value . " or";
  3391. }
  3392. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3393. }
  3394. //取得信息列表
  3395. /**
  3396. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3397. $rows = array();$list = array();
  3398. foreach ($info_list as $key=>$value)
  3399. {
  3400. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3401. }
  3402. **/
  3403. $wt = array();
  3404. $whlabel_type = $this->whlabel_type->find_all();
  3405. foreach ($whlabel_type as $v) {
  3406. $wt[$v['id']] = $v['title'];
  3407. }
  3408. $wh = array();
  3409. $w = $this->warehouse->find_all('1=1', 'id,title');
  3410. foreach ($w as $v) {
  3411. $wh[$v['id']] = $v['title'];
  3412. }
  3413. $list = array();
  3414. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3415. foreach ($rows as $key => $value) {
  3416. if (isset($wt[$value['type']])) {
  3417. $rows[$key]['type'] = $wt[$value['type']];
  3418. } else {
  3419. $rows[$key]['type'] = '未设置';
  3420. }
  3421. $bm = '03';
  3422. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3423. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3424. $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');
  3425. $details = array();
  3426. $cpid = array();
  3427. $cpbz = array();
  3428. $c = 0;
  3429. $g = 0;
  3430. $x = 0;
  3431. $t = 0;
  3432. $s = 0;
  3433. $q = 0;
  3434. foreach ($sd as $k => $v) {
  3435. if ($v['state'] == 0) {
  3436. $c++;
  3437. if ($v['cpid'] != 0) {
  3438. $cpid[$v['cpid']] = $v['cpid'];
  3439. }
  3440. if ($v['cpbz'] != '') {
  3441. $cpbz[$v['cpbz']] = $v['cpbz'];
  3442. }
  3443. }
  3444. if ($v['state'] != 9) {
  3445. $g++;
  3446. }
  3447. if ($v['state'] == 1) {
  3448. $x++;
  3449. }
  3450. if ($v['state'] == 2) {
  3451. $t++;
  3452. }
  3453. if ($v['state'] == 8) {
  3454. $s++;
  3455. }
  3456. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3457. $q++;
  3458. }
  3459. $details[$v['details']] = $v['details'];
  3460. }
  3461. $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'] . '"');
  3462. $rows[$key]['details'] = implode("、", $details);
  3463. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3464. $number = $value['number'];
  3465. $ftime = time() - 15 * 24 * 3600;
  3466. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3467. $rows[$key]['number'] = $g;
  3468. $rows[$key]['c'] = $c;
  3469. $rows[$key]['x'] = $x;
  3470. $rows[$key]['t'] = $t;
  3471. $rows[$key]['s'] = $s;
  3472. $rows[$key]['q'] = $q;
  3473. $rows[$key]['z'] = $z;
  3474. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3475. $features = explode('-', trim($features, '-'));
  3476. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3477. // $pm = $classid;
  3478. // $jm = $classid;
  3479. // foreach($features as $k=>$v)
  3480. // {
  3481. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3482. // {
  3483. // if($typeclass[$v]['bm'] != '')
  3484. // {
  3485. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3486. // }
  3487. // }
  3488. // if($v != 0)
  3489. // {
  3490. // if(!isset($typeclass[$v]))
  3491. // {
  3492. // continue;
  3493. // }
  3494. // if(isset($pm[$typeclass[$v]['classid']]))
  3495. // {
  3496. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3497. // {
  3498. // $tz = explode('|',$typeclass[$v]['zh']);
  3499. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3500. // }
  3501. // else
  3502. // {
  3503. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3504. // }
  3505. // }
  3506. // if(isset($jm[$typeclass[$v]['classid']]))
  3507. // {
  3508. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3509. // }
  3510. // }
  3511. // }
  3512. // $jm = array_filter($jm);
  3513. // $rows[$key]['bs'] = implode("-",$jm);
  3514. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3515. // $zh = implode(" ",$pm);
  3516. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3517. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3518. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3519. // $rows[$key]['features'] = $zh;
  3520. }
  3521. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3522. $final_list = [];
  3523. foreach ($list as $k => $v) {
  3524. if (empty($v['sku'])) {
  3525. continue;
  3526. }
  3527. $final_list[] = [
  3528. "warehouse" => $v["warehouse"],
  3529. "purchase" => $v["purchase"],
  3530. "details" => $v["details"],
  3531. "cpid" => $v["cpid"],
  3532. "dbcontent" => $v["dbcontent"],
  3533. "sku" => $v["sku"],
  3534. "cs" => $v["bm"],
  3535. "bs" => $v["jm"],
  3536. "title" => $v["title"],
  3537. "features" => $v["pm"],
  3538. "cpbz" => $v["cpbz"],
  3539. "sm" => $v["sm"],
  3540. "type" => $v["type"],
  3541. "number" => $v["number"],
  3542. "c" => $v["c"],
  3543. "x" => $v["x"],
  3544. "t" => $v["t"],
  3545. "s" => $v["s"],
  3546. "q" => $v["q"],
  3547. "z" => $v["z"],
  3548. "weight" => $v['weight'],
  3549. ];
  3550. }
  3551. $title = "总进销存统计表";
  3552. $titlename = "<table border=1>
  3553. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3554. <tr align='center'>
  3555. <td>仓库</td>
  3556. <td>供应商</td>
  3557. <td>位置</td>
  3558. <td>库存编码</td>
  3559. <td>类目</td>
  3560. <td>SKU</td>
  3561. <td>用友编码</td>
  3562. <td>用友料号</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>重量(g)</td>
  3576. </tr>
  3577. </table>";
  3578. $filename = $title . ".xls";
  3579. $tail = "";
  3580. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3581. }
  3582. }
  3583. //入库导出
  3584. public function _excelr()
  3585. {
  3586. if (isset($_GET['excel'])) {
  3587. $category = $this->input->get('category', true);
  3588. $size = $this->input->get('size', true);
  3589. $grade = $this->input->get('grade', true);
  3590. $color = $this->input->get('color', true);
  3591. $lowe = $this->input->get('lowe', true);
  3592. $sku = $this->input->get('sku', true);
  3593. $warehouse = $this->input->get('warehouse', true);
  3594. $purchase = $this->input->get('purchase', true);
  3595. $ktime = $this->input->get('ktime', true);
  3596. $jtime = $this->input->get('jtime', true);
  3597. $ktime = strtotime($ktime);
  3598. $jtime = strtotime($jtime);
  3599. $where = "1=1";
  3600. $gj = "";
  3601. $ck = "";
  3602. if ($category) {
  3603. $where .= " and features like '%-$category-%'";
  3604. }
  3605. if ($size) {
  3606. $where .= " and features like '%-$size-%'";
  3607. }
  3608. if ($grade) {
  3609. $where .= " and features like '%-$grade-%'";
  3610. }
  3611. if ($color) {
  3612. $where .= " and features like '%-$color-%'";
  3613. }
  3614. if ($lowe) {
  3615. $where .= " and features like '%-$lowe-%'";
  3616. }
  3617. if ($warehouse) {
  3618. $where .= " and warehouse = '$warehouse'";
  3619. }
  3620. if ($purchase) {
  3621. $where .= " and purchase = '$purchase'";
  3622. }
  3623. if ($sku) {
  3624. $where .= " and sku = '$sku'";
  3625. }
  3626. if ($ktime && $jtime) {
  3627. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3628. }
  3629. //数据排序
  3630. $order_str = "id desc";
  3631. if (empty($page)) {
  3632. $start = 0;
  3633. $perpage = 1;
  3634. } else {
  3635. $start = ($page - 1) * $perpage;
  3636. }
  3637. $list = array();
  3638. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3639. foreach ($rows as $value) {
  3640. $ck = $this->warehouse->read($value['warehouse']);
  3641. $warehouse = $ck['title'];
  3642. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3643. $retreatwarehouse = $tkck['title'];
  3644. $gy = $this->purchase->read($value['purchase']);
  3645. $purchase = $gy['title'];
  3646. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3647. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3648. }
  3649. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3650. $titlename = "<table border=1>
  3651. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3652. <tr align='center'>
  3653. <td>仓库</td>
  3654. <td>SKU</td>
  3655. <td>产品</td>
  3656. <td>时间</td>
  3657. <td>数量</td>
  3658. </tr>
  3659. </table>";
  3660. $filename = $title . ".xls";
  3661. $tail = "";
  3662. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3663. }
  3664. }
  3665. //出库、退库导出
  3666. public function _excelct()
  3667. {
  3668. $classid = $this->classid->sku();
  3669. $pm = $classid;
  3670. $typeclass = array();
  3671. $tc = $this->typeclass->find_all();
  3672. foreach ($tc as $v) {
  3673. $typeclass[$v['id']] = $v;
  3674. }
  3675. $prc = array();
  3676. $purchase = $this->purchase->find_all();
  3677. foreach ($purchase as $k => $v) {
  3678. $prc[$v['id']] = $v['title'];
  3679. }
  3680. if (isset($_GET['excel'])) {
  3681. $wh = array();
  3682. $w = $this->warehouse->find_all('1=1', 'id,title');
  3683. foreach ($w as $v) {
  3684. $wh[$v['id']] = $v['title'];
  3685. }
  3686. $type = $this->input->get('excel', true);
  3687. $category = $this->input->get('category', true);
  3688. $size = $this->input->get('size', true);
  3689. $grade = $this->input->get('grade', true);
  3690. $color = $this->input->get('color', true);
  3691. $lowe = $this->input->get('lowe', true);
  3692. $sku = $this->input->get('sku', true);
  3693. $title = $this->input->get('title', true);
  3694. $warehouse = $this->input->get('warehouse', true);
  3695. $purchase = $this->input->get('purchase', true);
  3696. $lacetype = $this->input->get('lacetype', true);
  3697. $haircap = $this->input->get('haircap', true);
  3698. $lacecolor = $this->input->get('lacecolor', true);
  3699. $density = $this->input->get('density', true);
  3700. $details = $this->input->get('details', true);
  3701. $state = $this->input->get('state', true);
  3702. $shop = $this->input->get('shop', true);
  3703. $hairnumber = $this->input->get('hairnumber', true);
  3704. $type_leixi = $this->input->get('type', true);
  3705. $cpbz = $this->input->get('cpbz', true);
  3706. $sm = $this->input->get('sm', true);
  3707. $sid = $this->input->get('sid', true);
  3708. $ktime = $this->input->get('ktime', true);
  3709. $jtime = $this->input->get('jtime', true);
  3710. $ktime = strtotime($ktime);
  3711. $jtime = strtotime($jtime);
  3712. //$where = " 1=1 ";
  3713. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3714. $where = " sku != '' ";
  3715. $gj = "";
  3716. $ck = "";
  3717. if ($category) {
  3718. $where .= " and features like '%-$category-%'";
  3719. }
  3720. if ($size) {
  3721. $where .= " and features like '%-$size-%'";
  3722. }
  3723. if ($grade) {
  3724. $where .= " and features like '%-$grade-%'";
  3725. }
  3726. if ($color) {
  3727. $where .= " and features like '%-$color-%'";
  3728. }
  3729. if ($lowe) {
  3730. $where .= " and features like '%-$lowe-%'";
  3731. }
  3732. if ($warehouse) {
  3733. $where .= " and warehouse = '$warehouse'";
  3734. }
  3735. if ($purchase) {
  3736. $where .= " and purchase = '$purchase'";
  3737. }
  3738. if ($state) {
  3739. $where .= " and state = '$state'";
  3740. }
  3741. if ($lacetype) {
  3742. $where .= " and features like '%-$lacetype-%'";
  3743. }
  3744. if ($lacecolor) {
  3745. $where .= " and features like '%-$lacecolor-%'";
  3746. }
  3747. if ($density) {
  3748. $where .= " and features like '%-$density-%'";
  3749. }
  3750. if ($haircap) {
  3751. $where .= " and features like '%-$haircap-%'";
  3752. }
  3753. if ($details) {
  3754. $where .= " and details = '$details'";
  3755. }
  3756. if ($shop) {
  3757. $where .= " and shop like '%$shop%'";
  3758. }
  3759. if ($title) {
  3760. $title = trim($title, ' ');
  3761. $title = trim($title, ' ');
  3762. $where .= " and title like '%$title%'";
  3763. }
  3764. if (!empty($hairnumber)) {
  3765. $where .= " and features like '%-128-%' ";
  3766. if ($hairnumber < 0) {
  3767. $class_list = $this->typeclass->find_all('classid = 43');
  3768. foreach ($class_list as $v) {
  3769. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3770. }
  3771. } else {
  3772. $where .= " and features like '%-$hairnumber-%'";
  3773. }
  3774. }
  3775. if ($type_leixi) {
  3776. $where .= " and type = '$type_leixi'";
  3777. }
  3778. if ($cpbz) {
  3779. $where .= " and cpbz like '%$cpbz%' ";
  3780. }
  3781. if ($sm) {
  3782. $where .= " and sm like '%$sm%' ";
  3783. }
  3784. if ($sku) {
  3785. $sku = trim($sku, ' ');
  3786. $sku = trim($sku, ' ');
  3787. $where .= " and sku like '%$sku%'";
  3788. }
  3789. if ($ktime && $jtime) {
  3790. if ($type == 1) {
  3791. $tl = '出库';
  3792. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3793. } else if ($type == 2) {
  3794. $tl = '退库';
  3795. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3796. } else if ($type == 3) {
  3797. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3798. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3799. } else if ($type == 4) {
  3800. $tl = '出库+零售';
  3801. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3802. } else if ($type == 5) {
  3803. $tl = '零售';
  3804. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3805. }
  3806. }
  3807. $sidwhere = '';
  3808. if ($sid) {
  3809. $sd = "";
  3810. $s = explode(',', trim($sid, ','));
  3811. foreach ($s as $value) {
  3812. $sd .= " id = " . $value . " or";
  3813. }
  3814. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3815. }
  3816. //数据排序
  3817. $order_str = "time desc";
  3818. if (empty($page)) {
  3819. $start = 0;
  3820. $perpage = 1;
  3821. } else {
  3822. $start = ($page - 1) * $perpage;
  3823. }
  3824. //取得信息列表
  3825. if ($type != 3 && $type != 5) {
  3826. if ($type == 1 || $type == 4) {
  3827. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3828. foreach ($info_list as $key => $value) {
  3829. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3830. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3831. $warehouse = $this->warehouse->read($value['warehouse']);
  3832. $info_list[$key]['warehouse'] = $warehouse['title'];
  3833. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3834. $features = explode('-', trim($features, '-'));
  3835. $pm = $classid;
  3836. foreach ($features as $k => $v) {
  3837. if ($v != 0) {
  3838. if (!isset($typeclass[$v])) {
  3839. continue;
  3840. }
  3841. if (isset($pm[$typeclass[$v]['classid']])) {
  3842. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3843. $tz = explode('|', $typeclass[$v]['zh']);
  3844. $pm[$typeclass[$v]['classid']] = $tz[0];
  3845. } else {
  3846. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3847. }
  3848. }
  3849. }
  3850. }
  3851. $zh = implode(" ", $pm);
  3852. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3853. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3854. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3855. $info_list[$key]['features'] = $zh;
  3856. }
  3857. $final_list = [];
  3858. foreach($info_list as $k=>$v){
  3859. $number = "";
  3860. if(!empty($v['orderinfo'])){
  3861. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3862. if(!empty($tmp_info['number'])){
  3863. $number = $tmp_info['number'];
  3864. }
  3865. }
  3866. $final_list[] = [
  3867. 'warehouse'=>$v['warehouse'],
  3868. 'purchase'=>$v['purchase'],
  3869. 'sku'=>$v['sku'],
  3870. 'title'=>$v['title'],
  3871. 'features'=>$v['features'],
  3872. 'label'=>$v['label'],
  3873. 'orderinfo'=>$v['orderinfo'],
  3874. 'number'=>$number,
  3875. 'waybill'=>$v['waybill'],
  3876. 'outk'=>$v['outk'],
  3877. ];
  3878. }
  3879. } else {
  3880. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3881. foreach ($info_list as $key => $value) {
  3882. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3883. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3884. $warehouse = $this->warehouse->read($value['warehouse']);
  3885. $info_list[$key]['warehouse'] = $warehouse['title'];
  3886. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3887. $features = explode('-', trim($features, '-'));
  3888. $pm = $classid;
  3889. foreach ($features as $k => $v) {
  3890. if ($v != 0) {
  3891. if (!isset($typeclass[$v])) {
  3892. continue;
  3893. }
  3894. if (isset($pm[$typeclass[$v]['classid']])) {
  3895. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3896. $tz = explode('|', $typeclass[$v]['zh']);
  3897. $pm[$typeclass[$v]['classid']] = $tz[0];
  3898. } else {
  3899. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3900. }
  3901. }
  3902. }
  3903. }
  3904. $zh = implode(" ", $pm);
  3905. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3906. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3907. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3908. $info_list[$key]['features'] = $zh;
  3909. }
  3910. $final_list = [];
  3911. foreach($info_list as $k=>$v){
  3912. $number = "";
  3913. if(!empty($v['orderinfo'])){
  3914. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3915. if(!empty($tmp_info['number'])){
  3916. $number = $tmp_info['number'];
  3917. }
  3918. }
  3919. $final_list[] = [
  3920. 'warehouse'=>$v['warehouse'],
  3921. 'purchase'=>$v['purchase'],
  3922. 'sku'=>$v['sku'],
  3923. 'title'=>$v['title'],
  3924. 'features'=>$v['features'],
  3925. 'label'=>$v['label'],
  3926. 'orderinfo'=>$v['orderinfo'],
  3927. 'number'=>$number,
  3928. 'waybill'=>$v['waybill'],
  3929. 'retreat'=>$v['retreat'],
  3930. ];
  3931. }
  3932. }
  3933. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3934. $titlename = "<table border=1>
  3935. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3936. <tr align='center'>
  3937. <td>仓库</td>
  3938. <td>供应商</td>
  3939. <td>SKU</td>
  3940. <td>商品名称</td>
  3941. <td>商品中文</td>
  3942. <td>标签</td>
  3943. <td>订单号</td>
  3944. <td>订单编码</td>
  3945. <td>运单号</td>
  3946. <td>" . $tl . "时间(中国时间)</td>
  3947. </tr>
  3948. </table>";
  3949. $filename = $title . ".xls";
  3950. $tail = "";
  3951. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3952. } else if ($type == 5) {
  3953. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3954. foreach ($info_list as $key => $value) {
  3955. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3956. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3957. $warehouse = $this->warehouse->read($value['warehouse']);
  3958. $info_list[$key]['warehouse'] = $warehouse['title'];
  3959. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3960. $features = explode('-', trim($features, '-'));
  3961. $pm = $classid;
  3962. foreach ($features as $k => $v) {
  3963. if ($v != 0) {
  3964. if (!isset($typeclass[$v])) {
  3965. continue;
  3966. }
  3967. if (isset($pm[$typeclass[$v]['classid']])) {
  3968. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3969. $tz = explode('|', $typeclass[$v]['zh']);
  3970. $pm[$typeclass[$v]['classid']] = $tz[0];
  3971. } else {
  3972. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3973. }
  3974. }
  3975. }
  3976. }
  3977. $zh = implode(" ", $pm);
  3978. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3979. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3980. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3981. $info_list[$key]['features'] = $zh;
  3982. }
  3983. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3984. $titlename = "<table border=1>
  3985. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3986. <tr align='center'>
  3987. <td>仓库</td>
  3988. <td>供应商</td>
  3989. <td>SKU</td>
  3990. <td>商品名称</td>
  3991. <td>商品中文</td>
  3992. <td>标签</td>
  3993. <td>" . $tl . "时间(中国时间)</td>
  3994. </tr>
  3995. </table>";
  3996. $filename = $title . ".xls";
  3997. $tail = "";
  3998. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3999. } else {
  4000. /**
  4001. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4002. $rows = array();$list = array();
  4003. foreach ($info_list as $key=>$value)
  4004. {
  4005. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4006. }
  4007. **/
  4008. $wh = array();
  4009. $w = $this->warehouse->find_all('1=1', 'id,title');
  4010. foreach ($w as $v) {
  4011. $wh[$v['id']] = $v['title'];
  4012. }
  4013. $wt = array();
  4014. $whlabel_type = $this->whlabel_type->find_all();
  4015. foreach ($whlabel_type as $v) {
  4016. $wt[$v['id']] = $v['title'];
  4017. }
  4018. $classid = $this->classid->sku();
  4019. $list = array();
  4020. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4021. foreach ($rows as $key => $value) {
  4022. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4023. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4024. $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');
  4025. $details = array();
  4026. $cpid = array();
  4027. $cpbz = array();
  4028. $c = 0;
  4029. $g = 0;
  4030. $x = 0;
  4031. $t = 0;
  4032. $s = 0;
  4033. $q = 0;
  4034. foreach ($sd as $k => $v) {
  4035. if ($v['state'] == 0) {
  4036. $c++;
  4037. }
  4038. if ($v['state'] != 9) {
  4039. $g++;
  4040. }
  4041. if ($v['outk'] > 1) {
  4042. $x++;
  4043. }
  4044. if ($v['retreat'] > 0) {
  4045. $t++;
  4046. }
  4047. if ($v['state'] == 8) {
  4048. $s++;
  4049. }
  4050. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4051. $q++;
  4052. }
  4053. $details[$v['details']] = $v['details'];
  4054. if ($v['cpid'] != 0) {
  4055. $cpid[$v['cpid']] = $v['cpid'];
  4056. }
  4057. if ($v['cpbz'] != '') {
  4058. $cpbz[$v['cpbz']] = $v['cpbz'];
  4059. }
  4060. }
  4061. if (isset($wt[$value['type']])) {
  4062. $rows[$key]['type'] = $wt[$value['type']];
  4063. } else {
  4064. $rows[$key]['type'] = '未设置';
  4065. }
  4066. $rows[$key]['details'] = implode("、", $details);
  4067. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4068. $ftime = time() - 15 * 24 * 3600;
  4069. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4070. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4071. $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);
  4072. $rows[$key]['c'] = $c;
  4073. $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);
  4074. $rows[$key]['t'] = $t;
  4075. $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'] . '"');
  4076. $rows[$key]['z'] = $z;
  4077. // $jm = $classid;
  4078. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4079. $features = explode('-', trim($features, '-'));
  4080. // $pm = $classid;
  4081. // foreach ($features as $k => $v) {
  4082. // if ($v != 0) {
  4083. // if (!isset($typeclass[$v])) {
  4084. // continue;
  4085. // }
  4086. // if (isset($pm[$typeclass[$v]['classid']])) {
  4087. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4088. // $tz = explode('|', $typeclass[$v]['zh']);
  4089. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4090. // } else {
  4091. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4092. // }
  4093. // if (isset($jm[$typeclass[$v]['classid']])) {
  4094. // if ($typeclass[$v]['jm']) {
  4095. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4096. // }
  4097. // }
  4098. // }
  4099. // }
  4100. // }
  4101. // $zh = implode(" ", $pm);
  4102. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4103. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4104. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4105. // $rows[$key]['features'] = $zh;
  4106. // $jm = array_filter($jm); //去除空值
  4107. // $jm = implode("-", $jm);
  4108. // $rows[$key]['jm'] = $jm;
  4109. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4110. }
  4111. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4112. // echo "<pre>";
  4113. // print_r($tmp_list);
  4114. // die;
  4115. $final_list =[];
  4116. foreach($tmp_list as $k=>$v){
  4117. $final_list[] = [
  4118. "warehouse"=>$v['warehouse'],
  4119. "purchase"=>$v['purchase'],
  4120. "details"=>$v['details'],
  4121. "cpid"=>$v['cpid'],
  4122. "sku"=>$v['sku'],
  4123. "title"=>$v['title'],
  4124. "features"=>$v['pm'],
  4125. "cpbz"=>$v['cpbz'],
  4126. "sm"=>$v['sm'],
  4127. "type"=>$v['type'],
  4128. "g"=>$v["g"],
  4129. "c"=>$v["c"],
  4130. "x"=>$v["x"],
  4131. "t"=>$v["t"],
  4132. "z"=>$v["z"],
  4133. "jm"=>$v["jm"],
  4134. "weight"=>$v["weight"],
  4135. "asd"=>$v["asd"],
  4136. ];
  4137. }
  4138. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4139. $titlename = "<table border=1>
  4140. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4141. <tr align='center'>
  4142. <td>仓库</td>
  4143. <td>供应商</td>
  4144. <td>位置</td>
  4145. <td>库存编码</td>
  4146. <td>SKU</td>
  4147. <td>商品名称</td>
  4148. <td>商品中文</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. </tr>
  4161. </table>";
  4162. $filename = $title . ".xls";
  4163. $tail = "";
  4164. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4165. }
  4166. }
  4167. }
  4168. //出库+入库数据整合
  4169. public function _excelcr()
  4170. {
  4171. if (isset($_GET['excel'])) {
  4172. $type = $this->input->get('excel', true);
  4173. $category = $this->input->get('category', true);
  4174. $size = $this->input->get('size', true);
  4175. $grade = $this->input->get('grade', true);
  4176. $color = $this->input->get('color', true);
  4177. $lowe = $this->input->get('lowe', true);
  4178. $sku = $this->input->get('sku', true);
  4179. $warehouse = $this->input->get('warehouse', true);
  4180. $purchase = $this->input->get('purchase', true);
  4181. $state = $this->input->get('state', true);
  4182. $sid = $this->input->get('sid', true);
  4183. $ktime = $this->input->get('ktime', true);
  4184. $jtime = $this->input->get('jtime', true);
  4185. $ktime = strtotime($ktime);
  4186. $jtime = strtotime($jtime);
  4187. $where = "1=1";
  4188. $gj = "";
  4189. $ck = "";
  4190. if ($category) {
  4191. $where .= " and features like '%-$category-%'";
  4192. }
  4193. if ($size) {
  4194. $where .= " and features like '%-$size-%'";
  4195. }
  4196. if ($grade) {
  4197. $where .= " and features like '%-$grade-%'";
  4198. }
  4199. if ($color) {
  4200. $where .= " and features like '%-$color-%'";
  4201. }
  4202. if ($lowe) {
  4203. $where .= " and features like '%-$lowe-%'";
  4204. }
  4205. if ($warehouse) {
  4206. $where .= " and warehouse = '$warehouse'";
  4207. }
  4208. if ($purchase) {
  4209. $where .= " and purchase = '$purchase'";
  4210. }
  4211. if ($state) {
  4212. $where .= " and state = '$state'";
  4213. }
  4214. if ($sku) {
  4215. $where .= " and sku like '%$sku%'";
  4216. }
  4217. if ($ktime && $jtime) {
  4218. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4219. }
  4220. $sidwhere = '';
  4221. if ($sid) {
  4222. $sd = "";
  4223. $s = explode(',', trim($sid, ','));
  4224. foreach ($s as $value) {
  4225. $sd .= " id = " . $value . " or";
  4226. }
  4227. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4228. }
  4229. //取得信息列表
  4230. $timeread = $ktime;
  4231. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4232. $timelist = array();
  4233. for ($i = 0; $i < $timenum; $i++) {
  4234. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4235. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4236. }
  4237. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4238. //echo "<pre>";
  4239. //print_r($info_list);
  4240. //exit();
  4241. $rows = array();
  4242. $list = array();
  4243. foreach ($info_list as $key => $value) {
  4244. $thistime = $timelist;
  4245. if (isset($rows[strtolower($value['sku'])])) {
  4246. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4247. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4248. }
  4249. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4250. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4251. }
  4252. } else {
  4253. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4254. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4255. }
  4256. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4257. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4258. }
  4259. $rows[strtolower($value['sku'])] = $thistime;
  4260. }
  4261. }
  4262. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4263. <head>
  4264. <!--[if gte mso 9]><xml>
  4265. <x:ExcelWorkbook>
  4266. <x:ExcelWorksheets>
  4267. <x:ExcelWorksheet>
  4268. <x:Name>EXCEL</x:Name>
  4269. <x:WorksheetOptions>
  4270. <x:Print>
  4271. <x:ValidPrinterInfo />
  4272. </x:Print>
  4273. </x:WorksheetOptions>
  4274. </x:ExcelWorksheet>
  4275. </x:ExcelWorksheets>
  4276. </x:ExcelWorkbook>
  4277. </xml>
  4278. <![endif]-->
  4279. </head><body>";
  4280. $str .= "<table border=1><tr><td>SKU</td>";
  4281. foreach ($timelist as $k => $v) {
  4282. $str .= "<td>" . $k . "出库</td>";
  4283. $str .= "<td>" . $k . "入库</td>";
  4284. }
  4285. $str .= "</tr></table>";
  4286. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4287. foreach ($rows as $key => $val) {
  4288. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4289. foreach ($val as $k => $v) {
  4290. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4291. if ($val[$k]['r'] > 0) {
  4292. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4293. } else {
  4294. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4295. }
  4296. }
  4297. $str .= "</tr>";
  4298. }
  4299. $str .= "</table>";
  4300. $str .= "</body></html>";
  4301. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4302. header("Content-type: application/octet-stream");
  4303. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4304. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4305. header("Pragma: no-cache");
  4306. header("Expires: 0");
  4307. exit($str);
  4308. }
  4309. }
  4310. //数量调整模板导出
  4311. public function _presetout()
  4312. {
  4313. if (isset($_GET['excel'])) {
  4314. $where = "sku != 'Preset' and purchase != 0";
  4315. //数据排序
  4316. $order_str = "id desc";
  4317. if (empty($page)) {
  4318. $start = 0;
  4319. $perpage = 1;
  4320. } else {
  4321. $start = ($page - 1) * $perpage;
  4322. }
  4323. //取得信息列表
  4324. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4325. $rows = array();
  4326. $list = array();
  4327. foreach ($info_list as $value) {
  4328. $warehouse = $this->warehouse->read($value['warehouse']);
  4329. $number = $value['number'];
  4330. $ftime = time() - 15 * 24 * 3600;
  4331. $purchase = $this->purchase->read($value['purchase']);
  4332. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4333. }
  4334. $title = "库存模板";
  4335. $titlename = "<table border=1>
  4336. <tr align='center'>
  4337. <td>仓库</td>
  4338. <td>供应商编码</td>
  4339. <td>SKU</td>
  4340. <td>增减数量(正数或负数)</td>
  4341. <td>增减备注</td>
  4342. <td>扣减方式:0减少库存1删除库存</td>
  4343. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4344. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4345. </tr>
  4346. </table>";
  4347. $filename = $title . ".xls";
  4348. $tail = "";
  4349. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4350. }
  4351. }
  4352. //数量调整模板导入
  4353. public function _presetedit()
  4354. {
  4355. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4356. $config['upload_path'] = '.' . $dir;
  4357. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4358. $config['allowed_types'] = 'xls|xlsx|csv';
  4359. $config['max_size'] = 10240;
  4360. $this->load->library('upload', $config);
  4361. $this->upload->initialize($config);
  4362. if ($this->upload->do_upload('userfile')) {
  4363. $full_path = $dir . $this->upload->data('file_name');
  4364. $fileName = '.' . $full_path;
  4365. if (!file_exists($fileName)) {
  4366. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4367. exit;
  4368. } else {
  4369. require_once "./data/excel/PHPExcel/IOFactory.php";
  4370. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4371. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4372. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4373. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4374. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4375. ++$column; //如果列数大于26行
  4376. $list = array();
  4377. for ($i = 2; $i <= $row; $i++) // 行数循环
  4378. {
  4379. $data = array();
  4380. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4381. {
  4382. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4383. }
  4384. $list[] = $data;
  4385. }
  4386. }
  4387. $i = 0;
  4388. $j = 0;
  4389. $ed = array();
  4390. foreach ($list as $key => $value) {
  4391. $time = time();
  4392. if ($value['0'] == "") {
  4393. continue;
  4394. }
  4395. $warehouse = $this->warehouse->get_title($value['0']);
  4396. $purchase = $this->purchase->get_bm($value['1']);
  4397. $sku = $value['2'];
  4398. $num = $value['3']; //调整数量
  4399. $text = $value['4']; //扣减说明
  4400. $type = $value['5']; //调整方式0扣减1删除
  4401. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4402. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4403. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4404. if (!$purchase) //如果没有这个SKU
  4405. {
  4406. $ed[] = array($purchase . '-不存在此供应商编码');
  4407. $j++;
  4408. continue;
  4409. }
  4410. if (!$d) //如果没有这个SKU
  4411. {
  4412. $ed[] = array($sku . '-库存中不存在此SKU');
  4413. $j++;
  4414. continue;
  4415. }
  4416. if (!isset($warehouse['id'])) {
  4417. $ed[] = array($sku . '-仓库名错误!');
  4418. $j++;
  4419. continue;
  4420. }
  4421. if ($type != '0' && $type != '1') {
  4422. $ed[] = array($sku . '-扣减方式填写错误!');
  4423. $j++;
  4424. continue;
  4425. }
  4426. if ($num < 0) //扣减库存
  4427. {
  4428. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4429. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4430. $j++;
  4431. continue;
  4432. }
  4433. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4434. if (count($data) < abs($num)) {
  4435. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4436. $j++;
  4437. continue;
  4438. }
  4439. if ($type == 0) //如果扣减方式为 扣减库存
  4440. {
  4441. for ($i = 0; $i < abs($num); $i++) {
  4442. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4443. }
  4444. } else if ($type == 1) {
  4445. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4446. if (count($zt) > 0) {
  4447. $ed[] = array($sku . '-有在途库存无法删除!');
  4448. $j++;
  4449. continue;
  4450. }
  4451. for ($i = 0; $i < abs($num); $i++) {
  4452. $this->whlabel->remove($data[$i]['id']);
  4453. }
  4454. }
  4455. } else if ($num > 0) //增加库存
  4456. {
  4457. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4458. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4459. $j++;
  4460. continue;
  4461. }
  4462. $post['sku'] = $d['sku'];
  4463. $post['shop'] = $d['shop'];
  4464. $post['warehouse'] = $warehouse['id'];
  4465. $post['purchase'] = $purchase['id'];
  4466. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4467. $post['state'] = 0;
  4468. $post['title'] = $d['title'];
  4469. $post['number'] = $d['number'];
  4470. $post['features'] = $d['features'];
  4471. $post['enter'] = $time;
  4472. $post['time'] = $time; //操作时间
  4473. $post['rktype'] = $rktype;
  4474. for ($i = 0; $i < $num; $i++) {
  4475. $post['label'] = time() . rand(100, 999) . $i;
  4476. $this->whlabel->insert($post);
  4477. }
  4478. }
  4479. sleep(1); //防止入库时间一样,需要延迟1秒
  4480. }
  4481. if ($j > 0) {
  4482. $tt = date('Ymd', time());
  4483. $title = '库存导入错误信息-' . $tt;
  4484. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4485. $tail = "\n";
  4486. $filename = $title . ".xls";
  4487. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4488. $dir = '/data/excel/' . $time . '/';
  4489. $file_name = 'error_' . $time . rand(1000, 9999);
  4490. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4491. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4492. fwrite($myfile, $ecl);
  4493. fclose($myfile);
  4494. $error = $dir . $file_name . '.xls';
  4495. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4496. exit;
  4497. } else {
  4498. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4499. exit;
  4500. }
  4501. }
  4502. }
  4503. //笛卡儿积
  4504. function cp($ps, $sets, $list)
  4505. {
  4506. $result = array();
  4507. $j = 0;
  4508. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4509. if ($i == 0) {
  4510. $result = $sets[$i];
  4511. }
  4512. $tmp = array();
  4513. foreach ($result as $res) {
  4514. foreach ($sets[$i + 1] as $set) {
  4515. $tmp[] = $res . ',' . $set;
  4516. }
  4517. }
  4518. $result = $tmp;
  4519. }
  4520. $this->db->trans_begin();
  4521. foreach ($result as $v) {
  4522. $post = array();
  4523. $title = "";
  4524. $num = "";
  4525. $data = explode(',', $v);
  4526. for ($i = 0; $i < count($list); $i++) {
  4527. $post[$list[$i]] = $data[$i];
  4528. $typeclass = $this->typeclass->read($data[$i]);
  4529. $title = $title . $typeclass['title'] . " ";
  4530. if ($data[$i] != 0) {
  4531. $num .= $data[$i]; //所有数据ID拼接
  4532. }
  4533. }
  4534. foreach ($ps as $kp => $vp) {
  4535. $post[$kp] = $vp;
  4536. }
  4537. $post['number'] = $num;
  4538. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4539. if ($info_list) {
  4540. $j++;
  4541. } else {
  4542. $skunum = $this->whlabel->find_count();
  4543. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4544. $post['title'] = rtrim($title, ' ');
  4545. $this->whlabel->insert($post);
  4546. }
  4547. }
  4548. if ($this->db->trans_status() === FALSE) {
  4549. $this->db->trans_commit();
  4550. return NULL;
  4551. } else {
  4552. $this->db->trans_commit();
  4553. return $j;
  4554. }
  4555. }
  4556. public function _kj($arg_array)
  4557. {
  4558. if (isset($_POST['sku'])) {
  4559. $time = time();
  4560. $sku = $this->input->post('sku', true);
  4561. $warehouse = $this->input->post('warehouse', true);
  4562. $num = $this->input->post('num', true);
  4563. $text = $this->input->post('text', true);
  4564. $purchase = $this->input->post('purchase', true);
  4565. $cktype = $this->input->post('cktype', true);
  4566. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4567. if ($cktype != 1 && $text == '') {
  4568. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4569. exit;
  4570. }
  4571. if ($num > count($order)) {
  4572. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4573. exit;
  4574. } else {
  4575. for ($i = 0; $i < $num; $i++) {
  4576. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4577. }
  4578. }
  4579. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4580. exit;
  4581. }
  4582. $uid = $this->whlabel->read($arg_array[0]);
  4583. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4584. $this->data['data'] = $uid;
  4585. $this->_Template('whlabel_kj', $this->data);
  4586. }
  4587. public function _summary($arg_array)
  4588. {
  4589. $prc = array();
  4590. $purchase = $this->purchase->find_all();
  4591. foreach ($purchase as $k => $v) {
  4592. $prc[$v['id']] = $v['title'];
  4593. }
  4594. if (isset($_GET['excel'])) {
  4595. $ktime = $this->input->get('ktime', true);
  4596. $jtime = $this->input->get('jtime', true);
  4597. $ktime = strtotime($ktime);
  4598. $jtime = strtotime($jtime);
  4599. $where = "1=1";
  4600. if ($ktime && $jtime) {
  4601. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4602. }
  4603. //数据排序
  4604. $order_str = "time desc";
  4605. if (empty($page)) {
  4606. $start = 0;
  4607. $perpage = 1;
  4608. } else {
  4609. $start = ($page - 1) * $perpage;
  4610. }
  4611. //取得信息列表
  4612. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4613. foreach ($info_list as $key => $value) {
  4614. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4615. $warehouse = $this->warehouse->read($value['warehouse']);
  4616. $info_list[$key]['warehouse'] = $warehouse['title'];
  4617. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4618. $details = array();
  4619. $cpid = array();
  4620. foreach ($x as $k => $v) {
  4621. if ($v['details'] != '') {
  4622. $details[$v['details']] = $v['details'];
  4623. }
  4624. if ($v['cpid'] != 0) {
  4625. $cpid[$v['cpid']] = $v['cpid'];
  4626. }
  4627. }
  4628. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4629. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4630. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4631. $info_list[$key]['s'] = $s;
  4632. $info_list[$key]['x'] = count($x);
  4633. }
  4634. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4635. $titlename = "<table border=1>
  4636. <tr align='center'>
  4637. <td>仓库</td>
  4638. <td>供应商</td>
  4639. <td>出库位置</td>
  4640. <td>出库编码</td>
  4641. <td>SKU</td>
  4642. <td>产品名</td>
  4643. <td>总剩余库存</td>
  4644. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4645. </tr>
  4646. </table>";
  4647. $filename = $title . ".xls";
  4648. $tail = "";
  4649. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4650. }
  4651. }
  4652. //usps发货清单
  4653. public function _manifest()
  4654. {
  4655. if (isset($_POST['manifest'])) {
  4656. $wltext = $this->input->post('wltext', true);
  4657. $time = time() - 16 * 3600;
  4658. $ptime = strtotime(date('Y-m-d', $time));
  4659. $waybill = array();
  4660. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4661. foreach ($fullorder as $v) {
  4662. $waybill[$v['waybill']] = $v['waybill'];
  4663. }
  4664. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4665. foreach ($fullordersmt as $v) {
  4666. $waybill[$v['waybill']] = $v['waybill'];
  4667. }
  4668. $wltext = explode(';', $wltext);
  4669. foreach ($wltext as $v) {
  4670. if (isset($waybill[$v])) {
  4671. unset($waybill[$v]);
  4672. }
  4673. }
  4674. $data = $this->usps->get_manifest($waybill);
  4675. if (isset($data['Description'])) {
  4676. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4677. exit;
  4678. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4679. $bctime = date('Ymd', time());
  4680. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4681. echo json_encode(array('msg' => $pdf, 'success' => true));
  4682. exit;
  4683. } else {
  4684. echo json_encode(array('msg' => $data, 'success' => false));
  4685. exit;
  4686. }
  4687. }
  4688. }
  4689. public function _pdf($pdf, $title, $bctime)
  4690. {
  4691. $pdf_path = './data/pdf/' . $bctime . '/';
  4692. $file_base64 = $pdf;
  4693. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4694. $file_base64 = base64_decode($file_base64);
  4695. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4696. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4697. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4698. }
  4699. /**
  4700. *
  4701. *
  4702. *
  4703. 进销存占单异常索引
  4704. *
  4705. *
  4706. *
  4707. **/
  4708. public function _abnormal()
  4709. {
  4710. $post = $this->input->post(NULL, TRUE);
  4711. if (isset($post['page'])) {
  4712. $page = $this->input->post('page', true);
  4713. $perpage = $this->input->post('perpage', true);
  4714. $sku = $this->input->post('sku', true);
  4715. $where = "1=1";
  4716. //数据排序
  4717. $order_str = "id desc";
  4718. if (empty($page)) {
  4719. $start = 0;
  4720. $perpage = 1;
  4721. } else {
  4722. $start = ($page - 1) * $perpage;
  4723. }
  4724. //取得信息列表
  4725. $info_list = $this->whlabel->find_all($where, '*');
  4726. $rows = array();
  4727. $list = array();
  4728. foreach ($info_list as $key => $value) {
  4729. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4730. }
  4731. foreach ($rows as $value) {
  4732. $warehouse = $this->warehouse->read($value['warehouse']);
  4733. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4734. $number = $value['number'];
  4735. $ftime = time() - 15 * 24 * 3600;
  4736. if ($value['shop'] != '') {
  4737. $shop = $value['shop'];
  4738. $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');
  4739. $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');
  4740. $order = array_merge($orderdlz, $ordersmt);
  4741. $od = 0;
  4742. $a = '';
  4743. $orid = '';
  4744. foreach ($order as $v) {
  4745. $or = explode('|', ltrim($v['whlabel'], '|'));
  4746. for ($i = 0; $i < count($or); $i++) {
  4747. $orod = explode('-', $or[$i]);
  4748. if ($orod[0] == $number) {
  4749. $od += $orod[1];
  4750. }
  4751. }
  4752. $orid .= $v['number'] . '-';
  4753. }
  4754. } else {
  4755. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4756. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4757. $order = array_merge($orderdlz, $ordersmt);
  4758. $od = 0;
  4759. $a = '';
  4760. $orid = '';
  4761. $qt = array();
  4762. foreach ($order as $v) {
  4763. $or = explode('|', ltrim($v['whlabel'], '|'));
  4764. for ($i = 0; $i < count($or); $i++) {
  4765. $orod = explode('-', $or[$i]);
  4766. if ($orod[0] == $number) {
  4767. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4768. if ($czzs > 0) {
  4769. if (isset($qt[$v['shop']])) {
  4770. if ($qt[$v['shop']] < $orod[1]) {
  4771. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4772. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4773. } else {
  4774. $qt[$v['shop']] -= $orod[1];
  4775. }
  4776. } else {
  4777. $qt[$v['shop']] = $czzs;
  4778. }
  4779. } else {
  4780. $od += $orod[1];
  4781. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4782. }
  4783. }
  4784. }
  4785. }
  4786. }
  4787. $z = $od . '(' . $orid . ')'; //查看订单号
  4788. //$z = $od;
  4789. if ($od > $c) {
  4790. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4791. }
  4792. }
  4793. $listdata = array_slice($list, $start, $perpage);
  4794. $total = count($list);
  4795. $pagenum = ceil($total / $perpage);
  4796. $over = $total - ($start + $perpage);
  4797. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4798. echo json_encode($rows);
  4799. exit;
  4800. }
  4801. $this->_Template('whlabel_abnormal', $this->data);
  4802. }
  4803. /**
  4804. *
  4805. *
  4806. *
  4807. 进销存占单异常索引
  4808. *
  4809. *
  4810. *
  4811. **/
  4812. public function _error()
  4813. {
  4814. $post = $this->input->post(NULL, TRUE);
  4815. if (isset($post['page'])) {
  4816. $page = $this->input->post('page', true);
  4817. $perpage = $this->input->post('perpage', true);
  4818. $sku = $this->input->post('sku', true);
  4819. $warehouse = $this->input->post('warehouse', true);
  4820. $ktime = $this->input->post('ktime', true);
  4821. $jtime = $this->input->post('jtime', true);
  4822. $ktime = strtotime($ktime);
  4823. $jtime = strtotime($jtime);
  4824. $where = "sku != 'Preset'";
  4825. $gj = '';
  4826. if ($sku) {
  4827. $where .= " and sku like '%$sku%'";
  4828. } else {
  4829. if ($ktime && $jtime) {
  4830. $gj = " and time > '$ktime' and time < '$jtime'";
  4831. }
  4832. }
  4833. if ($warehouse) {
  4834. $where .= " and warehouse = '$warehouse'";
  4835. }
  4836. //数据排序
  4837. $order_str = "id desc";
  4838. if (empty($page)) {
  4839. $start = 0;
  4840. $perpage = 1;
  4841. } else {
  4842. $start = ($page - 1) * $perpage;
  4843. }
  4844. //取得信息列表
  4845. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4846. $rows = array();
  4847. $list = array();
  4848. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4849. // foreach ($info_list as $value)
  4850. // {
  4851. // $warehouse = $this->warehouse->read($value['warehouse']);
  4852. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4853. // $number = $value['number'];$ftime = time()-15*24*3600;
  4854. // if($c < 1)
  4855. // {
  4856. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4857. // }
  4858. // }
  4859. $warehouse_list = $this->warehouse->find_all();
  4860. $warehouse_list = array_column($warehouse_list, null, 'id');
  4861. foreach ($info_list as $value) {
  4862. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4863. 'title' => "",
  4864. ];
  4865. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4866. $number = $value['number'];
  4867. $ftime = time() - 15 * 24 * 3600;
  4868. if ($c < 1) {
  4869. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4870. }
  4871. }
  4872. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4873. // $query = $this->db->query($sql);
  4874. // $info_list = $query->result_array();
  4875. // $sql_two = "select title,id from crowd_warehouse";
  4876. // $query_two = $this->db->query($sql_two);
  4877. // $warehouse_list = $query_two->result_array();
  4878. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4879. // foreach ($info_list as $value)
  4880. // {
  4881. // if(isset($warehouse_arr[$value['warehouse']])){
  4882. // $warehouse = $warehouse_arr[$value['warehouse']];
  4883. // }else{
  4884. // $warehouse = [
  4885. // 'id'=>0,
  4886. // 'title'=>"异常",
  4887. // ];
  4888. // }
  4889. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4890. // $number = $value['number'];$ftime = time()-15*24*3600;
  4891. // if($c < 1)
  4892. // {
  4893. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4894. // }
  4895. // }
  4896. $listdata = array_slice($list, $start, $perpage);
  4897. $total = count($list);
  4898. $pagenum = ceil($total / $perpage);
  4899. $over = $total - ($start + $perpage);
  4900. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4901. echo json_encode($rows);
  4902. exit;
  4903. }
  4904. if (isset($post['s'])) {
  4905. $id_arr = $this->input->post('s');
  4906. $id_arr = explode(',', trim($id_arr, ','));
  4907. if (!$id_arr) {
  4908. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4909. exit;
  4910. }
  4911. //循环删除记录
  4912. foreach ($id_arr as $v) {
  4913. $dd = $this->whlabel->read($v);
  4914. if (!isset($dd['id'])) {
  4915. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4916. exit;
  4917. }
  4918. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4919. if (isset($zt[0])) {
  4920. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4921. exit;
  4922. }
  4923. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4924. foreach ($deldd as $vv) {
  4925. $this->whlabel->remove($vv['id']);
  4926. }
  4927. }
  4928. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4929. exit;
  4930. }
  4931. $this->_Template('whlabel_error', $this->data);
  4932. }
  4933. public function _errorexcel()
  4934. {
  4935. $post = $this->input->post(NULL, TRUE);
  4936. if (isset($_GET['page'])) {
  4937. $page = $this->input->get('page', true);
  4938. $perpage = $this->input->get('perpage', true);
  4939. $sku = $this->input->get('sku', true);
  4940. $warehouse = $this->input->get('warehouse', true);
  4941. $ktime = $this->input->get('ktime', true);
  4942. $jtime = $this->input->get('jtime', true);
  4943. $ktime = strtotime($ktime);
  4944. $jtime = strtotime($jtime);
  4945. $where = "sku != 'Preset'";
  4946. $gj = '';
  4947. if ($sku) {
  4948. $where .= " and sku like '%$sku%'";
  4949. } else {
  4950. if ($ktime && $jtime) {
  4951. $gj = " and time > '$ktime' and time < '$jtime'";
  4952. }
  4953. }
  4954. if ($warehouse) {
  4955. $where .= " and warehouse = '$warehouse'";
  4956. }
  4957. //数据排序
  4958. $order_str = "id desc";
  4959. if (empty($page)) {
  4960. $start = 0;
  4961. $perpage = 1;
  4962. } else {
  4963. $start = ($page - 1) * $perpage;
  4964. }
  4965. //取得信息列表
  4966. $rows = array();
  4967. $list = array();
  4968. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4969. foreach ($info_list as $value) {
  4970. $warehouse = $this->warehouse->read($value['warehouse']);
  4971. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4972. $number = $value['number'];
  4973. $ftime = time() - 15 * 24 * 3600;
  4974. if ($c < 1) {
  4975. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4976. }
  4977. }
  4978. $title = "0库存汇总";
  4979. $titlename = "<table border=1>
  4980. <tr align='center'>
  4981. <td>仓库</td>
  4982. <td>SKU</td>
  4983. <td>产品</td>
  4984. <td>当前库存</td>
  4985. </tr>
  4986. </table>";
  4987. $filename = $title . ".xls";
  4988. $tail = "";
  4989. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4990. }
  4991. }
  4992. /**
  4993. *
  4994. *
  4995. * 占单
  4996. *
  4997. *
  4998. **/
  4999. public function _kcyz()
  5000. {
  5001. $post = $this->input->post(NULL, TRUE);
  5002. if (isset($post['warehouse'])) {
  5003. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5004. exit; //不再使用
  5005. $warehouse = $this->input->post('warehouse', true);
  5006. $whlabel = $this->input->post('whlabel', true);
  5007. $id = $this->input->post('id', true);
  5008. $shop = $this->input->post('shop', true);
  5009. $number = $this->input->post('number', true);
  5010. if (!$whlabel || $whlabel == '|') {
  5011. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5012. exit;
  5013. }
  5014. $pp = explode('|', trim($whlabel, '|'));
  5015. $x = 0;
  5016. $save = array();
  5017. foreach ($pp as $va) {
  5018. $num = explode('-', $va);
  5019. if ($number) {
  5020. $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 = '')"); //通用
  5021. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5022. } else {
  5023. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5024. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5025. }
  5026. $x++;
  5027. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5028. $save[] = $x - 1;
  5029. continue; //提前先加X不然出错,所以要减1
  5030. }
  5031. }
  5032. if (isset($save[0])) {
  5033. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5034. exit;
  5035. } else {
  5036. echo json_encode(array('success' => true));
  5037. exit;
  5038. }
  5039. }
  5040. }
  5041. public function _db()
  5042. {
  5043. $post = $this->input->post(NULL, TRUE);
  5044. if (isset($post['page'])) {
  5045. $page = $this->input->post('page', true);
  5046. $perpage = $this->input->post('perpage', true);
  5047. $sku = $this->input->post('sku', true);
  5048. $number = $this->input->post('number', true);
  5049. $warehouse = $this->input->post('warehouse', true);
  5050. $purchase = $this->input->post('purchase', true);
  5051. $orderinfo = $this->input->post('orderinfo', true);
  5052. $waybill = $this->input->post('waybill', true);
  5053. $category = $this->input->post('category', true);
  5054. $size = $this->input->post('size', true);
  5055. $grade = $this->input->post('grade', true);
  5056. $color = $this->input->post('color', true);
  5057. $lowe = $this->input->post('lowe', true);
  5058. $state = $this->input->post('state', true);
  5059. $label = $this->input->post('label', true);
  5060. $timetk = $this->input->post('timetkk', true);
  5061. $timetj = $this->input->post('timetjj', true);
  5062. $timetk = strtotime($timetk);
  5063. $timetj = strtotime($timetj);
  5064. $where = "dbtime > 0";
  5065. if ($timetk && $timetj) {
  5066. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5067. }
  5068. if ($sku) {
  5069. $where .= " and sku = '$sku'";
  5070. }
  5071. if ($warehouse) {
  5072. $where .= " and warehouse = '$warehouse'";
  5073. if ($warehouse == 12) {
  5074. $w = 'specialstock';
  5075. } else {
  5076. $w = 'whlabel';
  5077. }
  5078. }
  5079. if ($purchase) {
  5080. $where .= " and purchase = '$purchase'";
  5081. }
  5082. if ($category) {
  5083. $where .= " and features like '%-$category-%'";
  5084. }
  5085. if ($size) {
  5086. $where .= " and features like '%-$size-%'";
  5087. }
  5088. if ($grade) {
  5089. $where .= " and features like '%-$grade-%'";
  5090. }
  5091. if ($color) {
  5092. $where .= " and features like '%-$color-%'";
  5093. }
  5094. if ($lowe) {
  5095. $where .= " and features like '%-$lowe-%'";
  5096. }
  5097. if ($state != '') {
  5098. $where .= " and state = '$state'";
  5099. }
  5100. //数据排序
  5101. $order_str = "dbtime desc";
  5102. if (empty($page)) {
  5103. $start = 0;
  5104. $perpage = 1;
  5105. } else {
  5106. $start = ($page - 1) * $perpage;
  5107. }
  5108. //取得信息列表
  5109. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5110. foreach ($info_list as $key => $value) {
  5111. $warehouse = $this->$w->read($value['warehouse']);
  5112. $info_list[$key]['warehouse'] = $warehouse['title'];
  5113. $purchase = $this->purchase->read($value['purchase']);
  5114. $info_list[$key]['purchase'] = $purchase['title'];
  5115. if ($value['enter'] != 0) {
  5116. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5117. } else {
  5118. $info_list[$key]['enter'] = "";
  5119. }
  5120. if ($value['dbtime'] != 0) {
  5121. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5122. } else {
  5123. $info_list[$key]['dbtime'] = "";
  5124. }
  5125. if ($value['state'] == 0) {
  5126. $info_list[$key]['state'] = "在库";
  5127. } else if ($value['state'] == 1) {
  5128. $info_list[$key]['state'] = "出库";
  5129. } else if ($value['state'] == 2) {
  5130. $info_list[$key]['state'] = "退库";
  5131. } else if ($value['state'] == 3) {
  5132. $info_list[$key]['state'] = "调拨中";
  5133. } else if ($value['state'] == 4) {
  5134. $info_list[$key]['state'] = "再加工";
  5135. } else if ($value['state'] == 5) {
  5136. $info_list[$key]['state'] = "维修中";
  5137. } else if ($value['state'] == 6) {
  5138. $info_list[$key]['state'] = "盘亏";
  5139. } else if ($value['state'] == 7) {
  5140. $info_list[$key]['state'] = "更换标签";
  5141. } else if ($value['state'] == 8) {
  5142. $info_list[$key]['state'] = "其它";
  5143. } else if ($value['state'] == 9) {
  5144. $info_list[$key]['state'] = "预设";
  5145. }
  5146. }
  5147. $total = $this->whlabel->find_count($where);
  5148. $pagenum = ceil($total / $perpage);
  5149. $over = $total - ($start + $perpage);
  5150. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5151. echo json_encode($rows);
  5152. exit;
  5153. }
  5154. if (isset($post['outsku'])) {
  5155. $time = time();
  5156. $cz = $this->input->post('cz', true);
  5157. $label = $this->input->post('outsku', true);
  5158. $sl = $this->input->post('sl', true);
  5159. $num = $this->input->post('num', true);
  5160. //$warehouse = $this->input->post('warehouse',true);
  5161. if (!$sl) {
  5162. $sl = 1;
  5163. }
  5164. if (!$warehouse) {
  5165. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5166. exit;
  5167. }
  5168. $dblabel = $this->whlabellabel->get_label($label);
  5169. if ($dblabel) {
  5170. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5171. if (count($data) < 1) {
  5172. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5173. exit;
  5174. }
  5175. if (count($data) < $num) {
  5176. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5177. exit;
  5178. }
  5179. for ($i = 0; $i < $sl; $i++) {
  5180. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5181. }
  5182. echo json_encode(array('success' => true));
  5183. exit;
  5184. } else {
  5185. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5186. exit;
  5187. }
  5188. }
  5189. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5190. $this->_Template('whlabel_db', $this->data);
  5191. }
  5192. public function _dbrk()
  5193. {
  5194. $post = $this->input->post(NULL, TRUE);
  5195. if (isset($post['page'])) {
  5196. $page = $this->input->post('page', true);
  5197. $perpage = $this->input->post('perpage', true);
  5198. $sku = $this->input->post('sku', true);
  5199. $number = $this->input->post('number', true);
  5200. $warehouse = $this->input->post('warehouse', true);
  5201. $purchase = $this->input->post('purchase', true);
  5202. $orderinfo = $this->input->post('orderinfo', true);
  5203. $waybill = $this->input->post('waybill', true);
  5204. $category = $this->input->post('category', true);
  5205. $size = $this->input->post('size', true);
  5206. $grade = $this->input->post('grade', true);
  5207. $color = $this->input->post('color', true);
  5208. $lowe = $this->input->post('lowe', true);
  5209. $state = $this->input->post('state', true);
  5210. $label = $this->input->post('label', true);
  5211. $ctime = $this->input->post('ctime', true);
  5212. $timetk = $this->input->post('timetkk', true);
  5213. $timetj = $this->input->post('timetjj', true);
  5214. $timetk = strtotime($timetk);
  5215. $timetj = strtotime($timetj);
  5216. $where = "dbtime > 0";
  5217. if ($timetk && $timetj) {
  5218. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5219. }
  5220. if ($sku) {
  5221. $where .= " and sku = '$sku'";
  5222. }
  5223. if ($warehouse) {
  5224. $where .= " and warehouse = '$warehouse'";
  5225. }
  5226. if ($purchase) {
  5227. $where .= " and purchase = '$purchase'";
  5228. }
  5229. if ($category) {
  5230. $where .= " and features like '%-$category-%'";
  5231. }
  5232. if ($size) {
  5233. $where .= " and features like '%-$size-%'";
  5234. }
  5235. if ($grade) {
  5236. $where .= " and features like '%-$grade-%'";
  5237. }
  5238. if ($color) {
  5239. $where .= " and features like '%-$color-%'";
  5240. }
  5241. if ($lowe) {
  5242. $where .= " and features like '%-$lowe-%'";
  5243. }
  5244. if ($state != '') {
  5245. $where .= " and state = '$state'";
  5246. }
  5247. //数据排序
  5248. $order_str = "dbtime desc";
  5249. if (empty($page)) {
  5250. $start = 0;
  5251. $perpage = 1;
  5252. } else {
  5253. $start = ($page - 1) * $perpage;
  5254. }
  5255. //取得信息列表
  5256. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5257. foreach ($info_list as $key => $value) {
  5258. $warehouse = $this->warehouse->read($value['warehouse']);
  5259. $info_list[$key]['warehouse'] = $warehouse['title'];
  5260. $purchase = $this->purchase->read($value['purchase']);
  5261. $info_list[$key]['purchase'] = $purchase['title'];
  5262. if ($value['enter'] != 0) {
  5263. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5264. } else {
  5265. $info_list[$key]['enter'] = "";
  5266. }
  5267. if ($value['dbtime'] != 0) {
  5268. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5269. } else {
  5270. $info_list[$key]['dbtime'] = "";
  5271. }
  5272. if ($value['state'] == 0) {
  5273. $info_list[$key]['state'] = "在库";
  5274. } else if ($value['state'] == 1) {
  5275. $info_list[$key]['state'] = "出库";
  5276. } else if ($value['state'] == 2) {
  5277. $info_list[$key]['state'] = "退库";
  5278. } else if ($value['state'] == 3) {
  5279. $info_list[$key]['state'] = "调拨中";
  5280. } else if ($value['state'] == 4) {
  5281. $info_list[$key]['state'] = "再加工";
  5282. } else if ($value['state'] == 5) {
  5283. $info_list[$key]['state'] = "维修中";
  5284. } else if ($value['state'] == 6) {
  5285. $info_list[$key]['state'] = "盘亏";
  5286. } else if ($value['state'] == 7) {
  5287. $info_list[$key]['state'] = "更换标签";
  5288. } else if ($value['state'] == 8) {
  5289. $info_list[$key]['state'] = "其它";
  5290. } else if ($value['state'] == 9) {
  5291. $info_list[$key]['state'] = "预设";
  5292. }
  5293. }
  5294. $total = $this->whlabel->find_count($where);
  5295. $pagenum = ceil($total / $perpage);
  5296. $over = $total - ($start + $perpage);
  5297. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5298. echo json_encode($rows);
  5299. exit;
  5300. }
  5301. if (isset($post['rsku'])) {
  5302. $cz = $this->input->post('cz', true);
  5303. $label = $this->input->post('rsku', true);
  5304. $sl = $this->input->post('sl', true);
  5305. $warehouse = $this->input->post('warehouse', true);
  5306. if (!$sl) {
  5307. $sl = 1;
  5308. }
  5309. if (!$warehouse) {
  5310. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5311. exit;
  5312. }
  5313. $dblabel = $this->whlabellabel->get_label($label);
  5314. if ($dblabel) {
  5315. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5316. if (count($data) < 1) {
  5317. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5318. exit;
  5319. }
  5320. if ($sl > count($data)) {
  5321. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5322. exit;
  5323. }
  5324. $time = time();
  5325. for ($i = 0; $i < $sl; $i++) {
  5326. $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']);
  5327. }
  5328. echo json_encode(array('success' => true));
  5329. exit;
  5330. } else {
  5331. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5332. exit;
  5333. }
  5334. }
  5335. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5336. $this->_Template('whlabel_dbrk', $this->data);
  5337. }
  5338. public function _whlabelczdc()
  5339. {
  5340. if (isset($_GET['excel'])) {
  5341. //数据排序
  5342. $order_str = "id desc";
  5343. if (empty($page)) {
  5344. $start = 0;
  5345. $perpage = 1;
  5346. } else {
  5347. $start = ($page - 1) * $perpage;
  5348. }
  5349. $state = $this->input->get('state', true);
  5350. $sku = $this->input->get('sku', true);
  5351. $ctime = $this->input->get('ctime', true);
  5352. $category = $this->input->get('category', true);
  5353. $size = $this->input->get('size', true);
  5354. $grade = $this->input->get('grade', true);
  5355. $color = $this->input->get('color', true);
  5356. $lowe = $this->input->get('lowe', true);
  5357. $timetk = $this->input->get('timetkk', true);
  5358. $timetj = $this->input->get('timetjj', true);
  5359. $timetk = strtotime($timetk);
  5360. $timetj = strtotime($timetj);
  5361. $where = "dbtime > 0";
  5362. if ($timetk && $timetj) {
  5363. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5364. }
  5365. if ($category) {
  5366. $where .= " and features like '%-$category-%'";
  5367. }
  5368. if ($size) {
  5369. $where .= " and features like '%-$size-%'";
  5370. }
  5371. if ($grade) {
  5372. $where .= " and features like '%-$grade-%'";
  5373. }
  5374. if ($color) {
  5375. $where .= " and features like '%-$color-%'";
  5376. }
  5377. if ($lowe) {
  5378. $where .= " and features like '%-$lowe-%'";
  5379. }
  5380. //取得信息列表
  5381. $info_list = $this->whlabel->find_all($where, '*');
  5382. $rows = array();
  5383. $list = array();
  5384. foreach ($info_list as $key => $value) {
  5385. $rows[$value['sku']] = $value; //所有数据sku
  5386. }
  5387. foreach ($rows as $value) {
  5388. $warehouse = $this->warehouse->read($value['warehouse']);
  5389. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5390. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5391. if ($value['orderinfo'] == 0) {
  5392. $info_list[$key]['orderinfo'] = "";
  5393. }
  5394. if ($value['waybill'] == 0) {
  5395. $info_list[$key]['waybill'] = "";
  5396. }
  5397. if ($value['state'] == 0) {
  5398. $value['state'] = "在库";
  5399. } else if ($value['state'] == 3) {
  5400. $value['state'] = "调拨中";
  5401. }
  5402. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5403. }
  5404. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5405. $titlename = "<table border=1>
  5406. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5407. <tr align='center'>
  5408. <td>SKU</td>
  5409. <td>产品</td>
  5410. <td>调拨数量</td>
  5411. <td>入库数量</td>
  5412. </tr>
  5413. </table>";
  5414. $filename = $title . ".xls";
  5415. $tail = "";
  5416. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5417. }
  5418. }
  5419. public function _print($arg_array)
  5420. {
  5421. if (isset($_SESSION['api'])) {
  5422. $user = $this->user->get_api($_SESSION['api']);
  5423. $usp = $user;
  5424. $fgshop = "";
  5425. $sid = "";
  5426. $wid = "";
  5427. $wtype = "";
  5428. $usersp = explode('|', trim($user['shop'], '|'));
  5429. $userwh = explode('|', trim($user['warehouse'], '|'));
  5430. foreach ($usersp as $value) {
  5431. $fgshop .= " shop = " . $value . " or";
  5432. $sid .= " id = " . $value . " or";
  5433. }
  5434. foreach ($userwh as $value) {
  5435. $wid .= " id = " . $value . " or";
  5436. $wtype .= " type = " . $value . " or";
  5437. }
  5438. }
  5439. $post = $this->input->post(NULL, TRUE);
  5440. if (isset($post['tmsku'])) {
  5441. $tmsku = $this->input->post('tmsku', true);
  5442. if (is_numeric($tmsku)) {
  5443. $yyh = $this->whlabellabel->get_label($tmsku);
  5444. } else {
  5445. $yyh = $this->whlabellabel->get_sku($tmsku);
  5446. }
  5447. if ($yyh) {
  5448. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5449. exit;
  5450. } else {
  5451. echo json_encode(array('success' => false));
  5452. exit;
  5453. }
  5454. }
  5455. $classid = $this->classid->sku();
  5456. $pm = $classid;
  5457. $scsku = $classid;
  5458. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5459. if (isset($post['warehouse'])) {
  5460. if ($post['warehouse']) {
  5461. $list = array();
  5462. $num = "";
  5463. $title = "";
  5464. $features = "";
  5465. $order = 0;
  5466. $post['shop'] = '';
  5467. $brand = $this->input->post('brand', true);
  5468. if ($brand != '0,') {
  5469. $b = $this->brand->read(rtrim($brand, ','));
  5470. if ($b) {
  5471. $post['shop'] = str_replace('|', ',', $b['shop']);
  5472. }
  5473. }
  5474. $post['details'] = $this->input->post('details', true); //打印数量
  5475. $xbqnum = $this->input->post('xbqnum', true);
  5476. $post['purchase'] = $this->input->post('purchase', true);
  5477. $post['warehouse'] = $this->input->post('warehouse', true);
  5478. $post['purchase'] = $this->input->post('purchase', true);
  5479. $post['retreatwarehouse'] = $post['warehouse'];
  5480. $post['cpbz'] = $this->input->post('cpbz', true);
  5481. $post['state'] = 9;
  5482. $category = $this->input->post('category', true);
  5483. $list['category'] = $category;
  5484. $list['hairtype'] = $this->input->post('hairtype', true);
  5485. $list['grade'] = $this->input->post('grade', true);
  5486. $size = $this->input->post('size', true);
  5487. $list['size'] = rtrim($size, ',');
  5488. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5489. $list['extension'] = $this->input->post('extension', true);
  5490. if ($category == 1297) {
  5491. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5492. }
  5493. if ($category == 1702) {
  5494. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5495. $list['syother'] = $this->input->post('syother', true);
  5496. }
  5497. if ($category == 133) {
  5498. $list['fittype'] = $this->input->post('fittype', true);
  5499. $list['acother'] = $this->input->post('acother', true);
  5500. }
  5501. $list['color'] = $this->input->post('color', true);
  5502. $list['lowe'] = $this->input->post('lowe', true);
  5503. if ($category == 127) {
  5504. $list['type'] = $this->input->post('type', true);
  5505. $list['headroad'] = $this->input->post('headroad', true);
  5506. $list['density'] = $this->input->post('density', true);
  5507. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5508. $list['lacesize'] = $this->input->post('lacesize', true);
  5509. }
  5510. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5511. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5512. }
  5513. if ($category == 128) {
  5514. $list['lacetype'] = $this->input->post('lacetype', true);
  5515. $list['haircap'] = $this->input->post('haircap', true);
  5516. $list['density'] = $this->input->post('density', true);
  5517. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5518. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5519. $list['wigother'] = $this->input->post('wigother', true);
  5520. $list['wigother1'] = $this->input->post('wigother1', true);
  5521. $list['wigother2'] = $this->input->post('wigother2', true);
  5522. }
  5523. if ($category == 129) {
  5524. $list['wide'] = $this->input->post('wide', true);
  5525. }
  5526. if ($category == 131) {
  5527. $list['gifttype'] = $this->input->post('gifttype', true);
  5528. $list['giftother'] = $this->input->post('giftother', true);
  5529. }
  5530. if ($category == 134) {
  5531. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5532. }
  5533. if ($category == 1297) {
  5534. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5535. $list['sywigother'] = $this->input->post('sywigother', true);
  5536. }
  5537. if ($category == 130 || $category == 133 || $category == 1702) {
  5538. $list['items'] = $this->input->post('items', true);
  5539. $list['weight'] = $this->input->post('weight', true);
  5540. }
  5541. if ($category == 1702) {
  5542. $list['syhairther'] = $this->input->post('syhairther', true);
  5543. }
  5544. foreach ($list as $k => $v) {
  5545. if ($v != 0) {
  5546. $num .= $v;
  5547. $features .= $v . '-';
  5548. $post[$k] = $v;
  5549. $typeclass = $this->typeclass->read($v);
  5550. if (isset($pm[$typeclass['classid']])) {
  5551. if (stripos($typeclass['zh'], '|') !== false) {
  5552. $exzh = explode('|', $typeclass['zh']);
  5553. $pm[$typeclass['classid']] = $exzh[0];
  5554. } else {
  5555. $pm[$typeclass['classid']] = $typeclass['zh'];
  5556. }
  5557. }
  5558. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5559. if ($k != 'size') {
  5560. $title .= $typeclass['title'] . " ";
  5561. }
  5562. }
  5563. }
  5564. $typeclass = $this->typeclass->read($list['size']);
  5565. $title .= $typeclass['title'];
  5566. $time = time();
  5567. $post['title'] = rtrim($title, ' ');
  5568. $post['number'] = $num;
  5569. $post['features'] = '-' . $features;
  5570. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5571. $featurespp = explode('-', trim($featurespp, '-'));
  5572. if (isset($featurespp[5])) {
  5573. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5574. } else {
  5575. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5576. }
  5577. $post['enter'] = $time;
  5578. $post['time'] = $time; //操作时间
  5579. $scsku = implode("-", $scsku);
  5580. $zh = implode(" ", $pm);
  5581. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5582. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5583. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5584. $post['sku'] = $bqsku;
  5585. $label = time() . rand(0, 9);
  5586. $post['label'] = $label;
  5587. $cpid = $this->whlabellabel->find_count();
  5588. $post['cpid'] = $cpid + 1;
  5589. $cpid = $post['cpid'];
  5590. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5591. //if($whlabelbarcode)
  5592. //{
  5593. //$post['label'] = $whlabelbarcode['label'];
  5594. //if(!$this->whlabellabel->insert($post))
  5595. //{
  5596. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5597. //}
  5598. //}
  5599. //else
  5600. //{
  5601. $this->db->trans_begin();
  5602. $this->whlabellabel->insert($post);
  5603. //$this->whlabelbarcode->insert($post);
  5604. if ($this->db->trans_status() === TRUE) {
  5605. $this->db->trans_commit();
  5606. } else {
  5607. $this->db->trans_rollback();
  5608. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5609. exit;
  5610. }
  5611. //}
  5612. $warehouse_name = "";
  5613. $warehouse = $post['warehouse'];
  5614. if($warehouse == 12){
  5615. $warehouse_name = "特殊库存库";
  5616. }
  5617. // if($warehouse == 13){
  5618. // $warehouse_name = "许昌仓";
  5619. // }
  5620. // if($warehouse == 5){
  5621. // $warehouse_name = "美国店";
  5622. // }
  5623. // if($warehouse == 16){
  5624. // $warehouse_name = "定制头套仓";
  5625. // }
  5626. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5627. if(!empty($warehouse_name)){
  5628. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5629. }
  5630. $purchase = $this->purchase->read($post['purchase']);
  5631. 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));
  5632. exit; //特殊仓目前不需要仓库选项
  5633. }
  5634. }
  5635. if (isset($_SESSION['api'])) {
  5636. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5637. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5638. $this->data['wlshop'] = $wlshop;
  5639. $this->data['warehouse'] = $warehouse;
  5640. }
  5641. $whlabelwz = $this->whlabelwz->find_all();
  5642. $this->data['whlabelwz'] = $whlabelwz;
  5643. $this->_Template('whlabel_print', $this->data);
  5644. }
  5645. public function _usaprint($arg_array)
  5646. {
  5647. if (isset($_SESSION['api'])) {
  5648. $user = $this->user->get_api($_SESSION['api']);
  5649. $usp = $user;
  5650. $fgshop = "";
  5651. $sid = "";
  5652. $wid = "";
  5653. $wtype = "";
  5654. $usersp = explode('|', trim($user['shop'], '|'));
  5655. $userwh = explode('|', trim($user['warehouse'], '|'));
  5656. foreach ($usersp as $value) {
  5657. $fgshop .= " shop = " . $value . " or";
  5658. $sid .= " id = " . $value . " or";
  5659. }
  5660. foreach ($userwh as $value) {
  5661. $wid .= " id = " . $value . " or";
  5662. $wtype .= " type = " . $value . " or";
  5663. }
  5664. }
  5665. $post = $this->input->post(NULL, TRUE);
  5666. if (isset($post['tmsku'])) {
  5667. $tmsku = $this->input->post('tmsku', true);
  5668. if (is_numeric($tmsku)) {
  5669. $yyh = $this->whlabellabel->get_label($tmsku);
  5670. } else {
  5671. $yyh = $this->whlabellabel->get_sku($tmsku);
  5672. }
  5673. if ($yyh) {
  5674. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5675. exit;
  5676. } else {
  5677. echo json_encode(array('success' => false));
  5678. exit;
  5679. }
  5680. }
  5681. $classid = $this->classid->sku();
  5682. $pm = $classid;
  5683. $scsku = $classid;
  5684. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5685. if (isset($post['warehouse'])) {
  5686. if ($post['warehouse']) {
  5687. $list = array();
  5688. $num = "";
  5689. $title = "";
  5690. $features = "";
  5691. $order = 0;
  5692. $post['shop'] = '';
  5693. $brand = $this->input->post('brand', true);
  5694. if ($brand != '0,') {
  5695. $b = $this->brand->read(rtrim($brand, ','));
  5696. if ($b) {
  5697. $post['shop'] = str_replace('|', ',', $b['shop']);
  5698. }
  5699. }
  5700. $post['details'] = $this->input->post('details', true); //打印数量
  5701. $xbqnum = $this->input->post('xbqnum', true);
  5702. $post['purchase'] = $this->input->post('purchase', true);
  5703. $post['warehouse'] = $this->input->post('warehouse', true);
  5704. $post['purchase'] = $this->input->post('purchase', true);
  5705. $post['retreatwarehouse'] = $post['warehouse'];
  5706. $post['cpbz'] = $this->input->post('cpbz', true);
  5707. $post['state'] = 9;
  5708. $category = $this->input->post('category', true);
  5709. $list['category'] = $category;
  5710. $list['hairtype'] = $this->input->post('hairtype', true);
  5711. $list['grade'] = $this->input->post('grade', true);
  5712. $size = $this->input->post('size', true);
  5713. $list['size'] = rtrim($size, ',');
  5714. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5715. $list['extension'] = $this->input->post('extension', true);
  5716. if ($category == 1297) {
  5717. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5718. }
  5719. if ($category == 1702) {
  5720. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5721. $list['syother'] = $this->input->post('syother', true);
  5722. }
  5723. if ($category == 133) {
  5724. $list['fittype'] = $this->input->post('fittype', true);
  5725. $list['acother'] = $this->input->post('acother', true);
  5726. }
  5727. $list['color'] = $this->input->post('color', true);
  5728. $list['lowe'] = $this->input->post('lowe', true);
  5729. if ($category == 127) {
  5730. $list['type'] = $this->input->post('type', true);
  5731. $list['headroad'] = $this->input->post('headroad', true);
  5732. $list['density'] = $this->input->post('density', true);
  5733. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5734. $list['lacesize'] = $this->input->post('lacesize', true);
  5735. }
  5736. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5737. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5738. }
  5739. if ($category == 128) {
  5740. $list['lacetype'] = $this->input->post('lacetype', true);
  5741. $list['haircap'] = $this->input->post('haircap', true);
  5742. $list['density'] = $this->input->post('density', true);
  5743. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5744. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5745. $list['wigother'] = $this->input->post('wigother', true);
  5746. $list['wigother1'] = $this->input->post('wigother1', true);
  5747. $list['wigother2'] = $this->input->post('wigother2', true);
  5748. }
  5749. if ($category == 129) {
  5750. $list['wide'] = $this->input->post('wide', true);
  5751. }
  5752. if ($category == 131) {
  5753. $list['gifttype'] = $this->input->post('gifttype', true);
  5754. $list['giftother'] = $this->input->post('giftother', true);
  5755. }
  5756. if ($category == 134) {
  5757. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5758. }
  5759. if ($category == 1297) {
  5760. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5761. $list['sywigother'] = $this->input->post('sywigother', true);
  5762. }
  5763. if ($category == 130 || $category == 133 || $category == 1702) {
  5764. $list['items'] = $this->input->post('items', true);
  5765. $list['weight'] = $this->input->post('weight', true);
  5766. }
  5767. if ($category == 1702) {
  5768. $list['syhairther'] = $this->input->post('syhairther', true);
  5769. }
  5770. foreach ($list as $k => $v) {
  5771. if ($v != 0) {
  5772. $num .= $v;
  5773. $features .= $v . '-';
  5774. $post[$k] = $v;
  5775. $typeclass = $this->typeclass->read($v);
  5776. if (isset($pm[$typeclass['classid']])) {
  5777. if (stripos($typeclass['zh'], '|') !== false) {
  5778. $exzh = explode('|', $typeclass['zh']);
  5779. $pm[$typeclass['classid']] = $exzh[0];
  5780. } else {
  5781. $pm[$typeclass['classid']] = $typeclass['zh'];
  5782. }
  5783. }
  5784. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5785. if ($k != 'size') {
  5786. $title .= $typeclass['title'] . " ";
  5787. }
  5788. }
  5789. }
  5790. $typeclass = $this->typeclass->read($list['size']);
  5791. $title .= $typeclass['title'];
  5792. $time = time();
  5793. $post['title'] = rtrim($title, ' ');
  5794. $post['number'] = $num;
  5795. $post['features'] = '-' . $features;
  5796. $fp = $this->whlabel->get_features($post['features']);
  5797. if (!$fp) {
  5798. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5799. exit;
  5800. }
  5801. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5802. $featurespp = explode('-', trim($featurespp, '-'));
  5803. if (isset($featurespp[5])) {
  5804. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5805. } else {
  5806. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5807. }
  5808. $post['enter'] = $time;
  5809. $post['time'] = $time; //操作时间
  5810. $scsku = implode("-", $scsku);
  5811. $zh = implode(" ", $pm);
  5812. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5813. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5814. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5815. $post['sku'] = $fp['sku'];
  5816. $post['label'] = $fp['sku'];
  5817. $cpid = $this->whlabellabel->find_count();
  5818. $post['cpid'] = $cpid + 1;
  5819. $cpid = $post['cpid'];
  5820. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5821. //if($whlabelbarcode)
  5822. //{
  5823. //$post['label'] = $whlabelbarcode['label'];
  5824. //if(!$this->whlabellabel->insert($post))
  5825. //{
  5826. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5827. //}
  5828. //}
  5829. //else
  5830. //{
  5831. $this->db->trans_begin();
  5832. $this->whlabellabel->insert($post);
  5833. //$this->whlabelbarcode->insert($post);
  5834. if ($this->db->trans_status() === TRUE) {
  5835. $this->db->trans_commit();
  5836. } else {
  5837. $this->db->trans_rollback();
  5838. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5839. exit;
  5840. }
  5841. //}
  5842. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5843. $purchase = $this->purchase->read($post['purchase']);
  5844. 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));
  5845. exit; //特殊仓目前不需要仓库选项
  5846. }
  5847. }
  5848. if (isset($_SESSION['api'])) {
  5849. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5850. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5851. $this->data['wlshop'] = $wlshop;
  5852. $this->data['warehouse'] = $warehouse;
  5853. }
  5854. $whlabelwz = $this->whlabelwz->find_all();
  5855. $this->data['whlabelwz'] = $whlabelwz;
  5856. $this->_Template('whlabel_usaprint', $this->data);
  5857. }
  5858. public function _printrk($arg_array)
  5859. {
  5860. $prc = array();
  5861. $purchase = $this->purchase->find_all();
  5862. foreach ($purchase as $k => $v) {
  5863. $prc[$v['id']] = $v['title'];
  5864. }
  5865. $post = $this->input->post(NULL, TRUE);
  5866. if (isset($post['page'])) {
  5867. $page = $this->input->post('page', true);
  5868. $perpage = $this->input->post('perpage', true);
  5869. $sku = $this->input->post('sku', true);
  5870. $bs = $this->input->post('bs', true);
  5871. $number = $this->input->post('number', true);
  5872. $warehouse = $this->input->post('warehouse', true);
  5873. $purchase = $this->input->post('purchase', true);
  5874. $orderinfo = $this->input->post('orderinfo', true);
  5875. $waybill = $this->input->post('waybill', true);
  5876. $category = $this->input->post('category', true);
  5877. $size = $this->input->post('size', true);
  5878. $grade = $this->input->post('grade', true);
  5879. $color = $this->input->post('color', true);
  5880. $lowe = $this->input->post('lowe', true);
  5881. $state = $this->input->post('state', true);
  5882. $label = $this->input->post('label', true);
  5883. $timetk = $this->input->post('ktime', true);
  5884. $timetj = $this->input->post('jtime', true);
  5885. $timetk = strtotime($timetk);
  5886. $timetj = strtotime($timetj);
  5887. $where = "1=1 ";
  5888. if ($timetk && $timetj) {
  5889. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5890. }
  5891. if ($sku) {
  5892. $where .= " and sku = '$sku'";
  5893. }
  5894. if ($bs != '') {
  5895. $where .= " and bs = '$bs'";
  5896. }
  5897. if ($number) {
  5898. $where .= " and number = '$number'";
  5899. }
  5900. if ($warehouse) {
  5901. $where .= " and warehouse = '$warehouse'";
  5902. }
  5903. if ($purchase) {
  5904. $where .= " and purchase = '$purchase'";
  5905. }
  5906. if ($orderinfo) {
  5907. $where .= " and orderinfo = '$orderinfo'";
  5908. }
  5909. if ($waybill) {
  5910. $where .= " and waybill = '$waybill'";
  5911. }
  5912. if ($category) {
  5913. $where .= " and features like '%-$category-%'";
  5914. }
  5915. if ($size) {
  5916. $where .= " and features like '%-$size-%'";
  5917. }
  5918. if ($grade) {
  5919. $where .= " and features like '%-$grade-%'";
  5920. }
  5921. if ($color) {
  5922. $where .= " and features like '%-$color-%'";
  5923. }
  5924. if ($lowe) {
  5925. $where .= " and features like '%-$lowe-%'";
  5926. }
  5927. if ($label) {
  5928. $where .= " and label = '$label'";
  5929. }
  5930. if ($state || $state == 0) {
  5931. $where .= " and state = '$state'";
  5932. }
  5933. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5934. //数据排序
  5935. $order_str = "enter desc";
  5936. if (empty($page)) {
  5937. $start = 0;
  5938. $perpage = 1;
  5939. } else {
  5940. $start = ($page - 1) * $perpage;
  5941. }
  5942. //取得信息列表
  5943. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5944. foreach ($info_list as $key => $value) {
  5945. $warehouse = $this->warehouse->read($value['warehouse']);
  5946. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5947. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5948. if ($value['state'] == 0) {
  5949. $info_list[$key]['state'] = "在库";
  5950. } else if ($value['state'] == 1) {
  5951. $info_list[$key]['state'] = "出库";
  5952. } else if ($value['state'] == 2) {
  5953. $info_list[$key]['state'] = "退库";
  5954. } else if ($value['state'] == 3) {
  5955. $info_list[$key]['state'] = "调拨中";
  5956. } else if ($value['state'] == 4) {
  5957. $info_list[$key]['state'] = "再加工";
  5958. } else if ($value['state'] == 5) {
  5959. $info_list[$key]['state'] = "维修中";
  5960. } else if ($value['state'] == 6) {
  5961. $info_list[$key]['state'] = "盘亏";
  5962. } else if ($value['state'] == 7) {
  5963. $info_list[$key]['state'] = "更换标签";
  5964. } else if ($value['state'] == 8) {
  5965. $info_list[$key]['state'] = "其它";
  5966. } else if ($value['state'] == 9) {
  5967. $info_list[$key]['state'] = "预设";
  5968. } else if ($value['state'] == 10) {
  5969. $info_list[$key]['state'] = "美店零售";
  5970. }
  5971. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5972. }
  5973. $total = $this->$ck->find_count($where);
  5974. $pagenum = ceil($total / $perpage);
  5975. $over = $total - ($start + $perpage);
  5976. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5977. echo json_encode($rows);
  5978. exit;
  5979. }
  5980. if (isset($post['tmsku'])) {
  5981. $time = time();
  5982. $tmsku = $this->input->post('tmsku', true);
  5983. //$post['shop'] = $this->input->post('shop',true);
  5984. $num = $this->input->post('num', true);
  5985. $rktype = $this->input->post('rktype', true);
  5986. if ($num > 200) {
  5987. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5988. exit;
  5989. }
  5990. if (!$rktype) {
  5991. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5992. }
  5993. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5994. /**
  5995. $wz = array();
  5996. foreach ($rk as $key=>$value)
  5997. {
  5998. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5999. }
  6000. if(count($wz) > 1)
  6001. {
  6002. $wz = array_values($wz);
  6003. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6004. }
  6005. **/
  6006. if (isset($rk[0]['purchase'])) {
  6007. $rk = $rk[0];
  6008. $j = 0;
  6009. $post['purchase'] = $rk['purchase'];
  6010. $post['warehouse'] = $rk['warehouse'];
  6011. $post['retreatwarehouse'] = $rk['warehouse'];
  6012. $post['sku'] = $rk['sku'];
  6013. $post['number'] = $rk['number'];
  6014. $post['features'] = $rk['features'];
  6015. $post['title'] = $rk['title'];
  6016. $post['enter'] = $time;
  6017. $post['time'] = $time;
  6018. $post['bs'] = 1;
  6019. $post['shop'] = $rk['shop'];
  6020. $post['details'] = $rk['details'];
  6021. $post['cpid'] = $rk['cpid'];
  6022. $post['cpbz'] = $rk['cpbz'];
  6023. //$post['rktype'] = $rktype;
  6024. $warehouse = $this->warehouse->read($rk['warehouse']);
  6025. if ($warehouse['bdck'] == '') {
  6026. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6027. exit;
  6028. } else {
  6029. $bdck = $warehouse['bdck'];
  6030. }
  6031. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6032. if (isset($pdwz['details'])) {
  6033. if ($pdwz['details'] != $post['details']) {
  6034. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6035. exit;
  6036. }
  6037. }
  6038. $post['featurespp'] = $rk['featurespp'];
  6039. if ($post['warehouse'] == '5') {
  6040. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6041. if ($yza) {
  6042. if ($post['features'] != $yza[0]['features']) {
  6043. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6044. exit;
  6045. }
  6046. }
  6047. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6048. if ($yzb) {
  6049. if ($post['sku'] != $yzb[0]['sku']) {
  6050. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6051. exit;
  6052. }
  6053. }
  6054. }
  6055. for ($i = 0; $i < $num; $i++) {
  6056. $post['label'] = time() . rand(100, 999) . $i;
  6057. if ($this->$bdck->insert($post)) {
  6058. $j++;
  6059. }
  6060. }
  6061. /**
  6062. if($post['warehouse'] != 12)
  6063. {
  6064. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6065. }
  6066. **/
  6067. if ($j == $num) {
  6068. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6069. exit;
  6070. } else {
  6071. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6072. exit;
  6073. }
  6074. } else {
  6075. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6076. exit;
  6077. }
  6078. }
  6079. $this->_Template('whlabel_printrk', $this->data);
  6080. }
  6081. public function _printxzrk($arg_array)
  6082. {
  6083. $post = $this->input->post(NULL, TRUE);
  6084. if (isset($post['wzid'])) {
  6085. $time = time();
  6086. $id = $this->input->post('wzid', true);
  6087. //$post['shop'] = $this->input->post('shop',true);
  6088. $num = 1;
  6089. $rk = $this->whlabellabel->read($id);
  6090. if (isset($rk['purchase'])) {
  6091. $x = 0;
  6092. $post['purchase'] = $rk['purchase'];
  6093. $post['warehouse'] = $rk['warehouse'];
  6094. $post['retreatwarehouse'] = $rk['warehouse'];
  6095. $post['sku'] = $rk['sku'];
  6096. $post['number'] = $rk['number'];
  6097. $post['features'] = $rk['features'];
  6098. $post['title'] = $rk['title'];
  6099. $post['enter'] = $time;
  6100. $post['time'] = $time;
  6101. $post['bs'] = 1;
  6102. $post['shop'] = $rk['shop'];
  6103. $post['details'] = $rk['details'];
  6104. $post['cpid'] = $rk['cpid'];
  6105. $post['cpbz'] = $rk['cpbz'];
  6106. $warehouse = $this->warehouse->read($rk['warehouse']);
  6107. if ($warehouse['bdck'] == '') {
  6108. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6109. exit;
  6110. } else {
  6111. $bdck = $warehouse['bdck'];
  6112. }
  6113. $post['featurespp'] = $rk['featurespp'];
  6114. $this->db->trans_begin();
  6115. for ($i = 0; $i < $num; $i++) {
  6116. $post['label'] = time() . rand(100, 999) . $i;
  6117. $this->$bdck->insert($post);
  6118. }
  6119. /**
  6120. if($post['warehouse'] != 12)
  6121. {
  6122. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6123. }
  6124. **/
  6125. if ($this->db->trans_status() === TRUE) {
  6126. $this->db->trans_commit();
  6127. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6128. exit;
  6129. } else {
  6130. $this->db->trans_rollback();
  6131. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6132. exit;
  6133. }
  6134. } else {
  6135. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6136. exit;
  6137. }
  6138. }
  6139. }
  6140. public function _printck($arg_array)
  6141. {
  6142. $prc = array();
  6143. $purchase = $this->purchase->find_all();
  6144. foreach ($purchase as $k => $v) {
  6145. $prc[$v['id']] = $v['title'];
  6146. }
  6147. $post = $this->input->post(NULL, TRUE);
  6148. if (isset($post['page'])) {
  6149. $page = $this->input->post('page', true);
  6150. $perpage = $this->input->post('perpage', true);
  6151. $sku = $this->input->post('sku', true);
  6152. $bs = $this->input->post('bs', true);
  6153. $number = $this->input->post('number', true);
  6154. $warehouse = $this->input->post('warehouse', true);
  6155. $purchase = $this->input->post('purchase', true);
  6156. $orderinfo = $this->input->post('orderinfo', true);
  6157. $waybill = $this->input->post('waybill', true);
  6158. $category = $this->input->post('category', true);
  6159. $size = $this->input->post('size', true);
  6160. $grade = $this->input->post('grade', true);
  6161. $color = $this->input->post('color', true);
  6162. $lowe = $this->input->post('lowe', true);
  6163. $state = $this->input->post('state', true);
  6164. $label = $this->input->post('label', true);
  6165. $timetk = $this->input->post('ktime', true);
  6166. $timetj = $this->input->post('jtime', true);
  6167. $timetk = strtotime($timetk);
  6168. $timetj = strtotime($timetj);
  6169. $where = "state=1 ";
  6170. if ($timetk && $timetj) {
  6171. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6172. }
  6173. if ($sku) {
  6174. $where .= " and sku = '$sku'";
  6175. }
  6176. if ($bs != '') {
  6177. $where .= " and bs = '$bs'";
  6178. }
  6179. if ($number) {
  6180. $where .= " and number = '$number'";
  6181. }
  6182. if ($warehouse) {
  6183. $where .= " and warehouse = '$warehouse'";
  6184. }
  6185. if ($purchase) {
  6186. $where .= " and purchase = '$purchase'";
  6187. }
  6188. if ($orderinfo) {
  6189. $where .= " and orderinfo = '$orderinfo'";
  6190. }
  6191. if ($waybill) {
  6192. $where .= " and waybill = '$waybill'";
  6193. }
  6194. if ($category) {
  6195. $where .= " and features like '%-$category-%'";
  6196. }
  6197. if ($size) {
  6198. $where .= " and features like '%-$size-%'";
  6199. }
  6200. if ($grade) {
  6201. $where .= " and features like '%-$grade-%'";
  6202. }
  6203. if ($color) {
  6204. $where .= " and features like '%-$color-%'";
  6205. }
  6206. if ($lowe) {
  6207. $where .= " and features like '%-$lowe-%'";
  6208. }
  6209. if ($label) {
  6210. $where .= " and label = '$label'";
  6211. }
  6212. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6213. //数据排序
  6214. $order_str = "outk desc";
  6215. if (empty($page)) {
  6216. $start = 0;
  6217. $perpage = 1;
  6218. } else {
  6219. $start = ($page - 1) * $perpage;
  6220. }
  6221. //取得信息列表
  6222. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6223. foreach ($info_list as $key => $value) {
  6224. $warehouse = $this->warehouse->read($value['warehouse']);
  6225. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6226. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6227. if ($value['state'] == 0) {
  6228. $info_list[$key]['state'] = "在库";
  6229. } else if ($value['state'] == 1) {
  6230. $info_list[$key]['state'] = "出库";
  6231. } else if ($value['state'] == 2) {
  6232. $info_list[$key]['state'] = "退库";
  6233. } else if ($value['state'] == 3) {
  6234. $info_list[$key]['state'] = "调拨中";
  6235. } else if ($value['state'] == 4) {
  6236. $info_list[$key]['state'] = "再加工";
  6237. } else if ($value['state'] == 5) {
  6238. $info_list[$key]['state'] = "维修中";
  6239. } else if ($value['state'] == 6) {
  6240. $info_list[$key]['state'] = "盘亏";
  6241. } else if ($value['state'] == 7) {
  6242. $info_list[$key]['state'] = "更换标签";
  6243. } else if ($value['state'] == 8) {
  6244. $info_list[$key]['state'] = "其它";
  6245. } else if ($value['state'] == 9) {
  6246. $info_list[$key]['state'] = "预设";
  6247. } else if ($value['state'] == 10) {
  6248. $info_list[$key]['state'] = "美店零售";
  6249. }
  6250. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6251. }
  6252. $total = $this->$ck->find_count($where);
  6253. $pagenum = ceil($total / $perpage);
  6254. $over = $total - ($start + $perpage);
  6255. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6256. echo json_encode($rows);
  6257. exit;
  6258. }
  6259. if (isset($post['tmsku'])) {
  6260. $time = time();
  6261. $tmsku = $this->input->post('tmsku', true);
  6262. //$post['shop'] = $this->input->post('shop',true);
  6263. $num = $this->input->post('num', true);
  6264. $cktype = $this->input->post('cktype', true);
  6265. $label = $this->whlabellabel->get_label($tmsku);
  6266. if (!$cktype) {
  6267. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6268. }
  6269. if (!isset($label['warehouse'])) {
  6270. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6271. exit;
  6272. }
  6273. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6274. if (stripos($label['features'], '-126-') !== false) {
  6275. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6276. } else {
  6277. $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 = ''");
  6278. }
  6279. $j = 0;
  6280. if (count($ck) >= $num) {
  6281. for ($i = 0; $i < $num; $i++) {
  6282. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6283. {
  6284. $j++;
  6285. }
  6286. }
  6287. if ($j == $num) {
  6288. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6289. exit;
  6290. } else {
  6291. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6292. exit;
  6293. }
  6294. } else {
  6295. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6296. exit;
  6297. }
  6298. }
  6299. if(isset($_SESSION['api']))
  6300. {
  6301. $user = $this->user->get_api($_SESSION['api']);
  6302. if(in_array($user['power'],[1,27])){
  6303. $vip = 1;
  6304. }
  6305. }
  6306. else
  6307. {
  6308. $vip = 0;
  6309. header('Location: /');exit;
  6310. }
  6311. $this->data['vip'] = $vip;
  6312. $this->_Template('whlabel_printck', $this->data);
  6313. }
  6314. public function _printexcel()
  6315. {
  6316. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6317. $config['upload_path'] = '.' . $dir;
  6318. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6319. $config['allowed_types'] = 'xls|xlsx|csv';
  6320. $config['max_size'] = 10240;
  6321. $this->load->library('upload', $config);
  6322. $this->upload->initialize($config);
  6323. if ($this->upload->do_upload('userfile')) {
  6324. $full_path = $dir . $this->upload->data('file_name');
  6325. $fileName = '.' . $full_path;
  6326. if (!file_exists($fileName)) {
  6327. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6328. exit;
  6329. } else {
  6330. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6331. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6332. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6333. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6334. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6335. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6336. ++$column; //如果列数大于26行
  6337. $list = array();
  6338. for ($i = 2; $i <= $row; $i++) // 行数循环
  6339. {
  6340. $data = array();
  6341. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6342. {
  6343. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6344. }
  6345. $list[] = $data;
  6346. }
  6347. }
  6348. $ed = array();
  6349. $i = 0;
  6350. $j = 0;
  6351. $dcdata = array();
  6352. $yc = '';
  6353. $cmf_arr = array_column($list, '1');
  6354. array_multisort($cmf_arr, SORT_ASC, $list);
  6355. foreach ($list as $key => $value) {
  6356. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6357. if ($typeclass) {
  6358. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6359. } else {
  6360. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6361. $i++;
  6362. continue;
  6363. }
  6364. }
  6365. if ($i > 0) {
  6366. $yc = $i . '条异常';
  6367. }
  6368. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6369. exit;
  6370. }
  6371. }
  6372. public function _uck()
  6373. {
  6374. if (isset($_GET['excel'])) {
  6375. $tc = array();
  6376. $typeclass = $this->typeclass->find_all();
  6377. foreach ($typeclass as $v) {
  6378. $tc[$v['id']] = $v['zh'];
  6379. }
  6380. $data = array();
  6381. $t = array();
  6382. $rq = '';
  6383. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6384. $ts = $ts / (24 * 3600);
  6385. for ($i = 0; $i < $ts; $i++) {
  6386. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6387. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6388. }
  6389. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6390. foreach ($info_list as $k => $v) {
  6391. $features = explode('-', trim($v['features'], '-'));
  6392. if (!isset($features[3]) || !isset($features[4])) {
  6393. continue;
  6394. }
  6395. $data[$k][0] = $tc[$features[0]]; //类型
  6396. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6397. $data[$k][2] = $tc[$features[4]]; //曲度
  6398. $data[$k][3] = '';
  6399. if (isset($data[$k][1])) {
  6400. $data[$k][3] .= $data[$k][1];
  6401. }
  6402. if (isset($data[$k][2])) {
  6403. $data[$k][3] .= $data[$k][2];
  6404. }
  6405. if (isset($features[5])) {
  6406. $data[$k][3] .= $tc[$features[5]];
  6407. }
  6408. if (isset($features[2])) {
  6409. $data[$k][3] .= $tc[$features[2]];
  6410. }
  6411. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6412. $data[$k][4] = $v['sku'];
  6413. $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())) . '))'); //月初库存
  6414. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6415. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6416. $ztrq = '';
  6417. $ztsl = '';
  6418. if (count($zt) > 0) {
  6419. foreach ($zt as $vv) {
  6420. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6421. $ztsl .= $vv['num'] . '<br>';
  6422. }
  6423. }
  6424. $data[$k][] = trim($ztsl, '<br>');
  6425. $data[$k][] = trim($ztrq, '<br>');
  6426. $byck = 0;
  6427. foreach ($t as $vv) {
  6428. $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));
  6429. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6430. $byck += $sl;
  6431. }
  6432. $data[$k][] = ($byck > 0) ? $byck : '';
  6433. }
  6434. $title = "详情 " . date("Y-m-d", time());
  6435. $titlename = "<table border=1>
  6436. <tr align='center'>
  6437. <td>类别</td>
  6438. <td>颜色</td>
  6439. <td>曲度</td>
  6440. <td>名称</td>
  6441. <td>SKU</td>
  6442. <td>月初库存</td>
  6443. <td>剩余库存</td>
  6444. <td>在途数量</td>
  6445. <td>预达日期</td>" .
  6446. $rq
  6447. . "<td>本月出库</td></tr>
  6448. </table>";
  6449. $filename = $title . ".xls";
  6450. $tail = "";
  6451. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6452. }
  6453. }
  6454. public function _whlabelexcelzh()
  6455. {
  6456. if (isset($_GET['excel'])) {
  6457. $where = "sku != 'Preset'";
  6458. //数据排序
  6459. $order_str = "id desc";
  6460. if (empty($page)) {
  6461. $start = 0;
  6462. $perpage = 1;
  6463. } else {
  6464. $start = ($page - 1) * $perpage;
  6465. }
  6466. $category = $this->input->get('category', true);
  6467. $warehouse = $this->input->get('warehouse', true);
  6468. $excelid = $this->input->get('sid', true);
  6469. if ($category) {
  6470. $where .= " and features like '%-$category-%'";
  6471. }
  6472. if ($warehouse) {
  6473. $where .= " and warehouse = '$warehouse'";
  6474. }
  6475. $xzid = '';
  6476. if ($excelid) {
  6477. $excelid = explode(',', trim($excelid, ','));
  6478. foreach ($excelid as $key => $value) {
  6479. $xzid .= " id = " . $value . " or";
  6480. }
  6481. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6482. }
  6483. //取得信息列表
  6484. /**
  6485. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6486. $rows = array();$list = array();
  6487. foreach ($info_list as $key=>$value)
  6488. {
  6489. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6490. }
  6491. **/
  6492. $list = array();
  6493. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6494. foreach ($rows as $key => $value) {
  6495. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6496. $zh = '';
  6497. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6498. foreach ($zt as $v) {
  6499. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6500. }
  6501. $zt = array_sum(array_column($zt, 'num'));
  6502. $number = $value['number'];
  6503. $ftime = time() - 15 * 24 * 3600;
  6504. $warehouse = $this->warehouse->read($value['warehouse']);
  6505. $rows[$key]['warehouse'] = $warehouse['title'];
  6506. $rows[$key]['number'] = $c;
  6507. $rows[$key]['features'] = $zh;
  6508. $rows[$key]['hb'] = $c + $zt;
  6509. }
  6510. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6511. $titlename = "<table border=1>
  6512. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6513. <tr align='center'>
  6514. <td>仓库</td>
  6515. <td>SKU</td>
  6516. <td>产品</td>
  6517. <td>库存数量</td>
  6518. <td>在途数量及预达日期</td>
  6519. <td>在途+库存数量</td>
  6520. </tr>
  6521. </table>";
  6522. $filename = $title . ".xls";
  6523. $tail = "";
  6524. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6525. }
  6526. if (isset($_GET['excel'])) {
  6527. $warehouse = $this->input->get('warehouse', true);
  6528. $sku = $this->input->get('sku', true);
  6529. $cz = $this->input->get('cz', true);
  6530. $text = $this->input->post('text', true);
  6531. $xztime = $this->input->get('xztime', true);
  6532. $timetk = $this->input->get('timetk', true);
  6533. $timetj = $this->input->get('timetj', true);
  6534. $timetk = strtotime($timetk);
  6535. $timetj = strtotime($timetj);
  6536. $where = "time = '0' ";
  6537. if ($warehouse) {
  6538. $where .= " and warehouse = '$warehouse'";
  6539. }
  6540. if ($sku) {
  6541. $where .= " and sku = '$sku'";
  6542. }
  6543. if ($text) {
  6544. $where .= " and text like '%$text%'";
  6545. }
  6546. if ($cz != '') {
  6547. $where .= " and cz = '$cz'";
  6548. }
  6549. if ($timetk && $timetj) {
  6550. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6551. }
  6552. //数据排序
  6553. $order_str = $xztime . " desc";
  6554. //取得信息列表
  6555. $zh = array();
  6556. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6557. foreach ($info_list as $v) {
  6558. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6559. $warehouse = $this->warehouse->read($v['warehouse']);
  6560. $v['warehouse'] = $warehouse['title'];
  6561. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6562. $v['stime'] = date('Y-m-d', $v['stime']);
  6563. if (isset($zh[$v['features']])) {
  6564. $zh[$v['features']]['num'] += $v['num'];
  6565. } else {
  6566. $zh[$v['features']] = $v;
  6567. }
  6568. $zh[$v['features']]['features'] = $c;
  6569. }
  6570. $title = "在途数据" . date('Y-m-d', time());
  6571. $titlename = "<table border=1>
  6572. <tr align='center'>
  6573. <td>仓库</td>
  6574. <td>SKU</td>
  6575. <td>名称</td>
  6576. <td>在途数量</td>
  6577. <td>库存数量</td>
  6578. <td>添加在途日期</td>
  6579. <td>预达日期</td>
  6580. <td>备注</td>
  6581. </tr>
  6582. </table>";
  6583. $filename = $title . ".xls";
  6584. $tail = "";
  6585. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6586. }
  6587. }
  6588. public function _fc()
  6589. {
  6590. $vip = 0;
  6591. if (isset($_SESSION['api'])) {
  6592. $user = $this->user->get_api($_SESSION['api']);
  6593. if ($user['vip'] == 1) {
  6594. $vip = 1;
  6595. }
  6596. } else {
  6597. header('Location: /');
  6598. exit;
  6599. }
  6600. $post = $this->input->post(NULL, TRUE);
  6601. if (isset($post['page'])) {
  6602. $page = $this->input->post('page', true);
  6603. $perpage = $this->input->post('perpage', true);
  6604. $category = $this->input->post('category', true);
  6605. $size = $this->input->post('size', true);
  6606. $grade = $this->input->post('grade', true);
  6607. $color = $this->input->post('color', true);
  6608. $lowe = $this->input->post('lowe', true);
  6609. $sku = $this->input->post('sku');
  6610. $title = $this->input->post('title');
  6611. $warehouse = $this->input->post('warehouse', true);
  6612. $usa = $this->input->post('usa', true);
  6613. $purchase = $this->input->post('purchase', true);
  6614. $lacetype = $this->input->post('lacetype', true);
  6615. $haircap = $this->input->post('haircap', true);
  6616. $density = $this->input->post('density', true);
  6617. $details = $this->input->post('details', true);
  6618. $state = $this->input->post('state', true);
  6619. $ktime = $this->input->post('ktime', true);
  6620. $jtime = $this->input->post('jtime', true);
  6621. $ktime = strtotime($ktime);
  6622. $jtime = strtotime($jtime);
  6623. $where = "state = '11'";
  6624. $gj = "";
  6625. $ck = "";
  6626. if ($lacetype) {
  6627. $where .= " and features like '%-$lacetype-%'";
  6628. }
  6629. if ($category) {
  6630. $where .= " and features like '%-$category-%'";
  6631. }
  6632. if ($size) {
  6633. $where .= " and features like '%-$size-%'";
  6634. }
  6635. if ($grade) {
  6636. $where .= " and features like '%-$grade-%'";
  6637. }
  6638. if ($color) {
  6639. $where .= " and features like '%-$color-%'";
  6640. }
  6641. if ($lowe) {
  6642. $where .= " and features like '%-$lowe-%'";
  6643. }
  6644. if ($haircap) {
  6645. $where .= " and features like '%-$haircap-%'";
  6646. }
  6647. if ($density) {
  6648. $where .= " and features like '%-$density-%'";
  6649. }
  6650. if ($usa) {
  6651. if (!$warehouse) {
  6652. $where .= " and (warehouse = '5' or warehouse = '8')";
  6653. }
  6654. }
  6655. if ($warehouse) {
  6656. $where .= " and warehouse = '$warehouse'";
  6657. }
  6658. if ($details) {
  6659. $where .= " and details = '$details'";
  6660. }
  6661. if ($purchase) {
  6662. $where .= " and purchase = '$purchase'";
  6663. }
  6664. if ($state) {
  6665. $where .= " and state = '$state'";
  6666. }
  6667. if ($ktime && $jtime) {
  6668. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6669. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6670. }
  6671. //数据排序
  6672. $order_str = "id desc";
  6673. if (empty($page)) {
  6674. $start = 0;
  6675. $perpage = 1;
  6676. } else {
  6677. $start = ($page - 1) * $perpage;
  6678. }
  6679. if ($sku) {
  6680. $sku = trim($sku, ' ');
  6681. $sku = trim($sku, ' ');
  6682. $where .= " and sku like '%$sku%'";
  6683. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6684. } else if ($title) {
  6685. $title = trim($title, ' ');
  6686. $title = trim($title, ' ');
  6687. $where .= " and title like '%$title%'";
  6688. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6689. } else {
  6690. //$where .= " and time > '$ktime' and time < '$jtime'";
  6691. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6692. }
  6693. //取得信息列表
  6694. $rows = array();
  6695. $list = array();
  6696. foreach ($info_list as $key => $value) {
  6697. $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'] . '"');
  6698. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6699. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6700. $warehouse = $this->warehouse->read($value['warehouse']);
  6701. $info_list[$key]['warehouse'] = $warehouse['title'];
  6702. $info_list[$key]['number'] = $g;
  6703. $info_list[$key]['features'] = $x;
  6704. $info_list[$key]['x'] = $s;
  6705. }
  6706. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6707. $pagenum = ceil($total / $perpage);
  6708. $over = $total - ($start + $perpage);
  6709. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6710. echo json_encode($rows);
  6711. exit;
  6712. }
  6713. $this->data['vip'] = $vip;
  6714. $this->_Template('whlabel_fc', $this->data);
  6715. }
  6716. public function _fcmb()
  6717. {
  6718. $where = "sku != 'Preset'";
  6719. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6720. foreach ($rows as $k => $v) {
  6721. $warehouse = $this->warehouse->read($v['warehouse']);
  6722. $rows[$k]['warehouse'] = $warehouse['title'];
  6723. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6724. $rows[$k]['t'] = '';
  6725. $rows[$k]['n'] = '';
  6726. }
  6727. $title = "封货产品数据导入模板";
  6728. $titlename = "<table border=1>
  6729. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6730. <tr align='center'>
  6731. <td>仓库</td>
  6732. <td>SKU</td>
  6733. <td>产品</td>
  6734. <td>封存产品总数量</td>
  6735. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6736. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6737. </tr>
  6738. </table>";
  6739. $filename = $title . ".xls";
  6740. $tail = "";
  6741. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6742. }
  6743. public function _fcexcel()
  6744. {
  6745. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6746. $config['upload_path'] = '.' . $dir;
  6747. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6748. $config['allowed_types'] = 'xls|xlsx|csv';
  6749. $config['max_size'] = 10240;
  6750. $this->load->library('upload', $config);
  6751. $this->upload->initialize($config);
  6752. if ($this->upload->do_upload('userfile')) {
  6753. $full_path = $dir . $this->upload->data('file_name');
  6754. $fileName = '.' . $full_path;
  6755. if (!file_exists($fileName)) {
  6756. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6757. exit;
  6758. } else {
  6759. libxml_use_internal_errors(true);
  6760. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6761. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6762. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6763. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6764. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6765. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6766. ++$column; //如果列数大于26行
  6767. $list = array();
  6768. for ($i = 2; $i <= $row; $i++) // 行数循环
  6769. {
  6770. $data = array();
  6771. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6772. {
  6773. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6774. }
  6775. $list[] = $data;
  6776. }
  6777. }
  6778. $i = 0;
  6779. $j = 0;
  6780. $ed = array();
  6781. foreach ($list as $key => $value) {
  6782. $time = time();
  6783. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6784. continue;
  6785. }
  6786. $warehouse = $this->warehouse->get_title($value['0']);
  6787. $sku = $value['1'];
  6788. $type = $value['4']; //调整方式0扣减1删除
  6789. $num = $value['5']; //调整数量
  6790. //$text = $value['4'];//扣减说明
  6791. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6792. if (!$d) //如果没有这个SKU
  6793. {
  6794. $ed[] = array($sku . '-库存中不存在此SKU');
  6795. $j++;
  6796. continue;
  6797. }
  6798. if (!isset($warehouse['id'])) {
  6799. $ed[] = array($sku . '-仓库名错误!');
  6800. $j++;
  6801. continue;
  6802. }
  6803. if ($type == 1 || $type == 2) //扣减库存
  6804. {
  6805. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6806. if (count($data) < abs($num)) {
  6807. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6808. $j++;
  6809. continue;
  6810. }
  6811. if ($type == 1) //转入库存
  6812. {
  6813. for ($i = 0; $i < abs($num); $i++) {
  6814. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6815. }
  6816. } else if ($type == 2) //删除
  6817. {
  6818. for ($i = 0; $i < abs($num); $i++) {
  6819. $this->whlabel->remove($data[$i]['id']);
  6820. }
  6821. }
  6822. } else if ($type == 0) //增加库存
  6823. {
  6824. $post['sku'] = $d['sku'];
  6825. $post['shop'] = '';
  6826. $post['warehouse'] = $warehouse['id'];
  6827. $post['purchase'] = $d['purchase'];
  6828. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6829. $post['state'] = 11;
  6830. $post['title'] = $d['title'];
  6831. $post['number'] = $d['number'];
  6832. $post['features'] = $d['features'];
  6833. $post['enter'] = $time;
  6834. $post['time'] = $time; //操作时间
  6835. for ($i = 0; $i < $num; $i++) {
  6836. $post['label'] = time() . rand(100, 999) . $i;
  6837. $this->whlabel->insert($post);
  6838. }
  6839. }
  6840. sleep(1); //防止入库时间一样,需要延迟1秒
  6841. }
  6842. if ($j > 0) {
  6843. $tt = date('Ymd', time());
  6844. $title = '库存导入错误信息-' . $tt;
  6845. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6846. $tail = "\n";
  6847. $filename = $title . ".xls";
  6848. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6849. $dir = '/data/excel/' . $time . '/';
  6850. $file_name = 'error_' . $time . rand(1000, 9999);
  6851. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6852. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6853. fwrite($myfile, $ecl);
  6854. fclose($myfile);
  6855. $error = $dir . $file_name . '.xls';
  6856. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6857. exit;
  6858. } else {
  6859. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6860. exit;
  6861. }
  6862. }
  6863. }
  6864. public function _fcjxc($arg_array)
  6865. {
  6866. if (isset($_GET['excel'])) {
  6867. $category = $this->input->get('category', true);
  6868. $size = $this->input->get('size', true);
  6869. $grade = $this->input->get('grade', true);
  6870. $color = $this->input->get('color', true);
  6871. $lowe = $this->input->get('lowe', true);
  6872. $sku = $this->input->get('sku');
  6873. $title = $this->input->get('title');
  6874. $warehouse = $arg_array[0];
  6875. $usa = $this->input->get('usa', true);
  6876. $purchase = $this->input->get('purchase', true);
  6877. $lacetype = $this->input->get('lacetype', true);
  6878. $haircap = $this->input->get('haircap', true);
  6879. $density = $this->input->get('density', true);
  6880. $title = $this->input->get('title', true);
  6881. $state = $this->input->get('state', true);
  6882. $ktime = $this->input->get('ktime', true);
  6883. $jtime = $this->input->get('jtime', true);
  6884. $where = "state=11";
  6885. $gj = "";
  6886. $ck = "";
  6887. if ($lacetype) {
  6888. $where .= " and features like '%-$lacetype-%'";
  6889. }
  6890. if ($category) {
  6891. $where .= " and features like '%-$category-%'";
  6892. }
  6893. if ($size) {
  6894. $where .= " and features like '%-$size-%'";
  6895. }
  6896. if ($grade) {
  6897. $where .= " and features like '%-$grade-%'";
  6898. }
  6899. if ($color) {
  6900. $where .= " and features like '%-$color-%'";
  6901. }
  6902. if ($lowe) {
  6903. $where .= " and features like '%-$lowe-%'";
  6904. }
  6905. if ($haircap) {
  6906. $where .= " and features like '%-$haircap-%'";
  6907. }
  6908. if ($density) {
  6909. $where .= " and features like '%-$density-%'";
  6910. }
  6911. if ($usa) {
  6912. if (!$warehouse) {
  6913. $where .= " and (warehouse = '5' or warehouse = '8')";
  6914. }
  6915. }
  6916. if ($warehouse) {
  6917. $where .= " and warehouse = '$warehouse'";
  6918. }
  6919. if ($purchase) {
  6920. $where .= " and purchase = '$purchase'";
  6921. }
  6922. if ($state) {
  6923. $where .= " and state = '$state'";
  6924. }
  6925. $order_str = "id desc";
  6926. if ($sku) {
  6927. $sku = trim($sku, ' ');
  6928. $sku = trim($sku, ' ');
  6929. $where .= " and sku like '%$sku%'";
  6930. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6931. } else if ($title) {
  6932. $title = trim($title, ' ');
  6933. $title = trim($title, ' ');
  6934. $where .= " and title like '%$title%'";
  6935. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6936. } else {
  6937. //$where .= " and time > '$ktime' and time < '$jtime'";
  6938. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6939. }
  6940. //取得信息列表
  6941. $rows = array();
  6942. $list = array();
  6943. foreach ($info_list as $key => $value) {
  6944. $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'] . '"');
  6945. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6946. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6947. $rows[$key] = $value;
  6948. $warehouse = $this->warehouse->read($value['warehouse']);
  6949. $rows[$key]['warehouse'] = $warehouse['title'];
  6950. $rows[$key]['features'] = $g;
  6951. $rows[$key]['a'] = $x;
  6952. $rows[$key]['b'] = $s;
  6953. }
  6954. $title = "总统计表";
  6955. $titlename = "<table border=1>
  6956. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6957. <tr align='center'>
  6958. <td>仓库</td>
  6959. <td>SKU</td>
  6960. <td>产品名称</td>
  6961. <td>录入总量</td>
  6962. <td>取出总量</td>
  6963. <td>剩余总量</td>
  6964. </tr>
  6965. </table>";
  6966. $filename = $title . ".xls";
  6967. $tail = "";
  6968. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6969. }
  6970. $vip = 0;
  6971. if (isset($_SESSION['api'])) {
  6972. $user = $this->user->get_api($_SESSION['api']);
  6973. if ($user['vip'] == 1) {
  6974. $vip = 1;
  6975. }
  6976. } else {
  6977. header('Location: /');
  6978. exit;
  6979. }
  6980. $post = $this->input->post(NULL, TRUE);
  6981. if (isset($post['page'])) {
  6982. $page = $this->input->post('page', true);
  6983. $perpage = $this->input->post('perpage', true);
  6984. $category = $this->input->post('category', true);
  6985. $size = $this->input->post('size', true);
  6986. $grade = $this->input->post('grade', true);
  6987. $color = $this->input->post('color', true);
  6988. $lowe = $this->input->post('lowe', true);
  6989. $sku = $this->input->post('sku');
  6990. $title = $this->input->post('title');
  6991. $warehouse = $arg_array[0];
  6992. $usa = $this->input->post('usa', true);
  6993. $purchase = $this->input->post('purchase', true);
  6994. $lacetype = $this->input->post('lacetype', true);
  6995. $haircap = $this->input->post('haircap', true);
  6996. $density = $this->input->post('density', true);
  6997. $title = $this->input->post('title', true);
  6998. $state = $this->input->post('state', true);
  6999. $ktime = $this->input->post('ktime', true);
  7000. $jtime = $this->input->post('jtime', true);
  7001. $ktime = strtotime($ktime);
  7002. $jtime = strtotime($jtime);
  7003. $where = "state=11";
  7004. $gj = "";
  7005. $ck = "";
  7006. if ($lacetype) {
  7007. $where .= " and features like '%-$lacetype-%'";
  7008. }
  7009. if ($category) {
  7010. $where .= " and features like '%-$category-%'";
  7011. }
  7012. if ($size) {
  7013. $where .= " and features like '%-$size-%'";
  7014. }
  7015. if ($grade) {
  7016. $where .= " and features like '%-$grade-%'";
  7017. }
  7018. if ($color) {
  7019. $where .= " and features like '%-$color-%'";
  7020. }
  7021. if ($lowe) {
  7022. $where .= " and features like '%-$lowe-%'";
  7023. }
  7024. if ($haircap) {
  7025. $where .= " and features like '%-$haircap-%'";
  7026. }
  7027. if ($density) {
  7028. $where .= " and features like '%-$density-%'";
  7029. }
  7030. if ($usa) {
  7031. if (!$warehouse) {
  7032. $where .= " and (warehouse = '5' or warehouse = '8')";
  7033. }
  7034. }
  7035. if ($warehouse) {
  7036. $where .= " and warehouse = '$warehouse'";
  7037. }
  7038. if ($purchase) {
  7039. $where .= " and purchase = '$purchase'";
  7040. }
  7041. if ($state) {
  7042. $where .= " and state = '$state'";
  7043. }
  7044. if ($ktime && $jtime) {
  7045. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7046. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7047. }
  7048. //数据排序
  7049. $order_str = "id desc";
  7050. $xs = 0;
  7051. $rows = array();
  7052. $list = array();
  7053. if (empty($page)) {
  7054. $start = 0;
  7055. $perpage = 1;
  7056. } else {
  7057. $start = ($page - 1) * $perpage;
  7058. }
  7059. if ($sku || $title) {
  7060. if ($title) {
  7061. $title = trim($title, ' ');
  7062. $title = trim($title, ' ');
  7063. $where .= " and title like '%$title%'";
  7064. } else {
  7065. $sku = trim($sku, ' ');
  7066. $sku = trim($sku, ' ');
  7067. $where .= " and sku like '%$sku%'";
  7068. }
  7069. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7070. foreach ($info_list as $key => $value) {
  7071. $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'] . '"');
  7072. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7073. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7074. $rows[$key] = $value;
  7075. $warehouse = $this->warehouse->read($value['warehouse']);
  7076. $rows[$key]['warehouse'] = $warehouse['title'];
  7077. $rows[$key]['features'] = $g;
  7078. $rows[$key]['a'] = $x;
  7079. $rows[$key]['b'] = $s;
  7080. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7081. $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天销量
  7082. $yj = $c / ($xl / 30);
  7083. if ($yj < 7) {
  7084. $rows[$key]['y'] = round($yj) . '天销量';
  7085. } else {
  7086. $rows[$key]['y'] = '正常';
  7087. }
  7088. }
  7089. } else {
  7090. //$where .= " and time > '$ktime' and time < '$jtime'";
  7091. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7092. foreach ($info_list as $key => $value) {
  7093. $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'] . '"');
  7094. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7095. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7096. $zs[$key] = $value;
  7097. $warehouse = $this->warehouse->read($value['warehouse']);
  7098. $zs[$key]['warehouse'] = $warehouse['title'];
  7099. $zs[$key]['features'] = $g;
  7100. $zs[$key]['a'] = $x;
  7101. $zs[$key]['b'] = $s;
  7102. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7103. $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天销量
  7104. $yj = $c / ($xl / 30);
  7105. if ($yj < 7) {
  7106. $zs[$key]['y'] = round($yj) . '天销量';
  7107. $rows[$key] = $zs[$key];
  7108. }
  7109. }
  7110. }
  7111. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7112. $pagenum = ceil($total / $perpage);
  7113. $over = $total - ($start + $perpage);
  7114. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7115. echo json_encode($rows);
  7116. exit;
  7117. }
  7118. $this->data['arg_array'] = $arg_array[0];
  7119. $this->_Template('whlabel_fcjxc', $this->data);
  7120. }
  7121. public function _0kcdel()
  7122. {
  7123. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7124. $config['upload_path'] = '.' . $dir;
  7125. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7126. $config['allowed_types'] = 'xls|xlsx|csv';
  7127. $config['max_size'] = 10240;
  7128. $this->load->library('upload', $config);
  7129. $this->upload->initialize($config);
  7130. if ($this->upload->do_upload('userfile')) {
  7131. $full_path = $dir . $this->upload->data('file_name');
  7132. $fileName = '.' . $full_path;
  7133. if (!file_exists($fileName)) {
  7134. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7135. exit;
  7136. } else {
  7137. require_once "./data/excel/PHPExcel/IOFactory.php";
  7138. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7139. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7140. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7141. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7142. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7143. ++$column; //如果列数大于26行
  7144. $list = array();
  7145. for ($i = 2; $i <= $row; $i++) // 行数循环
  7146. {
  7147. $data = array();
  7148. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7149. {
  7150. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7151. }
  7152. $list[] = $data;
  7153. }
  7154. }
  7155. $i = 0;
  7156. $j = 0;
  7157. $ed = array();
  7158. foreach ($list as $key => $value) {
  7159. $time = time();
  7160. if ($value['0'] == "" || $value['1'] == "") {
  7161. continue;
  7162. }
  7163. $warehouse = $this->warehouse->get_title($value['0']);
  7164. $sku = $value['1'];
  7165. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7166. if (!$d) //如果没有这个SKU
  7167. {
  7168. $ed[] = array($sku . '-库存中不存在此SKU');
  7169. $j++;
  7170. continue;
  7171. }
  7172. if (!isset($warehouse['id'])) {
  7173. $ed[] = array($sku . '-仓库名错误!');
  7174. $j++;
  7175. continue;
  7176. }
  7177. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7178. if ($z < 1) {
  7179. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7180. foreach ($z as $v) {
  7181. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7182. if (count($zt) > 0) {
  7183. $ed[] = array($sku . '-有在途库存无法删除!');
  7184. $j++;
  7185. continue;
  7186. }
  7187. $this->whlabel->remove($v['id']);
  7188. }
  7189. } else {
  7190. $ed[] = array($sku . '-非0库存!');
  7191. $j++;
  7192. continue;
  7193. }
  7194. }
  7195. if ($j > 0) {
  7196. $tt = date('Ymd', time());
  7197. $title = '删除0库存错误信息-' . $tt;
  7198. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7199. $tail = "\n";
  7200. $filename = $title . ".xls";
  7201. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7202. $dir = '/data/excel/' . $time . '/';
  7203. $file_name = 'error_' . $time . rand(1000, 9999);
  7204. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7205. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7206. fwrite($myfile, $ecl);
  7207. fclose($myfile);
  7208. $error = $dir . $file_name . '.xls';
  7209. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7210. exit;
  7211. } else {
  7212. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7213. exit;
  7214. }
  7215. }
  7216. }
  7217. public function _gbhtype()
  7218. {
  7219. $post = $this->input->post(NULL, TRUE);
  7220. if (isset($post['s'])) {
  7221. $n = $this->input->post('n');
  7222. $d = $this->input->post('s');
  7223. if (!$d) {
  7224. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7225. exit;
  7226. }
  7227. $d = explode(',', trim($d, ','));
  7228. $t = $this->whlabel_type->read($n);
  7229. //循环删除记录
  7230. foreach ($d as $v) {
  7231. $u = $this->whlabel->read($v);
  7232. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7233. foreach ($data as $val) {
  7234. $this->whlabel->save(array('type' => $n), $val['id']);
  7235. }
  7236. }
  7237. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7238. }
  7239. }
  7240. //出库、退库导出
  7241. public function _dccrtype()
  7242. {
  7243. $classid = $this->classid->sku();
  7244. $pm = $classid;
  7245. $typeclass = array();
  7246. $tc = $this->typeclass->find_all();
  7247. foreach ($tc as $v) {
  7248. $typeclass[$v['id']] = $v;
  7249. }
  7250. $prc = array();
  7251. $purchase = $this->purchase->find_all();
  7252. foreach ($purchase as $k => $v) {
  7253. $prc[$v['id']] = $v['title'];
  7254. }
  7255. if (isset($_GET['sid'])) {
  7256. $wh = array();
  7257. $w = $this->warehouse->find_all('1=1', 'id,title');
  7258. foreach ($w as $v) {
  7259. $wh[$v['id']] = $v['title'];
  7260. }
  7261. $type = $this->input->get('excel', true);
  7262. $category = $this->input->get('category', true);
  7263. $size = $this->input->get('size', true);
  7264. $grade = $this->input->get('grade', true);
  7265. $color = $this->input->get('color', true);
  7266. $lowe = $this->input->get('lowe', true);
  7267. $sku = $this->input->get('sku', true);
  7268. $warehouse = $this->input->get('warehouse', true);
  7269. $lacetype = $this->input->get('lacetype', true);
  7270. $lacecolor = $this->input->get('lacecolor', true);
  7271. $density = $this->input->get('density', true);
  7272. $haircap = $this->input->get('haircap', true);
  7273. $purchase = $this->input->get('purchase', true);
  7274. $title = $this->input->get('title', true);
  7275. $state = $this->input->get('state', true);
  7276. $sid = $this->input->get('sid', true);
  7277. $ktime = $this->input->get('ktime', true);
  7278. $jtime = $this->input->get('jtime', true);
  7279. $ktime = strtotime($ktime);
  7280. $jtime = strtotime($jtime);
  7281. $where = "1=1";
  7282. $gj = "";
  7283. $ck = "";
  7284. if ($category) {
  7285. $where .= " and features like '%-$category-%'";
  7286. }
  7287. if ($size) {
  7288. $where .= " and features like '%-$size-%'";
  7289. }
  7290. if ($grade) {
  7291. $where .= " and features like '%-$grade-%'";
  7292. }
  7293. if ($color) {
  7294. $where .= " and features like '%-$color-%'";
  7295. }
  7296. if ($lowe) {
  7297. $where .= " and features like '%-$lowe-%'";
  7298. }
  7299. if ($warehouse) {
  7300. $where .= " and warehouse = '$warehouse'";
  7301. }
  7302. if ($purchase) {
  7303. $where .= " and purchase = '$purchase'";
  7304. }
  7305. if ($state) {
  7306. $where .= " and state = '$state'";
  7307. }
  7308. if ($lacetype) {
  7309. $where .= " and features like '%-$lacetype-%'";
  7310. }
  7311. if ($lacecolor) {
  7312. $where .= " and features like '%-$lacecolor-%'";
  7313. }
  7314. if ($density) {
  7315. $where .= " and features like '%-$density-%'";
  7316. }
  7317. if ($haircap) {
  7318. $where .= " and features like '%-$haircap-%'";
  7319. }
  7320. if ($title) {
  7321. $title = trim($title, ' ');
  7322. $title = trim($title, ' ');
  7323. $where .= " and title like '%$title%'";
  7324. }
  7325. if ($sku) {
  7326. $sku = trim($sku, ' ');
  7327. $sku = trim($sku, ' ');
  7328. $where .= " and sku like '%$sku%'";
  7329. }
  7330. if ($ktime && $jtime) {
  7331. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7332. }
  7333. $sidwhere = '';
  7334. if ($sid) {
  7335. $sd = "";
  7336. $s = explode(',', trim($sid, ','));
  7337. foreach ($s as $value) {
  7338. $sd .= " id = " . $value . " or";
  7339. }
  7340. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7341. }
  7342. //数据排序
  7343. $order_str = "time desc";
  7344. if (empty($page)) {
  7345. $start = 0;
  7346. $perpage = 1;
  7347. } else {
  7348. $start = ($page - 1) * $perpage;
  7349. }
  7350. $wh = array();
  7351. $w = $this->warehouse->find_all('1=1', 'id,title');
  7352. foreach ($w as $v) {
  7353. $wh[$v['id']] = $v['title'];
  7354. }
  7355. $wt = array();
  7356. $whlabel_type = $this->whlabel_type->find_all();
  7357. foreach ($whlabel_type as $v) {
  7358. $wt[$v['id']] = $v['title'];
  7359. }
  7360. $classid = $this->classid->sku();
  7361. $list = array();
  7362. $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');
  7363. foreach ($rows_r as $key => $value) {
  7364. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7365. $pm = $classid;
  7366. $jm = $classid;
  7367. $rows_r[$key]['enter'] = '入库';
  7368. $rows_r[$key]['time'] = $value['enter'];
  7369. if ($value['rktype'] == 1) {
  7370. $rows_r[$key]['rktype'] = '采购入库';
  7371. } else if ($value['rktype'] == 2) {
  7372. $rows_r[$key]['rktype'] = '盘盈调整';
  7373. } else if ($value['rktype'] == 3) {
  7374. $rows_r[$key]['rktype'] = '其他调整入库';
  7375. } else if ($value['rktype'] == 4) {
  7376. $rows_r[$key]['rktype'] = '其他调整入库';
  7377. } else if ($value['rktype'] == 5) {
  7378. $rows_r[$key]['rktype'] = '退库入库';
  7379. } else if ($value['rktype'] == 6) {
  7380. $rows_r[$key]['rktype'] = '退货可用入库';
  7381. } else if ($value['rktype'] == 7) {
  7382. $rows_r[$key]['rktype'] = '形态转换入库';
  7383. } else {
  7384. $rows_r[$key]['rktype'] = '';
  7385. }
  7386. $features = explode('-', trim($value['features'], '-'));
  7387. foreach ($features as $v) {
  7388. if (isset($typeclass[$v])) {
  7389. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7390. $pm[$typeclass[$v]['classid']] = $zh[0];
  7391. }
  7392. if (isset($typeclass[$v])) {
  7393. if (isset($jm[$typeclass[$v]['classid']])) {
  7394. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7395. }
  7396. }
  7397. }
  7398. $zh = implode(" ", $pm);
  7399. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7400. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7401. $rows_r[$key]['zh'] = $zh;
  7402. $jm = array_filter($jm);
  7403. $rows_r[$key]['features'] = implode("-", $jm);
  7404. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7405. }
  7406. $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');
  7407. foreach ($rows_c as $key => $value) {
  7408. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7409. $pm = $classid;
  7410. $jm = $classid;
  7411. $rows_c[$key]['time'] = $value['outk'];
  7412. $rows_c[$key]['outk'] = '出库';
  7413. if ($value['cktype'] == 1) {
  7414. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7415. } else if ($value['cktype'] == 2) {
  7416. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7417. } else if ($value['cktype'] == 3) {
  7418. $rows_c[$key]['cktype'] = '盘亏调整';
  7419. } else if ($value['cktype'] == 4) {
  7420. $rows_c[$key]['cktype'] = '其他调整出库';
  7421. } else if ($value['cktype'] == 5) {
  7422. $rows_c[$key]['cktype'] = '形态转换出库';
  7423. } else {
  7424. $rows_c[$key]['cktype'] = '';
  7425. }
  7426. unset($rows_c[$key]['state']);
  7427. $features = explode('-', trim($value['features'], '-'));
  7428. foreach ($features as $v) {
  7429. if (isset($typeclass[$v])) {
  7430. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7431. $pm[$typeclass[$v]['classid']] = $zh[0];
  7432. }
  7433. if (isset($typeclass[$v])) {
  7434. if (isset($jm[$typeclass[$v]['classid']])) {
  7435. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7436. }
  7437. }
  7438. }
  7439. $zh = implode(" ", $pm);
  7440. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7441. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7442. $rows_c[$key]['zh'] = $zh;
  7443. $jm = array_filter($jm);
  7444. $rows_c[$key]['features'] = implode("-", $jm);
  7445. $rows_c[$key]['number'] = 1;
  7446. }
  7447. $merged = $rows_r;
  7448. foreach ($rows_c as $key => $value) {
  7449. if (isset($merged[$key])) {
  7450. $merged[] = $value;
  7451. } else {
  7452. $merged[$key] = $value;
  7453. }
  7454. }
  7455. usort($merged, function ($a, $b) {
  7456. return $a['time'] - $b['time'];
  7457. });
  7458. foreach ($merged as $key => $value) {
  7459. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7460. }
  7461. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7462. $titlename = "<table border=1>
  7463. <tr align='center'>
  7464. <td>仓库</td>
  7465. <td>SKU</td>
  7466. <td>商品名称</td>
  7467. <td>仓库品名</td>
  7468. <td>料号</td>
  7469. <td>时间</td>
  7470. <td>操作</td>
  7471. <td>类型</td>
  7472. <td>数量</td>
  7473. <td>备注</td>
  7474. </tr>
  7475. </table>";
  7476. $filename = $title . ".xlsx";
  7477. $tail = "";
  7478. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7479. }
  7480. }
  7481. /*************************************处理exceljs导出****************************************************/
  7482. public function _excelrjs(){
  7483. if (isset($_GET['excel'])) {
  7484. $category = $this->input->get('category', true);
  7485. $size = $this->input->get('size', true);
  7486. $grade = $this->input->get('grade', true);
  7487. $color = $this->input->get('color', true);
  7488. $lowe = $this->input->get('lowe', true);
  7489. $sku = $this->input->get('sku', true);
  7490. $warehouse = $this->input->get('warehouse', true);
  7491. $purchase = $this->input->get('purchase', true);
  7492. $ktime = $this->input->get('ktime', true);
  7493. $jtime = $this->input->get('jtime', true);
  7494. $ktime = strtotime($ktime);
  7495. $jtime = strtotime($jtime);
  7496. $where = "1=1";
  7497. $gj = "";
  7498. $ck = "";
  7499. if ($category) {
  7500. $where .= " and features like '%-$category-%'";
  7501. }
  7502. if ($size) {
  7503. $where .= " and features like '%-$size-%'";
  7504. }
  7505. if ($grade) {
  7506. $where .= " and features like '%-$grade-%'";
  7507. }
  7508. if ($color) {
  7509. $where .= " and features like '%-$color-%'";
  7510. }
  7511. if ($lowe) {
  7512. $where .= " and features like '%-$lowe-%'";
  7513. }
  7514. if ($warehouse) {
  7515. $where .= " and warehouse = '$warehouse'";
  7516. }
  7517. if ($purchase) {
  7518. $where .= " and purchase = '$purchase'";
  7519. }
  7520. if ($sku) {
  7521. $where .= " and sku = '$sku'";
  7522. }
  7523. if ($ktime && $jtime) {
  7524. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7525. }
  7526. //数据排序
  7527. $order_str = "id desc";
  7528. if (empty($page)) {
  7529. $start = 0;
  7530. $perpage = 1;
  7531. } else {
  7532. $start = ($page - 1) * $perpage;
  7533. }
  7534. $list = array();
  7535. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7536. foreach ($rows as $value) {
  7537. $ck = $this->warehouse->read($value['warehouse']);
  7538. $warehouse = $ck['title'];
  7539. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7540. $retreatwarehouse = $tkck['title'];
  7541. $gy = $this->purchase->read($value['purchase']);
  7542. $purchase = $gy['title'];
  7543. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7544. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7545. }
  7546. if(empty($list)){
  7547. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7548. }else{
  7549. $final_list = [];
  7550. foreach($list as $v){
  7551. $final_list[] = array_values($v);
  7552. }
  7553. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7554. array_unshift($final_list,[
  7555. "仓库","SKU","商品名称","时间","数量"
  7556. ]);
  7557. array_unshift($final_list,[
  7558. $title,"","","",""
  7559. ]);
  7560. $merges = [
  7561. [
  7562. "s"=>["r"=>0,"c"=>0],
  7563. "e"=>["r"=>0,"c"=>4]
  7564. ]
  7565. ];
  7566. $cols = [
  7567. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7568. ];
  7569. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7570. }
  7571. }
  7572. }
  7573. //出库、退库导出
  7574. public function _excelctjs()
  7575. {
  7576. $classid = $this->classid->sku();
  7577. $pm = $classid;
  7578. $typeclass = array();
  7579. $tc = $this->typeclass->find_all();
  7580. foreach ($tc as $v) {
  7581. $typeclass[$v['id']] = $v;
  7582. }
  7583. $prc = array();
  7584. $purchase = $this->purchase->find_all();
  7585. foreach ($purchase as $k => $v) {
  7586. $prc[$v['id']] = $v['title'];
  7587. }
  7588. if (isset($_GET['excel'])) {
  7589. $wh = array();
  7590. $w = $this->warehouse->find_all('1=1', 'id,title');
  7591. foreach ($w as $v) {
  7592. $wh[$v['id']] = $v['title'];
  7593. }
  7594. $type = $this->input->get('excel', true);
  7595. $category = $this->input->get('category', true);
  7596. $size = $this->input->get('size', true);
  7597. $grade = $this->input->get('grade', true);
  7598. $color = $this->input->get('color', true);
  7599. $lowe = $this->input->get('lowe', true);
  7600. $sku = $this->input->get('sku', true);
  7601. $title = $this->input->get('title', true);
  7602. $warehouse = $this->input->get('warehouse', true);
  7603. $purchase = $this->input->get('purchase', true);
  7604. $lacetype = $this->input->get('lacetype', true);
  7605. $haircap = $this->input->get('haircap', true);
  7606. $lacecolor = $this->input->get('lacecolor', true);
  7607. $density = $this->input->get('density', true);
  7608. $details = $this->input->get('details', true);
  7609. $state = $this->input->get('state', true);
  7610. $shop = $this->input->get('shop', true);
  7611. $hairnumber = $this->input->get('hairnumber', true);
  7612. $type_leixi = $this->input->get('type', true);
  7613. $cpbz = $this->input->get('cpbz', true);
  7614. $sm = $this->input->get('sm', true);
  7615. $sid = $this->input->get('sid', true);
  7616. $ktime = $this->input->get('ktime', true);
  7617. $jtime = $this->input->get('jtime', true);
  7618. $ktime = strtotime($ktime);
  7619. $jtime = strtotime($jtime);
  7620. //$where = " 1=1 ";
  7621. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7622. $where = " sku != '' ";
  7623. $gj = "";
  7624. $ck = "";
  7625. if ($category) {
  7626. $where .= " and features like '%-$category-%'";
  7627. }
  7628. if ($size) {
  7629. $where .= " and features like '%-$size-%'";
  7630. }
  7631. if ($grade) {
  7632. $where .= " and features like '%-$grade-%'";
  7633. }
  7634. if ($color) {
  7635. $where .= " and features like '%-$color-%'";
  7636. }
  7637. if ($lowe) {
  7638. $where .= " and features like '%-$lowe-%'";
  7639. }
  7640. if ($warehouse) {
  7641. $where .= " and warehouse = '$warehouse'";
  7642. }
  7643. if ($purchase) {
  7644. $where .= " and purchase = '$purchase'";
  7645. }
  7646. if ($state) {
  7647. $where .= " and state = '$state'";
  7648. }
  7649. if ($lacetype) {
  7650. $where .= " and features like '%-$lacetype-%'";
  7651. }
  7652. if ($lacecolor) {
  7653. $where .= " and features like '%-$lacecolor-%'";
  7654. }
  7655. if ($density) {
  7656. $where .= " and features like '%-$density-%'";
  7657. }
  7658. if ($haircap) {
  7659. $where .= " and features like '%-$haircap-%'";
  7660. }
  7661. if ($details) {
  7662. $where .= " and details = '$details'";
  7663. }
  7664. if ($shop) {
  7665. $where .= " and shop like '%$shop%'";
  7666. }
  7667. if ($title) {
  7668. $title = trim($title, ' ');
  7669. $title = trim($title, ' ');
  7670. $where .= " and title like '%$title%'";
  7671. }
  7672. if (!empty($hairnumber)) {
  7673. $where .= " and features like '%-128-%' ";
  7674. if ($hairnumber < 0) {
  7675. $class_list = $this->typeclass->find_all('classid = 43');
  7676. foreach ($class_list as $v) {
  7677. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7678. }
  7679. } else {
  7680. $where .= " and features like '%-$hairnumber-%'";
  7681. }
  7682. }
  7683. if ($type_leixi) {
  7684. $where .= " and type = '$type_leixi'";
  7685. }
  7686. if ($cpbz) {
  7687. $where .= " and cpbz like '%$cpbz%' ";
  7688. }
  7689. if ($sm) {
  7690. $where .= " and sm like '%$sm%' ";
  7691. }
  7692. if ($sku) {
  7693. $sku = trim($sku, ' ');
  7694. $sku = trim($sku, ' ');
  7695. $where .= " and sku like '%$sku%'";
  7696. }
  7697. if ($ktime && $jtime) {
  7698. if ($type == 1) {
  7699. $tl = '出库';
  7700. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7701. } else if ($type == 2) {
  7702. $tl = '退库';
  7703. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7704. } else if ($type == 3) {
  7705. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7706. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7707. } else if ($type == 4) {
  7708. $tl = '出库+零售';
  7709. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7710. } else if ($type == 5) {
  7711. $tl = '零售';
  7712. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7713. }
  7714. }
  7715. $sidwhere = '';
  7716. if ($sid) {
  7717. $sd = "";
  7718. $s = explode(',', trim($sid, ','));
  7719. foreach ($s as $value) {
  7720. $sd .= " id = " . $value . " or";
  7721. }
  7722. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7723. }
  7724. //数据排序
  7725. $order_str = "time desc";
  7726. if (empty($page)) {
  7727. $start = 0;
  7728. $perpage = 1;
  7729. } else {
  7730. $start = ($page - 1) * $perpage;
  7731. }
  7732. //取得信息列表
  7733. if ($type != 3 && $type != 5) {
  7734. if ($type == 1 || $type == 4) {
  7735. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7736. foreach ($info_list as $key => $value) {
  7737. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7738. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7739. $warehouse = $this->warehouse->read($value['warehouse']);
  7740. $info_list[$key]['warehouse'] = $warehouse['title'];
  7741. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7742. $features = explode('-', trim($features, '-'));
  7743. $pm = $classid;
  7744. foreach ($features as $k => $v) {
  7745. if ($v != 0) {
  7746. if (!isset($typeclass[$v])) {
  7747. continue;
  7748. }
  7749. if (isset($pm[$typeclass[$v]['classid']])) {
  7750. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7751. $tz = explode('|', $typeclass[$v]['zh']);
  7752. $pm[$typeclass[$v]['classid']] = $tz[0];
  7753. } else {
  7754. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7755. }
  7756. }
  7757. }
  7758. }
  7759. $zh = implode(" ", $pm);
  7760. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7761. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7762. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7763. $info_list[$key]['features'] = $zh;
  7764. }
  7765. $final_list = [];
  7766. foreach($info_list as $k=>$v){
  7767. $number = "";
  7768. if(!empty($v['orderinfo'])){
  7769. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7770. if(!empty($tmp_info['number'])){
  7771. $number = $tmp_info['number'];
  7772. }
  7773. }
  7774. $final_list[] = [
  7775. 'warehouse'=>$v['warehouse'],
  7776. 'purchase'=>$v['purchase'],
  7777. 'sku'=>$v['sku'],
  7778. 'title'=>$v['title'],
  7779. 'features'=>$v['features'],
  7780. 'label'=>$v['label'],
  7781. 'orderinfo'=>$v['orderinfo'],
  7782. 'number'=>$number,
  7783. 'waybill'=>$v['waybill'],
  7784. 'outk'=>$v['outk'],
  7785. ];
  7786. }
  7787. } else {
  7788. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7789. foreach ($info_list as $key => $value) {
  7790. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7791. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7792. $warehouse = $this->warehouse->read($value['warehouse']);
  7793. $info_list[$key]['warehouse'] = $warehouse['title'];
  7794. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7795. $features = explode('-', trim($features, '-'));
  7796. $pm = $classid;
  7797. foreach ($features as $k => $v) {
  7798. if ($v != 0) {
  7799. if (!isset($typeclass[$v])) {
  7800. continue;
  7801. }
  7802. if (isset($pm[$typeclass[$v]['classid']])) {
  7803. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7804. $tz = explode('|', $typeclass[$v]['zh']);
  7805. $pm[$typeclass[$v]['classid']] = $tz[0];
  7806. } else {
  7807. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7808. }
  7809. }
  7810. }
  7811. }
  7812. $zh = implode(" ", $pm);
  7813. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7814. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7815. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7816. $info_list[$key]['features'] = $zh;
  7817. }
  7818. $final_list = [];
  7819. foreach($info_list as $k=>$v){
  7820. $number = "";
  7821. if(!empty($v['orderinfo'])){
  7822. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7823. if(!empty($tmp_info['number'])){
  7824. $number = $tmp_info['number'];
  7825. }
  7826. }
  7827. $final_list[] = [
  7828. 'warehouse'=>$v['warehouse'],
  7829. 'purchase'=>$v['purchase'],
  7830. 'sku'=>$v['sku'],
  7831. 'title'=>$v['title'],
  7832. 'features'=>$v['features'],
  7833. 'label'=>$v['label'],
  7834. 'orderinfo'=>$v['orderinfo'],
  7835. 'number'=>$number,
  7836. 'waybill'=>$v['waybill'],
  7837. 'retreat'=>$v['retreat'],
  7838. ];
  7839. }
  7840. }
  7841. if(empty($final_list)){
  7842. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7843. }else{
  7844. $end_list = [];
  7845. foreach($final_list as $v){
  7846. $end_list[] = array_values($v);
  7847. }
  7848. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7849. array_unshift($end_list,[
  7850. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7851. ]);
  7852. array_unshift($end_list,[
  7853. $title,"","","","","","","","",""
  7854. ]);
  7855. $merges = [
  7856. [
  7857. "s"=>["r"=>0,"c"=>0],
  7858. "e"=>["r"=>0,"c"=>9]
  7859. ]
  7860. ];
  7861. $cols = [
  7862. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  7863. ];
  7864. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  7865. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  7866. ] )));
  7867. }
  7868. } else if ($type == 5) {
  7869. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  7870. foreach ($info_list as $key => $value) {
  7871. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7872. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7873. $warehouse = $this->warehouse->read($value['warehouse']);
  7874. $info_list[$key]['warehouse'] = $warehouse['title'];
  7875. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7876. $features = explode('-', trim($features, '-'));
  7877. $pm = $classid;
  7878. foreach ($features as $k => $v) {
  7879. if ($v != 0) {
  7880. if (!isset($typeclass[$v])) {
  7881. continue;
  7882. }
  7883. if (isset($pm[$typeclass[$v]['classid']])) {
  7884. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7885. $tz = explode('|', $typeclass[$v]['zh']);
  7886. $pm[$typeclass[$v]['classid']] = $tz[0];
  7887. } else {
  7888. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7889. }
  7890. }
  7891. }
  7892. }
  7893. $zh = implode(" ", $pm);
  7894. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7895. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7896. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7897. $info_list[$key]['features'] = $zh;
  7898. }
  7899. if(empty($info_list)){
  7900. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7901. }else{
  7902. $final_list = [];
  7903. foreach($info_list as $v){
  7904. $final_list[] = array_values($v);
  7905. }
  7906. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  7907. array_unshift($final_list,[
  7908. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  7909. ]);
  7910. array_unshift($final_list,[
  7911. $title,"","","","","","",
  7912. ]);
  7913. $merges = [
  7914. [
  7915. "s"=>["r"=>0,"c"=>0],
  7916. "e"=>["r"=>0,"c"=>6]
  7917. ]
  7918. ];
  7919. $cols = [
  7920. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  7921. ];
  7922. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  7923. }
  7924. } else {
  7925. $wh = array();
  7926. $w = $this->warehouse->find_all('1=1', 'id,title');
  7927. foreach ($w as $v) {
  7928. $wh[$v['id']] = $v['title'];
  7929. }
  7930. $wt = array();
  7931. $whlabel_type = $this->whlabel_type->find_all();
  7932. foreach ($whlabel_type as $v) {
  7933. $wt[$v['id']] = $v['title'];
  7934. }
  7935. $classid = $this->classid->sku();
  7936. $list = array();
  7937. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  7938. foreach ($rows as $key => $value) {
  7939. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7940. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7941. $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');
  7942. $details = array();
  7943. $cpid = array();
  7944. $cpbz = array();
  7945. $c = 0;
  7946. $g = 0;
  7947. $x = 0;
  7948. $t = 0;
  7949. $s = 0;
  7950. $q = 0;
  7951. foreach ($sd as $k => $v) {
  7952. if ($v['state'] == 0) {
  7953. $c++;
  7954. }
  7955. if ($v['state'] != 9) {
  7956. $g++;
  7957. }
  7958. if ($v['outk'] > 1) {
  7959. $x++;
  7960. }
  7961. if ($v['retreat'] > 0) {
  7962. $t++;
  7963. }
  7964. if ($v['state'] == 8) {
  7965. $s++;
  7966. }
  7967. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  7968. $q++;
  7969. }
  7970. $details[$v['details']] = $v['details'];
  7971. if ($v['cpid'] != 0) {
  7972. $cpid[$v['cpid']] = $v['cpid'];
  7973. }
  7974. if ($v['cpbz'] != '') {
  7975. $cpbz[$v['cpbz']] = $v['cpbz'];
  7976. }
  7977. }
  7978. if (isset($wt[$value['type']])) {
  7979. $rows[$key]['type'] = $wt[$value['type']];
  7980. } else {
  7981. $rows[$key]['type'] = '未设置';
  7982. }
  7983. $rows[$key]['details'] = implode("、", $details);
  7984. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  7985. $ftime = time() - 15 * 24 * 3600;
  7986. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  7987. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  7988. $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);
  7989. $rows[$key]['c'] = $c;
  7990. $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);
  7991. $rows[$key]['t'] = $t;
  7992. $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'] . '"');
  7993. $rows[$key]['z'] = $z;
  7994. // $jm = $classid;
  7995. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7996. $features = explode('-', trim($features, '-'));
  7997. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  7998. }
  7999. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8000. $final_list =[];
  8001. foreach($tmp_list as $k=>$v){
  8002. $final_list[] = [
  8003. "warehouse"=>$v['warehouse'],
  8004. "purchase"=>$v['purchase'],
  8005. "details"=>$v['details'],
  8006. "cpid"=>$v['cpid'],
  8007. "sku"=>$v['sku'],
  8008. "title"=>$v['title'],
  8009. "features"=>$v['pm'],
  8010. "cpbz"=>$v['cpbz'],
  8011. "sm"=>$v['sm'],
  8012. "type"=>$v['type'],
  8013. "g"=>$v["g"],
  8014. "c"=>$v["c"],
  8015. "x"=>$v["x"],
  8016. "t"=>$v["t"],
  8017. "z"=>$v["z"],
  8018. "jm"=>$v["jm"],
  8019. "weight"=>$v["weight"],
  8020. "asd"=>$v["asd"],
  8021. ];
  8022. }
  8023. if(empty($final_list)){
  8024. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8025. }else{
  8026. $end_list = [];
  8027. foreach($final_list as $v){
  8028. $end_list[] = array_values($v);
  8029. }
  8030. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8031. array_unshift($end_list,[
  8032. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8033. ]);
  8034. array_unshift($end_list,[
  8035. $title,"","","","","","","","","","","","","","","","","",""
  8036. ]);
  8037. $merges = [
  8038. [
  8039. "s"=>["r"=>0,"c"=>0],
  8040. "e"=>["r"=>0,"c"=>6]
  8041. ]
  8042. ];
  8043. $cols = [
  8044. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8045. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8046. ];
  8047. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8048. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8049. ])));
  8050. }
  8051. }
  8052. }
  8053. }
  8054. public function _exceljxcjs(){
  8055. $classid = $this->classid->sku();
  8056. $pm = $classid;
  8057. $typeclass = array();
  8058. $tc = $this->typeclass->find_all();
  8059. foreach ($tc as $v) {
  8060. $typeclass[$v['id']] = $v;
  8061. }
  8062. $prc = array();
  8063. $purchase = $this->purchase->find_all();
  8064. foreach ($purchase as $k => $v) {
  8065. $prc[$v['id']] = $v['title'];
  8066. }
  8067. if(!isset($_GET['excel'])){
  8068. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8069. }
  8070. $where = "sku != 'Preset'";
  8071. //数据排序
  8072. $order_str = "id desc";
  8073. if (empty($page)) {
  8074. $start = 0;
  8075. $perpage = 1;
  8076. } else {
  8077. $start = ($page - 1) * $perpage;
  8078. }
  8079. $category = $this->input->get('category', true);
  8080. $warehouse = $this->input->get('warehouse', true);
  8081. $excelid = $this->input->get('sid', true);
  8082. if ($category) {
  8083. $where .= " and features like '%-$category-%'";
  8084. }
  8085. if ($warehouse) {
  8086. $where .= " and warehouse = '$warehouse'";
  8087. }
  8088. $xzid = '';
  8089. if ($excelid) {
  8090. $excelid = explode(',', trim($excelid, ','));
  8091. foreach ($excelid as $key => $value) {
  8092. $xzid .= " id = " . $value . " or";
  8093. }
  8094. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8095. }
  8096. $wt = array();
  8097. $whlabel_type = $this->whlabel_type->find_all();
  8098. foreach ($whlabel_type as $v) {
  8099. $wt[$v['id']] = $v['title'];
  8100. }
  8101. $wh = array();
  8102. $w = $this->warehouse->find_all('1=1', 'id,title');
  8103. foreach ($w as $v) {
  8104. $wh[$v['id']] = $v['title'];
  8105. }
  8106. $list = array();
  8107. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8108. foreach ($rows as $key => $value) {
  8109. if (isset($wt[$value['type']])) {
  8110. $rows[$key]['type'] = $wt[$value['type']];
  8111. } else {
  8112. $rows[$key]['type'] = '未设置';
  8113. }
  8114. $bm = '03';
  8115. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8116. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8117. $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');
  8118. $details = array();
  8119. $cpid = array();
  8120. $cpbz = array();
  8121. $c = 0;
  8122. $g = 0;
  8123. $x = 0;
  8124. $t = 0;
  8125. $s = 0;
  8126. $q = 0;
  8127. foreach ($sd as $k => $v) {
  8128. if ($v['state'] == 0) {
  8129. $c++;
  8130. if ($v['cpid'] != 0) {
  8131. $cpid[$v['cpid']] = $v['cpid'];
  8132. }
  8133. if ($v['cpbz'] != '') {
  8134. $cpbz[$v['cpbz']] = $v['cpbz'];
  8135. }
  8136. }
  8137. if ($v['state'] != 9) {
  8138. $g++;
  8139. }
  8140. if ($v['state'] == 1) {
  8141. $x++;
  8142. }
  8143. if ($v['state'] == 2) {
  8144. $t++;
  8145. }
  8146. if ($v['state'] == 8) {
  8147. $s++;
  8148. }
  8149. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8150. $q++;
  8151. }
  8152. $details[$v['details']] = $v['details'];
  8153. }
  8154. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  8155. $rows[$key]['details'] = implode("、", $details);
  8156. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8157. $number = $value['number'];
  8158. $ftime = time() - 15 * 24 * 3600;
  8159. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8160. $rows[$key]['number'] = $g;
  8161. $rows[$key]['c'] = $c;
  8162. $rows[$key]['x'] = $x;
  8163. $rows[$key]['t'] = $t;
  8164. $rows[$key]['s'] = $s;
  8165. $rows[$key]['q'] = $q;
  8166. $rows[$key]['z'] = $z;
  8167. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8168. $features = explode('-', trim($features, '-'));
  8169. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8170. }
  8171. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8172. $final_list = [];
  8173. foreach ($list as $k => $v) {
  8174. if (empty($v['sku'])) {
  8175. continue;
  8176. }
  8177. $final_list[] = [
  8178. $v["warehouse"],
  8179. $v["purchase"],
  8180. $v["details"],
  8181. $v["cpid"],
  8182. $v["dbcontent"],
  8183. $v["sku"],
  8184. $v["bm"],
  8185. $v["jm"],
  8186. $v["title"],
  8187. $v["pm"],
  8188. $v["cpbz"],
  8189. $v["sm"],
  8190. $v["type"],
  8191. $v["number"],
  8192. $v["c"],
  8193. $v["x"],
  8194. $v["t"],
  8195. $v["s"],
  8196. $v["q"],
  8197. $v["z"],
  8198. $v['weight'],
  8199. ];
  8200. }
  8201. if(empty($final_list)){
  8202. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8203. }
  8204. $title = "总进销存统计表";
  8205. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8206. $merges = [
  8207. [
  8208. "s"=>["r"=>0,"c"=>0],
  8209. "e"=>["r"=>0,"c"=>21]
  8210. ]
  8211. ];
  8212. $cols = [
  8213. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8214. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8215. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8216. ];
  8217. array_unshift($final_list, $first_row);
  8218. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8219. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8220. }
  8221. public function _summaryjs($arg_array)
  8222. {
  8223. $prc = array();
  8224. $purchase = $this->purchase->find_all();
  8225. foreach ($purchase as $k => $v) {
  8226. $prc[$v['id']] = $v['title'];
  8227. }
  8228. if (isset($_GET['excel'])) {
  8229. $ktime = $this->input->get('ktime', true);
  8230. $jtime = $this->input->get('jtime', true);
  8231. $ktime = strtotime($ktime);
  8232. $jtime = strtotime($jtime);
  8233. $where = "1=1";
  8234. if ($ktime && $jtime) {
  8235. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8236. }
  8237. //数据排序
  8238. $order_str = "time desc";
  8239. if (empty($page)) {
  8240. $start = 0;
  8241. $perpage = 1;
  8242. } else {
  8243. $start = ($page - 1) * $perpage;
  8244. }
  8245. //取得信息列表
  8246. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8247. foreach ($info_list as $key => $value) {
  8248. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8249. $warehouse = $this->warehouse->read($value['warehouse']);
  8250. $info_list[$key]['warehouse'] = $warehouse['title'];
  8251. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8252. $details = array();
  8253. $cpid = array();
  8254. foreach ($x as $k => $v) {
  8255. if ($v['details'] != '') {
  8256. $details[$v['details']] = $v['details'];
  8257. }
  8258. if ($v['cpid'] != 0) {
  8259. $cpid[$v['cpid']] = $v['cpid'];
  8260. }
  8261. }
  8262. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8263. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8264. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8265. $info_list[$key]['s'] = $s;
  8266. $info_list[$key]['x'] = count($x);
  8267. }
  8268. if(empty($info_list)){
  8269. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8270. }
  8271. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8272. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8273. $merges = [
  8274. [
  8275. "s"=>["r"=>0,"c"=>0],
  8276. "e"=>["r"=>0,"c"=>7]
  8277. ]
  8278. ];
  8279. $cols = [
  8280. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8281. ];
  8282. $final_list = [];
  8283. foreach($info_list as $k => $v){
  8284. $final_list[] = array_values($v);
  8285. }
  8286. array_unshift($final_list, $first_row);
  8287. array_unshift($final_list,[
  8288. $title,"","","","","","","","",
  8289. ]);
  8290. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8291. $titlename = "<table border=1>
  8292. <tr align='center'>
  8293. <td>仓库</td>
  8294. <td>供应商</td>
  8295. <td>出库位置</td>
  8296. <td>出库编码</td>
  8297. <td>SKU</td>
  8298. <td>产品名</td>
  8299. <td>总剩余库存</td>
  8300. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8301. </tr>
  8302. </table>";
  8303. $filename = $title . ".xls";
  8304. $tail = "";
  8305. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8306. }
  8307. }
  8308. public function _uckjs()
  8309. {
  8310. if (isset($_GET['excel'])) {
  8311. $tc = array();
  8312. $typeclass = $this->typeclass->find_all();
  8313. foreach ($typeclass as $v) {
  8314. $tc[$v['id']] = $v['zh'];
  8315. }
  8316. $first_row = [
  8317. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8318. ];
  8319. $t = array();
  8320. $rq = '';
  8321. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8322. $ts = $ts / (24 * 3600);
  8323. for ($i = 0; $i < $ts; $i++) {
  8324. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8325. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8326. }
  8327. $day_len = count($t);
  8328. $first_row[] = "本月出库";
  8329. $merges = [
  8330. ];
  8331. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8332. $excel_key = 1;
  8333. $final_list = [];
  8334. foreach ($info_list as $k => $v) {
  8335. $features = explode('-', trim($v['features'], '-'));
  8336. if (!isset($features[3]) || !isset($features[4])) {
  8337. continue;
  8338. }
  8339. $tmp = [];
  8340. $tmp[0] = $tc[$features[0]]; //类型
  8341. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8342. $tmp[2] = $tc[$features[4]]; //曲度
  8343. $tmp[3] = '';
  8344. if (isset($data[$k][1])) {
  8345. $tmp[3] .=$tmp[1];
  8346. }
  8347. if (isset($data[$k][2])) {
  8348. $tmp[3] .= $tmp[2];
  8349. }
  8350. if (isset($features[5])) {
  8351. $tmp[3] .= $tc[$features[5]];
  8352. }
  8353. if (isset($features[2])) {
  8354. $tmp[3] .= $tc[$features[2]];
  8355. }
  8356. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8357. $tmp[4] = $v['sku'];
  8358. $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())) . '))'); //月初库存
  8359. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8360. $tmp[7] ="";
  8361. $tmp[8] ="";
  8362. $byck = 0;
  8363. foreach ($t as $vv) {
  8364. $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));
  8365. $tmp[] = ($sl > 0) ? $sl : '';
  8366. $byck += $sl;
  8367. }
  8368. $tmp[] = ($byck > 0) ? $byck : '';
  8369. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8370. // $ztrq = '';
  8371. // $ztsl = '';
  8372. // if (count($zt) > 0) {
  8373. // foreach ($zt as $vv) {
  8374. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8375. // $ztsl .= $vv['num'] . '<br>';
  8376. // }
  8377. // }
  8378. if(empty($zt)){
  8379. $final_list[] = $tmp;
  8380. $excel_key = $excel_key + 1;
  8381. }else{
  8382. $len = count($zt);
  8383. if($len == 1){
  8384. $tmp[7] = $zt[0]['num'] ;
  8385. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8386. $final_list[] = $tmp;
  8387. $excel_key = $excel_key + 1;
  8388. }else{
  8389. foreach($zt as $vv){
  8390. $tmp[7] = "";
  8391. $tmp[8] = "";
  8392. $tmp[7] = $vv['num'];
  8393. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8394. $final_list[] = $tmp;
  8395. }
  8396. $merges[] = [
  8397. "s"=>["r"=>$excel_key,"c"=>0],
  8398. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8399. ];
  8400. $merges[] = [
  8401. "s"=>["r"=>$excel_key,"c"=>1],
  8402. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8403. ];
  8404. $merges[] = [
  8405. "s"=>["r"=>$excel_key,"c"=>2],
  8406. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8407. ];
  8408. $merges[] = [
  8409. "s"=>["r"=>$excel_key,"c"=>3],
  8410. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8411. ];
  8412. $merges[] = [
  8413. "s"=>["r"=>$excel_key,"c"=>4],
  8414. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8415. ];
  8416. $merges[] = [
  8417. "s"=>["r"=>$excel_key,"c"=>5],
  8418. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8419. ];
  8420. $merges[] = [
  8421. "s"=>["r"=>$excel_key,"c"=>6],
  8422. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8423. ];
  8424. for($i=1;$i<=$day_len;$i++){
  8425. $merges[] = [
  8426. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8427. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8428. ];
  8429. }
  8430. $merges[] = [
  8431. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8432. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8433. ];
  8434. $excel_key = $excel_key + $len;
  8435. }
  8436. }
  8437. }
  8438. $title = "详情 " . date("Y-m-d", time());
  8439. if(empty($final_list)){
  8440. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8441. }
  8442. $cols = [
  8443. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8444. ];
  8445. array_unshift($final_list, $first_row);
  8446. // echo "<pre>";
  8447. // print_r($merges);
  8448. // die;
  8449. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8450. exit();
  8451. $titlename = "<table border=1>
  8452. <tr align='center'>
  8453. <td>类别</td>
  8454. <td>颜色</td>
  8455. <td>曲度</td>
  8456. <td>名称</td>
  8457. <td>SKU</td>
  8458. <td>月初库存</td>
  8459. <td>剩余库存</td>
  8460. <td>在途数量</td>
  8461. <td>预达日期</td>" .
  8462. $rq
  8463. . "<td>本月出库</td></tr>
  8464. </table>";
  8465. $filename = $title . ".xls";
  8466. $tail = "";
  8467. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  8468. }
  8469. }
  8470. }