Whlabel.php 311 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. } else if($arg == 'excelctjs'){
  192. $this->_excelctjs();
  193. }else if ($arg == 'exceljxcjs') //进销存信息导出
  194. {
  195. $this->_exceljxcjs();
  196. } else if ($arg == 'summaryjs') //汇总导出
  197. {
  198. $this->_summaryjs($arg_array);
  199. }else if($arg == 'uckjs'){
  200. $this->_uckjs();
  201. }else if ($arg == 'whlabelexcelzhjs') {
  202. $this->_whlabelexcelzhjs();
  203. }else if($arg == 'dccrtypejs'){
  204. $this->_dccrtypejs();
  205. }else if($arg == 'errorexceljs'){
  206. $this->_errorexceljs();
  207. }else if($arg == "w_t_cs"){
  208. $this->_w_t_cs(); //首页
  209. }else {
  210. $this->_index();
  211. }
  212. }
  213. public function _w_t_cs(){
  214. $vip = 0;
  215. if (isset($_SESSION['api'])) {
  216. $user = $this->user->get_api($_SESSION['api']);
  217. $fgshop = "";
  218. $sid = "";
  219. $usersp = explode('|', trim($user['shop'], '|'));
  220. foreach ($usersp as $value) {
  221. $fgshop .= " shop = " . $value . " or";
  222. $sid .= " id = " . $value . " or";
  223. }
  224. if ($user['vip'] == 1) {
  225. $vip = 1;
  226. }
  227. } else {
  228. header('Location: /');
  229. exit;
  230. }
  231. $prc = array();
  232. $purchase = $this->purchase->find_all();
  233. foreach ($purchase as $k => $v) {
  234. $prc[$v['id']] = $v['title'];
  235. }
  236. $company = array();
  237. $ct = $this->company->find_all();
  238. foreach ($ct as $k => $v) {
  239. $company[$v['id']] = $v['title'];
  240. }
  241. $sp = array();
  242. $s = $this->shop->find_all('1=1', 'id,shopname');
  243. foreach ($s as $v) {
  244. $sp[$v['id']] = $v['shopname'];
  245. }
  246. $wh = array();
  247. $w = $this->warehouse->find_all('1=1', 'id,title');
  248. foreach ($w as $v) {
  249. $wh[$v['id']] = $v['title'];
  250. }
  251. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  252. $this->data['shop'] = $wlshop;
  253. $this->data['vip'] = $vip;
  254. $this->_Template('whlabel_typejs', $this->data);
  255. }
  256. //管理
  257. public function _index()
  258. {
  259. $post = $this->input->post(NULL, TRUE);
  260. if (isset($post['page'])) {
  261. $page = $this->input->post('page', true);
  262. $perpage = $this->input->post('perpage', true);
  263. $sku = $this->input->post('sku', true);
  264. $number = $this->input->post('number', true);
  265. $warehouse = $this->input->post('warehouse', true);
  266. $purchase = $this->input->post('purchase', true);
  267. $orderinfo = $this->input->post('orderinfo', true);
  268. $waybill = $this->input->post('waybill', true);
  269. $category = $this->input->post('category', true);
  270. $size = $this->input->post('size', true);
  271. $grade = $this->input->post('grade', true);
  272. $color = $this->input->post('color', true);
  273. $lowe = $this->input->post('lowe', true);
  274. $state = $this->input->post('state', true);
  275. $label = $this->input->post('label', true);
  276. $timetk = $this->input->post('timetkk', true);
  277. $timetj = $this->input->post('timetjj', true);
  278. $timetk = strtotime($timetk);
  279. $timetj = strtotime($timetj);
  280. $where = "1=1 ";
  281. if ($timetk && $timetj) {
  282. $where .= " and time > '$timetk' and time < '$timetj'";
  283. }
  284. if ($sku) {
  285. $where .= " and sku = '$sku'";
  286. }
  287. if ($number) {
  288. $where .= " and number = '$number'";
  289. }
  290. if ($warehouse) {
  291. $where .= " and warehouse = '$warehouse'";
  292. }
  293. if ($purchase) {
  294. $where .= " and purchase = '$purchase'";
  295. }
  296. if ($orderinfo) {
  297. $where .= " and orderinfo = '$orderinfo'";
  298. }
  299. if ($waybill) {
  300. $where .= " and waybill = '$waybill'";
  301. }
  302. if ($category) {
  303. $where .= " and features like '%-$category-%'";
  304. }
  305. if ($size) {
  306. $where .= " and features like '%-$size-%'";
  307. }
  308. if ($grade) {
  309. $where .= " and features like '%-$grade-%'";
  310. }
  311. if ($color) {
  312. $where .= " and features like '%-$color-%'";
  313. }
  314. if ($lowe) {
  315. $where .= " and features like '%-$lowe-%'";
  316. }
  317. if ($label) {
  318. $where .= " and label = '$label'";
  319. }
  320. if ($state != '') {
  321. $where .= " and state = '$state'";
  322. }
  323. //数据排序
  324. $order_str = "time desc";
  325. if (empty($page)) {
  326. $start = 0;
  327. $perpage = 1;
  328. } else {
  329. $start = ($page - 1) * $perpage;
  330. }
  331. //取得信息列表
  332. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  333. foreach ($info_list as $key => $value) {
  334. $warehouse = $this->warehouse->read($value['warehouse']);
  335. $info_list[$key]['warehouse'] = $warehouse['title'];
  336. $purchase = $this->purchase->read($value['purchase']);
  337. $info_list[$key]['purchase'] = $purchase['title'];
  338. if ($value['enter'] != 0) {
  339. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  340. } else {
  341. $info_list[$key]['enter'] = "";
  342. }
  343. if ($value['outk'] != 0) {
  344. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  345. } else {
  346. $info_list[$key]['outk'] = "";
  347. }
  348. if ($value['printing'] != 0) {
  349. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  350. } else {
  351. $info_list[$key]['printing'] = "";
  352. }
  353. if ($value['orderinfo'] == 0) {
  354. $info_list[$key]['orderinfo'] = "";
  355. }
  356. if ($value['waybill'] == 0) {
  357. $info_list[$key]['waybill'] = "";
  358. }
  359. if ($value['state'] == 0) {
  360. $info_list[$key]['state'] = "在库";
  361. } else if ($value['state'] == 1) {
  362. $info_list[$key]['state'] = "出库";
  363. } else if ($value['state'] == 2) {
  364. $info_list[$key]['state'] = "退库";
  365. } else if ($value['state'] == 3) {
  366. $info_list[$key]['state'] = "调拨中";
  367. } else if ($value['state'] == 4) {
  368. $info_list[$key]['state'] = "再加工";
  369. } else if ($value['state'] == 5) {
  370. $info_list[$key]['state'] = "维修中";
  371. } else if ($value['state'] == 6) {
  372. $info_list[$key]['state'] = "盘亏";
  373. } else if ($value['state'] == 7) {
  374. $info_list[$key]['state'] = "更换标签";
  375. } else if ($value['state'] == 8) {
  376. $info_list[$key]['state'] = "其它";
  377. } else if ($value['state'] == 9) {
  378. $info_list[$key]['state'] = "预设";
  379. } else if ($value['state'] == 10) {
  380. $info_list[$key]['state'] = "美店零售";
  381. }
  382. if ($value['text'] == "") {
  383. $info_list[$key]['text'] = "";
  384. }
  385. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  386. }
  387. $total = $this->whlabel->find_count($where);
  388. $pagenum = ceil($total / $perpage);
  389. $over = $total - ($start + $perpage);
  390. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  391. echo json_encode($rows);
  392. exit;
  393. }
  394. if (isset($post['outsku'])) {
  395. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  396. $cz = $this->input->post('cz', true);
  397. if ($cz == '1') {
  398. $sku = $this->input->post('outsku', true);
  399. if ($sku) {
  400. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  401. if (count($data) < 1) {
  402. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  403. exit;
  404. }
  405. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  406. echo json_encode(array('success' => true));
  407. exit;
  408. }
  409. } else {
  410. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  411. exit;
  412. $sku = $this->input->post('outsku', true);
  413. if ($sku) {
  414. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  415. if (count($data) < 1) {
  416. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  417. exit;
  418. }
  419. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  420. echo json_encode(array('success' => true));
  421. exit;
  422. }
  423. }
  424. }
  425. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  426. $this->_Template('whlabel', $this->data);
  427. }
  428. //在库标签
  429. public function _existence()
  430. {
  431. $post = $this->input->post(NULL, TRUE);
  432. if (isset($post['s'])) {
  433. $id_arr = $this->input->post('s');
  434. $id_arr = explode(',', $id_arr);
  435. if (!$id_arr) {
  436. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  437. exit;
  438. }
  439. //循环删除记录
  440. foreach ($id_arr as $v) {
  441. $sid = $this->whlabel->read($v);
  442. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  443. if ($count > 0) {
  444. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  445. exit;
  446. }
  447. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  448. if (count($zt) > 0) {
  449. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  450. exit;
  451. }
  452. $this->whlabel->remove($v);
  453. }
  454. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  455. exit;
  456. }
  457. if (isset($post['page'])) {
  458. $page = $this->input->post('page', true);
  459. $perpage = $this->input->post('perpage', true);
  460. $warehouse = $this->input->post('warehouse', true);
  461. $label = $this->input->post('label', true);
  462. $where = "1=1 and state = 0";
  463. if ($warehouse) {
  464. $where .= " and warehouse = '$warehouse'";
  465. }
  466. if ($label) {
  467. $where .= " and label = '$label'";
  468. }
  469. //数据排序
  470. $order_str = "time asc";
  471. if (empty($page)) {
  472. $start = 0;
  473. $perpage = 1;
  474. } else {
  475. $start = ($page - 1) * $perpage;
  476. }
  477. //取得信息列表
  478. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  479. foreach ($info_list as $key => $value) {
  480. if ($value['enter'] != 0) {
  481. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  482. } else {
  483. $info_list[$key]['enter'] = "";
  484. }
  485. if ($value['printing'] != 0) {
  486. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  487. } else {
  488. $info_list[$key]['printing'] = "";
  489. }
  490. }
  491. $total = $this->whlabel->find_count($where);
  492. $pagenum = ceil($total / $perpage);
  493. $over = $total - ($start + $perpage);
  494. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  495. echo json_encode($rows);
  496. exit;
  497. }
  498. $this->_Template('whlabel_existence', $this->data);
  499. }
  500. //进销存浏览
  501. public function _typedy($arg_array)
  502. {
  503. $prc = array();
  504. $purchase = $this->purchase->find_all();
  505. foreach ($purchase as $k => $v) {
  506. $prc[$v['id']] = $v['title'];
  507. }
  508. $post = $this->input->post(NULL, TRUE);
  509. if (isset($post['page'])) {
  510. $page = $this->input->post('page', true);
  511. $perpage = $this->input->post('perpage', true);
  512. $category = $this->input->post('category', true);
  513. $size = $this->input->post('size', true);
  514. $grade = $this->input->post('grade', true);
  515. $color = $this->input->post('color', true);
  516. $lowe = $this->input->post('lowe', true);
  517. $sku = $this->input->post('sku');
  518. $title = $this->input->post('title');
  519. $warehouse = $this->input->post('warehouse', true);
  520. $usa = $this->input->post('usa', true);
  521. $purchase = $this->input->post('purchase', true);
  522. $lacetype = $this->input->post('lacetype', true);
  523. $haircap = $this->input->post('haircap', true);
  524. $density = $this->input->post('density', true);
  525. $details = $this->input->post('details', true);
  526. $state = $this->input->post('state', true);
  527. $lacecolor = $this->input->post('lacecolor', true);
  528. $hairnumber = $this->input->post('hairnumber', true);
  529. $cklx = $this->input->post('cklx', true);
  530. $ktime = $this->input->post('ktime', true);
  531. $jtime = $this->input->post('jtime', true);
  532. $sm = $this->input->post('sm', true);
  533. $cpbz = $this->input->post('cpbz', true);
  534. $type = $this->input->post('type', true);
  535. $ktime = strtotime($ktime);
  536. $jtime = strtotime($jtime);
  537. $where = "1=1";
  538. $gj = "";
  539. $ck = "";
  540. if ($usa) {
  541. if (!$warehouse) {
  542. $where .= " and (warehouse = '5' or warehouse = '8')";
  543. }
  544. }
  545. if ($warehouse) {
  546. $where .= " and warehouse = '$warehouse'";
  547. }
  548. if ($details) {
  549. $where .= " and details = '$details'";
  550. }
  551. if ($purchase) {
  552. $where .= " and purchase = '$purchase'";
  553. }
  554. if (isset($state)) {
  555. if($state >-1){
  556. $where .= " and state = '$state'";
  557. }
  558. }
  559. if ($lacetype) {
  560. $where .= " and features like '%-$lacetype-%'";
  561. }
  562. if ($category) {
  563. $where .= " and features like '%-$category-%'";
  564. }
  565. if ($size) {
  566. $where .= " and features like '%-$size-%'";
  567. }
  568. if ($grade) {
  569. $where .= " and features like '%-$grade-%'";
  570. }
  571. if ($color) {
  572. $where .= " and features like '%-$color-%'";
  573. }
  574. if ($lowe) {
  575. $where .= " and features like '%-$lowe-%'";
  576. }
  577. if ($haircap) {
  578. $where .= " and features like '%-$haircap-%'";
  579. }
  580. if ($density) {
  581. $where .= " and features like '%-$density-%'";
  582. }
  583. if ($lacecolor) {
  584. $where .= " and features like '%-$lacecolor-%'";
  585. }
  586. if($sm){
  587. $where .= " and sm like '%".$sm."%'";
  588. }
  589. if($cpbz){
  590. $where .= " and cpbz like '%".$cpbz."%'";
  591. }
  592. if($type){
  593. $where .= " and type = ".$type."";
  594. }
  595. if (!empty($hairnumber)) {
  596. $where .= " and features like '%-128-%' ";
  597. if ($hairnumber < 0) {
  598. $class_list = $this->typeclass->find_all('classid = 43');
  599. foreach ($class_list as $v) {
  600. $where .= " and features not like '%-" . $v['id'] . "-%'";
  601. }
  602. } else {
  603. $where .= " and features like '%-$hairnumber-%'";
  604. }
  605. }
  606. $where_add = '';
  607. if ($cklx) {
  608. $shop = $this->shop->read($cklx);
  609. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  610. }
  611. if ($ktime && $jtime) {
  612. $gj = " and enter > '$ktime' and enter < '$jtime'";
  613. $ck = " and outk > '$ktime' and outk < '$jtime'";
  614. }
  615. //数据排序
  616. $order_str = "id desc";
  617. if (empty($page)) {
  618. $start = 0;
  619. $perpage = 1;
  620. } else {
  621. $start = ($page - 1) * $perpage;
  622. }
  623. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  624. if ($sku) {
  625. $sku = trim($sku, ' ');
  626. $sku = trim($sku, ' ');
  627. $where .= " and sku like '%$sku%'";
  628. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  629. } else if ($title) {
  630. $title = trim($title, ' ');
  631. $title = trim($title, ' ');
  632. $where .= " and title like '%$title%'";
  633. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  634. } else {
  635. //$where .= " and time > '$ktime' and time < '$jtime'";
  636. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  637. }
  638. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  639. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  640. foreach ($info_list as $k => $v) {
  641. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  642. unset($info_list[$k]['pm']);
  643. unset($info_list[$k]['jm']);
  644. unset($info_list[$k]['bm']);
  645. }
  646. //取得信息列表
  647. $rows = array();
  648. $list = array();
  649. foreach ($info_list as $key => $value) {
  650. $warehouse = $this->warehouse->read($value['warehouse']);
  651. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  652. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  653. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  654. $info_list[$key]['cpbz'] = empty($value['cpbz'])?$value['sm']:$value['cpbz']." ".$value['sm'] ;
  655. $info_list[$key]['label'] = "";
  656. // $info_list[$key]['cpbz'] = $value['cpbz'] ;
  657. // $info_list[$key]['label'] = $value['sm'];
  658. $number = $value['number'];
  659. $ftime = time() - 15 * 24 * 3600;
  660. $info_list[$key]['warehouse'] = $warehouse['title'];
  661. $info_list[$key]['features'] = count($c);
  662. $z = count($z); //查看订单号
  663. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  664. $ztdata = '';
  665. if (count($zt) > 0) {
  666. foreach ($zt as $vv) {
  667. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  668. }
  669. }
  670. $info_list[$key]['number'] = $ztdata;
  671. $info_list[$key]['sm'] = $z;
  672. $details = array();
  673. $cpid = array();
  674. foreach ($c as $k => $v) {
  675. $details[$v['details']] = $v['details'];
  676. if ($v['cpid'] != 0) {
  677. $cpid[$v['cpid']] = $v['cpid'];
  678. }
  679. }
  680. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  681. if ($value['shop'] != '') {
  682. $shop = explode(',', trim($value['shop'], ','));
  683. $shop = $this->shop->read($shop[0]);
  684. $info_list[$key]['shop'] = $shop['shopname'];
  685. }
  686. }
  687. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  688. $pagenum = ceil($total / $perpage);
  689. $over = $total - ($start + $perpage);
  690. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  691. echo json_encode($rows);
  692. exit;
  693. }
  694. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  695. $this->_Template('whlabel_typedy', $this->data);
  696. }
  697. //进销存浏览
  698. public function _typedy_ck($arg_array)
  699. {
  700. $prc = array();
  701. $purchase = $this->purchase->find_all();
  702. foreach ($purchase as $k => $v) {
  703. $prc[$v['id']] = $v['title'];
  704. }
  705. $post = $this->input->post(NULL, TRUE);
  706. if (isset($post['page'])) {
  707. $page = $this->input->post('page', true);
  708. $perpage = $this->input->post('perpage', true);
  709. $category = $this->input->post('category', true);
  710. $size = $this->input->post('size', true);
  711. $grade = $this->input->post('grade', true);
  712. $color = $this->input->post('color', true);
  713. $lowe = $this->input->post('lowe', true);
  714. $sku = $this->input->post('sku');
  715. $title = $this->input->post('title');
  716. $warehouse = $this->input->post('warehouse', true);
  717. $usa = $this->input->post('usa', true);
  718. $purchase = $this->input->post('purchase', true);
  719. $lacetype = $this->input->post('lacetype', true);
  720. $haircap = $this->input->post('haircap', true);
  721. $density = $this->input->post('density', true);
  722. $details = $this->input->post('details', true);
  723. $state = $this->input->post('state', true);
  724. $lacecolor = $this->input->post('lacecolor', true);
  725. $cklx = $this->input->post('cklx', true);
  726. $ktime = $this->input->post('ktime', true);
  727. $jtime = $this->input->post('jtime', true);
  728. $ktime = strtotime($ktime);
  729. $jtime = strtotime($jtime);
  730. $where = "1=1";
  731. $gj = "";
  732. $ck = "";
  733. if ($lacetype) {
  734. $where .= " and features like '%-$lacetype-%'";
  735. }
  736. if ($category) {
  737. $where .= " and features like '%-$category-%'";
  738. }
  739. if ($size) {
  740. $where .= " and features like '%-$size-%'";
  741. }
  742. if ($grade) {
  743. $where .= " and features like '%-$grade-%'";
  744. }
  745. if ($color) {
  746. $where .= " and features like '%-$color-%'";
  747. }
  748. if ($lowe) {
  749. $where .= " and features like '%-$lowe-%'";
  750. }
  751. if ($haircap) {
  752. $where .= " and features like '%-$haircap-%'";
  753. }
  754. if ($density) {
  755. $where .= " and features like '%-$density-%'";
  756. }
  757. if ($lacecolor) {
  758. $where .= " and features like '%-$lacecolor-%'";
  759. }
  760. if ($usa) {
  761. if (!$warehouse) {
  762. $where .= " and (warehouse = '5' or warehouse = '8')";
  763. }
  764. }
  765. if ($warehouse) {
  766. $where .= " and warehouse = '$warehouse'";
  767. }
  768. if ($details) {
  769. $where .= " and details = '$details'";
  770. }
  771. if ($purchase) {
  772. $where .= " and purchase = '$purchase'";
  773. }
  774. if ($state) {
  775. $where .= " and state = '$state'";
  776. }
  777. $where_add = '';
  778. if ($cklx) {
  779. $shop = $this->shop->read($cklx);
  780. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  781. }
  782. if ($ktime && $jtime) {
  783. $gj = " and enter > '$ktime' and enter < '$jtime'";
  784. $ck = " and outk > '$ktime' and outk < '$jtime'";
  785. }
  786. //数据排序
  787. $order_str = "id desc";
  788. if (empty($page)) {
  789. $start = 0;
  790. $perpage = 1;
  791. } else {
  792. $start = ($page - 1) * $perpage;
  793. }
  794. if ($sku) {
  795. $sku = trim($sku, ' ');
  796. $sku = trim($sku, ' ');
  797. $where .= " and sku like '%$sku%'";
  798. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  799. } else if ($title) {
  800. $title = trim($title, ' ');
  801. $title = trim($title, ' ');
  802. $where .= " and title like '%$title%'";
  803. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  804. } else {
  805. //$where .= " and time > '$ktime' and time < '$jtime'";
  806. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  807. }
  808. //取得信息列表
  809. $rows = array();
  810. $list = array();
  811. foreach ($info_list as $key => $value) {
  812. $warehouse = $this->warehouse->read($value['warehouse']);
  813. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  814. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  815. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  816. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  817. $ftime = time() - 15 * 24 * 3600;
  818. $info_list[$key]['warehouse'] = $warehouse['title'];
  819. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  820. //$z = count($z);//查看订单号
  821. //$info_list[$key]['zd'] = $z;
  822. $details = array();
  823. $cpid = array();
  824. foreach ($c as $k => $v) {
  825. $details[$v['details']] = $v['details'];
  826. if ($v['cpid'] != 0) {
  827. $cpid[$v['cpid']] = $v['cpid'];
  828. }
  829. }
  830. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  831. if ($value['shop'] != '') {
  832. $shop = explode(',', trim($value['shop'], ','));
  833. $shop = $this->shop->read($shop[0]);
  834. $info_list[$key]['shop'] = $shop['shopname'];
  835. }
  836. }
  837. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  838. $pagenum = ceil($total / $perpage);
  839. $over = $total - ($start + $perpage);
  840. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  841. echo json_encode($rows);
  842. exit;
  843. }
  844. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  845. $this->_Template('whlabel_typedy_ck', $this->data);
  846. }
  847. public function _typeck($arg_array)
  848. {
  849. $prc = array();
  850. $purchase = $this->purchase->find_all();
  851. foreach ($purchase as $k => $v) {
  852. $prc[$v['id']] = $v['title'];
  853. }
  854. $post = $this->input->post(NULL, TRUE);
  855. if (isset($post['page'])) {
  856. $page = $this->input->post('page', true);
  857. $perpage = $this->input->post('perpage', true);
  858. $category = $this->input->post('category', true);
  859. $size = $this->input->post('size', true);
  860. $grade = $this->input->post('grade', true);
  861. $color = $this->input->post('color', true);
  862. $lacecolor = $this->input->post('lacecolor', true);
  863. $lowe = $this->input->post('lowe', true);
  864. $sku = $this->input->post('sku');
  865. $title = $this->input->post('title');
  866. $warehouse = 13;
  867. $usa = $this->input->post('usa', true);
  868. $purchase = $this->input->post('purchase', true);
  869. $lacetype = $this->input->post('lacetype', true);
  870. $haircap = $this->input->post('haircap', true);
  871. $density = $this->input->post('density', true);
  872. $details = $this->input->post('details', true);
  873. $state = $this->input->post('state', true);
  874. $ktime = $this->input->post('ktime', true);
  875. $jtime = $this->input->post('jtime', true);
  876. $ktime = strtotime($ktime);
  877. $jtime = strtotime($jtime);
  878. $where = "1=1";
  879. $gj = "";
  880. $ck = "";
  881. if ($lacetype) {
  882. $where .= " and features like '%-$lacetype-%'";
  883. }
  884. if ($category) {
  885. $where .= " and features like '%-$category-%'";
  886. }
  887. if ($size) {
  888. $where .= " and features like '%-$size-%'";
  889. }
  890. if ($grade) {
  891. $where .= " and features like '%-$grade-%'";
  892. }
  893. if ($color) {
  894. $where .= " and features like '%-$color-%'";
  895. }
  896. if ($lacecolor) {
  897. $where .= " and features like '%-$lacecolor-%'";
  898. }
  899. if ($lowe) {
  900. $where .= " and features like '%-$lowe-%'";
  901. }
  902. if ($haircap) {
  903. $where .= " and features like '%-$haircap-%'";
  904. }
  905. if ($density) {
  906. $where .= " and features like '%-$density-%'";
  907. }
  908. if ($warehouse) {
  909. $where .= " and warehouse = '$warehouse'";
  910. }
  911. if ($details) {
  912. $where .= " and details = '$details'";
  913. }
  914. if ($purchase) {
  915. $where .= " and purchase = '$purchase'";
  916. }
  917. if ($state) {
  918. $where .= " and state = '$state'";
  919. }
  920. if ($ktime && $jtime) {
  921. $gj = " and enter > '$ktime' and enter < '$jtime'";
  922. $ck = " and outk > '$ktime' and outk < '$jtime'";
  923. }
  924. //数据排序
  925. $order_str = "id desc";
  926. if (empty($page)) {
  927. $start = 0;
  928. $perpage = 1;
  929. } else {
  930. $start = ($page - 1) * $perpage;
  931. }
  932. if ($sku) {
  933. $sku = trim($sku, ' ');
  934. $sku = trim($sku, ' ');
  935. $where .= " and sku like '%$sku%'";
  936. } else if ($title) {
  937. $title = trim($title, ' ');
  938. $title = trim($title, ' ');
  939. $where .= " and title like '%$title%'";
  940. }
  941. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  942. //取得信息列表
  943. $t = array();
  944. $typeclass = $this->typeclass->find_all();
  945. foreach ($typeclass as $v) {
  946. $t[$v['id']] = $v;
  947. }
  948. $rows = array();
  949. $list = array();
  950. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  951. foreach ($info_list as $key => $value) {
  952. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  953. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  954. $warehouse = $this->warehouse->read($value['warehouse']);
  955. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  956. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  957. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  958. $number = $value['number'];
  959. $ftime = time() - 15 * 24 * 3600;
  960. $z = count($z); //查看订单号
  961. $info_list[$key]['warehouse'] = $warehouse['title'];
  962. $info_list[$key]['features'] = count($c);
  963. $info_list[$key]['number'] = $z;
  964. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  965. $details = array();
  966. $cpid = array();
  967. foreach ($c as $k => $v) {
  968. $details[$v['details']] = $v['details'];
  969. if ($v['cpid'] != 0) {
  970. $cpid[$v['cpid']] = $v['cpid'];
  971. }
  972. }
  973. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  974. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  975. unset($info_list[$key]['pm']);
  976. unset($info_list[$key]['jm']);
  977. unset($info_list[$key]['bm']);
  978. }
  979. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  980. $pagenum = ceil($total / $perpage);
  981. $over = $total - ($start + $perpage);
  982. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  983. echo json_encode($rows);
  984. exit;
  985. }
  986. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  987. $this->_Template('whlabel_typeck', $this->data);
  988. }
  989. //进销存导出
  990. public function _whlabeckdc()
  991. {
  992. $prc = array();
  993. $purchase = $this->purchase->find_all();
  994. foreach ($purchase as $k => $v) {
  995. $prc[$v['id']] = $v['title'];
  996. }
  997. if (isset($_GET['excel'])) {
  998. $where = "sku != 'Preset'";
  999. //数据排序
  1000. $order_str = "id desc";
  1001. if (empty($page)) {
  1002. $start = 0;
  1003. $perpage = 1;
  1004. } else {
  1005. $start = ($page - 1) * $perpage;
  1006. }
  1007. $category = $this->input->get('category', true);
  1008. $color = $this->input->get('color', true);
  1009. $lowe = $this->input->get('lowe', true);
  1010. $lacetype = $this->input->get('lacetype', true);
  1011. $size = $this->input->get('size', true);
  1012. $density = $this->input->get('density', true);
  1013. $haircap = $this->input->get('haircap', true);
  1014. $sku = $this->input->get('sku', true);
  1015. $details = $this->input->get('details', true);
  1016. $warehouse = 13;
  1017. $excelid = $this->input->get('sid', true);
  1018. if ($category) {
  1019. $where .= " and features like '%-$category-%'";
  1020. }
  1021. if ($color) {
  1022. $where .= " and features like '%-$color-%'";
  1023. }
  1024. if ($lowe) {
  1025. $where .= " and features like '%-$lowe-%'";
  1026. }
  1027. if ($lacetype) {
  1028. $where .= " and features like '%-$lacetype-%'";
  1029. }
  1030. if ($size) {
  1031. $where .= " and features like '%-$size-%'";
  1032. }
  1033. if ($density) {
  1034. $where .= " and features like '%-$density-%'";
  1035. }
  1036. if ($haircap) {
  1037. $where .= " and features like '%-$haircap-%'";
  1038. }
  1039. if ($warehouse) {
  1040. $where .= " and warehouse = '$warehouse'";
  1041. }
  1042. if ($sku) {
  1043. $where .= " and sku like '%$sku%'";
  1044. }
  1045. if ($details) {
  1046. $where .= " and details = '$details'";
  1047. }
  1048. $xzid = '';
  1049. if ($excelid) {
  1050. $excelid = explode(',', trim($excelid, ','));
  1051. foreach ($excelid as $key => $value) {
  1052. $xzid .= " id = " . $value . " or";
  1053. }
  1054. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1055. }
  1056. //取得信息列表
  1057. /**
  1058. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1059. $rows = array();$list = array();
  1060. foreach ($info_list as $key=>$value)
  1061. {
  1062. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1063. }
  1064. **/
  1065. $wh = array();
  1066. $w = $this->warehouse->find_all('1=1', 'id,title');
  1067. foreach ($w as $v) {
  1068. $wh[$v['id']] = $v['title'];
  1069. }
  1070. $tc = array();
  1071. $tcdata = array();
  1072. $list = array();
  1073. $classid = $this->classid->sku();
  1074. $tcall = $this->typeclass->find_all();
  1075. $typeclass = array();
  1076. foreach ($tcall as $v)
  1077. {
  1078. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1079. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1080. }
  1081. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1082. foreach ($rows as $key => $value) {
  1083. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1084. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1085. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1086. $rows[$key]['cpbz'] = $u9_info['bm'];
  1087. $rows[$key]['cs'] = $u9_info['jm'];
  1088. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1089. $details = array();
  1090. $cpid = array();
  1091. $cpbz = array();
  1092. $c = 0;
  1093. $g = 0;
  1094. $x = 0;
  1095. $t = 0;
  1096. $s = 0;
  1097. $q = 0;
  1098. foreach ($sd as $k => $v) {
  1099. if ($v['state'] == 0) {
  1100. $c++;
  1101. }
  1102. if ($v['state'] != 9) {
  1103. $g++;
  1104. }
  1105. if ($v['state'] == 1) {
  1106. $x++;
  1107. }
  1108. if ($v['state'] == 2) {
  1109. $t++;
  1110. }
  1111. if ($v['state'] == 8) {
  1112. $s++;
  1113. }
  1114. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1115. $q++;
  1116. }
  1117. $details[$v['details']] = $v['details'];
  1118. if ($v['cpid'] != 0) {
  1119. $cpid[$v['cpid']] = $v['cpid'];
  1120. }
  1121. if ($v['cpbz'] != '') {
  1122. $cpbz[$v['cpbz']] = $v['cpbz'];
  1123. }
  1124. }
  1125. $rows[$key]['details'] = implode("、", $details);
  1126. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1127. $number = $value['number'];
  1128. $ftime = time() - 15 * 24 * 3600;
  1129. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1130. $rows[$key]['number'] = $g;
  1131. $rows[$key]['features'] = $c;
  1132. $rows[$key]['x'] = $x;
  1133. $rows[$key]['t'] = $t;
  1134. $rows[$key]['s'] = $s;
  1135. $rows[$key]['q'] = $q;
  1136. $rows[$key]['wzsl'] = count($details);
  1137. }
  1138. $title = "进销存统计表" . date('Y-m-d', time());
  1139. $titlename = "<table border=1>
  1140. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1141. <tr align='center'>
  1142. <td>仓库</td>
  1143. <td>供应商</td>
  1144. <td>位置</td>
  1145. <td>库存编码</td>
  1146. <td>SKU</td>
  1147. <td>用友编码</td>
  1148. <td>用友料号</td>
  1149. <td>产品英文名</td>
  1150. <td>产品中文名</td>
  1151. <td>入库总量</td>
  1152. <td>库存数量</td>
  1153. <td>销售数量</td>
  1154. <td>退货数量</td>
  1155. <td>删除数量</td>
  1156. <td>其它操作</td>
  1157. <td>位置数量</td>
  1158. </tr>
  1159. </table>";
  1160. $filename = $title . ".xls";
  1161. $tail = "";
  1162. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1163. }
  1164. }
  1165. public function _type()
  1166. {
  1167. $vip = 0;
  1168. if (isset($_SESSION['api'])) {
  1169. $user = $this->user->get_api($_SESSION['api']);
  1170. $fgshop = "";
  1171. $sid = "";
  1172. $usersp = explode('|', trim($user['shop'], '|'));
  1173. foreach ($usersp as $value) {
  1174. $fgshop .= " shop = " . $value . " or";
  1175. $sid .= " id = " . $value . " or";
  1176. }
  1177. if ($user['vip'] == 1) {
  1178. $vip = 1;
  1179. }
  1180. } else {
  1181. header('Location: /');
  1182. exit;
  1183. }
  1184. $prc = array();
  1185. $purchase = $this->purchase->find_all();
  1186. foreach ($purchase as $k => $v) {
  1187. $prc[$v['id']] = $v['title'];
  1188. }
  1189. $company = array();
  1190. $ct = $this->company->find_all();
  1191. foreach ($ct as $k => $v) {
  1192. $company[$v['id']] = $v['title'];
  1193. }
  1194. $sp = array();
  1195. $s = $this->shop->find_all('1=1', 'id,shopname');
  1196. foreach ($s as $v) {
  1197. $sp[$v['id']] = $v['shopname'];
  1198. }
  1199. $wh = array();
  1200. $w = $this->warehouse->find_all('1=1', 'id,title');
  1201. foreach ($w as $v) {
  1202. $wh[$v['id']] = $v['title'];
  1203. }
  1204. $post = $this->input->post(NULL, TRUE);
  1205. if (isset($post['page'])) {
  1206. $page = $this->input->post('page', true);
  1207. $perpage = $this->input->post('perpage', true);
  1208. $category = $this->input->post('category', true);
  1209. $size = $this->input->post('size', true);
  1210. $grade = $this->input->post('grade', true);
  1211. $color = $this->input->post('color', true);
  1212. $lowe = $this->input->post('lowe', true);
  1213. $sku = $this->input->post('sku');
  1214. $title = $this->input->post('title');
  1215. $warehouse = $this->input->post('warehouse', true);
  1216. $usa = $this->input->post('usa', true);
  1217. $purchase = $this->input->post('purchase', true);
  1218. $lacetype = $this->input->post('lacetype', true);
  1219. $haircap = $this->input->post('haircap', true);
  1220. $density = $this->input->post('density', true);
  1221. $details = $this->input->post('details', true);
  1222. $state = $this->input->post('state', true);
  1223. $shop = $this->input->post('shop', true);
  1224. $lacecolor = $this->input->post('lacecolor', true);
  1225. $hairnumber = $this->input->post('hairnumber', true);
  1226. $type = $this->input->post('type', true);
  1227. $ktime = $this->input->post('ktime', true);
  1228. $jtime = $this->input->post('jtime', true);
  1229. $ktime = strtotime($ktime);
  1230. $jtime = strtotime($jtime);
  1231. $cpbz = $this->input->post('cpbz', true);
  1232. $sm = $this->input->post('sm', true);
  1233. $where = "1=1";
  1234. $gj = "";
  1235. $ck = "";
  1236. if ($usa) {
  1237. if (!$warehouse) {
  1238. $where .= " and (warehouse = '5' or warehouse = '8')";
  1239. }
  1240. }
  1241. if ($warehouse) {
  1242. $where .= " and warehouse = '$warehouse'";
  1243. }
  1244. if ($details) {
  1245. $where .= " and details = '$details'";
  1246. }
  1247. if ($purchase) {
  1248. $where .= " and purchase = '$purchase'";
  1249. }
  1250. if ($state) {
  1251. $where .= " and state = '$state'";
  1252. }
  1253. if ($shop) {
  1254. $where .= " and shop like '%$shop%'";
  1255. }
  1256. if ($type) {
  1257. $where .= " and type = '$type'";
  1258. }
  1259. if ($ktime && $jtime) {
  1260. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1261. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1262. }
  1263. if ($cpbz) {
  1264. $where .= " and cpbz like '%$cpbz%' ";
  1265. }
  1266. if ($sm) {
  1267. $where .= " and sm like '%$sm%' ";
  1268. }
  1269. if ($lacecolor) {
  1270. $where .= " and features like '%-$lacecolor-%'";
  1271. }
  1272. if ($lacetype) {
  1273. $where .= " and features like '%-$lacetype-%'";
  1274. }
  1275. if ($category) {
  1276. $where .= " and features like '%-$category-%'";
  1277. }
  1278. if ($size) {
  1279. $where .= " and features like '%-$size-%'";
  1280. }
  1281. if ($grade) {
  1282. $where .= " and features like '%-$grade-%'";
  1283. }
  1284. if ($color) {
  1285. $where .= " and features like '%-$color-%'";
  1286. }
  1287. if ($lowe) {
  1288. $where .= " and features like '%-$lowe-%'";
  1289. }
  1290. if ($haircap) {
  1291. $where .= " and features like '%-$haircap-%'";
  1292. }
  1293. if ($density) {
  1294. $where .= " and features like '%-$density-%'";
  1295. }
  1296. if (!empty($hairnumber)) {
  1297. $where .= " and features like '%-128-%' ";
  1298. if ($hairnumber < 0) {
  1299. $class_list = $this->typeclass->find_all('classid = 43');
  1300. foreach ($class_list as $v) {
  1301. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1302. }
  1303. } else {
  1304. $where .= " and features like '%-$hairnumber-%'";
  1305. }
  1306. }
  1307. //数据排序
  1308. $order_str = "id desc";
  1309. if (empty($page)) {
  1310. $start = 0;
  1311. $perpage = 1;
  1312. } else {
  1313. $start = ($page - 1) * $perpage;
  1314. }
  1315. $fjnr = '';
  1316. if ($sku) {
  1317. $sku = trim($sku, ' ');
  1318. $sku = trim($sku, ' ');
  1319. $fjnr .= " and sku like '%$sku%'";
  1320. }
  1321. if ($title) {
  1322. $title = trim($title, ' ');
  1323. $title = trim($title, ' ');
  1324. $fjnr .= " and title like '%$title%'";
  1325. }
  1326. $wt = array();
  1327. $whlabel_type = $this->whlabel_type->find_all();
  1328. foreach ($whlabel_type as $v) {
  1329. $wt[$v['id']] = $v['title'];
  1330. }
  1331. //$where .= " and time > '$ktime' and time < '$jtime'";
  1332. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1333. //取得信息列表
  1334. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1335. $rows = array();
  1336. $list = array();
  1337. foreach ($info_list as $key => $value) {
  1338. if (isset($wt[$value['type']])) {
  1339. $info_list[$key]['type'] = $wt[$value['type']];
  1340. } else {
  1341. $info_list[$key]['type'] = '未设置';
  1342. }
  1343. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1344. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1345. $ztdata = '';
  1346. if (count($zt) > 0) {
  1347. foreach ($zt as $vv) {
  1348. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1349. }
  1350. }
  1351. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1352. $cdata = array_filter($qbdata, function ($item) {
  1353. return $item['state'] < 1;
  1354. });
  1355. $c = array_sum(array_column($cdata, 'jnum'));
  1356. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1357. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1358. });
  1359. $g = array_sum(array_column($gdata, 'jnum'));
  1360. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1361. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1362. });
  1363. $x = array_sum(array_column($xdata, 'jnum'));
  1364. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1365. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1366. });
  1367. $t = array_sum(array_column($tdata, 'jnum'));
  1368. // $zdata = array_filter($qbdata, function ($item) {
  1369. // return $item['zd'] != "" && $item['state'] < 1;
  1370. // });
  1371. // $z = array_sum(array_column($zdata, 'jnum'));
  1372. $zdata = array_filter($qbdata, function ($item) {
  1373. return $item['zd'] != "" && $item['state'] < 1;
  1374. });
  1375. $z = array_sum(array_column($zdata, 'jnum'));
  1376. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1377. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1378. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1379. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1380. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1381. $details = array();
  1382. $cpid = array();
  1383. $od = array();
  1384. $odid = '';
  1385. $companytitle = '';
  1386. $shop_list = [];
  1387. foreach ($qbdata as $v) {
  1388. if ($v['zd'] != "" && $v['state'] < 1) {
  1389. if (!isset($od[$v['zd']])) {
  1390. $od[$v['zd']] = 1; //所有数据sku
  1391. } else {
  1392. $od[$v['zd']] = $od[$v['zd']] + 1;
  1393. }
  1394. }
  1395. if ($v['state'] < 1) {
  1396. $details[$v['details']] = $v['details'];
  1397. if ($v['cpid'] != 0) {
  1398. $cpid[$v['cpid']] = $v['cpid'];
  1399. }
  1400. }
  1401. if($v['state'] == 0){
  1402. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1403. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1404. }
  1405. if ($v['shop'] != '') {
  1406. $shop = explode(',', trim($v['shop'], ','));
  1407. foreach ($shop as $vv) {
  1408. if (!in_array($vv, $shop_list)) {
  1409. $shop_list[] = $vv;
  1410. }
  1411. }
  1412. }
  1413. }
  1414. }
  1415. foreach ($od as $k => $vv) {
  1416. $odid .= $k . '数量' . $vv;
  1417. }
  1418. $info_list[$key]['cpbz'] = empty($value['cpbz'])?$value['sm']: $value['cpbz']." ".$value['sm'];
  1419. $info_list[$key]['label'] = "";
  1420. // $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1421. // $info_list[$key]['label'] = $value['sm'];
  1422. $number = $value['number'];
  1423. $ftime = time() - 15 * 24 * 3600;
  1424. $z = $z . '(' . $odid . ')'; //查看订单号
  1425. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1426. $info_list[$key]['features'] = $c;
  1427. $info_list[$key]['number'] = $ztdata;
  1428. $info_list[$key]['sm'] = $g;
  1429. $info_list[$key]['x'] = $x;
  1430. $info_list[$key]['t'] = $t;
  1431. $info_list[$key]['z'] = $z;
  1432. /**
  1433. foreach ($cdata as $k=>$v)
  1434. {
  1435. $details[$v['details']] = $v['details'];
  1436. if($v['cpid'] != 0)
  1437. {
  1438. $cpid[$v['cpid']] = $v['cpid'];
  1439. }
  1440. }
  1441. **/
  1442. $info_list[$key]['shop'] = '';
  1443. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1444. // if ($value['shop'] != '') {
  1445. // $shop = explode(',', trim($value['shop'], ','));
  1446. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1447. // }
  1448. $shop_list = array_unique($shop_list);
  1449. $shop_str = '';
  1450. foreach ($shop_list as $v) {
  1451. if(isset($sp[$v])){
  1452. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1453. }
  1454. }
  1455. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1456. /**
  1457. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1458. if(isset($companytitle[0]))
  1459. {
  1460. foreach ($companytitle as $k=>$v)
  1461. {
  1462. if($v['companytitle'] != '')
  1463. {
  1464. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1465. }
  1466. }
  1467. }
  1468. **/
  1469. }
  1470. $final_all_list = [];
  1471. foreach ($info_list as $k => $v) {
  1472. $final_all_list[] = [
  1473. 'id' => $v['id'],
  1474. "warehouse" => $v["warehouse"],
  1475. "purchase" => $v["purchase"],
  1476. "sku" => $v["sku"],
  1477. "title" => $v["title"] . "<br/>" . $v["pm"],
  1478. "details" => $v["details"],
  1479. "shop" => $v["shop"],
  1480. "cpbz" => $v["cpbz"],
  1481. 'label' => $v['label'],
  1482. "type" => $v["type"],
  1483. "features" => $v["features"],
  1484. "number" => $v["number"],
  1485. "sm" => $v["sm"],
  1486. "x" => $v["x"],
  1487. "t" => $v["t"],
  1488. "z" => $v["z"]
  1489. ];
  1490. }
  1491. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1492. $pagenum = ceil($total / $perpage);
  1493. $over = $total - ($start + $perpage);
  1494. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1495. echo json_encode($rows);
  1496. exit;
  1497. }
  1498. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1499. $this->data['shop'] = $wlshop;
  1500. $this->data['vip'] = $vip;
  1501. $this->_Template('whlabel_type', $this->data);
  1502. }
  1503. //美仓进销存浏览
  1504. public function _usatype()
  1505. {
  1506. if (isset($_SESSION['api'])) {
  1507. $user = $this->user->get_api($_SESSION['api']);
  1508. $usp = $user;
  1509. $fgshop = "";
  1510. $sid = "";
  1511. $wid = "";
  1512. $wtype = "";
  1513. $userwh = explode('|', trim($user['warehouse'], '|'));
  1514. foreach ($userwh as $value) {
  1515. $wid .= " id = " . $value . " or";
  1516. $wtype .= " type = " . $value . " or";
  1517. }
  1518. }
  1519. $prc = array();
  1520. $purchase = $this->purchase->find_all();
  1521. foreach ($purchase as $k => $v) {
  1522. $prc[$v['id']] = $v['title'];
  1523. }
  1524. $post = $this->input->post(NULL, TRUE);
  1525. if (isset($post['page'])) {
  1526. $page = $this->input->post('page', true);
  1527. $perpage = $this->input->post('perpage', true);
  1528. $category = $this->input->post('category', true);
  1529. $size = $this->input->post('size', true);
  1530. $grade = $this->input->post('grade', true);
  1531. $color = $this->input->post('color', true);
  1532. $lowe = $this->input->post('lowe', true);
  1533. $sku = $this->input->post('sku');
  1534. $title = $this->input->post('title');
  1535. $warehouse = $this->input->post('warehouse', true);
  1536. $usa = $this->input->post('usa', true);
  1537. $purchase = $this->input->post('purchase', true);
  1538. $lacetype = $this->input->post('lacetype', true);
  1539. $haircap = $this->input->post('haircap', true);
  1540. $density = $this->input->post('density', true);
  1541. $details = $this->input->post('details', true);
  1542. $state = $this->input->post('state', true);
  1543. $lacecolor = $this->input->post('lacecolor', true);
  1544. $cklx = $this->input->post('cklx', true);
  1545. $ktime = $this->input->post('ktime', true);
  1546. $jtime = $this->input->post('jtime', true);
  1547. $ktime = strtotime($ktime);
  1548. $jtime = strtotime($jtime);
  1549. $where = "1=1";
  1550. $gj = "";
  1551. $ck = "";
  1552. if ($lacetype) {
  1553. $where .= " and features like '%-$lacetype-%'";
  1554. }
  1555. if ($category) {
  1556. $where .= " and features like '%-$category-%'";
  1557. }
  1558. if ($size) {
  1559. $where .= " and features like '%-$size-%'";
  1560. }
  1561. if ($grade) {
  1562. $where .= " and features like '%-$grade-%'";
  1563. }
  1564. if ($color) {
  1565. $where .= " and features like '%-$color-%'";
  1566. }
  1567. if ($lowe) {
  1568. $where .= " and features like '%-$lowe-%'";
  1569. }
  1570. if ($haircap) {
  1571. $where .= " and features like '%-$haircap-%'";
  1572. }
  1573. if ($density) {
  1574. $where .= " and features like '%-$density-%'";
  1575. }
  1576. if ($lacecolor) {
  1577. $where .= " and features like '%-$lacecolor-%'";
  1578. }
  1579. if ($usa) {
  1580. if (!$warehouse) {
  1581. $where .= " and (warehouse = '5' or warehouse = '8')";
  1582. }
  1583. }
  1584. if ($warehouse) {
  1585. $where .= " and warehouse = '$warehouse'";
  1586. }
  1587. if ($details) {
  1588. $where .= " and details = '$details'";
  1589. }
  1590. if ($purchase) {
  1591. $where .= " and purchase = '$purchase'";
  1592. }
  1593. if ($state) {
  1594. $where .= " and state = '$state'";
  1595. }
  1596. $where_add = '';
  1597. if ($cklx) {
  1598. $shop = $this->shop->read($cklx);
  1599. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1600. }
  1601. if ($ktime && $jtime) {
  1602. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1603. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1604. }
  1605. //数据排序
  1606. $order_str = "id desc";
  1607. if (empty($page)) {
  1608. $start = 0;
  1609. $perpage = 1;
  1610. } else {
  1611. $start = ($page - 1) * $perpage;
  1612. }
  1613. if ($sku) {
  1614. $sku = trim($sku, ' ');
  1615. $sku = trim($sku, ' ');
  1616. $where .= " and sku like '%$sku%'";
  1617. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1618. } else if ($title) {
  1619. $title = trim($title, ' ');
  1620. $title = trim($title, ' ');
  1621. $where .= " and title like '%$title%'";
  1622. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1623. } else {
  1624. //$where .= " and time > '$ktime' and time < '$jtime'";
  1625. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1626. }
  1627. //取得信息列表
  1628. $rows = array();
  1629. $list = array();
  1630. foreach ($info_list as $key => $value) {
  1631. $warehouse = $this->warehouse->read($value['warehouse']);
  1632. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1633. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1635. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1636. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1637. $od = array();
  1638. $odid = '';
  1639. foreach ($z as $v) {
  1640. if (!isset($od[$v['zd']])) {
  1641. $od[$v['zd']] = 1; //所有数据sku
  1642. } else {
  1643. $od[$v['zd']] = $od[$v['zd']] + 1;
  1644. }
  1645. }
  1646. foreach ($od as $k => $vv) {
  1647. $odid .= $k . '数量' . $vv . ' ';
  1648. }
  1649. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1650. $info_list[$key]['features'] = $c;
  1651. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1652. $ztdata = '';
  1653. if (count($zt) > 0) {
  1654. foreach ($zt as $vv) {
  1655. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1656. }
  1657. }
  1658. $info_list[$key]['warehouse'] = $ztdata;
  1659. $info_list[$key]['g'] = $g;
  1660. $info_list[$key]['x'] = $x;
  1661. $info_list[$key]['t'] = $t;
  1662. $info_list[$key]['z'] = $z;
  1663. }
  1664. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1665. $pagenum = ceil($total / $perpage);
  1666. $over = $total - ($start + $perpage);
  1667. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1668. echo json_encode($rows);
  1669. exit;
  1670. }
  1671. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1672. $this->data['warehouse'] = $warehouse;
  1673. $this->_Template('whlabel_typeusa', $this->data);
  1674. }
  1675. //美仓进销存浏览
  1676. public function _usatypeapp()
  1677. {
  1678. $post = $this->input->post(NULL, TRUE);
  1679. if (isset($post['page'])) {
  1680. $page = $this->input->post('page', true);
  1681. $perpage = $this->input->post('perpage', true);
  1682. $sku = $this->input->post('sku', true);
  1683. $warehouse = 5;
  1684. $title = $this->input->post('title', true);
  1685. $state = $this->input->post('state', true);
  1686. $ktime = $this->input->post('ktime', true);
  1687. $jtime = $this->input->post('jtime', true);
  1688. $ktime = strtotime($ktime);
  1689. $jtime = strtotime($jtime);
  1690. $where = "1=1";
  1691. $gj = "";
  1692. $ck = "";
  1693. if ($title) {
  1694. $st = explode(' ', trim($title, ' '));
  1695. foreach ($st as $v) {
  1696. $where .= " and title like '%$v%'";
  1697. }
  1698. }
  1699. if ($warehouse) {
  1700. $where .= " and warehouse = '$warehouse'";
  1701. }
  1702. if ($state) {
  1703. $where .= " and state = '$state'";
  1704. }
  1705. if ($sku) {
  1706. $where .= " and sku like '%$sku%'";
  1707. }
  1708. if ($ktime && $jtime) {
  1709. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1710. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1711. }
  1712. //数据排序
  1713. $order_str = "id desc";
  1714. if (empty($page)) {
  1715. $start = 0;
  1716. $perpage = 1;
  1717. } else {
  1718. $start = ($page - 1) * $perpage;
  1719. }
  1720. //取得信息列表
  1721. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1722. $rows = array();
  1723. $list = array();
  1724. foreach ($info_list as $key => $value) {
  1725. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1726. }
  1727. $rowsdq = array_slice($rows, $start, $perpage);
  1728. foreach ($rowsdq as $value) {
  1729. $warehouse = $this->warehouse->read($value['warehouse']);
  1730. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1731. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1732. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1733. $od = array();
  1734. $odid = '';
  1735. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1736. }
  1737. $total = count($rows);
  1738. $pagenum = ceil($total / $perpage);
  1739. $over = $total - ($start + $perpage);
  1740. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1741. echo json_encode($rows);
  1742. exit;
  1743. }
  1744. $this->_Template('phone/p_usatypeapp', $this->data);
  1745. }
  1746. //入库操作
  1747. public function _enteradd()
  1748. {
  1749. $dt = 0;
  1750. if (isset($_SESSION['api'])) {
  1751. $user = $this->user->get_api($_SESSION['api']);
  1752. $usp = $user;
  1753. $fgshop = "";
  1754. $sid = "";
  1755. $user = explode('|', trim($user['shop'], '|'));
  1756. foreach ($user as $value) {
  1757. $fgshop .= " shop = " . $value . " or";
  1758. $sid .= " id = " . $value . " or";
  1759. }
  1760. }
  1761. $tc = $this->typeclass->find_all();
  1762. $typeclass = array();
  1763. foreach ($tc as $v) {
  1764. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1765. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1766. }
  1767. $post = $this->input->post(NULL, TRUE);
  1768. if (isset($post['sku'])) {
  1769. $list = array();
  1770. $num = "";
  1771. $title = "";
  1772. $features = "";
  1773. $order = $this->input->post('order', true);
  1774. $shop = $this->input->post('shop', true);
  1775. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1776. $sku = $this->input->post('sku', true);
  1777. $post['sm'] = $this->input->post('sm', true);
  1778. $post['warehouse'] = $this->input->post('warehouse', true);
  1779. $post['purchase'] = $this->input->post('purchase', true);
  1780. $post['retreatwarehouse'] = $post['warehouse'];
  1781. $post['state'] = $this->input->post('state', true);
  1782. $post['rktype'] = $this->input->post('rktype', true);
  1783. $post['text'] = $this->input->post('text', true);
  1784. $category = $this->input->post('category', true);
  1785. $list['category'] = $category;
  1786. $list['hairtype'] = $this->input->post('hairtype', true);
  1787. $list['grade'] = $this->input->post('grade', true);
  1788. $size = $this->input->post('size', true);
  1789. $xzsku = $this->input->post('xzsku', true);
  1790. $list['size'] = rtrim($size, ',');
  1791. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1792. $list['extension'] = $this->input->post('extension', true);
  1793. if ($category == 1297) {
  1794. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1795. }
  1796. if ($category == 1702) {
  1797. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1798. $list['syother'] = $this->input->post('syother', true);
  1799. }
  1800. if ($category == 133) {
  1801. $list['fittype'] = $this->input->post('fittype', true);
  1802. $list['acother'] = $this->input->post('acother', true);
  1803. }
  1804. $list['color'] = $this->input->post('color', true);
  1805. $list['lowe'] = $this->input->post('lowe', true);
  1806. if (!$post['purchase']) {
  1807. $post['purchase'] = 1;
  1808. }
  1809. if ($category == 127) {
  1810. $list['type'] = $this->input->post('type', true);
  1811. $list['headroad'] = $this->input->post('headroad', true);
  1812. $list['density'] = $this->input->post('density', true);
  1813. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1814. $list['lacesize'] = $this->input->post('lacesize', true);
  1815. }
  1816. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1817. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1818. }
  1819. if ($category == 128) {
  1820. $list['lacetype'] = $this->input->post('lacetype', true);
  1821. $list['haircap'] = $this->input->post('haircap', true);
  1822. $list['density'] = $this->input->post('density', true);
  1823. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1824. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1825. $list['wigother'] = $this->input->post('wigother', true);
  1826. $list['wigother1'] = $this->input->post('wigother1', true);
  1827. $list['wigother2'] = $this->input->post('wigother2', true);
  1828. }
  1829. if ($category == 129) {
  1830. $list['wide'] = $this->input->post('wide', true);
  1831. }
  1832. if ($category == 131) {
  1833. $list['gifttype'] = $this->input->post('gifttype', true);
  1834. $list['giftother'] = $this->input->post('giftother', true);
  1835. }
  1836. if ($category == 134) {
  1837. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1838. }
  1839. if ($category == 1297) {
  1840. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1841. $list['sywigother'] = $this->input->post('sywigother', true);
  1842. }
  1843. if ($category == 130 || $category == 133 || $category == 1702) {
  1844. $list['items'] = $this->input->post('items', true);
  1845. $list['weight'] = $this->input->post('weight', true);
  1846. }
  1847. if ($category == 1702) {
  1848. $list['syhairther'] = $this->input->post('syhairther', true);
  1849. }
  1850. $classid = $this->classid->sku();
  1851. $scsku = $classid;
  1852. $pm = $classid;
  1853. foreach ($list as $k => $v) {
  1854. if ($v != 0) {
  1855. $num .= $v;
  1856. $features .= $v . '-';
  1857. $post[$k] = $v;
  1858. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1859. if ($k != 'size') {
  1860. $title .= $typeclass[$v]['title'] . " ";
  1861. }
  1862. if (isset($pm[$typeclass[$v]['classid']])) {
  1863. if ($typeclass[$v]['title'] == '9A') {
  1864. $pm[$typeclass[$v]['classid']] = '9A';
  1865. } else if ($typeclass[$v]['title'] == '10A') {
  1866. $pm[$typeclass[$v]['classid']] = '10A';
  1867. } else {
  1868. $clzh = $typeclass[$v]['zh'];
  1869. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1870. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1871. $clzh = $clzh[0];
  1872. }
  1873. $pm[$typeclass[$v]['classid']] = $clzh;
  1874. }
  1875. }
  1876. }
  1877. }
  1878. $zh = implode(" ", $pm);
  1879. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1880. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1881. if ($list['size']) {
  1882. $typeclass = $this->typeclass->read($list['size']);
  1883. $title .= $typeclass['title'];
  1884. }
  1885. $time = time();
  1886. if ($xzsku) {
  1887. $scsku = implode("-", $scsku);
  1888. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1889. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1890. $post['sku'] = trim($scsku, ' ');
  1891. } else {
  1892. $post['sku'] = $sku;
  1893. }
  1894. //$post['sku'] = trim($sku,' ');
  1895. $post['title'] = rtrim($title, ' ');
  1896. $post['number'] = $num;
  1897. $post['features'] = '-' . $features;
  1898. $post['enter'] = $time;
  1899. $post['time'] = $time; //操作时间
  1900. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1901. if ($yza) {
  1902. if ($post['features'] != $yza[0]['features']) {
  1903. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1904. exit;
  1905. }
  1906. }
  1907. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1908. if ($yzb) {
  1909. if ($post['sku'] != $yzb[0]['sku']) {
  1910. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1911. exit;
  1912. }
  1913. }
  1914. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1915. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1916. exit;
  1917. }
  1918. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1919. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1920. exit;
  1921. }
  1922. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1923. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1924. exit;
  1925. }
  1926. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1927. if (isset($yz[0]['type'])) {
  1928. $post['type'] = $yz[0]['type'];
  1929. }
  1930. if ($post['state'] == 9) //如果选择预设库存
  1931. {
  1932. $this->whlabel->insert($post);
  1933. } else {
  1934. /**
  1935. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1936. if($ljg == 1)
  1937. {
  1938. for($i=0;$i<$order;$i++)
  1939. {
  1940. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1941. $this->whlabel->insert($post);
  1942. }
  1943. }
  1944. **/
  1945. //if($post['warehouse'] == '5')
  1946. //{
  1947. //}
  1948. $yydata = $post;
  1949. $yydata['zh'] = $zh;
  1950. /**
  1951. $wl = $this->apiyy->get_cjlp($yydata);
  1952. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1953. {
  1954. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1955. }
  1956. if($wl['Data'][0]['m_isSucess'] != 1)
  1957. {
  1958. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1959. }
  1960. **/
  1961. for ($i = 0; $i < $order; $i++) {
  1962. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1963. $this->whlabel->insert($post);
  1964. }
  1965. }
  1966. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1967. exit;
  1968. }
  1969. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1970. $this->data['wlshop'] = $wlshop;
  1971. $this->_Template('whlabel_enteradd', $this->data);
  1972. }
  1973. //修改产品
  1974. public function _enteredit($arg_array)
  1975. {
  1976. $dt = 0;
  1977. if (isset($_SESSION['api'])) {
  1978. $user = $this->user->get_api($_SESSION['api']);
  1979. $usp = $user;
  1980. $fgshop = "";
  1981. $sid = "";
  1982. $user = explode('|', trim($user['shop'], '|'));
  1983. foreach ($user as $value) {
  1984. $fgshop .= " shop = " . $value . " or";
  1985. $sid .= " id = " . $value . " or";
  1986. }
  1987. }
  1988. $post = $this->input->post(NULL, TRUE);
  1989. if (isset($post['sku'])) {
  1990. $list = array();
  1991. $num = "";
  1992. $title = "";
  1993. $features = "";
  1994. $id = $this->input->post('id', true);
  1995. $order = $this->input->post('order', true);
  1996. $shop = $this->input->post('shop', true);
  1997. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1998. $post['sku'] = $this->input->post('sku', true);
  1999. $post['sm'] = $this->input->post('sm', true);
  2000. $post['warehouse'] = $this->input->post('warehouse', true);
  2001. $post['purchase'] = $this->input->post('purchase', true);
  2002. $post['retreatwarehouse'] = $post['warehouse'];
  2003. $category = $this->input->post('category', true);
  2004. $list['category'] = $category;
  2005. $list['hairtype'] = $this->input->post('hairtype', true);
  2006. $list['grade'] = $this->input->post('grade', true);
  2007. $size = $this->input->post('size', true);
  2008. $list['size'] = rtrim($size, ',');
  2009. $post['rktype'] = $this->input->post('rktype', true);
  2010. $post['text'] = $this->input->post('text', true);
  2011. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2012. $list['extension'] = $this->input->post('extension', true);
  2013. if ($category == 1297) {
  2014. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2015. }
  2016. if ($category == 1702) {
  2017. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2018. $list['syother'] = $this->input->post('syother', true);
  2019. }
  2020. if ($category == 133) {
  2021. $list['fittype'] = $this->input->post('fittype', true);
  2022. $list['acother'] = $this->input->post('acother', true);
  2023. }
  2024. $list['color'] = $this->input->post('color', true);
  2025. $list['lowe'] = $this->input->post('lowe', true);
  2026. if (!$post['purchase']) {
  2027. $post['purchase'] = 1;
  2028. }
  2029. if ($category == 127) {
  2030. $list['type'] = $this->input->post('type', true);
  2031. $list['headroad'] = $this->input->post('headroad', true);
  2032. $list['density'] = $this->input->post('density', true);
  2033. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2034. $list['lacesize'] = $this->input->post('lacesize', true);
  2035. }
  2036. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2037. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2038. }
  2039. if ($category == 128) {
  2040. $list['lacetype'] = $this->input->post('lacetype', true);
  2041. $list['haircap'] = $this->input->post('haircap', true);
  2042. $list['density'] = $this->input->post('density', true);
  2043. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2044. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2045. $list['wigother'] = $this->input->post('wigother', true);
  2046. $list['wigother1'] = $this->input->post('wigother1', true);
  2047. $list['wigother2'] = $this->input->post('wigother2', true);
  2048. }
  2049. if ($category == 129) {
  2050. $list['wide'] = $this->input->post('wide', true);
  2051. }
  2052. if ($category == 131) {
  2053. $list['gifttype'] = $this->input->post('gifttype', true);
  2054. $list['giftother'] = $this->input->post('giftother', true);
  2055. }
  2056. if ($category == 134) {
  2057. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2058. }
  2059. if ($category == 1297) {
  2060. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2061. $list['sywigother'] = $this->input->post('sywigother', true);
  2062. }
  2063. if ($category == 130 || $category == 133 || $category == 1702) {
  2064. $list['items'] = $this->input->post('items', true);
  2065. $list['weight'] = $this->input->post('weight', true);
  2066. }
  2067. if ($category == 1702) {
  2068. $list['syhairther'] = $this->input->post('syhairther', true);
  2069. }
  2070. foreach ($list as $k => $v) {
  2071. if ($v != 0) {
  2072. $num .= $v;
  2073. $features .= $v . '-';
  2074. $typeclass = $this->typeclass->read($v);
  2075. if ($k != 'size') {
  2076. $title .= $typeclass['title'] . " ";
  2077. }
  2078. }
  2079. }
  2080. $typeclass = $this->typeclass->read($list['size']);
  2081. $title .= $typeclass['title'];
  2082. $time = time();
  2083. $post['title'] = rtrim($title, ' ');
  2084. $post['number'] = $num;
  2085. $post['features'] = '-' . $features;
  2086. $post['time'] = $time; //操作时间
  2087. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2088. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2089. exit;
  2090. }
  2091. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2092. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2093. exit;
  2094. }
  2095. $uid = $this->whlabel->read($id);
  2096. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2097. if ($datanum > 0) {
  2098. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2099. exit;
  2100. }
  2101. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2102. {
  2103. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2104. if ($yza) {
  2105. if ($post['features'] != $yza[0]['features']) {
  2106. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2107. exit;
  2108. }
  2109. }
  2110. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2111. if ($yzb) {
  2112. if ($post['sku'] != $yzb[0]['sku']) {
  2113. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2114. exit;
  2115. }
  2116. }
  2117. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2118. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2119. exit;
  2120. }
  2121. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2122. foreach ($data as $v) {
  2123. $post['id'] = $v['id'];
  2124. $this->whlabel->save($post, $v['id']);
  2125. }
  2126. } else {
  2127. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2128. if ($data > 0) {
  2129. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2130. exit;
  2131. } else {
  2132. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2133. foreach ($data as $v) {
  2134. $post['id'] = $v['id'];
  2135. $this->whlabel->save($post, $v['id']);
  2136. }
  2137. }
  2138. }
  2139. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2140. exit;
  2141. }
  2142. $uid = $this->whlabel->read($arg_array[0]);
  2143. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2144. $this->data['enter'] = $uid;
  2145. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2146. $this->data['wlshop'] = $wlshop;
  2147. $this->_Template('whlabel_enteredit', $this->data);
  2148. }
  2149. //入库浏览
  2150. public function _enter()
  2151. {
  2152. $post = $this->input->post(NULL, TRUE);
  2153. if (isset($post['s'])) {
  2154. $id_arr = $this->input->post('s');
  2155. $id_arr = explode(',', $id_arr);
  2156. if (!$id_arr) {
  2157. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2158. exit;
  2159. }
  2160. //循环删除记录
  2161. foreach ($id_arr as $v) {
  2162. $sid = $this->whlabel->read($v);
  2163. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2164. if ($count > 0) {
  2165. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2166. exit;
  2167. }
  2168. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2169. foreach ($info_list as $va) {
  2170. $this->whlabel->remove($va['id']);
  2171. }
  2172. }
  2173. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2174. exit;
  2175. }
  2176. $sp = array();
  2177. $s = $this->shop->find_all('1=1', 'id,shopname');
  2178. foreach ($s as $v) {
  2179. $sp[$v['id']] = $v['shopname'];
  2180. }
  2181. $wh = array();
  2182. $w = $this->warehouse->find_all('1=1', 'id,title');
  2183. foreach ($w as $v) {
  2184. $wh[$v['id']] = $v['title'];
  2185. }
  2186. if (isset($post['page'])) {
  2187. $page = $this->input->post('page', true);
  2188. $perpage = $this->input->post('perpage', true);
  2189. $category = $this->input->post('category', true);
  2190. $size = $this->input->post('size', true);
  2191. $grade = $this->input->post('grade', true);
  2192. $color = $this->input->post('color', true);
  2193. $lowe = $this->input->post('lowe', true);
  2194. $sku = $this->input->post('sku', true);
  2195. $warehouse = $this->input->post('warehouse', true);
  2196. $purchase = $this->input->post('purchase', true);
  2197. $ktime = $this->input->post('ktime', true);
  2198. $jtime = $this->input->post('jtime', true);
  2199. $ktime = strtotime($ktime);
  2200. $jtime = strtotime($jtime);
  2201. $where = "1=1";
  2202. $gj = "";
  2203. $ck = "";
  2204. if ($category) {
  2205. $where .= " and features like '%-$category-%'";
  2206. }
  2207. if ($size) {
  2208. $where .= " and features like '%-$size-%'";
  2209. }
  2210. if ($grade) {
  2211. $where .= " and features like '%-$grade-%'";
  2212. }
  2213. if ($color) {
  2214. $where .= " and features like '%-$color-%'";
  2215. }
  2216. if ($lowe) {
  2217. $where .= " and features like '%-$lowe-%'";
  2218. }
  2219. if ($warehouse) {
  2220. $where .= " and warehouse = '$warehouse'";
  2221. }
  2222. if ($purchase) {
  2223. $where .= " and purchase = '$purchase'";
  2224. }
  2225. if ($sku) {
  2226. $where .= " and sku like '%$sku%'";
  2227. }
  2228. if ($ktime && $jtime) {
  2229. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2230. }
  2231. //数据排序
  2232. $order_str = "enter desc";
  2233. if (empty($page)) {
  2234. $start = 0;
  2235. $perpage = 1;
  2236. } else {
  2237. $start = ($page - 1) * $perpage;
  2238. }
  2239. //取得信息列表
  2240. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2241. foreach ($info_list as $k => $v) {
  2242. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2243. if ($v['shop'] == '') {
  2244. $s = '通用';
  2245. } else {
  2246. $info_list[$k]['shop'] = '';
  2247. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2248. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2249. }
  2250. }
  2251. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2252. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2253. $info_list[$k]['g'] = $g;
  2254. }
  2255. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2256. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2257. $pagenum = ceil($total / $perpage);
  2258. $over = $total - ($start + $perpage);
  2259. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2260. echo json_encode($rows);
  2261. exit;
  2262. }
  2263. $this->_Template('whlabel_enter', $this->data);
  2264. }
  2265. //出库浏览
  2266. public function _out()
  2267. {
  2268. $post = $this->input->post(NULL, TRUE);
  2269. if (isset($post['page'])) {
  2270. $page = $this->input->post('page', true);
  2271. $perpage = $this->input->post('perpage', true);
  2272. $category = $this->input->post('category', true);
  2273. $size = $this->input->post('size', true);
  2274. $grade = $this->input->post('grade', true);
  2275. $color = $this->input->post('color', true);
  2276. $lowe = $this->input->post('lowe', true);
  2277. $sku = $this->input->post('sku', true);
  2278. $warehouse = $this->input->post('warehouse', true);
  2279. $purchase = $this->input->post('purchase', true);
  2280. $state = $this->input->post('state', true);
  2281. $ktime = $this->input->post('ktime', true);
  2282. $jtime = $this->input->post('jtime', true);
  2283. $ktime = strtotime($ktime);
  2284. $jtime = strtotime($jtime);
  2285. $where = "state=3";
  2286. $gj = "";
  2287. $ck = "";
  2288. if ($category) {
  2289. $where .= " and features like '%-$category-%'";
  2290. }
  2291. if ($size) {
  2292. $where .= " and features like '%-$size-%'";
  2293. }
  2294. if ($grade) {
  2295. $where .= " and features like '%-$grade-%'";
  2296. }
  2297. if ($color) {
  2298. $where .= " and features like '%-$color-%'";
  2299. }
  2300. if ($lowe) {
  2301. $where .= " and features like '%-$lowe-%'";
  2302. }
  2303. if ($state) {
  2304. $where .= " and state = '$state'";
  2305. }
  2306. if ($warehouse) {
  2307. $where .= " and warehouse = '$warehouse'";
  2308. }
  2309. if ($purchase) {
  2310. $where .= " and purchase = '$purchase'";
  2311. }
  2312. if ($sku) {
  2313. $where .= " and sku = '$sku'";
  2314. }
  2315. if ($ktime && $jtime) {
  2316. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2317. }
  2318. //数据排序
  2319. $order_str = "id desc";
  2320. if (empty($page)) {
  2321. $start = 0;
  2322. $perpage = 1;
  2323. } else {
  2324. $start = ($page - 1) * $perpage;
  2325. }
  2326. //取得信息列表
  2327. $info_list = $this->whlabel->find_all($where, 'sku');
  2328. $rows = array();
  2329. $list = array();
  2330. foreach ($info_list as $key => $value) {
  2331. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2332. }
  2333. $rows = array_unique($rows); //删除重复记录
  2334. foreach ($rows as $key => $value) {
  2335. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2336. $ck = $this->warehouse->read($data['warehouse']);
  2337. $warehouse = $ck['title'];
  2338. $gy = $this->purchase->read($data['purchase']);
  2339. $purchase = $gy['purchase'];
  2340. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2341. $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);
  2342. }
  2343. $total = count($list);
  2344. $pagenum = ceil($total / $perpage);
  2345. $over = $total - ($start + $perpage);
  2346. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2347. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2348. echo json_encode($rows);
  2349. exit;
  2350. }
  2351. $this->_Template('whlabel_out', $this->data);
  2352. }
  2353. //出库标签浏览
  2354. public function _label()
  2355. {
  2356. $post = $this->input->post(NULL, TRUE);
  2357. if (isset($post['page'])) {
  2358. $page = $this->input->post('page', true);
  2359. $perpage = $this->input->post('perpage', true);
  2360. $sku = $this->input->post('sku', true);
  2361. $warehouse = $this->input->post('warehouse', true);
  2362. $purchase = $this->input->post('purchase', true);
  2363. $orderinfo = $this->input->post('orderinfo', true);
  2364. $waybill = $this->input->post('waybill', true);
  2365. $category = $this->input->post('category', true);
  2366. $size = $this->input->post('size', true);
  2367. $grade = $this->input->post('grade', true);
  2368. $color = $this->input->post('color', true);
  2369. $lowe = $this->input->post('lowe', true);
  2370. $where = "state=1";
  2371. if ($sku) {
  2372. $where .= " and sku = '$sku'";
  2373. }
  2374. if ($warehouse) {
  2375. $where .= " and warehouse = '$warehouse'";
  2376. }
  2377. if ($purchase) {
  2378. $where .= " and purchase = '$purchase'";
  2379. }
  2380. if ($orderinfo) {
  2381. $where .= " and orderinfo = '$orderinfo'";
  2382. }
  2383. if ($waybill) {
  2384. $where .= " and waybill = '$waybill'";
  2385. }
  2386. if ($category) {
  2387. $where .= " and features like '%-$category-%'";
  2388. }
  2389. if ($size) {
  2390. $where .= " and features like '%-$size-%'";
  2391. }
  2392. if ($grade) {
  2393. $where .= " and features like '%-$grade-%'";
  2394. }
  2395. if ($color) {
  2396. $where .= " and features like '%-$color-%'";
  2397. }
  2398. if ($lowe) {
  2399. $where .= " and features like '%-$lowe-%'";
  2400. }
  2401. //数据排序
  2402. $order_str = "outk desc";
  2403. if (empty($page)) {
  2404. $start = 0;
  2405. $perpage = 1;
  2406. } else {
  2407. $start = ($page - 1) * $perpage;
  2408. }
  2409. //取得信息列表
  2410. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2411. foreach ($info_list as $key => $value) {
  2412. $warehouse = $this->warehouse->read($value['warehouse']);
  2413. $info_list[$key]['warehouse'] = $warehouse['title'];
  2414. $purchase = $this->purchase->read($value['purchase']);
  2415. $info_list[$key]['purchase'] = $purchase['title'];
  2416. if ($value['outk'] != 0) {
  2417. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2418. } else {
  2419. $info_list[$key]['outk'] = "";
  2420. }
  2421. if ($value['orderinfo'] == 0) {
  2422. $info_list[$key]['orderinfo'] = "";
  2423. }
  2424. if ($value['waybill'] == 0) {
  2425. $info_list[$key]['waybill'] = "";
  2426. }
  2427. }
  2428. $total = $this->whlabel->find_count($where);
  2429. $pagenum = ceil($total / $perpage);
  2430. $over = $total - ($start + $perpage);
  2431. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2432. echo json_encode($rows);
  2433. exit;
  2434. }
  2435. $this->_Template('whlabel_label', $this->data);
  2436. }
  2437. //独立站出库订单
  2438. public function _outorder()
  2439. {
  2440. if (isset($_SESSION['api'])) {
  2441. $user = $this->user->get_api($_SESSION['api']);
  2442. $usp = $user;
  2443. $fgshop = "";
  2444. $sid = "";
  2445. $user = explode('|', trim($user['shop'], '|'));
  2446. foreach ($user as $value) {
  2447. $fgshop .= " shop = " . $value . " or";
  2448. $sid .= " id = " . $value . " or";
  2449. }
  2450. } else {
  2451. echo "请重新登录";
  2452. }
  2453. $post = $this->input->post(NULL, TRUE);
  2454. if (isset($post['page'])) {
  2455. $page = $this->input->post('page', true);
  2456. $perpage = $this->input->post('perpage', true);
  2457. $warehouse = $this->input->post('warehouse', true);
  2458. $xztime = $this->input->post('xztime', true);
  2459. $timetk = $this->input->post('timetkk', true);
  2460. $timetj = $this->input->post('timetjj', true);
  2461. $shop = $this->input->post('shop', true);
  2462. $source = $this->input->post('source', true);
  2463. $orderinfo = $this->input->post('orderinfo', true);
  2464. $number = $this->input->post('number', true);
  2465. $sfxh = $this->input->post('sfxh', true);
  2466. $express = $this->input->post('express', true);
  2467. $waybill = $this->input->post('waybill', true);
  2468. $library = $this->input->post('library', true);
  2469. $country = $this->input->post('country', true);
  2470. $so = $this->input->post('so', true);
  2471. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2472. $print = $this->input->post('print', true);
  2473. $state = $this->input->post('state', true);
  2474. $orderurl = $this->input->post('orderurl', true);
  2475. $productid = $this->input->post('productid', true);
  2476. $timetk = strtotime($timetk);
  2477. $timetj = strtotime($timetj);
  2478. /**
  2479. $sj = $this->input->post('sj',true);
  2480. if($sj)
  2481. {
  2482. $sj = $this->input->post('sj',true);
  2483. }
  2484. else
  2485. {
  2486. $sj = "fullorder";
  2487. }
  2488. **/
  2489. $sj = "fullorder";
  2490. $where = "1=1";
  2491. if ($warehouse) {
  2492. $where .= " and type = '$warehouse'";
  2493. }
  2494. if ($timetk && $timetj) {
  2495. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2496. }
  2497. if ($orderinfo) {
  2498. $where .= " and orderinfo = '$orderinfo'";
  2499. }
  2500. if ($number) {
  2501. $where .= " and number = '$number'";
  2502. }
  2503. if ($express) {
  2504. $where .= " and express = '$express'";
  2505. }
  2506. if ($waybill) {
  2507. $where .= " and waybill = '$waybill'";
  2508. }
  2509. if ($library) {
  2510. $where .= " and library = '$library'";
  2511. }
  2512. if ($print) {
  2513. $where .= " and print = '$print'";
  2514. }
  2515. if ($libraryconfirm) {
  2516. $where .= " and libraryconfirm = '$libraryconfirm'";
  2517. }
  2518. if ($state) {
  2519. $where .= " and state = '$state'";
  2520. }
  2521. if ($shop) {
  2522. $where .= " and shop = '$shop'";
  2523. }
  2524. if ($country) {
  2525. $where .= " and country = '$country'";
  2526. }
  2527. if ($sfxh != '') {
  2528. $where .= " and sfxh = '$sfxh'";
  2529. }
  2530. if ($so) {
  2531. $where .= " and shipremarks like '%$so%'";
  2532. }
  2533. if ($source) {
  2534. if ($source == '2d') {
  2535. $where .= " and source >= '2'";
  2536. } else {
  2537. $where .= " and source = '$source'";
  2538. }
  2539. }
  2540. if (isset($_SESSION['api'])) {
  2541. foreach ($user as $value) {
  2542. $fgshop .= " shop = " . $value . " or";
  2543. }
  2544. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2545. }
  2546. if ($orderurl) {
  2547. $url = $this->orderurl->read($orderurl);
  2548. $where .= " and link like '%" . $url['url'] . "%'";
  2549. }
  2550. if($productid){
  2551. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2552. }
  2553. //数据排序
  2554. $order_str = "librarytime desc";
  2555. if (empty($page)) {
  2556. $start = 0;
  2557. $perpage = 1;
  2558. } else {
  2559. $start = ($page - 1) * $perpage;
  2560. }
  2561. //取得信息列表
  2562. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2563. //格式化数据
  2564. foreach ($info_list as $key => $value) {
  2565. $shop = $this->shop->read($value['shop']);
  2566. $info_list[$key]['shop'] = $shop['shopname'];
  2567. $express = $this->express->read($value['express']);
  2568. $info_list[$key]['express'] = $express['servicename'];
  2569. $warehouse = $this->warehouse->read($value['type']);
  2570. $info_list[$key]['type'] = $warehouse['title'];
  2571. if ($value['librarytime'] == '0') {
  2572. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2573. } else {
  2574. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2575. }
  2576. }
  2577. $total = $this->$sj->find_count($where);
  2578. $pagenum = ceil($total / $perpage);
  2579. $over = $total - ($start + $perpage);
  2580. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2581. echo json_encode($rows);
  2582. exit;
  2583. }
  2584. $this->data['express'] = $this->express->find_all();
  2585. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2586. $this->data['wlshop'] = $wlshop;
  2587. $user = $this->user->get_api($_SESSION['api']);
  2588. $powerid = $this->power->read($user['power']);
  2589. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2590. $pid = '';
  2591. foreach ($powertext as $v) {
  2592. $pid .= " id = " . $v . " or";
  2593. }
  2594. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2595. $this->data['fullorderexcel'] = $fullorderexcel;
  2596. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2597. $this->data['orderurl'] = $orderurl;
  2598. $this->_Template('whlabel_outorder', $this->data);
  2599. }
  2600. //tt出库
  2601. public function _toutorder()
  2602. {
  2603. $fgshop = "";
  2604. $sid = "";
  2605. if (isset($_SESSION['api'])) {
  2606. $user = $this->user->get_api($_SESSION['api']);
  2607. $usp = $user;
  2608. $user = explode('|', trim($user['shop'], '|'));
  2609. foreach ($user as $value) {
  2610. $fgshop .= " shop = " . $value . " or";
  2611. $sid .= " id = " . $value . " or";
  2612. }
  2613. } else {
  2614. echo "请重新登录";
  2615. die;
  2616. }
  2617. $post = $this->input->post(NULL, TRUE);
  2618. if (isset($post['page'])) {
  2619. $page = $this->input->post('page', true);
  2620. $perpage = $this->input->post('perpage', true);
  2621. $warehouse = $this->input->post('warehouse', true);
  2622. $xztime = $this->input->post('xztime', true);
  2623. $timetk = $this->input->post('timetkk', true);
  2624. $timetj = $this->input->post('timetjj', true);
  2625. $shop = $this->input->post('shop', true);
  2626. $source = $this->input->post('source', true);
  2627. $orderinfo = $this->input->post('orderinfo', true);
  2628. $number = $this->input->post('number', true);
  2629. $sfxh = $this->input->post('sfxh', true);
  2630. $express = $this->input->post('express', true);
  2631. $waybill = $this->input->post('waybill', true);
  2632. $library = $this->input->post('library', true);
  2633. $country = $this->input->post('country', true);
  2634. $so = $this->input->post('so', true);
  2635. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2636. $print = $this->input->post('print', true);
  2637. $state = $this->input->post('state', true);
  2638. $orderurl = $this->input->post('orderurl', true);
  2639. $timetk = strtotime($timetk);
  2640. $timetj = strtotime($timetj);
  2641. /**
  2642. $sj = $this->input->post('sj',true);
  2643. if($sj)
  2644. {
  2645. $sj = $this->input->post('sj',true);
  2646. }
  2647. else
  2648. {
  2649. $sj = "fullorder";
  2650. }
  2651. **/
  2652. $sj = "fullordertt";
  2653. $where = "1=1";
  2654. if ($warehouse) {
  2655. $where .= " and type = '$warehouse'";
  2656. }
  2657. if ($timetk && $timetj) {
  2658. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2659. }
  2660. if ($orderinfo) {
  2661. $where .= " and orderinfo = '$orderinfo'";
  2662. }
  2663. if ($number) {
  2664. $where .= " and number = '$number'";
  2665. }
  2666. if ($express) {
  2667. $where .= " and express = '$express'";
  2668. }
  2669. if ($waybill) {
  2670. $where .= " and waybill = '$waybill'";
  2671. }
  2672. if ($library) {
  2673. $where .= " and library = '$library'";
  2674. }
  2675. if ($print) {
  2676. $where .= " and print = '$print'";
  2677. }
  2678. if ($libraryconfirm) {
  2679. $where .= " and libraryconfirm = '$libraryconfirm'";
  2680. }
  2681. if ($state) {
  2682. $where .= " and state = '$state'";
  2683. }
  2684. if ($shop) {
  2685. $where .= " and shop = '$shop'";
  2686. }
  2687. if ($country) {
  2688. $where .= " and country = '$country'";
  2689. }
  2690. if ($sfxh != '') {
  2691. $where .= " and sfxh = '$sfxh'";
  2692. }
  2693. if ($so) {
  2694. $where .= " and shipremarks like '%$so%'";
  2695. }
  2696. if ($source) {
  2697. if ($source == '2d') {
  2698. $where .= " and source >= '2'";
  2699. } else {
  2700. $where .= " and source = '$source'";
  2701. }
  2702. }
  2703. if (isset($_SESSION['api'])) {
  2704. foreach ($user as $value) {
  2705. $fgshop .= " shop = " . $value . " or";
  2706. }
  2707. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2708. }
  2709. if ($orderurl) {
  2710. $url = $this->orderurl->read($orderurl);
  2711. $where .= " and link like '%" . $url['url'] . "%'";
  2712. }
  2713. //数据排序
  2714. $order_str = "librarytime desc";
  2715. if (empty($page)) {
  2716. $start = 0;
  2717. $perpage = 1;
  2718. } else {
  2719. $start = ($page - 1) * $perpage;
  2720. }
  2721. //取得信息列表
  2722. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2723. //格式化数据
  2724. foreach ($info_list as $key => $value) {
  2725. $shop = $this->shop->read($value['shop']);
  2726. $info_list[$key]['shop'] = $shop['shopname'];
  2727. $express = $this->express->read($value['express']);
  2728. $info_list[$key]['express'] = $express['servicename'];
  2729. $warehouse = $this->warehouse->read($value['type']);
  2730. $info_list[$key]['type'] = $warehouse['title'];
  2731. if ($value['librarytime'] == '0') {
  2732. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2733. } else {
  2734. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2735. }
  2736. }
  2737. $total = $this->$sj->find_count($where);
  2738. $pagenum = ceil($total / $perpage);
  2739. $over = $total - ($start + $perpage);
  2740. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2741. echo json_encode($rows);
  2742. exit;
  2743. }
  2744. $this->data['express'] = $this->express->find_all();
  2745. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2746. $this->data['wlshop'] = $wlshop;
  2747. $user = $this->user->get_api($_SESSION['api']);
  2748. $powerid = $this->power->read($user['power']);
  2749. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2750. $pid = '';
  2751. foreach ($powertext as $v) {
  2752. $pid .= " id = " . $v . " or";
  2753. }
  2754. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2755. $this->data['fullorderexcel'] = $fullorderexcel;
  2756. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2757. $this->data['orderurl'] = $orderurl;
  2758. $this->_Template('whlabel_toutorder', $this->data);
  2759. }
  2760. //tt出库
  2761. public function _aoutorder()
  2762. {
  2763. if (isset($_SESSION['api'])) {
  2764. $user = $this->user->get_api($_SESSION['api']);
  2765. $usp = $user;
  2766. $fgshop = "";
  2767. $sid = "";
  2768. $user = explode('|', trim($user['shop'], '|'));
  2769. foreach ($user as $value) {
  2770. $fgshop .= " shop = " . $value . " or";
  2771. $sid .= " id = " . $value . " or";
  2772. }
  2773. } else {
  2774. echo "请重新登录";
  2775. }
  2776. $post = $this->input->post(NULL, TRUE);
  2777. if (isset($post['page'])) {
  2778. $page = $this->input->post('page', true);
  2779. $perpage = $this->input->post('perpage', true);
  2780. $warehouse = $this->input->post('warehouse', true);
  2781. $xztime = $this->input->post('xztime', true);
  2782. $timetk = $this->input->post('timetkk', true);
  2783. $timetj = $this->input->post('timetjj', true);
  2784. $shop = $this->input->post('shop', true);
  2785. $source = $this->input->post('source', true);
  2786. $orderinfo = $this->input->post('orderinfo', true);
  2787. $number = $this->input->post('number', true);
  2788. $sfxh = $this->input->post('sfxh', true);
  2789. $express = $this->input->post('express', true);
  2790. $waybill = $this->input->post('waybill', true);
  2791. $library = $this->input->post('library', true);
  2792. $country = $this->input->post('country', true);
  2793. $so = $this->input->post('so', true);
  2794. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2795. $print = $this->input->post('print', true);
  2796. $state = $this->input->post('state', true);
  2797. $orderurl = $this->input->post('orderurl', true);
  2798. $timetk = strtotime($timetk);
  2799. $timetj = strtotime($timetj);
  2800. /**
  2801. $sj = $this->input->post('sj',true);
  2802. if($sj)
  2803. {
  2804. $sj = $this->input->post('sj',true);
  2805. }
  2806. else
  2807. {
  2808. $sj = "fullorder";
  2809. }
  2810. **/
  2811. $sj = "fullorderamz";
  2812. $where = "1=1";
  2813. if ($warehouse) {
  2814. $where .= " and type = '$warehouse'";
  2815. }
  2816. if ($timetk && $timetj) {
  2817. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2818. }
  2819. if ($orderinfo) {
  2820. $where .= " and orderinfo = '$orderinfo'";
  2821. }
  2822. if ($number) {
  2823. $where .= " and number = '$number'";
  2824. }
  2825. if ($express) {
  2826. $where .= " and express = '$express'";
  2827. }
  2828. if ($waybill) {
  2829. $where .= " and waybill = '$waybill'";
  2830. }
  2831. if ($library) {
  2832. $where .= " and library = '$library'";
  2833. }
  2834. if ($print) {
  2835. $where .= " and print = '$print'";
  2836. }
  2837. if ($libraryconfirm) {
  2838. $where .= " and libraryconfirm = '$libraryconfirm'";
  2839. }
  2840. if ($state) {
  2841. $where .= " and state = '$state'";
  2842. }
  2843. if ($shop) {
  2844. $where .= " and shop = '$shop'";
  2845. }
  2846. if ($country) {
  2847. $where .= " and country = '$country'";
  2848. }
  2849. if ($sfxh != '') {
  2850. $where .= " and sfxh = '$sfxh'";
  2851. }
  2852. if ($so) {
  2853. $where .= " and shipremarks like '%$so%'";
  2854. }
  2855. if ($source) {
  2856. if ($source == '2d') {
  2857. $where .= " and source >= '2'";
  2858. } else {
  2859. $where .= " and source = '$source'";
  2860. }
  2861. }
  2862. if (isset($_SESSION['api'])) {
  2863. foreach ($user as $value) {
  2864. $fgshop .= " shop = " . $value . " or";
  2865. }
  2866. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2867. }
  2868. if ($orderurl) {
  2869. $url = $this->orderurl->read($orderurl);
  2870. $where .= " and link like '%" . $url['url'] . "%'";
  2871. }
  2872. //数据排序
  2873. $order_str = "librarytime desc";
  2874. if (empty($page)) {
  2875. $start = 0;
  2876. $perpage = 1;
  2877. } else {
  2878. $start = ($page - 1) * $perpage;
  2879. }
  2880. //取得信息列表
  2881. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2882. //格式化数据
  2883. foreach ($info_list as $key => $value) {
  2884. $shop = $this->shop->read($value['shop']);
  2885. $info_list[$key]['shop'] = $shop['shopname'];
  2886. $express = $this->express->read($value['express']);
  2887. $info_list[$key]['express'] = $express['servicename'];
  2888. $warehouse = $this->warehouse->read($value['type']);
  2889. $info_list[$key]['type'] = $warehouse['title'];
  2890. if ($value['librarytime'] == '0') {
  2891. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2892. } else {
  2893. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2894. }
  2895. }
  2896. $total = $this->$sj->find_count($where);
  2897. $pagenum = ceil($total / $perpage);
  2898. $over = $total - ($start + $perpage);
  2899. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2900. echo json_encode($rows);
  2901. exit;
  2902. }
  2903. $this->data['express'] = $this->express->find_all();
  2904. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2905. $this->data['wlshop'] = $wlshop;
  2906. $user = $this->user->get_api($_SESSION['api']);
  2907. $powerid = $this->power->read($user['power']);
  2908. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2909. $pid = '';
  2910. foreach ($powertext as $v) {
  2911. $pid .= " id = " . $v . " or";
  2912. }
  2913. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2914. $this->data['fullorderexcel'] = $fullorderexcel;
  2915. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2916. $this->data['orderurl'] = $orderurl;
  2917. $this->_Template('whlabel_aoutorder', $this->data);
  2918. }
  2919. //速卖通出库订单
  2920. public function _soutorder()
  2921. {
  2922. if (isset($_SESSION['api'])) {
  2923. $user = $this->user->get_api($_SESSION['api']);
  2924. $usp = $user;
  2925. $fgshop = "";
  2926. $sid = "";
  2927. $user = explode('|', trim($user['shop'], '|'));
  2928. foreach ($user as $value) {
  2929. $sid .= " id = " . $value . " or";
  2930. }
  2931. }
  2932. $post = $this->input->post(NULL, TRUE);
  2933. if (isset($post['page'])) {
  2934. $page = $this->input->post('page', true);
  2935. $perpage = $this->input->post('perpage', true);
  2936. $warehouse = $this->input->post('warehouse', true);
  2937. $xztime = $this->input->post('xztime', true);
  2938. $timetk = $this->input->post('timetkk', true);
  2939. $timetj = $this->input->post('timetjj', true);
  2940. $shop = $this->input->post('shop', true);
  2941. $source = $this->input->post('source', true);
  2942. $orderinfo = $this->input->post('orderinfo', true);
  2943. $number = $this->input->post('number', true);
  2944. $express = $this->input->post('express', true);
  2945. $waybill = $this->input->post('waybill', true);
  2946. $library = $this->input->post('library', true);
  2947. $country = $this->input->post('country', true);
  2948. $sfxh = $this->input->post('sfxh', true);
  2949. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2950. $print = $this->input->post('print', true);
  2951. $state = $this->input->post('state', true);
  2952. $so = $this->input->post('so', true);
  2953. $timetk = strtotime($timetk);
  2954. $timetj = strtotime($timetj);
  2955. /**
  2956. $sj = $this->input->post('sj',true);
  2957. if($sj)
  2958. {
  2959. $sj = $this->input->post('sj',true);
  2960. }
  2961. else
  2962. {
  2963. $sj = "fullorder";
  2964. }
  2965. **/
  2966. $sj = "fullordersmt";
  2967. $where = "1=1";
  2968. if ($warehouse) {
  2969. $where .= " and type = '$warehouse'";
  2970. }
  2971. if ($timetk && $timetj) {
  2972. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2973. }
  2974. if ($orderinfo) {
  2975. $where .= " and orderinfo = '$orderinfo'";
  2976. }
  2977. if ($number) {
  2978. $where .= " and number = '$number'";
  2979. }
  2980. if ($express) {
  2981. $where .= " and express = '$express'";
  2982. }
  2983. if ($waybill) {
  2984. $where .= " and waybill = '$waybill'";
  2985. }
  2986. if ($library) {
  2987. $where .= " and library = '$library'";
  2988. }
  2989. if ($print) {
  2990. $where .= " and print = '$print'";
  2991. }
  2992. if ($libraryconfirm) {
  2993. $where .= " and libraryconfirm = '$libraryconfirm'";
  2994. }
  2995. if ($state) {
  2996. $where .= " and state = '$state'";
  2997. }
  2998. if ($shop) {
  2999. $where .= " and shop = '$shop'";
  3000. }
  3001. if ($sfxh != '') {
  3002. $where .= " and sfxh = '$sfxh'";
  3003. }
  3004. if ($so) {
  3005. $where .= " and shipremarks like '%$so%'";
  3006. }
  3007. if ($source) {
  3008. $where .= " and source = '$source'";
  3009. }
  3010. if ($country) {
  3011. $where .= " and country = '$country'";
  3012. } else {
  3013. if (isset($_SESSION['api'])) {
  3014. foreach ($user as $value) {
  3015. $fgshop .= " shop = " . $value . " or";
  3016. }
  3017. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3018. }
  3019. }
  3020. //数据排序
  3021. $order_str = "librarytime desc";
  3022. if (empty($page)) {
  3023. $start = 0;
  3024. $perpage = 1;
  3025. } else {
  3026. $start = ($page - 1) * $perpage;
  3027. }
  3028. //取得信息列表
  3029. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3030. //格式化数据
  3031. foreach ($info_list as $key => $value) {
  3032. $shop = $this->shop->read($value['shop']);
  3033. $info_list[$key]['shop'] = $shop['shopname'];
  3034. $express = $this->express->read($value['express']);
  3035. $info_list[$key]['express'] = $express['servicename'];
  3036. $warehouse = $this->warehouse->read($value['type']);
  3037. $info_list[$key]['type'] = $warehouse['title'];
  3038. if ($value['librarytime'] == '0') {
  3039. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3040. } else {
  3041. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3042. }
  3043. }
  3044. $total = $this->$sj->find_count($where);
  3045. $pagenum = ceil($total / $perpage);
  3046. $over = $total - ($start + $perpage);
  3047. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3048. echo json_encode($rows);
  3049. exit;
  3050. }
  3051. $this->data['express'] = $this->express->find_all();
  3052. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3053. $this->data['wlshop'] = $wlshop;
  3054. $user = $this->user->get_api($_SESSION['api']);
  3055. $powerid = $this->power->read($user['power']);
  3056. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3057. $pid = '';
  3058. foreach ($powertext as $v) {
  3059. $pid .= " id = " . $v . " or";
  3060. }
  3061. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3062. $this->data['fullorderexcel'] = $fullorderexcel;
  3063. $this->_Template('whlabel_soutorder', $this->data);
  3064. }
  3065. //订单退库
  3066. public function _retreat()
  3067. {
  3068. $post = $this->input->post(NULL, TRUE);
  3069. if (isset($post['page'])) {
  3070. $page = $this->input->post('page', true);
  3071. $perpage = $this->input->post('perpage', true);
  3072. $warehouse = $this->input->post('warehouse', true);
  3073. $timetk = $this->input->post('timetk', true);
  3074. $timetj = $this->input->post('timetj', true);
  3075. $shop = $this->input->post('shop', true);
  3076. $source = $this->input->post('source', true);
  3077. $state = $this->input->post('state', true);
  3078. $review = $this->input->post('review', true);
  3079. $state = $this->input->post('state', true);
  3080. $express = $this->input->post('express', true);
  3081. $orderinfo = $this->input->post('orderinfo', true);
  3082. $user = $this->input->post('user', true);
  3083. $name = $this->input->post('name', true);
  3084. $waybill = $this->input->post('waybill', true);
  3085. $timetk = strtotime($timetk);
  3086. $timetj = strtotime($timetj);
  3087. $where = "(state=206 or state=210) and mergeid = 0";
  3088. if ($warehouse) {
  3089. $where .= " and state = '$warehouse'";
  3090. }
  3091. if ($timetk && $timetj) {
  3092. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3093. }
  3094. if ($shop) {
  3095. $where .= " and shop = '$shop'";
  3096. }
  3097. if ($source) {
  3098. $where .= " and source = '$source'";
  3099. }
  3100. if ($state) {
  3101. $where .= " and state = '$state'";
  3102. }
  3103. if ($review) {
  3104. $where .= " and review = '$review'";
  3105. }
  3106. if ($state) {
  3107. $where .= " and state = '$state'";
  3108. }
  3109. if ($express) {
  3110. $where .= " and express = '$express'";
  3111. }
  3112. if ($orderinfo) {
  3113. $where .= " and orderinfo = '$orderinfo'";
  3114. }
  3115. if ($user) {
  3116. $where .= " and user = '$user'";
  3117. }
  3118. if ($name) {
  3119. $where .= " and name = '$name'";
  3120. }
  3121. if ($waybill) {
  3122. $where .= " and waybill = '$waybill'";
  3123. }
  3124. //数据排序
  3125. $order_str = "id desc";
  3126. if (empty($page)) {
  3127. $start = 0;
  3128. $perpage = 1;
  3129. } else {
  3130. $start = ($page - 1) * $perpage;
  3131. }
  3132. //取得信息列表
  3133. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3134. //格式化数据
  3135. foreach ($info_list as $key => $value) {
  3136. $shop = $this->shop->read($value['shop']);
  3137. $info_list[$key]['shop'] = $shop['shopname'];
  3138. $warehouse = $this->warehouse->read($value['warehouse']);
  3139. $info_list[$key]['warehouse'] = $warehouse['title'];
  3140. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3141. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3142. if ($value['waybill'] == 0) {
  3143. $info_list[$key]['waybill'] = "";
  3144. }
  3145. $express = $this->express->read($value['express']);
  3146. $info_list[$key]['express'] = $express['title'];
  3147. $typeclass = $this->typeclass->read($value['state']);
  3148. $info_list[$key]['state'] = $typeclass['title'];
  3149. }
  3150. $total = $this->fullorder->find_count($where);
  3151. $pagenum = ceil($total / $perpage);
  3152. $over = $total - ($start + $perpage);
  3153. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3154. echo json_encode($rows);
  3155. exit;
  3156. }
  3157. $this->data['express'] = $this->express->find_all();
  3158. $this->_Template('whlabel_retreat', $this->data);
  3159. }
  3160. //退库标签浏览
  3161. public function _retreatlk()
  3162. {
  3163. $post = $this->input->post(NULL, TRUE);
  3164. if (isset($post['page'])) {
  3165. $page = $this->input->post('page', true);
  3166. $perpage = $this->input->post('perpage', true);
  3167. $timetk = $this->input->post('timetk', true);
  3168. $timetj = $this->input->post('timetj', true);
  3169. $sku = $this->input->post('sku', true);
  3170. $warehouse = $this->input->post('warehouse', true);
  3171. $purchase = $this->input->post('purchase', true);
  3172. $orderinfo = $this->input->post('orderinfo', true);
  3173. $waybill = $this->input->post('waybill', true);
  3174. $category = $this->input->post('category', true);
  3175. $size = $this->input->post('size', true);
  3176. $grade = $this->input->post('grade', true);
  3177. $color = $this->input->post('color', true);
  3178. $lowe = $this->input->post('lowe', true);
  3179. $state = $this->input->post('state', true);
  3180. $timetk = strtotime($timetk);
  3181. $timetj = strtotime($timetj);
  3182. $where = "state=2";
  3183. if ($timetk && $timetj) {
  3184. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3185. }
  3186. if ($sku) {
  3187. $where .= " and sku = '$sku'";
  3188. }
  3189. if ($warehouse) {
  3190. $where .= " and warehouse = '$warehouse'";
  3191. }
  3192. if ($purchase) {
  3193. $where .= " and purchase = '$purchase'";
  3194. }
  3195. if ($orderinfo) {
  3196. $where .= " and orderinfo = '$orderinfo'";
  3197. }
  3198. if ($waybill) {
  3199. $where .= " and waybill = '$waybill'";
  3200. }
  3201. if ($category) {
  3202. $where .= " and features like '%-$category-%'";
  3203. }
  3204. if ($size) {
  3205. $where .= " and features like '%-$size-%'";
  3206. }
  3207. if ($grade) {
  3208. $where .= " and features like '%-$grade-%'";
  3209. }
  3210. if ($color) {
  3211. $where .= " and features like '%-$color-%'";
  3212. }
  3213. if ($lowe) {
  3214. $where .= " and features like '%-$lowe-%'";
  3215. }
  3216. //数据排序
  3217. $order_str = "time desc";
  3218. if (empty($page)) {
  3219. $start = 0;
  3220. $perpage = 1;
  3221. } else {
  3222. $start = ($page - 1) * $perpage;
  3223. }
  3224. //取得信息列表
  3225. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3226. foreach ($info_list as $key => $value) {
  3227. $warehouse = $this->warehouse->read($value['warehouse']);
  3228. $info_list[$key]['warehouse'] = $warehouse['title'];
  3229. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3230. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3231. $purchase = $this->purchase->read($value['purchase']);
  3232. $info_list[$key]['purchase'] = $purchase['title'];
  3233. if ($value['outk'] != 0) {
  3234. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3235. } else {
  3236. $info_list[$key]['outk'] = "";
  3237. }
  3238. if ($value['retreat'] != 0) {
  3239. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3240. } else {
  3241. $info_list[$key]['retreat'] = "";
  3242. }
  3243. if ($value['orderinfo'] == 0) {
  3244. $info_list[$key]['orderinfo'] = "";
  3245. }
  3246. if ($value['waybill'] == 0) {
  3247. $info_list[$key]['waybill'] = "";
  3248. }
  3249. }
  3250. $total = $this->whlabel->find_count($where);
  3251. $pagenum = ceil($total / $perpage);
  3252. $over = $total - ($start + $perpage);
  3253. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3254. echo json_encode($rows);
  3255. exit;
  3256. }
  3257. $this->_Template('whlabel_retreatlk', $this->data);
  3258. }
  3259. //更换标签及浏览
  3260. public function _change()
  3261. {
  3262. $post = $this->input->post(NULL, TRUE);
  3263. if (isset($post['page'])) {
  3264. $page = $this->input->post('page', true);
  3265. $perpage = $this->input->post('perpage', true);
  3266. $timetk = $this->input->post('timetk', true);
  3267. $timetj = $this->input->post('timetj', true);
  3268. $label = $this->input->post('label', true);
  3269. $oldlabel = $this->input->post('oldlabel', true);
  3270. $timetk = strtotime($timetk);
  3271. $timetj = strtotime($timetj);
  3272. $where = "state=10 ";
  3273. if ($timetk && $timetj) {
  3274. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3275. }
  3276. if ($label) {
  3277. $where .= " and label = '$label'";
  3278. }
  3279. if ($oldlabel) {
  3280. $where .= " and oldlabel = '$oldlabel'";
  3281. }
  3282. //数据排序
  3283. $order_str = "time asc";
  3284. if (empty($page)) {
  3285. $start = 0;
  3286. $perpage = 1;
  3287. } else {
  3288. $start = ($page - 1) * $perpage;
  3289. }
  3290. //取得信息列表
  3291. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3292. foreach ($info_list as $key => $value) {
  3293. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3294. }
  3295. $total = $this->whlabel->find_count($where);
  3296. $pagenum = ceil($total / $perpage);
  3297. $over = $total - ($start + $perpage);
  3298. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3299. echo json_encode($rows);
  3300. exit;
  3301. }
  3302. $this->_Template('whlabel_change', $this->data);
  3303. }
  3304. //产品标签
  3305. public function _cpbqdc()
  3306. {
  3307. if (isset($_GET['excel'])) {
  3308. $where = "1=1";
  3309. //数据排序
  3310. $order_str = "id desc";
  3311. if (empty($page)) {
  3312. $start = 0;
  3313. $perpage = 1;
  3314. } else {
  3315. $start = ($page - 1) * $perpage;
  3316. }
  3317. $warehouse = $this->input->get('warehouse', true);
  3318. $state = $this->input->get('state', true);
  3319. $timetk = $this->input->get('timetkk', true);
  3320. $timetj = $this->input->get('timetjj', true);
  3321. $timetk = strtotime($timetk);
  3322. $timetj = strtotime($timetj);
  3323. if ($warehouse) {
  3324. $where .= " and warehouse = '$warehouse'";
  3325. }
  3326. if ($state || $state == 0) {
  3327. $where .= " and state = '$state'";
  3328. }
  3329. if ($timetk && $timetj) {
  3330. $where .= " and time > '$timetk' and time < '$timetj'";
  3331. }
  3332. //取得信息列表
  3333. $info_list = $this->whlabel->find_all($where, '*');
  3334. $rows = array();
  3335. $list = array();
  3336. foreach ($info_list as $key => $value) {
  3337. $rows[$value['time']] = $value; //所有数据sku
  3338. }
  3339. foreach ($rows as $value) {
  3340. $warehouse = $this->warehouse->read($value['warehouse']);
  3341. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3342. $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);
  3343. }
  3344. $title = "产品标签统计表";
  3345. $titlename = "<table border=1>
  3346. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3347. <tr align='center'>
  3348. <td>仓库</td>
  3349. <td>SKU</td>
  3350. <td>产品</td>
  3351. <td>入库时间</td>
  3352. <td>操作时间</td>
  3353. <td>备注</td>
  3354. <td>数量</td>
  3355. </tr>
  3356. </table>";
  3357. $filename = $title . ".xls";
  3358. $tail = "";
  3359. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3360. }
  3361. }
  3362. //进销存导出
  3363. public function _exceljxc()
  3364. {
  3365. $classid = $this->classid->sku();
  3366. $pm = $classid;
  3367. $typeclass = array();
  3368. $tc = $this->typeclass->find_all();
  3369. foreach ($tc as $v) {
  3370. $typeclass[$v['id']] = $v;
  3371. }
  3372. $prc = array();
  3373. $purchase = $this->purchase->find_all();
  3374. foreach ($purchase as $k => $v) {
  3375. $prc[$v['id']] = $v['title'];
  3376. }
  3377. if (isset($_GET['excel'])) {
  3378. $where = "sku != 'Preset'";
  3379. //数据排序
  3380. $order_str = "id desc";
  3381. if (empty($page)) {
  3382. $start = 0;
  3383. $perpage = 1;
  3384. } else {
  3385. $start = ($page - 1) * $perpage;
  3386. }
  3387. $category = $this->input->get('category', true);
  3388. $warehouse = $this->input->get('warehouse', true);
  3389. $excelid = $this->input->get('sid', true);
  3390. if ($category) {
  3391. $where .= " and features like '%-$category-%'";
  3392. }
  3393. if ($warehouse) {
  3394. $where .= " and warehouse = '$warehouse'";
  3395. }
  3396. $xzid = '';
  3397. if ($excelid) {
  3398. $excelid = explode(',', trim($excelid, ','));
  3399. foreach ($excelid as $key => $value) {
  3400. $xzid .= " id = " . $value . " or";
  3401. }
  3402. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3403. }
  3404. //取得信息列表
  3405. /**
  3406. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3407. $rows = array();$list = array();
  3408. foreach ($info_list as $key=>$value)
  3409. {
  3410. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3411. }
  3412. **/
  3413. $wt = array();
  3414. $whlabel_type = $this->whlabel_type->find_all();
  3415. foreach ($whlabel_type as $v) {
  3416. $wt[$v['id']] = $v['title'];
  3417. }
  3418. $wh = array();
  3419. $w = $this->warehouse->find_all('1=1', 'id,title');
  3420. foreach ($w as $v) {
  3421. $wh[$v['id']] = $v['title'];
  3422. }
  3423. $list = array();
  3424. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3425. foreach ($rows as $key => $value) {
  3426. if (isset($wt[$value['type']])) {
  3427. $rows[$key]['type'] = $wt[$value['type']];
  3428. } else {
  3429. $rows[$key]['type'] = '未设置';
  3430. }
  3431. $bm = '03';
  3432. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3433. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3434. $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');
  3435. $details = array();
  3436. $cpid = array();
  3437. $cpbz = array();
  3438. $c = 0;
  3439. $g = 0;
  3440. $x = 0;
  3441. $t = 0;
  3442. $s = 0;
  3443. $q = 0;
  3444. foreach ($sd as $k => $v) {
  3445. if ($v['state'] == 0) {
  3446. $c++;
  3447. if ($v['cpid'] != 0) {
  3448. $cpid[$v['cpid']] = $v['cpid'];
  3449. }
  3450. if ($v['cpbz'] != '') {
  3451. $cpbz[$v['cpbz']] = $v['cpbz'];
  3452. }
  3453. }
  3454. if ($v['state'] != 9) {
  3455. $g++;
  3456. }
  3457. if ($v['state'] == 1) {
  3458. $x++;
  3459. }
  3460. if ($v['state'] == 2) {
  3461. $t++;
  3462. }
  3463. if ($v['state'] == 8) {
  3464. $s++;
  3465. }
  3466. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3467. $q++;
  3468. }
  3469. $details[$v['details']] = $v['details'];
  3470. }
  3471. $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'] . '"');
  3472. $rows[$key]['details'] = implode("、", $details);
  3473. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3474. $number = $value['number'];
  3475. $ftime = time() - 15 * 24 * 3600;
  3476. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3477. $rows[$key]['number'] = $g;
  3478. $rows[$key]['c'] = $c;
  3479. $rows[$key]['x'] = $x;
  3480. $rows[$key]['t'] = $t;
  3481. $rows[$key]['s'] = $s;
  3482. $rows[$key]['q'] = $q;
  3483. $rows[$key]['z'] = $z;
  3484. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3485. $features = explode('-', trim($features, '-'));
  3486. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3487. // $pm = $classid;
  3488. // $jm = $classid;
  3489. // foreach($features as $k=>$v)
  3490. // {
  3491. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3492. // {
  3493. // if($typeclass[$v]['bm'] != '')
  3494. // {
  3495. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3496. // }
  3497. // }
  3498. // if($v != 0)
  3499. // {
  3500. // if(!isset($typeclass[$v]))
  3501. // {
  3502. // continue;
  3503. // }
  3504. // if(isset($pm[$typeclass[$v]['classid']]))
  3505. // {
  3506. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3507. // {
  3508. // $tz = explode('|',$typeclass[$v]['zh']);
  3509. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3510. // }
  3511. // else
  3512. // {
  3513. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3514. // }
  3515. // }
  3516. // if(isset($jm[$typeclass[$v]['classid']]))
  3517. // {
  3518. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3519. // }
  3520. // }
  3521. // }
  3522. // $jm = array_filter($jm);
  3523. // $rows[$key]['bs'] = implode("-",$jm);
  3524. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3525. // $zh = implode(" ",$pm);
  3526. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3527. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3528. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3529. // $rows[$key]['features'] = $zh;
  3530. }
  3531. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3532. $final_list = [];
  3533. foreach ($list as $k => $v) {
  3534. if (empty($v['sku'])) {
  3535. continue;
  3536. }
  3537. $final_list[] = [
  3538. "warehouse" => $v["warehouse"],
  3539. "purchase" => $v["purchase"],
  3540. "details" => $v["details"],
  3541. "cpid" => $v["cpid"],
  3542. "dbcontent" => $v["dbcontent"],
  3543. "sku" => $v["sku"],
  3544. "cs" => $v["bm"],
  3545. "bs" => $v["jm"],
  3546. "title" => $v["title"],
  3547. "features" => $v["pm"],
  3548. // "cpbz" => $v["cpbz"],
  3549. // "sm" => $v["sm"],
  3550. "cpbz" => empty($v["cpbz"])? $v["sm"] : $v["cpbz"]." ".$v['sm'],
  3551. "sm" => "",
  3552. "type" => $v["type"],
  3553. "number" => $v["number"],
  3554. "c" => $v["c"],
  3555. "x" => $v["x"],
  3556. "t" => $v["t"],
  3557. "s" => $v["s"],
  3558. "q" => $v["q"],
  3559. "z" => $v["z"],
  3560. "weight" => $v['weight'],
  3561. ];
  3562. }
  3563. $title = "总进销存统计表";
  3564. $titlename = "<table border=1>
  3565. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3566. <tr align='center'>
  3567. <td>仓库</td>
  3568. <td>供应商</td>
  3569. <td>位置</td>
  3570. <td>库存编码</td>
  3571. <td>类目</td>
  3572. <td>SKU</td>
  3573. <td>用友编码</td>
  3574. <td>用友料号</td>
  3575. <td>商品名称</td>
  3576. <td>商品中文</td>
  3577. <td>产品备注</td>
  3578. <td>说明</td>
  3579. <td>类型</td>
  3580. <td>入库总量</td>
  3581. <td>库存数量</td>
  3582. <td>销售数量</td>
  3583. <td>退货数量</td>
  3584. <td>删除数量</td>
  3585. <td>其它操作</td>
  3586. <td>占单数量</td>
  3587. <td>重量(g)</td>
  3588. </tr>
  3589. </table>";
  3590. $filename = $title . ".xls";
  3591. $tail = "";
  3592. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3593. }
  3594. }
  3595. //入库导出
  3596. public function _excelr()
  3597. {
  3598. if (isset($_GET['excel'])) {
  3599. $category = $this->input->get('category', true);
  3600. $size = $this->input->get('size', true);
  3601. $grade = $this->input->get('grade', true);
  3602. $color = $this->input->get('color', true);
  3603. $lowe = $this->input->get('lowe', true);
  3604. $sku = $this->input->get('sku', true);
  3605. $warehouse = $this->input->get('warehouse', true);
  3606. $purchase = $this->input->get('purchase', true);
  3607. $ktime = $this->input->get('ktime', true);
  3608. $jtime = $this->input->get('jtime', true);
  3609. $ktime = strtotime($ktime);
  3610. $jtime = strtotime($jtime);
  3611. $where = "1=1";
  3612. $gj = "";
  3613. $ck = "";
  3614. if ($category) {
  3615. $where .= " and features like '%-$category-%'";
  3616. }
  3617. if ($size) {
  3618. $where .= " and features like '%-$size-%'";
  3619. }
  3620. if ($grade) {
  3621. $where .= " and features like '%-$grade-%'";
  3622. }
  3623. if ($color) {
  3624. $where .= " and features like '%-$color-%'";
  3625. }
  3626. if ($lowe) {
  3627. $where .= " and features like '%-$lowe-%'";
  3628. }
  3629. if ($warehouse) {
  3630. $where .= " and warehouse = '$warehouse'";
  3631. }
  3632. if ($purchase) {
  3633. $where .= " and purchase = '$purchase'";
  3634. }
  3635. if ($sku) {
  3636. $where .= " and sku = '$sku'";
  3637. }
  3638. if ($ktime && $jtime) {
  3639. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3640. }
  3641. //数据排序
  3642. $order_str = "id desc";
  3643. if (empty($page)) {
  3644. $start = 0;
  3645. $perpage = 1;
  3646. } else {
  3647. $start = ($page - 1) * $perpage;
  3648. }
  3649. $list = array();
  3650. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3651. foreach ($rows as $value) {
  3652. $ck = $this->warehouse->read($value['warehouse']);
  3653. $warehouse = $ck['title'];
  3654. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3655. $retreatwarehouse = $tkck['title'];
  3656. $gy = $this->purchase->read($value['purchase']);
  3657. $purchase = $gy['title'];
  3658. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3659. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3660. }
  3661. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3662. $titlename = "<table border=1>
  3663. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3664. <tr align='center'>
  3665. <td>仓库</td>
  3666. <td>SKU</td>
  3667. <td>产品</td>
  3668. <td>时间</td>
  3669. <td>数量</td>
  3670. </tr>
  3671. </table>";
  3672. $filename = $title . ".xls";
  3673. $tail = "";
  3674. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3675. }
  3676. }
  3677. //出库、退库导出
  3678. public function _excelct()
  3679. {
  3680. $classid = $this->classid->sku();
  3681. $pm = $classid;
  3682. $typeclass = array();
  3683. $tc = $this->typeclass->find_all();
  3684. foreach ($tc as $v) {
  3685. $typeclass[$v['id']] = $v;
  3686. }
  3687. $prc = array();
  3688. $purchase = $this->purchase->find_all();
  3689. foreach ($purchase as $k => $v) {
  3690. $prc[$v['id']] = $v['title'];
  3691. }
  3692. if (isset($_GET['excel'])) {
  3693. $wh = array();
  3694. $w = $this->warehouse->find_all('1=1', 'id,title');
  3695. foreach ($w as $v) {
  3696. $wh[$v['id']] = $v['title'];
  3697. }
  3698. $type = $this->input->get('excel', true);
  3699. $category = $this->input->get('category', true);
  3700. $size = $this->input->get('size', true);
  3701. $grade = $this->input->get('grade', true);
  3702. $color = $this->input->get('color', true);
  3703. $lowe = $this->input->get('lowe', true);
  3704. $sku = $this->input->get('sku', true);
  3705. $title = $this->input->get('title', true);
  3706. $warehouse = $this->input->get('warehouse', true);
  3707. $purchase = $this->input->get('purchase', true);
  3708. $lacetype = $this->input->get('lacetype', true);
  3709. $haircap = $this->input->get('haircap', true);
  3710. $lacecolor = $this->input->get('lacecolor', true);
  3711. $density = $this->input->get('density', true);
  3712. $details = $this->input->get('details', true);
  3713. $state = $this->input->get('state', true);
  3714. $shop = $this->input->get('shop', true);
  3715. $hairnumber = $this->input->get('hairnumber', true);
  3716. $type_leixi = $this->input->get('type', true);
  3717. $cpbz = $this->input->get('cpbz', true);
  3718. $sm = $this->input->get('sm', true);
  3719. $sid = $this->input->get('sid', true);
  3720. $ktime = $this->input->get('ktime', true);
  3721. $jtime = $this->input->get('jtime', true);
  3722. $ktime = strtotime($ktime);
  3723. $jtime = strtotime($jtime);
  3724. //$where = " 1=1 ";
  3725. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3726. $where = " sku != '' ";
  3727. $gj = "";
  3728. $ck = "";
  3729. if ($category) {
  3730. $where .= " and features like '%-$category-%'";
  3731. }
  3732. if ($size) {
  3733. $where .= " and features like '%-$size-%'";
  3734. }
  3735. if ($grade) {
  3736. $where .= " and features like '%-$grade-%'";
  3737. }
  3738. if ($color) {
  3739. $where .= " and features like '%-$color-%'";
  3740. }
  3741. if ($lowe) {
  3742. $where .= " and features like '%-$lowe-%'";
  3743. }
  3744. if ($warehouse) {
  3745. $where .= " and warehouse = '$warehouse'";
  3746. }
  3747. if ($purchase) {
  3748. $where .= " and purchase = '$purchase'";
  3749. }
  3750. if ($state) {
  3751. $where .= " and state = '$state'";
  3752. }
  3753. if ($lacetype) {
  3754. $where .= " and features like '%-$lacetype-%'";
  3755. }
  3756. if ($lacecolor) {
  3757. $where .= " and features like '%-$lacecolor-%'";
  3758. }
  3759. if ($density) {
  3760. $where .= " and features like '%-$density-%'";
  3761. }
  3762. if ($haircap) {
  3763. $where .= " and features like '%-$haircap-%'";
  3764. }
  3765. if ($details) {
  3766. $where .= " and details = '$details'";
  3767. }
  3768. if ($shop) {
  3769. $where .= " and shop like '%$shop%'";
  3770. }
  3771. if ($title) {
  3772. $title = trim($title, ' ');
  3773. $title = trim($title, ' ');
  3774. $where .= " and title like '%$title%'";
  3775. }
  3776. if (!empty($hairnumber)) {
  3777. $where .= " and features like '%-128-%' ";
  3778. if ($hairnumber < 0) {
  3779. $class_list = $this->typeclass->find_all('classid = 43');
  3780. foreach ($class_list as $v) {
  3781. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3782. }
  3783. } else {
  3784. $where .= " and features like '%-$hairnumber-%'";
  3785. }
  3786. }
  3787. if ($type_leixi) {
  3788. $where .= " and type = '$type_leixi'";
  3789. }
  3790. if ($cpbz) {
  3791. $where .= " and cpbz like '%$cpbz%' ";
  3792. }
  3793. if ($sm) {
  3794. $where .= " and sm like '%$sm%' ";
  3795. }
  3796. if ($sku) {
  3797. $sku = trim($sku, ' ');
  3798. $sku = trim($sku, ' ');
  3799. $where .= " and sku like '%$sku%'";
  3800. }
  3801. if ($ktime && $jtime) {
  3802. if ($type == 1) {
  3803. $tl = '出库';
  3804. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3805. } else if ($type == 2) {
  3806. $tl = '退库';
  3807. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3808. } else if ($type == 3) {
  3809. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3810. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3811. } else if ($type == 4) {
  3812. $tl = '出库+零售';
  3813. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3814. } else if ($type == 5) {
  3815. $tl = '零售';
  3816. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3817. }
  3818. }
  3819. $sidwhere = '';
  3820. if ($sid) {
  3821. $sd = "";
  3822. $s = explode(',', trim($sid, ','));
  3823. foreach ($s as $value) {
  3824. $sd .= " id = " . $value . " or";
  3825. }
  3826. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3827. }
  3828. //数据排序
  3829. $order_str = "time desc";
  3830. if (empty($page)) {
  3831. $start = 0;
  3832. $perpage = 1;
  3833. } else {
  3834. $start = ($page - 1) * $perpage;
  3835. }
  3836. //取得信息列表
  3837. if ($type != 3 && $type != 5) {
  3838. if ($type == 1 || $type == 4) {
  3839. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3840. foreach ($info_list as $key => $value) {
  3841. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3842. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3843. $warehouse = $this->warehouse->read($value['warehouse']);
  3844. $info_list[$key]['warehouse'] = $warehouse['title'];
  3845. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3846. $features = explode('-', trim($features, '-'));
  3847. $pm = $classid;
  3848. foreach ($features as $k => $v) {
  3849. if ($v != 0) {
  3850. if (!isset($typeclass[$v])) {
  3851. continue;
  3852. }
  3853. if (isset($pm[$typeclass[$v]['classid']])) {
  3854. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3855. $tz = explode('|', $typeclass[$v]['zh']);
  3856. $pm[$typeclass[$v]['classid']] = $tz[0];
  3857. } else {
  3858. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3859. }
  3860. }
  3861. }
  3862. }
  3863. $zh = implode(" ", $pm);
  3864. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3865. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3866. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3867. $info_list[$key]['features'] = $zh;
  3868. }
  3869. $final_list = [];
  3870. foreach($info_list as $k=>$v){
  3871. $number = "";
  3872. if(!empty($v['orderinfo'])){
  3873. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3874. if(!empty($tmp_info['number'])){
  3875. $number = $tmp_info['number'];
  3876. }
  3877. }
  3878. $final_list[] = [
  3879. 'warehouse'=>$v['warehouse'],
  3880. 'purchase'=>$v['purchase'],
  3881. 'sku'=>$v['sku'],
  3882. 'title'=>$v['title'],
  3883. 'features'=>$v['features'],
  3884. 'label'=>$v['label'],
  3885. 'orderinfo'=>$v['orderinfo'],
  3886. 'number'=>$number,
  3887. 'waybill'=>$v['waybill'],
  3888. 'outk'=>$v['outk'],
  3889. ];
  3890. }
  3891. } else {
  3892. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3893. foreach ($info_list as $key => $value) {
  3894. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3895. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3896. $warehouse = $this->warehouse->read($value['warehouse']);
  3897. $info_list[$key]['warehouse'] = $warehouse['title'];
  3898. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3899. $features = explode('-', trim($features, '-'));
  3900. $pm = $classid;
  3901. foreach ($features as $k => $v) {
  3902. if ($v != 0) {
  3903. if (!isset($typeclass[$v])) {
  3904. continue;
  3905. }
  3906. if (isset($pm[$typeclass[$v]['classid']])) {
  3907. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3908. $tz = explode('|', $typeclass[$v]['zh']);
  3909. $pm[$typeclass[$v]['classid']] = $tz[0];
  3910. } else {
  3911. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3912. }
  3913. }
  3914. }
  3915. }
  3916. $zh = implode(" ", $pm);
  3917. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3918. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3919. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3920. $info_list[$key]['features'] = $zh;
  3921. }
  3922. $final_list = [];
  3923. foreach($info_list as $k=>$v){
  3924. $number = "";
  3925. if(!empty($v['orderinfo'])){
  3926. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3927. if(!empty($tmp_info['number'])){
  3928. $number = $tmp_info['number'];
  3929. }
  3930. }
  3931. $final_list[] = [
  3932. 'warehouse'=>$v['warehouse'],
  3933. 'purchase'=>$v['purchase'],
  3934. 'sku'=>$v['sku'],
  3935. 'title'=>$v['title'],
  3936. 'features'=>$v['features'],
  3937. 'label'=>$v['label'],
  3938. 'orderinfo'=>$v['orderinfo'],
  3939. 'number'=>$number,
  3940. 'waybill'=>$v['waybill'],
  3941. 'retreat'=>$v['retreat'],
  3942. ];
  3943. }
  3944. }
  3945. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3946. $titlename = "<table border=1>
  3947. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3948. <tr align='center'>
  3949. <td>仓库</td>
  3950. <td>供应商</td>
  3951. <td>SKU</td>
  3952. <td>商品名称</td>
  3953. <td>商品中文</td>
  3954. <td>标签</td>
  3955. <td>订单号</td>
  3956. <td>订单编码</td>
  3957. <td>运单号</td>
  3958. <td>" . $tl . "时间(中国时间)</td>
  3959. </tr>
  3960. </table>";
  3961. $filename = $title . ".xls";
  3962. $tail = "";
  3963. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3964. } else if ($type == 5) {
  3965. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3966. foreach ($info_list as $key => $value) {
  3967. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3968. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3969. $warehouse = $this->warehouse->read($value['warehouse']);
  3970. $info_list[$key]['warehouse'] = $warehouse['title'];
  3971. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3972. $features = explode('-', trim($features, '-'));
  3973. $pm = $classid;
  3974. foreach ($features as $k => $v) {
  3975. if ($v != 0) {
  3976. if (!isset($typeclass[$v])) {
  3977. continue;
  3978. }
  3979. if (isset($pm[$typeclass[$v]['classid']])) {
  3980. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3981. $tz = explode('|', $typeclass[$v]['zh']);
  3982. $pm[$typeclass[$v]['classid']] = $tz[0];
  3983. } else {
  3984. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3985. }
  3986. }
  3987. }
  3988. }
  3989. $zh = implode(" ", $pm);
  3990. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3991. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3992. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3993. $info_list[$key]['features'] = $zh;
  3994. }
  3995. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3996. $titlename = "<table border=1>
  3997. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3998. <tr align='center'>
  3999. <td>仓库</td>
  4000. <td>供应商</td>
  4001. <td>SKU</td>
  4002. <td>商品名称</td>
  4003. <td>商品中文</td>
  4004. <td>标签</td>
  4005. <td>" . $tl . "时间(中国时间)</td>
  4006. </tr>
  4007. </table>";
  4008. $filename = $title . ".xls";
  4009. $tail = "";
  4010. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4011. } else {
  4012. /**
  4013. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4014. $rows = array();$list = array();
  4015. foreach ($info_list as $key=>$value)
  4016. {
  4017. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4018. }
  4019. **/
  4020. $wh = array();
  4021. $w = $this->warehouse->find_all('1=1', 'id,title');
  4022. foreach ($w as $v) {
  4023. $wh[$v['id']] = $v['title'];
  4024. }
  4025. $wt = array();
  4026. $whlabel_type = $this->whlabel_type->find_all();
  4027. foreach ($whlabel_type as $v) {
  4028. $wt[$v['id']] = $v['title'];
  4029. }
  4030. $classid = $this->classid->sku();
  4031. $list = array();
  4032. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4033. foreach ($rows as $key => $value) {
  4034. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4035. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4036. $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');
  4037. $details = array();
  4038. $cpid = array();
  4039. $cpbz = array();
  4040. $c = 0;
  4041. $g = 0;
  4042. $x = 0;
  4043. $t = 0;
  4044. $s = 0;
  4045. $q = 0;
  4046. foreach ($sd as $k => $v) {
  4047. if ($v['state'] == 0) {
  4048. $c++;
  4049. }
  4050. if ($v['state'] != 9) {
  4051. $g++;
  4052. }
  4053. if ($v['outk'] > 1) {
  4054. $x++;
  4055. }
  4056. if ($v['retreat'] > 0) {
  4057. $t++;
  4058. }
  4059. if ($v['state'] == 8) {
  4060. $s++;
  4061. }
  4062. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4063. $q++;
  4064. }
  4065. $details[$v['details']] = $v['details'];
  4066. if ($v['cpid'] != 0) {
  4067. $cpid[$v['cpid']] = $v['cpid'];
  4068. }
  4069. if ($v['cpbz'] != '') {
  4070. $cpbz[$v['cpbz']] = $v['cpbz'];
  4071. }
  4072. }
  4073. if (isset($wt[$value['type']])) {
  4074. $rows[$key]['type'] = $wt[$value['type']];
  4075. } else {
  4076. $rows[$key]['type'] = '未设置';
  4077. }
  4078. $rows[$key]['details'] = implode("、", $details);
  4079. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4080. $ftime = time() - 15 * 24 * 3600;
  4081. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4082. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4083. $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);
  4084. $rows[$key]['c'] = $c;
  4085. $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);
  4086. $rows[$key]['t'] = $t;
  4087. $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'] . '"');
  4088. $rows[$key]['z'] = $z;
  4089. // $jm = $classid;
  4090. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4091. $features = explode('-', trim($features, '-'));
  4092. // $pm = $classid;
  4093. // foreach ($features as $k => $v) {
  4094. // if ($v != 0) {
  4095. // if (!isset($typeclass[$v])) {
  4096. // continue;
  4097. // }
  4098. // if (isset($pm[$typeclass[$v]['classid']])) {
  4099. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4100. // $tz = explode('|', $typeclass[$v]['zh']);
  4101. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4102. // } else {
  4103. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4104. // }
  4105. // if (isset($jm[$typeclass[$v]['classid']])) {
  4106. // if ($typeclass[$v]['jm']) {
  4107. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4108. // }
  4109. // }
  4110. // }
  4111. // }
  4112. // }
  4113. // $zh = implode(" ", $pm);
  4114. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4115. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4116. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4117. // $rows[$key]['features'] = $zh;
  4118. // $jm = array_filter($jm); //去除空值
  4119. // $jm = implode("-", $jm);
  4120. // $rows[$key]['jm'] = $jm;
  4121. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4122. }
  4123. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4124. // echo "<pre>";
  4125. // print_r($tmp_list);
  4126. // die;
  4127. $final_list =[];
  4128. foreach($tmp_list as $k=>$v){
  4129. $final_list[] = [
  4130. "warehouse"=>$v['warehouse'],
  4131. "purchase"=>$v['purchase'],
  4132. "details"=>$v['details'],
  4133. "cpid"=>$v['cpid'],
  4134. "sku"=>$v['sku'],
  4135. "title"=>$v['title'],
  4136. "features"=>$v['pm'],
  4137. "cpbz"=>$v['cpbz'],
  4138. "sm"=>$v['sm'],
  4139. "type"=>$v['type'],
  4140. "g"=>$v["g"],
  4141. "c"=>$v["c"],
  4142. "x"=>$v["x"],
  4143. "t"=>$v["t"],
  4144. "z"=>$v["z"],
  4145. "jm"=>$v["jm"],
  4146. "weight"=>$v["weight"],
  4147. "asd"=>$v["asd"],
  4148. ];
  4149. }
  4150. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4151. $titlename = "<table border=1>
  4152. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4153. <tr align='center'>
  4154. <td>仓库</td>
  4155. <td>供应商</td>
  4156. <td>位置</td>
  4157. <td>库存编码</td>
  4158. <td>SKU</td>
  4159. <td>商品名称</td>
  4160. <td>商品中文</td>
  4161. <td>产品备注</td>
  4162. <td>说明</td>
  4163. <td>类型</td>
  4164. <td>入库总量</td>
  4165. <td>库存数量</td>
  4166. <td>销售数量</td>
  4167. <td>退货数量</td>
  4168. <td>占单数量</td>
  4169. <td>料号</td>
  4170. <td>重量</td>
  4171. <td>类目</td>
  4172. </tr>
  4173. </table>";
  4174. $filename = $title . ".xls";
  4175. $tail = "";
  4176. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4177. }
  4178. }
  4179. }
  4180. //出库+入库数据整合
  4181. public function _excelcr()
  4182. {
  4183. if (isset($_GET['excel'])) {
  4184. $type = $this->input->get('excel', true);
  4185. $category = $this->input->get('category', true);
  4186. $size = $this->input->get('size', true);
  4187. $grade = $this->input->get('grade', true);
  4188. $color = $this->input->get('color', true);
  4189. $lowe = $this->input->get('lowe', true);
  4190. $sku = $this->input->get('sku', true);
  4191. $warehouse = $this->input->get('warehouse', true);
  4192. $purchase = $this->input->get('purchase', true);
  4193. $state = $this->input->get('state', true);
  4194. $sid = $this->input->get('sid', true);
  4195. $ktime = $this->input->get('ktime', true);
  4196. $jtime = $this->input->get('jtime', true);
  4197. $ktime = strtotime($ktime);
  4198. $jtime = strtotime($jtime);
  4199. $where = "1=1";
  4200. $gj = "";
  4201. $ck = "";
  4202. if ($category) {
  4203. $where .= " and features like '%-$category-%'";
  4204. }
  4205. if ($size) {
  4206. $where .= " and features like '%-$size-%'";
  4207. }
  4208. if ($grade) {
  4209. $where .= " and features like '%-$grade-%'";
  4210. }
  4211. if ($color) {
  4212. $where .= " and features like '%-$color-%'";
  4213. }
  4214. if ($lowe) {
  4215. $where .= " and features like '%-$lowe-%'";
  4216. }
  4217. if ($warehouse) {
  4218. $where .= " and warehouse = '$warehouse'";
  4219. }
  4220. if ($purchase) {
  4221. $where .= " and purchase = '$purchase'";
  4222. }
  4223. if ($state) {
  4224. $where .= " and state = '$state'";
  4225. }
  4226. if ($sku) {
  4227. $where .= " and sku like '%$sku%'";
  4228. }
  4229. if ($ktime && $jtime) {
  4230. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4231. }
  4232. $sidwhere = '';
  4233. if ($sid) {
  4234. $sd = "";
  4235. $s = explode(',', trim($sid, ','));
  4236. foreach ($s as $value) {
  4237. $sd .= " id = " . $value . " or";
  4238. }
  4239. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4240. }
  4241. //取得信息列表
  4242. $timeread = $ktime;
  4243. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4244. $timelist = array();
  4245. for ($i = 0; $i < $timenum; $i++) {
  4246. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4247. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4248. }
  4249. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4250. //echo "<pre>";
  4251. //print_r($info_list);
  4252. //exit();
  4253. $rows = array();
  4254. $list = array();
  4255. foreach ($info_list as $key => $value) {
  4256. $thistime = $timelist;
  4257. if (isset($rows[strtolower($value['sku'])])) {
  4258. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4259. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4260. }
  4261. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4262. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4263. }
  4264. } else {
  4265. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4266. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4267. }
  4268. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4269. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4270. }
  4271. $rows[strtolower($value['sku'])] = $thistime;
  4272. }
  4273. }
  4274. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4275. <head>
  4276. <!--[if gte mso 9]><xml>
  4277. <x:ExcelWorkbook>
  4278. <x:ExcelWorksheets>
  4279. <x:ExcelWorksheet>
  4280. <x:Name>EXCEL</x:Name>
  4281. <x:WorksheetOptions>
  4282. <x:Print>
  4283. <x:ValidPrinterInfo />
  4284. </x:Print>
  4285. </x:WorksheetOptions>
  4286. </x:ExcelWorksheet>
  4287. </x:ExcelWorksheets>
  4288. </x:ExcelWorkbook>
  4289. </xml>
  4290. <![endif]-->
  4291. </head><body>";
  4292. $str .= "<table border=1><tr><td>SKU</td>";
  4293. foreach ($timelist as $k => $v) {
  4294. $str .= "<td>" . $k . "出库</td>";
  4295. $str .= "<td>" . $k . "入库</td>";
  4296. }
  4297. $str .= "</tr></table>";
  4298. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4299. foreach ($rows as $key => $val) {
  4300. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4301. foreach ($val as $k => $v) {
  4302. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4303. if ($val[$k]['r'] > 0) {
  4304. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4305. } else {
  4306. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4307. }
  4308. }
  4309. $str .= "</tr>";
  4310. }
  4311. $str .= "</table>";
  4312. $str .= "</body></html>";
  4313. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4314. header("Content-type: application/octet-stream");
  4315. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4316. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4317. header("Pragma: no-cache");
  4318. header("Expires: 0");
  4319. exit($str);
  4320. }
  4321. }
  4322. //数量调整模板导出
  4323. public function _presetout()
  4324. {
  4325. if (isset($_GET['excel'])) {
  4326. $where = "sku != 'Preset' and purchase != 0";
  4327. //数据排序
  4328. $order_str = "id desc";
  4329. if (empty($page)) {
  4330. $start = 0;
  4331. $perpage = 1;
  4332. } else {
  4333. $start = ($page - 1) * $perpage;
  4334. }
  4335. //取得信息列表
  4336. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4337. $rows = array();
  4338. $list = array();
  4339. foreach ($info_list as $value) {
  4340. $warehouse = $this->warehouse->read($value['warehouse']);
  4341. $number = $value['number'];
  4342. $ftime = time() - 15 * 24 * 3600;
  4343. $purchase = $this->purchase->read($value['purchase']);
  4344. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4345. }
  4346. $title = "库存模板";
  4347. $titlename = "<table border=1>
  4348. <tr align='center'>
  4349. <td>仓库</td>
  4350. <td>供应商编码</td>
  4351. <td>SKU</td>
  4352. <td>增减数量(正数或负数)</td>
  4353. <td>增减备注</td>
  4354. <td>扣减方式:0减少库存1删除库存</td>
  4355. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4356. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4357. </tr>
  4358. </table>";
  4359. $filename = $title . ".xls";
  4360. $tail = "";
  4361. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4362. }
  4363. }
  4364. //数量调整模板导入
  4365. public function _presetedit()
  4366. {
  4367. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4368. $config['upload_path'] = '.' . $dir;
  4369. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4370. $config['allowed_types'] = 'xls|xlsx|csv';
  4371. $config['max_size'] = 10240;
  4372. $this->load->library('upload', $config);
  4373. $this->upload->initialize($config);
  4374. if ($this->upload->do_upload('userfile')) {
  4375. $full_path = $dir . $this->upload->data('file_name');
  4376. $fileName = '.' . $full_path;
  4377. if (!file_exists($fileName)) {
  4378. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4379. exit;
  4380. } else {
  4381. require_once "./data/excel/PHPExcel/IOFactory.php";
  4382. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4383. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4384. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4385. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4386. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4387. ++$column; //如果列数大于26行
  4388. $list = array();
  4389. for ($i = 2; $i <= $row; $i++) // 行数循环
  4390. {
  4391. $data = array();
  4392. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4393. {
  4394. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4395. }
  4396. $list[] = $data;
  4397. }
  4398. }
  4399. $i = 0;
  4400. $j = 0;
  4401. $ed = array();
  4402. foreach ($list as $key => $value) {
  4403. $time = time();
  4404. if ($value['0'] == "") {
  4405. continue;
  4406. }
  4407. $warehouse = $this->warehouse->get_title($value['0']);
  4408. $purchase = $this->purchase->get_bm($value['1']);
  4409. $sku = $value['2'];
  4410. $num = $value['3']; //调整数量
  4411. $text = $value['4']; //扣减说明
  4412. $type = $value['5']; //调整方式0扣减1删除
  4413. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4414. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4415. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4416. if (!$purchase) //如果没有这个SKU
  4417. {
  4418. $ed[] = array($purchase . '-不存在此供应商编码');
  4419. $j++;
  4420. continue;
  4421. }
  4422. if (!$d) //如果没有这个SKU
  4423. {
  4424. $ed[] = array($sku . '-库存中不存在此SKU');
  4425. $j++;
  4426. continue;
  4427. }
  4428. if (!isset($warehouse['id'])) {
  4429. $ed[] = array($sku . '-仓库名错误!');
  4430. $j++;
  4431. continue;
  4432. }
  4433. if ($type != '0' && $type != '1') {
  4434. $ed[] = array($sku . '-扣减方式填写错误!');
  4435. $j++;
  4436. continue;
  4437. }
  4438. if ($num < 0) //扣减库存
  4439. {
  4440. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4441. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4442. $j++;
  4443. continue;
  4444. }
  4445. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4446. if (count($data) < abs($num)) {
  4447. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4448. $j++;
  4449. continue;
  4450. }
  4451. if ($type == 0) //如果扣减方式为 扣减库存
  4452. {
  4453. for ($i = 0; $i < abs($num); $i++) {
  4454. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4455. }
  4456. } else if ($type == 1) {
  4457. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4458. if (count($zt) > 0) {
  4459. $ed[] = array($sku . '-有在途库存无法删除!');
  4460. $j++;
  4461. continue;
  4462. }
  4463. for ($i = 0; $i < abs($num); $i++) {
  4464. $this->whlabel->remove($data[$i]['id']);
  4465. }
  4466. }
  4467. } else if ($num > 0) //增加库存
  4468. {
  4469. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4470. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4471. $j++;
  4472. continue;
  4473. }
  4474. $post['sku'] = $d['sku'];
  4475. $post['shop'] = $d['shop'];
  4476. $post['warehouse'] = $warehouse['id'];
  4477. $post['purchase'] = $purchase['id'];
  4478. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4479. $post['state'] = 0;
  4480. $post['title'] = $d['title'];
  4481. $post['number'] = $d['number'];
  4482. $post['features'] = $d['features'];
  4483. $post['enter'] = $time;
  4484. $post['time'] = $time; //操作时间
  4485. $post['rktype'] = $rktype;
  4486. for ($i = 0; $i < $num; $i++) {
  4487. $post['label'] = time() . rand(100, 999) . $i;
  4488. $this->whlabel->insert($post);
  4489. }
  4490. }
  4491. sleep(1); //防止入库时间一样,需要延迟1秒
  4492. }
  4493. if ($j > 0) {
  4494. $tt = date('Ymd', time());
  4495. $title = '库存导入错误信息-' . $tt;
  4496. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4497. $tail = "\n";
  4498. $filename = $title . ".xls";
  4499. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4500. $dir = '/data/excel/' . $time . '/';
  4501. $file_name = 'error_' . $time . rand(1000, 9999);
  4502. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4503. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4504. fwrite($myfile, $ecl);
  4505. fclose($myfile);
  4506. $error = $dir . $file_name . '.xls';
  4507. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4508. exit;
  4509. } else {
  4510. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4511. exit;
  4512. }
  4513. }
  4514. }
  4515. //笛卡儿积
  4516. function cp($ps, $sets, $list)
  4517. {
  4518. $result = array();
  4519. $j = 0;
  4520. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4521. if ($i == 0) {
  4522. $result = $sets[$i];
  4523. }
  4524. $tmp = array();
  4525. foreach ($result as $res) {
  4526. foreach ($sets[$i + 1] as $set) {
  4527. $tmp[] = $res . ',' . $set;
  4528. }
  4529. }
  4530. $result = $tmp;
  4531. }
  4532. $this->db->trans_begin();
  4533. foreach ($result as $v) {
  4534. $post = array();
  4535. $title = "";
  4536. $num = "";
  4537. $data = explode(',', $v);
  4538. for ($i = 0; $i < count($list); $i++) {
  4539. $post[$list[$i]] = $data[$i];
  4540. $typeclass = $this->typeclass->read($data[$i]);
  4541. $title = $title . $typeclass['title'] . " ";
  4542. if ($data[$i] != 0) {
  4543. $num .= $data[$i]; //所有数据ID拼接
  4544. }
  4545. }
  4546. foreach ($ps as $kp => $vp) {
  4547. $post[$kp] = $vp;
  4548. }
  4549. $post['number'] = $num;
  4550. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4551. if ($info_list) {
  4552. $j++;
  4553. } else {
  4554. $skunum = $this->whlabel->find_count();
  4555. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4556. $post['title'] = rtrim($title, ' ');
  4557. $this->whlabel->insert($post);
  4558. }
  4559. }
  4560. if ($this->db->trans_status() === FALSE) {
  4561. $this->db->trans_commit();
  4562. return NULL;
  4563. } else {
  4564. $this->db->trans_commit();
  4565. return $j;
  4566. }
  4567. }
  4568. public function _kj($arg_array)
  4569. {
  4570. if (isset($_POST['sku'])) {
  4571. $time = time();
  4572. $sku = $this->input->post('sku', true);
  4573. $warehouse = $this->input->post('warehouse', true);
  4574. $num = $this->input->post('num', true);
  4575. $text = $this->input->post('text', true);
  4576. $purchase = $this->input->post('purchase', true);
  4577. $cktype = $this->input->post('cktype', true);
  4578. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4579. if ($cktype != 1 && $text == '') {
  4580. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4581. exit;
  4582. }
  4583. if ($num > count($order)) {
  4584. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4585. exit;
  4586. } else {
  4587. for ($i = 0; $i < $num; $i++) {
  4588. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4589. }
  4590. }
  4591. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4592. exit;
  4593. }
  4594. $uid = $this->whlabel->read($arg_array[0]);
  4595. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4596. $this->data['data'] = $uid;
  4597. $this->_Template('whlabel_kj', $this->data);
  4598. }
  4599. public function _summary($arg_array)
  4600. {
  4601. $prc = array();
  4602. $purchase = $this->purchase->find_all();
  4603. foreach ($purchase as $k => $v) {
  4604. $prc[$v['id']] = $v['title'];
  4605. }
  4606. if (isset($_GET['excel'])) {
  4607. $ktime = $this->input->get('ktime', true);
  4608. $jtime = $this->input->get('jtime', true);
  4609. $ktime = strtotime($ktime);
  4610. $jtime = strtotime($jtime);
  4611. $where = "1=1";
  4612. if ($ktime && $jtime) {
  4613. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4614. }
  4615. //数据排序
  4616. $order_str = "time desc";
  4617. if (empty($page)) {
  4618. $start = 0;
  4619. $perpage = 1;
  4620. } else {
  4621. $start = ($page - 1) * $perpage;
  4622. }
  4623. //取得信息列表
  4624. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4625. foreach ($info_list as $key => $value) {
  4626. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4627. $warehouse = $this->warehouse->read($value['warehouse']);
  4628. $info_list[$key]['warehouse'] = $warehouse['title'];
  4629. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4630. $details = array();
  4631. $cpid = array();
  4632. foreach ($x as $k => $v) {
  4633. if ($v['details'] != '') {
  4634. $details[$v['details']] = $v['details'];
  4635. }
  4636. if ($v['cpid'] != 0) {
  4637. $cpid[$v['cpid']] = $v['cpid'];
  4638. }
  4639. }
  4640. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4641. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4642. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4643. $info_list[$key]['s'] = $s;
  4644. $info_list[$key]['x'] = count($x);
  4645. }
  4646. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4647. $titlename = "<table border=1>
  4648. <tr align='center'>
  4649. <td>仓库</td>
  4650. <td>供应商</td>
  4651. <td>出库位置</td>
  4652. <td>出库编码</td>
  4653. <td>SKU</td>
  4654. <td>产品名</td>
  4655. <td>总剩余库存</td>
  4656. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4657. </tr>
  4658. </table>";
  4659. $filename = $title . ".xls";
  4660. $tail = "";
  4661. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4662. }
  4663. }
  4664. //usps发货清单
  4665. public function _manifest()
  4666. {
  4667. if (isset($_POST['manifest'])) {
  4668. $wltext = $this->input->post('wltext', true);
  4669. $time = time() - 16 * 3600;
  4670. $ptime = strtotime(date('Y-m-d', $time));
  4671. $waybill = array();
  4672. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4673. foreach ($fullorder as $v) {
  4674. $waybill[$v['waybill']] = $v['waybill'];
  4675. }
  4676. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4677. foreach ($fullordersmt as $v) {
  4678. $waybill[$v['waybill']] = $v['waybill'];
  4679. }
  4680. $wltext = explode(';', $wltext);
  4681. foreach ($wltext as $v) {
  4682. if (isset($waybill[$v])) {
  4683. unset($waybill[$v]);
  4684. }
  4685. }
  4686. $data = $this->usps->get_manifest($waybill);
  4687. if (isset($data['Description'])) {
  4688. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4689. exit;
  4690. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4691. $bctime = date('Ymd', time());
  4692. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4693. echo json_encode(array('msg' => $pdf, 'success' => true));
  4694. exit;
  4695. } else {
  4696. echo json_encode(array('msg' => $data, 'success' => false));
  4697. exit;
  4698. }
  4699. }
  4700. }
  4701. public function _pdf($pdf, $title, $bctime)
  4702. {
  4703. $pdf_path = './data/pdf/' . $bctime . '/';
  4704. $file_base64 = $pdf;
  4705. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4706. $file_base64 = base64_decode($file_base64);
  4707. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4708. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4709. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4710. }
  4711. /**
  4712. *
  4713. *
  4714. *
  4715. 进销存占单异常索引
  4716. *
  4717. *
  4718. *
  4719. **/
  4720. public function _abnormal()
  4721. {
  4722. $post = $this->input->post(NULL, TRUE);
  4723. if (isset($post['page'])) {
  4724. $page = $this->input->post('page', true);
  4725. $perpage = $this->input->post('perpage', true);
  4726. $sku = $this->input->post('sku', true);
  4727. $where = "1=1";
  4728. //数据排序
  4729. $order_str = "id desc";
  4730. if (empty($page)) {
  4731. $start = 0;
  4732. $perpage = 1;
  4733. } else {
  4734. $start = ($page - 1) * $perpage;
  4735. }
  4736. //取得信息列表
  4737. $info_list = $this->whlabel->find_all($where, '*');
  4738. $rows = array();
  4739. $list = array();
  4740. foreach ($info_list as $key => $value) {
  4741. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4742. }
  4743. foreach ($rows as $value) {
  4744. $warehouse = $this->warehouse->read($value['warehouse']);
  4745. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4746. $number = $value['number'];
  4747. $ftime = time() - 15 * 24 * 3600;
  4748. if ($value['shop'] != '') {
  4749. $shop = $value['shop'];
  4750. $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');
  4751. $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');
  4752. $order = array_merge($orderdlz, $ordersmt);
  4753. $od = 0;
  4754. $a = '';
  4755. $orid = '';
  4756. foreach ($order as $v) {
  4757. $or = explode('|', ltrim($v['whlabel'], '|'));
  4758. for ($i = 0; $i < count($or); $i++) {
  4759. $orod = explode('-', $or[$i]);
  4760. if ($orod[0] == $number) {
  4761. $od += $orod[1];
  4762. }
  4763. }
  4764. $orid .= $v['number'] . '-';
  4765. }
  4766. } else {
  4767. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4768. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4769. $order = array_merge($orderdlz, $ordersmt);
  4770. $od = 0;
  4771. $a = '';
  4772. $orid = '';
  4773. $qt = array();
  4774. foreach ($order as $v) {
  4775. $or = explode('|', ltrim($v['whlabel'], '|'));
  4776. for ($i = 0; $i < count($or); $i++) {
  4777. $orod = explode('-', $or[$i]);
  4778. if ($orod[0] == $number) {
  4779. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4780. if ($czzs > 0) {
  4781. if (isset($qt[$v['shop']])) {
  4782. if ($qt[$v['shop']] < $orod[1]) {
  4783. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4784. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4785. } else {
  4786. $qt[$v['shop']] -= $orod[1];
  4787. }
  4788. } else {
  4789. $qt[$v['shop']] = $czzs;
  4790. }
  4791. } else {
  4792. $od += $orod[1];
  4793. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4794. }
  4795. }
  4796. }
  4797. }
  4798. }
  4799. $z = $od . '(' . $orid . ')'; //查看订单号
  4800. //$z = $od;
  4801. if ($od > $c) {
  4802. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4803. }
  4804. }
  4805. $listdata = array_slice($list, $start, $perpage);
  4806. $total = count($list);
  4807. $pagenum = ceil($total / $perpage);
  4808. $over = $total - ($start + $perpage);
  4809. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4810. echo json_encode($rows);
  4811. exit;
  4812. }
  4813. $this->_Template('whlabel_abnormal', $this->data);
  4814. }
  4815. /**
  4816. *
  4817. *
  4818. *
  4819. 进销存占单异常索引
  4820. *
  4821. *
  4822. *
  4823. **/
  4824. public function _error()
  4825. {
  4826. $post = $this->input->post(NULL, TRUE);
  4827. if (isset($post['page'])) {
  4828. $page = $this->input->post('page', true);
  4829. $perpage = $this->input->post('perpage', true);
  4830. $sku = $this->input->post('sku', true);
  4831. $warehouse = $this->input->post('warehouse', true);
  4832. $ktime = $this->input->post('ktime', true);
  4833. $jtime = $this->input->post('jtime', true);
  4834. $ktime = strtotime($ktime);
  4835. $jtime = strtotime($jtime);
  4836. $where = "sku != 'Preset'";
  4837. $gj = '';
  4838. if ($sku) {
  4839. $where .= " and sku like '%$sku%'";
  4840. } else {
  4841. if ($ktime && $jtime) {
  4842. $gj = " and time > '$ktime' and time < '$jtime'";
  4843. }
  4844. }
  4845. if ($warehouse) {
  4846. $where .= " and warehouse = '$warehouse'";
  4847. }
  4848. //数据排序
  4849. $order_str = "id desc";
  4850. if (empty($page)) {
  4851. $start = 0;
  4852. $perpage = 1;
  4853. } else {
  4854. $start = ($page - 1) * $perpage;
  4855. }
  4856. //取得信息列表
  4857. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4858. $rows = array();
  4859. $list = array();
  4860. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4861. // foreach ($info_list as $value)
  4862. // {
  4863. // $warehouse = $this->warehouse->read($value['warehouse']);
  4864. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4865. // $number = $value['number'];$ftime = time()-15*24*3600;
  4866. // if($c < 1)
  4867. // {
  4868. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4869. // }
  4870. // }
  4871. $warehouse_list = $this->warehouse->find_all();
  4872. $warehouse_list = array_column($warehouse_list, null, 'id');
  4873. foreach ($info_list as $value) {
  4874. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4875. 'title' => "",
  4876. ];
  4877. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4878. $number = $value['number'];
  4879. $ftime = time() - 15 * 24 * 3600;
  4880. if ($c < 1) {
  4881. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4882. }
  4883. }
  4884. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4885. // $query = $this->db->query($sql);
  4886. // $info_list = $query->result_array();
  4887. // $sql_two = "select title,id from crowd_warehouse";
  4888. // $query_two = $this->db->query($sql_two);
  4889. // $warehouse_list = $query_two->result_array();
  4890. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4891. // foreach ($info_list as $value)
  4892. // {
  4893. // if(isset($warehouse_arr[$value['warehouse']])){
  4894. // $warehouse = $warehouse_arr[$value['warehouse']];
  4895. // }else{
  4896. // $warehouse = [
  4897. // 'id'=>0,
  4898. // 'title'=>"异常",
  4899. // ];
  4900. // }
  4901. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4902. // $number = $value['number'];$ftime = time()-15*24*3600;
  4903. // if($c < 1)
  4904. // {
  4905. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4906. // }
  4907. // }
  4908. $listdata = array_slice($list, $start, $perpage);
  4909. $total = count($list);
  4910. $pagenum = ceil($total / $perpage);
  4911. $over = $total - ($start + $perpage);
  4912. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4913. echo json_encode($rows);
  4914. exit;
  4915. }
  4916. if (isset($post['s'])) {
  4917. $id_arr = $this->input->post('s');
  4918. $id_arr = explode(',', trim($id_arr, ','));
  4919. if (!$id_arr) {
  4920. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4921. exit;
  4922. }
  4923. //循环删除记录
  4924. foreach ($id_arr as $v) {
  4925. $dd = $this->whlabel->read($v);
  4926. if (!isset($dd['id'])) {
  4927. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4928. exit;
  4929. }
  4930. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4931. if (isset($zt[0])) {
  4932. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4933. exit;
  4934. }
  4935. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4936. foreach ($deldd as $vv) {
  4937. $this->whlabel->remove($vv['id']);
  4938. }
  4939. }
  4940. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4941. exit;
  4942. }
  4943. $this->_Template('whlabel_error', $this->data);
  4944. }
  4945. public function _errorexcel()
  4946. {
  4947. $post = $this->input->post(NULL, TRUE);
  4948. if (isset($_GET['page'])) {
  4949. $page = $this->input->get('page', true);
  4950. $perpage = $this->input->get('perpage', true);
  4951. $sku = $this->input->get('sku', true);
  4952. $warehouse = $this->input->get('warehouse', true);
  4953. $ktime = $this->input->get('ktime', true);
  4954. $jtime = $this->input->get('jtime', true);
  4955. $ktime = strtotime($ktime);
  4956. $jtime = strtotime($jtime);
  4957. $where = "sku != 'Preset'";
  4958. $gj = '';
  4959. if ($sku) {
  4960. $where .= " and sku like '%$sku%'";
  4961. } else {
  4962. if ($ktime && $jtime) {
  4963. $gj = " and time > '$ktime' and time < '$jtime'";
  4964. }
  4965. }
  4966. if ($warehouse) {
  4967. $where .= " and warehouse = '$warehouse'";
  4968. }
  4969. //数据排序
  4970. $order_str = "id desc";
  4971. if (empty($page)) {
  4972. $start = 0;
  4973. $perpage = 1;
  4974. } else {
  4975. $start = ($page - 1) * $perpage;
  4976. }
  4977. //取得信息列表
  4978. $rows = array();
  4979. $list = array();
  4980. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4981. foreach ($info_list as $value) {
  4982. $warehouse = $this->warehouse->read($value['warehouse']);
  4983. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4984. $number = $value['number'];
  4985. $ftime = time() - 15 * 24 * 3600;
  4986. if ($c < 1) {
  4987. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4988. }
  4989. }
  4990. $title = "0库存汇总";
  4991. $titlename = "<table border=1>
  4992. <tr align='center'>
  4993. <td>仓库</td>
  4994. <td>SKU</td>
  4995. <td>产品</td>
  4996. <td>当前库存</td>
  4997. </tr>
  4998. </table>";
  4999. $filename = $title . ".xls";
  5000. $tail = "";
  5001. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5002. }
  5003. }
  5004. /**
  5005. *
  5006. *
  5007. * 占单
  5008. *
  5009. *
  5010. **/
  5011. public function _kcyz()
  5012. {
  5013. $post = $this->input->post(NULL, TRUE);
  5014. if (isset($post['warehouse'])) {
  5015. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5016. exit; //不再使用
  5017. $warehouse = $this->input->post('warehouse', true);
  5018. $whlabel = $this->input->post('whlabel', true);
  5019. $id = $this->input->post('id', true);
  5020. $shop = $this->input->post('shop', true);
  5021. $number = $this->input->post('number', true);
  5022. if (!$whlabel || $whlabel == '|') {
  5023. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5024. exit;
  5025. }
  5026. $pp = explode('|', trim($whlabel, '|'));
  5027. $x = 0;
  5028. $save = array();
  5029. foreach ($pp as $va) {
  5030. $num = explode('-', $va);
  5031. if ($number) {
  5032. $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 = '')"); //通用
  5033. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5034. } else {
  5035. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5036. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5037. }
  5038. $x++;
  5039. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5040. $save[] = $x - 1;
  5041. continue; //提前先加X不然出错,所以要减1
  5042. }
  5043. }
  5044. if (isset($save[0])) {
  5045. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5046. exit;
  5047. } else {
  5048. echo json_encode(array('success' => true));
  5049. exit;
  5050. }
  5051. }
  5052. }
  5053. public function _db()
  5054. {
  5055. $post = $this->input->post(NULL, TRUE);
  5056. if (isset($post['page'])) {
  5057. $page = $this->input->post('page', true);
  5058. $perpage = $this->input->post('perpage', true);
  5059. $sku = $this->input->post('sku', true);
  5060. $number = $this->input->post('number', true);
  5061. $warehouse = $this->input->post('warehouse', true);
  5062. $purchase = $this->input->post('purchase', true);
  5063. $orderinfo = $this->input->post('orderinfo', true);
  5064. $waybill = $this->input->post('waybill', true);
  5065. $category = $this->input->post('category', true);
  5066. $size = $this->input->post('size', true);
  5067. $grade = $this->input->post('grade', true);
  5068. $color = $this->input->post('color', true);
  5069. $lowe = $this->input->post('lowe', true);
  5070. $state = $this->input->post('state', true);
  5071. $label = $this->input->post('label', true);
  5072. $timetk = $this->input->post('timetkk', true);
  5073. $timetj = $this->input->post('timetjj', true);
  5074. $timetk = strtotime($timetk);
  5075. $timetj = strtotime($timetj);
  5076. $where = "dbtime > 0";
  5077. if ($timetk && $timetj) {
  5078. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5079. }
  5080. if ($sku) {
  5081. $where .= " and sku = '$sku'";
  5082. }
  5083. if ($warehouse) {
  5084. $where .= " and warehouse = '$warehouse'";
  5085. if ($warehouse == 12) {
  5086. $w = 'specialstock';
  5087. } else {
  5088. $w = 'whlabel';
  5089. }
  5090. }
  5091. if ($purchase) {
  5092. $where .= " and purchase = '$purchase'";
  5093. }
  5094. if ($category) {
  5095. $where .= " and features like '%-$category-%'";
  5096. }
  5097. if ($size) {
  5098. $where .= " and features like '%-$size-%'";
  5099. }
  5100. if ($grade) {
  5101. $where .= " and features like '%-$grade-%'";
  5102. }
  5103. if ($color) {
  5104. $where .= " and features like '%-$color-%'";
  5105. }
  5106. if ($lowe) {
  5107. $where .= " and features like '%-$lowe-%'";
  5108. }
  5109. if ($state != '') {
  5110. $where .= " and state = '$state'";
  5111. }
  5112. //数据排序
  5113. $order_str = "dbtime desc";
  5114. if (empty($page)) {
  5115. $start = 0;
  5116. $perpage = 1;
  5117. } else {
  5118. $start = ($page - 1) * $perpage;
  5119. }
  5120. //取得信息列表
  5121. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5122. foreach ($info_list as $key => $value) {
  5123. $warehouse = $this->$w->read($value['warehouse']);
  5124. $info_list[$key]['warehouse'] = $warehouse['title'];
  5125. $purchase = $this->purchase->read($value['purchase']);
  5126. $info_list[$key]['purchase'] = $purchase['title'];
  5127. if ($value['enter'] != 0) {
  5128. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5129. } else {
  5130. $info_list[$key]['enter'] = "";
  5131. }
  5132. if ($value['dbtime'] != 0) {
  5133. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5134. } else {
  5135. $info_list[$key]['dbtime'] = "";
  5136. }
  5137. if ($value['state'] == 0) {
  5138. $info_list[$key]['state'] = "在库";
  5139. } else if ($value['state'] == 1) {
  5140. $info_list[$key]['state'] = "出库";
  5141. } else if ($value['state'] == 2) {
  5142. $info_list[$key]['state'] = "退库";
  5143. } else if ($value['state'] == 3) {
  5144. $info_list[$key]['state'] = "调拨中";
  5145. } else if ($value['state'] == 4) {
  5146. $info_list[$key]['state'] = "再加工";
  5147. } else if ($value['state'] == 5) {
  5148. $info_list[$key]['state'] = "维修中";
  5149. } else if ($value['state'] == 6) {
  5150. $info_list[$key]['state'] = "盘亏";
  5151. } else if ($value['state'] == 7) {
  5152. $info_list[$key]['state'] = "更换标签";
  5153. } else if ($value['state'] == 8) {
  5154. $info_list[$key]['state'] = "其它";
  5155. } else if ($value['state'] == 9) {
  5156. $info_list[$key]['state'] = "预设";
  5157. }
  5158. }
  5159. $total = $this->whlabel->find_count($where);
  5160. $pagenum = ceil($total / $perpage);
  5161. $over = $total - ($start + $perpage);
  5162. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5163. echo json_encode($rows);
  5164. exit;
  5165. }
  5166. if (isset($post['outsku'])) {
  5167. $time = time();
  5168. $cz = $this->input->post('cz', true);
  5169. $label = $this->input->post('outsku', true);
  5170. $sl = $this->input->post('sl', true);
  5171. $num = $this->input->post('num', true);
  5172. //$warehouse = $this->input->post('warehouse',true);
  5173. if (!$sl) {
  5174. $sl = 1;
  5175. }
  5176. if (!$warehouse) {
  5177. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5178. exit;
  5179. }
  5180. $dblabel = $this->whlabellabel->get_label($label);
  5181. if ($dblabel) {
  5182. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5183. if (count($data) < 1) {
  5184. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5185. exit;
  5186. }
  5187. if (count($data) < $num) {
  5188. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5189. exit;
  5190. }
  5191. for ($i = 0; $i < $sl; $i++) {
  5192. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5193. }
  5194. echo json_encode(array('success' => true));
  5195. exit;
  5196. } else {
  5197. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5198. exit;
  5199. }
  5200. }
  5201. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5202. $this->_Template('whlabel_db', $this->data);
  5203. }
  5204. public function _dbrk()
  5205. {
  5206. $post = $this->input->post(NULL, TRUE);
  5207. if (isset($post['page'])) {
  5208. $page = $this->input->post('page', true);
  5209. $perpage = $this->input->post('perpage', true);
  5210. $sku = $this->input->post('sku', true);
  5211. $number = $this->input->post('number', true);
  5212. $warehouse = $this->input->post('warehouse', true);
  5213. $purchase = $this->input->post('purchase', true);
  5214. $orderinfo = $this->input->post('orderinfo', true);
  5215. $waybill = $this->input->post('waybill', true);
  5216. $category = $this->input->post('category', true);
  5217. $size = $this->input->post('size', true);
  5218. $grade = $this->input->post('grade', true);
  5219. $color = $this->input->post('color', true);
  5220. $lowe = $this->input->post('lowe', true);
  5221. $state = $this->input->post('state', true);
  5222. $label = $this->input->post('label', true);
  5223. $ctime = $this->input->post('ctime', true);
  5224. $timetk = $this->input->post('timetkk', true);
  5225. $timetj = $this->input->post('timetjj', true);
  5226. $timetk = strtotime($timetk);
  5227. $timetj = strtotime($timetj);
  5228. $where = "dbtime > 0";
  5229. if ($timetk && $timetj) {
  5230. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5231. }
  5232. if ($sku) {
  5233. $where .= " and sku = '$sku'";
  5234. }
  5235. if ($warehouse) {
  5236. $where .= " and warehouse = '$warehouse'";
  5237. }
  5238. if ($purchase) {
  5239. $where .= " and purchase = '$purchase'";
  5240. }
  5241. if ($category) {
  5242. $where .= " and features like '%-$category-%'";
  5243. }
  5244. if ($size) {
  5245. $where .= " and features like '%-$size-%'";
  5246. }
  5247. if ($grade) {
  5248. $where .= " and features like '%-$grade-%'";
  5249. }
  5250. if ($color) {
  5251. $where .= " and features like '%-$color-%'";
  5252. }
  5253. if ($lowe) {
  5254. $where .= " and features like '%-$lowe-%'";
  5255. }
  5256. if ($state != '') {
  5257. $where .= " and state = '$state'";
  5258. }
  5259. //数据排序
  5260. $order_str = "dbtime desc";
  5261. if (empty($page)) {
  5262. $start = 0;
  5263. $perpage = 1;
  5264. } else {
  5265. $start = ($page - 1) * $perpage;
  5266. }
  5267. //取得信息列表
  5268. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5269. foreach ($info_list as $key => $value) {
  5270. $warehouse = $this->warehouse->read($value['warehouse']);
  5271. $info_list[$key]['warehouse'] = $warehouse['title'];
  5272. $purchase = $this->purchase->read($value['purchase']);
  5273. $info_list[$key]['purchase'] = $purchase['title'];
  5274. if ($value['enter'] != 0) {
  5275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5276. } else {
  5277. $info_list[$key]['enter'] = "";
  5278. }
  5279. if ($value['dbtime'] != 0) {
  5280. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5281. } else {
  5282. $info_list[$key]['dbtime'] = "";
  5283. }
  5284. if ($value['state'] == 0) {
  5285. $info_list[$key]['state'] = "在库";
  5286. } else if ($value['state'] == 1) {
  5287. $info_list[$key]['state'] = "出库";
  5288. } else if ($value['state'] == 2) {
  5289. $info_list[$key]['state'] = "退库";
  5290. } else if ($value['state'] == 3) {
  5291. $info_list[$key]['state'] = "调拨中";
  5292. } else if ($value['state'] == 4) {
  5293. $info_list[$key]['state'] = "再加工";
  5294. } else if ($value['state'] == 5) {
  5295. $info_list[$key]['state'] = "维修中";
  5296. } else if ($value['state'] == 6) {
  5297. $info_list[$key]['state'] = "盘亏";
  5298. } else if ($value['state'] == 7) {
  5299. $info_list[$key]['state'] = "更换标签";
  5300. } else if ($value['state'] == 8) {
  5301. $info_list[$key]['state'] = "其它";
  5302. } else if ($value['state'] == 9) {
  5303. $info_list[$key]['state'] = "预设";
  5304. }
  5305. }
  5306. $total = $this->whlabel->find_count($where);
  5307. $pagenum = ceil($total / $perpage);
  5308. $over = $total - ($start + $perpage);
  5309. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5310. echo json_encode($rows);
  5311. exit;
  5312. }
  5313. if (isset($post['rsku'])) {
  5314. $cz = $this->input->post('cz', true);
  5315. $label = $this->input->post('rsku', true);
  5316. $sl = $this->input->post('sl', true);
  5317. $warehouse = $this->input->post('warehouse', true);
  5318. if (!$sl) {
  5319. $sl = 1;
  5320. }
  5321. if (!$warehouse) {
  5322. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5323. exit;
  5324. }
  5325. $dblabel = $this->whlabellabel->get_label($label);
  5326. if ($dblabel) {
  5327. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5328. if (count($data) < 1) {
  5329. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5330. exit;
  5331. }
  5332. if ($sl > count($data)) {
  5333. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5334. exit;
  5335. }
  5336. $time = time();
  5337. for ($i = 0; $i < $sl; $i++) {
  5338. $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']);
  5339. }
  5340. echo json_encode(array('success' => true));
  5341. exit;
  5342. } else {
  5343. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5344. exit;
  5345. }
  5346. }
  5347. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5348. $this->_Template('whlabel_dbrk', $this->data);
  5349. }
  5350. public function _whlabelczdc()
  5351. {
  5352. if (isset($_GET['excel'])) {
  5353. //数据排序
  5354. $order_str = "id desc";
  5355. if (empty($page)) {
  5356. $start = 0;
  5357. $perpage = 1;
  5358. } else {
  5359. $start = ($page - 1) * $perpage;
  5360. }
  5361. $state = $this->input->get('state', true);
  5362. $sku = $this->input->get('sku', true);
  5363. $ctime = $this->input->get('ctime', true);
  5364. $category = $this->input->get('category', true);
  5365. $size = $this->input->get('size', true);
  5366. $grade = $this->input->get('grade', true);
  5367. $color = $this->input->get('color', true);
  5368. $lowe = $this->input->get('lowe', true);
  5369. $timetk = $this->input->get('timetkk', true);
  5370. $timetj = $this->input->get('timetjj', true);
  5371. $timetk = strtotime($timetk);
  5372. $timetj = strtotime($timetj);
  5373. $where = "dbtime > 0";
  5374. if ($timetk && $timetj) {
  5375. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5376. }
  5377. if ($category) {
  5378. $where .= " and features like '%-$category-%'";
  5379. }
  5380. if ($size) {
  5381. $where .= " and features like '%-$size-%'";
  5382. }
  5383. if ($grade) {
  5384. $where .= " and features like '%-$grade-%'";
  5385. }
  5386. if ($color) {
  5387. $where .= " and features like '%-$color-%'";
  5388. }
  5389. if ($lowe) {
  5390. $where .= " and features like '%-$lowe-%'";
  5391. }
  5392. //取得信息列表
  5393. $info_list = $this->whlabel->find_all($where, '*');
  5394. $rows = array();
  5395. $list = array();
  5396. foreach ($info_list as $key => $value) {
  5397. $rows[$value['sku']] = $value; //所有数据sku
  5398. }
  5399. foreach ($rows as $value) {
  5400. $warehouse = $this->warehouse->read($value['warehouse']);
  5401. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5402. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5403. if ($value['orderinfo'] == 0) {
  5404. $info_list[$key]['orderinfo'] = "";
  5405. }
  5406. if ($value['waybill'] == 0) {
  5407. $info_list[$key]['waybill'] = "";
  5408. }
  5409. if ($value['state'] == 0) {
  5410. $value['state'] = "在库";
  5411. } else if ($value['state'] == 3) {
  5412. $value['state'] = "调拨中";
  5413. }
  5414. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5415. }
  5416. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5417. $titlename = "<table border=1>
  5418. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5419. <tr align='center'>
  5420. <td>SKU</td>
  5421. <td>产品</td>
  5422. <td>调拨数量</td>
  5423. <td>入库数量</td>
  5424. </tr>
  5425. </table>";
  5426. $filename = $title . ".xls";
  5427. $tail = "";
  5428. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5429. }
  5430. }
  5431. public function _print($arg_array)
  5432. {
  5433. if (isset($_SESSION['api'])) {
  5434. $user = $this->user->get_api($_SESSION['api']);
  5435. $usp = $user;
  5436. $fgshop = "";
  5437. $sid = "";
  5438. $wid = "";
  5439. $wtype = "";
  5440. $usersp = explode('|', trim($user['shop'], '|'));
  5441. $userwh = explode('|', trim($user['warehouse'], '|'));
  5442. foreach ($usersp as $value) {
  5443. $fgshop .= " shop = " . $value . " or";
  5444. $sid .= " id = " . $value . " or";
  5445. }
  5446. foreach ($userwh as $value) {
  5447. $wid .= " id = " . $value . " or";
  5448. $wtype .= " type = " . $value . " or";
  5449. }
  5450. }
  5451. $post = $this->input->post(NULL, TRUE);
  5452. if (isset($post['tmsku'])) {
  5453. $tmsku = $this->input->post('tmsku', true);
  5454. if (is_numeric($tmsku)) {
  5455. $yyh = $this->whlabellabel->get_label($tmsku);
  5456. } else {
  5457. $yyh = $this->whlabellabel->get_sku($tmsku);
  5458. }
  5459. if ($yyh) {
  5460. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5461. exit;
  5462. } else {
  5463. echo json_encode(array('success' => false));
  5464. exit;
  5465. }
  5466. }
  5467. $classid = $this->classid->sku();
  5468. $pm = $classid;
  5469. $scsku = $classid;
  5470. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5471. if (isset($post['warehouse'])) {
  5472. if ($post['warehouse']) {
  5473. $list = array();
  5474. $num = "";
  5475. $title = "";
  5476. $features = "";
  5477. $order = 0;
  5478. $post['shop'] = '';
  5479. $brand = $this->input->post('brand', true);
  5480. if ($brand != '0,') {
  5481. $b = $this->brand->read(rtrim($brand, ','));
  5482. if ($b) {
  5483. $post['shop'] = str_replace('|', ',', $b['shop']);
  5484. }
  5485. }
  5486. $post['details'] = $this->input->post('details', true); //打印数量
  5487. $xbqnum = $this->input->post('xbqnum', true);
  5488. $post['purchase'] = $this->input->post('purchase', true);
  5489. $post['warehouse'] = $this->input->post('warehouse', true);
  5490. $post['purchase'] = $this->input->post('purchase', true);
  5491. $post['retreatwarehouse'] = $post['warehouse'];
  5492. $post['cpbz'] = $this->input->post('cpbz', true);
  5493. $post['state'] = 9;
  5494. $category = $this->input->post('category', true);
  5495. $list['category'] = $category;
  5496. $list['hairtype'] = $this->input->post('hairtype', true);
  5497. $list['grade'] = $this->input->post('grade', true);
  5498. $size = $this->input->post('size', true);
  5499. $list['size'] = rtrim($size, ',');
  5500. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5501. $list['extension'] = $this->input->post('extension', true);
  5502. if ($category == 1297) {
  5503. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5504. }
  5505. if ($category == 1702) {
  5506. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5507. $list['syother'] = $this->input->post('syother', true);
  5508. }
  5509. if ($category == 133) {
  5510. $list['fittype'] = $this->input->post('fittype', true);
  5511. $list['acother'] = $this->input->post('acother', true);
  5512. }
  5513. $list['color'] = $this->input->post('color', true);
  5514. $list['lowe'] = $this->input->post('lowe', true);
  5515. if ($category == 127) {
  5516. $list['type'] = $this->input->post('type', true);
  5517. $list['headroad'] = $this->input->post('headroad', true);
  5518. $list['density'] = $this->input->post('density', true);
  5519. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5520. $list['lacesize'] = $this->input->post('lacesize', true);
  5521. }
  5522. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5523. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5524. }
  5525. if ($category == 128) {
  5526. $list['lacetype'] = $this->input->post('lacetype', true);
  5527. $list['haircap'] = $this->input->post('haircap', true);
  5528. $list['density'] = $this->input->post('density', true);
  5529. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5530. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5531. $list['wigother'] = $this->input->post('wigother', true);
  5532. $list['wigother1'] = $this->input->post('wigother1', true);
  5533. $list['wigother2'] = $this->input->post('wigother2', true);
  5534. }
  5535. if ($category == 129) {
  5536. $list['wide'] = $this->input->post('wide', true);
  5537. }
  5538. if ($category == 131) {
  5539. $list['gifttype'] = $this->input->post('gifttype', true);
  5540. $list['giftother'] = $this->input->post('giftother', true);
  5541. }
  5542. if ($category == 134) {
  5543. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5544. }
  5545. if ($category == 1297) {
  5546. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5547. $list['sywigother'] = $this->input->post('sywigother', true);
  5548. }
  5549. if ($category == 130 || $category == 133 || $category == 1702) {
  5550. $list['items'] = $this->input->post('items', true);
  5551. $list['weight'] = $this->input->post('weight', true);
  5552. }
  5553. if ($category == 1702) {
  5554. $list['syhairther'] = $this->input->post('syhairther', true);
  5555. }
  5556. foreach ($list as $k => $v) {
  5557. if ($v != 0) {
  5558. $num .= $v;
  5559. $features .= $v . '-';
  5560. $post[$k] = $v;
  5561. $typeclass = $this->typeclass->read($v);
  5562. if (isset($pm[$typeclass['classid']])) {
  5563. if (stripos($typeclass['zh'], '|') !== false) {
  5564. $exzh = explode('|', $typeclass['zh']);
  5565. $pm[$typeclass['classid']] = $exzh[0];
  5566. } else {
  5567. $pm[$typeclass['classid']] = $typeclass['zh'];
  5568. }
  5569. }
  5570. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5571. if ($k != 'size') {
  5572. $title .= $typeclass['title'] . " ";
  5573. }
  5574. }
  5575. }
  5576. $typeclass = $this->typeclass->read($list['size']);
  5577. $title .= $typeclass['title'];
  5578. $time = time();
  5579. $post['title'] = rtrim($title, ' ');
  5580. $post['number'] = $num;
  5581. $post['features'] = '-' . $features;
  5582. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5583. $featurespp = explode('-', trim($featurespp, '-'));
  5584. if (isset($featurespp[5])) {
  5585. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5586. } else {
  5587. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5588. }
  5589. $post['enter'] = $time;
  5590. $post['time'] = $time; //操作时间
  5591. $scsku = implode("-", $scsku);
  5592. $zh = implode(" ", $pm);
  5593. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5594. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5595. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5596. $post['sku'] = $bqsku;
  5597. $label = time() . rand(0, 9);
  5598. $post['label'] = $label;
  5599. $cpid = $this->whlabellabel->find_count();
  5600. $post['cpid'] = $cpid + 1;
  5601. $cpid = $post['cpid'];
  5602. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5603. //if($whlabelbarcode)
  5604. //{
  5605. //$post['label'] = $whlabelbarcode['label'];
  5606. //if(!$this->whlabellabel->insert($post))
  5607. //{
  5608. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5609. //}
  5610. //}
  5611. //else
  5612. //{
  5613. $this->db->trans_begin();
  5614. $this->whlabellabel->insert($post);
  5615. //$this->whlabelbarcode->insert($post);
  5616. if ($this->db->trans_status() === TRUE) {
  5617. $this->db->trans_commit();
  5618. } else {
  5619. $this->db->trans_rollback();
  5620. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5621. exit;
  5622. }
  5623. //}
  5624. $warehouse_name = "";
  5625. $warehouse = $post['warehouse'];
  5626. if($warehouse == 12){
  5627. $warehouse_name = "特殊库存库";
  5628. }
  5629. // if($warehouse == 13){
  5630. // $warehouse_name = "许昌仓";
  5631. // }
  5632. // if($warehouse == 5){
  5633. // $warehouse_name = "美国店";
  5634. // }
  5635. // if($warehouse == 16){
  5636. // $warehouse_name = "定制头套仓";
  5637. // }
  5638. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5639. if(!empty($warehouse_name)){
  5640. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5641. }
  5642. $purchase = $this->purchase->read($post['purchase']);
  5643. 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));
  5644. exit; //特殊仓目前不需要仓库选项
  5645. }
  5646. }
  5647. if (isset($_SESSION['api'])) {
  5648. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5649. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5650. $this->data['wlshop'] = $wlshop;
  5651. $this->data['warehouse'] = $warehouse;
  5652. }
  5653. $whlabelwz = $this->whlabelwz->find_all();
  5654. $this->data['whlabelwz'] = $whlabelwz;
  5655. $this->_Template('whlabel_print', $this->data);
  5656. }
  5657. public function _usaprint($arg_array)
  5658. {
  5659. if (isset($_SESSION['api'])) {
  5660. $user = $this->user->get_api($_SESSION['api']);
  5661. $usp = $user;
  5662. $fgshop = "";
  5663. $sid = "";
  5664. $wid = "";
  5665. $wtype = "";
  5666. $usersp = explode('|', trim($user['shop'], '|'));
  5667. $userwh = explode('|', trim($user['warehouse'], '|'));
  5668. foreach ($usersp as $value) {
  5669. $fgshop .= " shop = " . $value . " or";
  5670. $sid .= " id = " . $value . " or";
  5671. }
  5672. foreach ($userwh as $value) {
  5673. $wid .= " id = " . $value . " or";
  5674. $wtype .= " type = " . $value . " or";
  5675. }
  5676. }
  5677. $post = $this->input->post(NULL, TRUE);
  5678. if (isset($post['tmsku'])) {
  5679. $tmsku = $this->input->post('tmsku', true);
  5680. if (is_numeric($tmsku)) {
  5681. $yyh = $this->whlabellabel->get_label($tmsku);
  5682. } else {
  5683. $yyh = $this->whlabellabel->get_sku($tmsku);
  5684. }
  5685. if ($yyh) {
  5686. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5687. exit;
  5688. } else {
  5689. echo json_encode(array('success' => false));
  5690. exit;
  5691. }
  5692. }
  5693. $classid = $this->classid->sku();
  5694. $pm = $classid;
  5695. $scsku = $classid;
  5696. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5697. if (isset($post['warehouse'])) {
  5698. if ($post['warehouse']) {
  5699. $list = array();
  5700. $num = "";
  5701. $title = "";
  5702. $features = "";
  5703. $order = 0;
  5704. $post['shop'] = '';
  5705. $brand = $this->input->post('brand', true);
  5706. if ($brand != '0,') {
  5707. $b = $this->brand->read(rtrim($brand, ','));
  5708. if ($b) {
  5709. $post['shop'] = str_replace('|', ',', $b['shop']);
  5710. }
  5711. }
  5712. $post['details'] = $this->input->post('details', true); //打印数量
  5713. $xbqnum = $this->input->post('xbqnum', true);
  5714. $post['purchase'] = $this->input->post('purchase', true);
  5715. $post['warehouse'] = $this->input->post('warehouse', true);
  5716. $post['purchase'] = $this->input->post('purchase', true);
  5717. $post['retreatwarehouse'] = $post['warehouse'];
  5718. $post['cpbz'] = $this->input->post('cpbz', true);
  5719. $post['state'] = 9;
  5720. $category = $this->input->post('category', true);
  5721. $list['category'] = $category;
  5722. $list['hairtype'] = $this->input->post('hairtype', true);
  5723. $list['grade'] = $this->input->post('grade', true);
  5724. $size = $this->input->post('size', true);
  5725. $list['size'] = rtrim($size, ',');
  5726. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5727. $list['extension'] = $this->input->post('extension', true);
  5728. if ($category == 1297) {
  5729. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5730. }
  5731. if ($category == 1702) {
  5732. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5733. $list['syother'] = $this->input->post('syother', true);
  5734. }
  5735. if ($category == 133) {
  5736. $list['fittype'] = $this->input->post('fittype', true);
  5737. $list['acother'] = $this->input->post('acother', true);
  5738. }
  5739. $list['color'] = $this->input->post('color', true);
  5740. $list['lowe'] = $this->input->post('lowe', true);
  5741. if ($category == 127) {
  5742. $list['type'] = $this->input->post('type', true);
  5743. $list['headroad'] = $this->input->post('headroad', true);
  5744. $list['density'] = $this->input->post('density', true);
  5745. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5746. $list['lacesize'] = $this->input->post('lacesize', true);
  5747. }
  5748. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5749. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5750. }
  5751. if ($category == 128) {
  5752. $list['lacetype'] = $this->input->post('lacetype', true);
  5753. $list['haircap'] = $this->input->post('haircap', true);
  5754. $list['density'] = $this->input->post('density', true);
  5755. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5756. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5757. $list['wigother'] = $this->input->post('wigother', true);
  5758. $list['wigother1'] = $this->input->post('wigother1', true);
  5759. $list['wigother2'] = $this->input->post('wigother2', true);
  5760. }
  5761. if ($category == 129) {
  5762. $list['wide'] = $this->input->post('wide', true);
  5763. }
  5764. if ($category == 131) {
  5765. $list['gifttype'] = $this->input->post('gifttype', true);
  5766. $list['giftother'] = $this->input->post('giftother', true);
  5767. }
  5768. if ($category == 134) {
  5769. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5770. }
  5771. if ($category == 1297) {
  5772. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5773. $list['sywigother'] = $this->input->post('sywigother', true);
  5774. }
  5775. if ($category == 130 || $category == 133 || $category == 1702) {
  5776. $list['items'] = $this->input->post('items', true);
  5777. $list['weight'] = $this->input->post('weight', true);
  5778. }
  5779. if ($category == 1702) {
  5780. $list['syhairther'] = $this->input->post('syhairther', true);
  5781. }
  5782. foreach ($list as $k => $v) {
  5783. if ($v != 0) {
  5784. $num .= $v;
  5785. $features .= $v . '-';
  5786. $post[$k] = $v;
  5787. $typeclass = $this->typeclass->read($v);
  5788. if (isset($pm[$typeclass['classid']])) {
  5789. if (stripos($typeclass['zh'], '|') !== false) {
  5790. $exzh = explode('|', $typeclass['zh']);
  5791. $pm[$typeclass['classid']] = $exzh[0];
  5792. } else {
  5793. $pm[$typeclass['classid']] = $typeclass['zh'];
  5794. }
  5795. }
  5796. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5797. if ($k != 'size') {
  5798. $title .= $typeclass['title'] . " ";
  5799. }
  5800. }
  5801. }
  5802. $typeclass = $this->typeclass->read($list['size']);
  5803. $title .= $typeclass['title'];
  5804. $time = time();
  5805. $post['title'] = rtrim($title, ' ');
  5806. $post['number'] = $num;
  5807. $post['features'] = '-' . $features;
  5808. $fp = $this->whlabel->get_features($post['features']);
  5809. if (!$fp) {
  5810. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5811. exit;
  5812. }
  5813. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5814. $featurespp = explode('-', trim($featurespp, '-'));
  5815. if (isset($featurespp[5])) {
  5816. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5817. } else {
  5818. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5819. }
  5820. $post['enter'] = $time;
  5821. $post['time'] = $time; //操作时间
  5822. $scsku = implode("-", $scsku);
  5823. $zh = implode(" ", $pm);
  5824. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5825. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5826. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5827. $post['sku'] = $fp['sku'];
  5828. $post['label'] = $fp['sku'];
  5829. $cpid = $this->whlabellabel->find_count();
  5830. $post['cpid'] = $cpid + 1;
  5831. $cpid = $post['cpid'];
  5832. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5833. //if($whlabelbarcode)
  5834. //{
  5835. //$post['label'] = $whlabelbarcode['label'];
  5836. //if(!$this->whlabellabel->insert($post))
  5837. //{
  5838. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5839. //}
  5840. //}
  5841. //else
  5842. //{
  5843. $this->db->trans_begin();
  5844. $this->whlabellabel->insert($post);
  5845. //$this->whlabelbarcode->insert($post);
  5846. if ($this->db->trans_status() === TRUE) {
  5847. $this->db->trans_commit();
  5848. } else {
  5849. $this->db->trans_rollback();
  5850. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5851. exit;
  5852. }
  5853. //}
  5854. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5855. $purchase = $this->purchase->read($post['purchase']);
  5856. 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));
  5857. exit; //特殊仓目前不需要仓库选项
  5858. }
  5859. }
  5860. if (isset($_SESSION['api'])) {
  5861. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5862. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5863. $this->data['wlshop'] = $wlshop;
  5864. $this->data['warehouse'] = $warehouse;
  5865. }
  5866. $whlabelwz = $this->whlabelwz->find_all();
  5867. $this->data['whlabelwz'] = $whlabelwz;
  5868. $this->_Template('whlabel_usaprint', $this->data);
  5869. }
  5870. public function _printrk($arg_array)
  5871. {
  5872. $prc = array();
  5873. $purchase = $this->purchase->find_all();
  5874. foreach ($purchase as $k => $v) {
  5875. $prc[$v['id']] = $v['title'];
  5876. }
  5877. $post = $this->input->post(NULL, TRUE);
  5878. if (isset($post['page'])) {
  5879. $page = $this->input->post('page', true);
  5880. $perpage = $this->input->post('perpage', true);
  5881. $sku = $this->input->post('sku', true);
  5882. $bs = $this->input->post('bs', true);
  5883. $number = $this->input->post('number', true);
  5884. $warehouse = $this->input->post('warehouse', true);
  5885. $purchase = $this->input->post('purchase', true);
  5886. $orderinfo = $this->input->post('orderinfo', true);
  5887. $waybill = $this->input->post('waybill', true);
  5888. $category = $this->input->post('category', true);
  5889. $size = $this->input->post('size', true);
  5890. $grade = $this->input->post('grade', true);
  5891. $color = $this->input->post('color', true);
  5892. $lowe = $this->input->post('lowe', true);
  5893. $state = $this->input->post('state', true);
  5894. $label = $this->input->post('label', true);
  5895. $timetk = $this->input->post('ktime', true);
  5896. $timetj = $this->input->post('jtime', true);
  5897. $timetk = strtotime($timetk);
  5898. $timetj = strtotime($timetj);
  5899. $where = "1=1 ";
  5900. if ($timetk && $timetj) {
  5901. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5902. }
  5903. if ($sku) {
  5904. $where .= " and sku = '$sku'";
  5905. }
  5906. if ($bs != '') {
  5907. $where .= " and bs = '$bs'";
  5908. }
  5909. if ($number) {
  5910. $where .= " and number = '$number'";
  5911. }
  5912. if ($warehouse) {
  5913. $where .= " and warehouse = '$warehouse'";
  5914. }
  5915. if ($purchase) {
  5916. $where .= " and purchase = '$purchase'";
  5917. }
  5918. if ($orderinfo) {
  5919. $where .= " and orderinfo = '$orderinfo'";
  5920. }
  5921. if ($waybill) {
  5922. $where .= " and waybill = '$waybill'";
  5923. }
  5924. if ($category) {
  5925. $where .= " and features like '%-$category-%'";
  5926. }
  5927. if ($size) {
  5928. $where .= " and features like '%-$size-%'";
  5929. }
  5930. if ($grade) {
  5931. $where .= " and features like '%-$grade-%'";
  5932. }
  5933. if ($color) {
  5934. $where .= " and features like '%-$color-%'";
  5935. }
  5936. if ($lowe) {
  5937. $where .= " and features like '%-$lowe-%'";
  5938. }
  5939. if ($label) {
  5940. $where .= " and label = '$label'";
  5941. }
  5942. if ($state || $state == 0) {
  5943. $where .= " and state = '$state'";
  5944. }
  5945. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5946. //数据排序
  5947. $order_str = "enter desc";
  5948. if (empty($page)) {
  5949. $start = 0;
  5950. $perpage = 1;
  5951. } else {
  5952. $start = ($page - 1) * $perpage;
  5953. }
  5954. //取得信息列表
  5955. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5956. foreach ($info_list as $key => $value) {
  5957. $warehouse = $this->warehouse->read($value['warehouse']);
  5958. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5959. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5960. if ($value['state'] == 0) {
  5961. $info_list[$key]['state'] = "在库";
  5962. } else if ($value['state'] == 1) {
  5963. $info_list[$key]['state'] = "出库";
  5964. } else if ($value['state'] == 2) {
  5965. $info_list[$key]['state'] = "退库";
  5966. } else if ($value['state'] == 3) {
  5967. $info_list[$key]['state'] = "调拨中";
  5968. } else if ($value['state'] == 4) {
  5969. $info_list[$key]['state'] = "再加工";
  5970. } else if ($value['state'] == 5) {
  5971. $info_list[$key]['state'] = "维修中";
  5972. } else if ($value['state'] == 6) {
  5973. $info_list[$key]['state'] = "盘亏";
  5974. } else if ($value['state'] == 7) {
  5975. $info_list[$key]['state'] = "更换标签";
  5976. } else if ($value['state'] == 8) {
  5977. $info_list[$key]['state'] = "其它";
  5978. } else if ($value['state'] == 9) {
  5979. $info_list[$key]['state'] = "预设";
  5980. } else if ($value['state'] == 10) {
  5981. $info_list[$key]['state'] = "美店零售";
  5982. }
  5983. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5984. }
  5985. $total = $this->$ck->find_count($where);
  5986. $pagenum = ceil($total / $perpage);
  5987. $over = $total - ($start + $perpage);
  5988. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5989. echo json_encode($rows);
  5990. exit;
  5991. }
  5992. if (isset($post['tmsku'])) {
  5993. $time = time();
  5994. $tmsku = $this->input->post('tmsku', true);
  5995. //$post['shop'] = $this->input->post('shop',true);
  5996. $num = $this->input->post('num', true);
  5997. $rktype = $this->input->post('rktype', true);
  5998. if ($num > 200) {
  5999. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6000. exit;
  6001. }
  6002. if (!$rktype) {
  6003. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6004. }
  6005. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6006. /**
  6007. $wz = array();
  6008. foreach ($rk as $key=>$value)
  6009. {
  6010. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6011. }
  6012. if(count($wz) > 1)
  6013. {
  6014. $wz = array_values($wz);
  6015. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6016. }
  6017. **/
  6018. if (isset($rk[0]['purchase'])) {
  6019. $rk = $rk[0];
  6020. $j = 0;
  6021. $post['purchase'] = $rk['purchase'];
  6022. $post['warehouse'] = $rk['warehouse'];
  6023. $post['retreatwarehouse'] = $rk['warehouse'];
  6024. $post['sku'] = $rk['sku'];
  6025. $post['number'] = $rk['number'];
  6026. $post['features'] = $rk['features'];
  6027. $post['title'] = $rk['title'];
  6028. $post['enter'] = $time;
  6029. $post['time'] = $time;
  6030. $post['bs'] = 1;
  6031. $post['shop'] = $rk['shop'];
  6032. $post['details'] = $rk['details'];
  6033. $post['cpid'] = $rk['cpid'];
  6034. $post['cpbz'] = $rk['cpbz'];
  6035. //$post['rktype'] = $rktype;
  6036. $warehouse = $this->warehouse->read($rk['warehouse']);
  6037. if ($warehouse['bdck'] == '') {
  6038. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6039. exit;
  6040. } else {
  6041. $bdck = $warehouse['bdck'];
  6042. }
  6043. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6044. if (isset($pdwz['details'])) {
  6045. if ($pdwz['details'] != $post['details']) {
  6046. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6047. exit;
  6048. }
  6049. }
  6050. $post['featurespp'] = $rk['featurespp'];
  6051. if ($post['warehouse'] == '5') {
  6052. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6053. if ($yza) {
  6054. if ($post['features'] != $yza[0]['features']) {
  6055. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6056. exit;
  6057. }
  6058. }
  6059. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6060. if ($yzb) {
  6061. if ($post['sku'] != $yzb[0]['sku']) {
  6062. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6063. exit;
  6064. }
  6065. }
  6066. }
  6067. for ($i = 0; $i < $num; $i++) {
  6068. $post['label'] = time() . rand(100, 999) . $i;
  6069. if ($this->$bdck->insert($post)) {
  6070. $j++;
  6071. }
  6072. }
  6073. /**
  6074. if($post['warehouse'] != 12)
  6075. {
  6076. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6077. }
  6078. **/
  6079. if ($j == $num) {
  6080. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6081. exit;
  6082. } else {
  6083. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6084. exit;
  6085. }
  6086. } else {
  6087. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6088. exit;
  6089. }
  6090. }
  6091. $this->_Template('whlabel_printrk', $this->data);
  6092. }
  6093. public function _printxzrk($arg_array)
  6094. {
  6095. $post = $this->input->post(NULL, TRUE);
  6096. if (isset($post['wzid'])) {
  6097. $time = time();
  6098. $id = $this->input->post('wzid', true);
  6099. //$post['shop'] = $this->input->post('shop',true);
  6100. $num = 1;
  6101. $rk = $this->whlabellabel->read($id);
  6102. if (isset($rk['purchase'])) {
  6103. $x = 0;
  6104. $post['purchase'] = $rk['purchase'];
  6105. $post['warehouse'] = $rk['warehouse'];
  6106. $post['retreatwarehouse'] = $rk['warehouse'];
  6107. $post['sku'] = $rk['sku'];
  6108. $post['number'] = $rk['number'];
  6109. $post['features'] = $rk['features'];
  6110. $post['title'] = $rk['title'];
  6111. $post['enter'] = $time;
  6112. $post['time'] = $time;
  6113. $post['bs'] = 1;
  6114. $post['shop'] = $rk['shop'];
  6115. $post['details'] = $rk['details'];
  6116. $post['cpid'] = $rk['cpid'];
  6117. $post['cpbz'] = $rk['cpbz'];
  6118. $warehouse = $this->warehouse->read($rk['warehouse']);
  6119. if ($warehouse['bdck'] == '') {
  6120. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6121. exit;
  6122. } else {
  6123. $bdck = $warehouse['bdck'];
  6124. }
  6125. $post['featurespp'] = $rk['featurespp'];
  6126. $this->db->trans_begin();
  6127. for ($i = 0; $i < $num; $i++) {
  6128. $post['label'] = time() . rand(100, 999) . $i;
  6129. $this->$bdck->insert($post);
  6130. }
  6131. /**
  6132. if($post['warehouse'] != 12)
  6133. {
  6134. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6135. }
  6136. **/
  6137. if ($this->db->trans_status() === TRUE) {
  6138. $this->db->trans_commit();
  6139. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6140. exit;
  6141. } else {
  6142. $this->db->trans_rollback();
  6143. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6144. exit;
  6145. }
  6146. } else {
  6147. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6148. exit;
  6149. }
  6150. }
  6151. }
  6152. public function _printck($arg_array)
  6153. {
  6154. $prc = array();
  6155. $purchase = $this->purchase->find_all();
  6156. foreach ($purchase as $k => $v) {
  6157. $prc[$v['id']] = $v['title'];
  6158. }
  6159. $post = $this->input->post(NULL, TRUE);
  6160. if (isset($post['page'])) {
  6161. $page = $this->input->post('page', true);
  6162. $perpage = $this->input->post('perpage', true);
  6163. $sku = $this->input->post('sku', true);
  6164. $bs = $this->input->post('bs', true);
  6165. $number = $this->input->post('number', true);
  6166. $warehouse = $this->input->post('warehouse', true);
  6167. $purchase = $this->input->post('purchase', true);
  6168. $orderinfo = $this->input->post('orderinfo', true);
  6169. $waybill = $this->input->post('waybill', true);
  6170. $category = $this->input->post('category', true);
  6171. $size = $this->input->post('size', true);
  6172. $grade = $this->input->post('grade', true);
  6173. $color = $this->input->post('color', true);
  6174. $lowe = $this->input->post('lowe', true);
  6175. $state = $this->input->post('state', true);
  6176. $label = $this->input->post('label', true);
  6177. $timetk = $this->input->post('ktime', true);
  6178. $timetj = $this->input->post('jtime', true);
  6179. $timetk = strtotime($timetk);
  6180. $timetj = strtotime($timetj);
  6181. $where = "state=1 ";
  6182. if ($timetk && $timetj) {
  6183. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6184. }
  6185. if ($sku) {
  6186. $where .= " and sku = '$sku'";
  6187. }
  6188. if ($bs != '') {
  6189. $where .= " and bs = '$bs'";
  6190. }
  6191. if ($number) {
  6192. $where .= " and number = '$number'";
  6193. }
  6194. if ($warehouse) {
  6195. $where .= " and warehouse = '$warehouse'";
  6196. }
  6197. if ($purchase) {
  6198. $where .= " and purchase = '$purchase'";
  6199. }
  6200. if ($orderinfo) {
  6201. $where .= " and orderinfo = '$orderinfo'";
  6202. }
  6203. if ($waybill) {
  6204. $where .= " and waybill = '$waybill'";
  6205. }
  6206. if ($category) {
  6207. $where .= " and features like '%-$category-%'";
  6208. }
  6209. if ($size) {
  6210. $where .= " and features like '%-$size-%'";
  6211. }
  6212. if ($grade) {
  6213. $where .= " and features like '%-$grade-%'";
  6214. }
  6215. if ($color) {
  6216. $where .= " and features like '%-$color-%'";
  6217. }
  6218. if ($lowe) {
  6219. $where .= " and features like '%-$lowe-%'";
  6220. }
  6221. if ($label) {
  6222. $where .= " and label = '$label'";
  6223. }
  6224. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6225. //数据排序
  6226. $order_str = "outk desc";
  6227. if (empty($page)) {
  6228. $start = 0;
  6229. $perpage = 1;
  6230. } else {
  6231. $start = ($page - 1) * $perpage;
  6232. }
  6233. //取得信息列表
  6234. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6235. foreach ($info_list as $key => $value) {
  6236. $warehouse = $this->warehouse->read($value['warehouse']);
  6237. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6238. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6239. if ($value['state'] == 0) {
  6240. $info_list[$key]['state'] = "在库";
  6241. } else if ($value['state'] == 1) {
  6242. $info_list[$key]['state'] = "出库";
  6243. } else if ($value['state'] == 2) {
  6244. $info_list[$key]['state'] = "退库";
  6245. } else if ($value['state'] == 3) {
  6246. $info_list[$key]['state'] = "调拨中";
  6247. } else if ($value['state'] == 4) {
  6248. $info_list[$key]['state'] = "再加工";
  6249. } else if ($value['state'] == 5) {
  6250. $info_list[$key]['state'] = "维修中";
  6251. } else if ($value['state'] == 6) {
  6252. $info_list[$key]['state'] = "盘亏";
  6253. } else if ($value['state'] == 7) {
  6254. $info_list[$key]['state'] = "更换标签";
  6255. } else if ($value['state'] == 8) {
  6256. $info_list[$key]['state'] = "其它";
  6257. } else if ($value['state'] == 9) {
  6258. $info_list[$key]['state'] = "预设";
  6259. } else if ($value['state'] == 10) {
  6260. $info_list[$key]['state'] = "美店零售";
  6261. }
  6262. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6263. }
  6264. $total = $this->$ck->find_count($where);
  6265. $pagenum = ceil($total / $perpage);
  6266. $over = $total - ($start + $perpage);
  6267. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6268. echo json_encode($rows);
  6269. exit;
  6270. }
  6271. if (isset($post['tmsku'])) {
  6272. $time = time();
  6273. $tmsku = $this->input->post('tmsku', true);
  6274. //$post['shop'] = $this->input->post('shop',true);
  6275. $num = $this->input->post('num', true);
  6276. $cktype = $this->input->post('cktype', true);
  6277. $label = $this->whlabellabel->get_label($tmsku);
  6278. if (!$cktype) {
  6279. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6280. }
  6281. if (!isset($label['warehouse'])) {
  6282. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6283. exit;
  6284. }
  6285. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6286. if (stripos($label['features'], '-126-') !== false) {
  6287. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6288. } else {
  6289. $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 = ''");
  6290. }
  6291. $j = 0;
  6292. if (count($ck) >= $num) {
  6293. for ($i = 0; $i < $num; $i++) {
  6294. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6295. {
  6296. $j++;
  6297. }
  6298. }
  6299. if ($j == $num) {
  6300. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6301. exit;
  6302. } else {
  6303. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6304. exit;
  6305. }
  6306. } else {
  6307. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6308. exit;
  6309. }
  6310. }
  6311. if(isset($_SESSION['api']))
  6312. {
  6313. $user = $this->user->get_api($_SESSION['api']);
  6314. if(in_array($user['power'],[1,27])){
  6315. $vip = 1;
  6316. }
  6317. }
  6318. else
  6319. {
  6320. $vip = 0;
  6321. header('Location: /');exit;
  6322. }
  6323. $this->data['vip'] = $vip;
  6324. $this->_Template('whlabel_printck', $this->data);
  6325. }
  6326. public function _printexcel()
  6327. {
  6328. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6329. $config['upload_path'] = '.' . $dir;
  6330. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6331. $config['allowed_types'] = 'xls|xlsx|csv';
  6332. $config['max_size'] = 10240;
  6333. $this->load->library('upload', $config);
  6334. $this->upload->initialize($config);
  6335. if ($this->upload->do_upload('userfile')) {
  6336. $full_path = $dir . $this->upload->data('file_name');
  6337. $fileName = '.' . $full_path;
  6338. if (!file_exists($fileName)) {
  6339. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6340. exit;
  6341. } else {
  6342. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6343. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6344. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6345. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6346. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6347. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6348. ++$column; //如果列数大于26行
  6349. $list = array();
  6350. for ($i = 2; $i <= $row; $i++) // 行数循环
  6351. {
  6352. $data = array();
  6353. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6354. {
  6355. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6356. }
  6357. $list[] = $data;
  6358. }
  6359. }
  6360. $ed = array();
  6361. $i = 0;
  6362. $j = 0;
  6363. $dcdata = array();
  6364. $yc = '';
  6365. $cmf_arr = array_column($list, '1');
  6366. array_multisort($cmf_arr, SORT_ASC, $list);
  6367. foreach ($list as $key => $value) {
  6368. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6369. if ($typeclass) {
  6370. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6371. } else {
  6372. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6373. $i++;
  6374. continue;
  6375. }
  6376. }
  6377. if ($i > 0) {
  6378. $yc = $i . '条异常';
  6379. }
  6380. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6381. exit;
  6382. }
  6383. }
  6384. public function _uck()
  6385. {
  6386. if (isset($_GET['excel'])) {
  6387. $tc = array();
  6388. $typeclass = $this->typeclass->find_all();
  6389. foreach ($typeclass as $v) {
  6390. $tc[$v['id']] = $v['zh'];
  6391. }
  6392. $data = array();
  6393. $t = array();
  6394. $rq = '';
  6395. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6396. $ts = $ts / (24 * 3600);
  6397. for ($i = 0; $i < $ts; $i++) {
  6398. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6399. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6400. }
  6401. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6402. foreach ($info_list as $k => $v) {
  6403. $features = explode('-', trim($v['features'], '-'));
  6404. if (!isset($features[3]) || !isset($features[4])) {
  6405. continue;
  6406. }
  6407. $data[$k][0] = $tc[$features[0]]; //类型
  6408. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6409. $data[$k][2] = $tc[$features[4]]; //曲度
  6410. $data[$k][3] = '';
  6411. if (isset($data[$k][1])) {
  6412. $data[$k][3] .= $data[$k][1];
  6413. }
  6414. if (isset($data[$k][2])) {
  6415. $data[$k][3] .= $data[$k][2];
  6416. }
  6417. if (isset($features[5])) {
  6418. $data[$k][3] .= $tc[$features[5]];
  6419. }
  6420. if (isset($features[2])) {
  6421. $data[$k][3] .= $tc[$features[2]];
  6422. }
  6423. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6424. $data[$k][4] = $v['sku'];
  6425. $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())) . '))'); //月初库存
  6426. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6427. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6428. $ztrq = '';
  6429. $ztsl = '';
  6430. if (count($zt) > 0) {
  6431. foreach ($zt as $vv) {
  6432. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6433. $ztsl .= $vv['num'] . '<br>';
  6434. }
  6435. }
  6436. $data[$k][] = trim($ztsl, '<br>');
  6437. $data[$k][] = trim($ztrq, '<br>');
  6438. $byck = 0;
  6439. foreach ($t as $vv) {
  6440. $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));
  6441. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6442. $byck += $sl;
  6443. }
  6444. $data[$k][] = ($byck > 0) ? $byck : '';
  6445. }
  6446. $title = "详情 " . date("Y-m-d", time());
  6447. $titlename = "<table border=1>
  6448. <tr align='center'>
  6449. <td>类别</td>
  6450. <td>颜色</td>
  6451. <td>曲度</td>
  6452. <td>名称</td>
  6453. <td>SKU</td>
  6454. <td>月初库存</td>
  6455. <td>剩余库存</td>
  6456. <td>在途数量</td>
  6457. <td>预达日期</td>" .
  6458. $rq
  6459. . "<td>本月出库</td></tr>
  6460. </table>";
  6461. $filename = $title . ".xls";
  6462. $tail = "";
  6463. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6464. }
  6465. }
  6466. public function _whlabelexcelzh()
  6467. {
  6468. if (isset($_GET['excel'])) {
  6469. $where = "sku != 'Preset'";
  6470. //数据排序
  6471. $order_str = "id desc";
  6472. if (empty($page)) {
  6473. $start = 0;
  6474. $perpage = 1;
  6475. } else {
  6476. $start = ($page - 1) * $perpage;
  6477. }
  6478. $category = $this->input->get('category', true);
  6479. $warehouse = $this->input->get('warehouse', true);
  6480. $excelid = $this->input->get('sid', true);
  6481. if ($category) {
  6482. $where .= " and features like '%-$category-%'";
  6483. }
  6484. if ($warehouse) {
  6485. $where .= " and warehouse = '$warehouse'";
  6486. }
  6487. $xzid = '';
  6488. if ($excelid) {
  6489. $excelid = explode(',', trim($excelid, ','));
  6490. foreach ($excelid as $key => $value) {
  6491. $xzid .= " id = " . $value . " or";
  6492. }
  6493. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6494. }
  6495. //取得信息列表
  6496. /**
  6497. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6498. $rows = array();$list = array();
  6499. foreach ($info_list as $key=>$value)
  6500. {
  6501. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6502. }
  6503. **/
  6504. $list = array();
  6505. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6506. foreach ($rows as $key => $value) {
  6507. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6508. $zh = '';
  6509. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6510. foreach ($zt as $v) {
  6511. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6512. }
  6513. $zt = array_sum(array_column($zt, 'num'));
  6514. $number = $value['number'];
  6515. $ftime = time() - 15 * 24 * 3600;
  6516. $warehouse = $this->warehouse->read($value['warehouse']);
  6517. $rows[$key]['warehouse'] = $warehouse['title'];
  6518. $rows[$key]['number'] = $c;
  6519. $rows[$key]['features'] = $zh;
  6520. $rows[$key]['hb'] = $c + $zt;
  6521. }
  6522. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6523. $titlename = "<table border=1>
  6524. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6525. <tr align='center'>
  6526. <td>仓库</td>
  6527. <td>SKU</td>
  6528. <td>产品</td>
  6529. <td>库存数量</td>
  6530. <td>在途数量及预达日期</td>
  6531. <td>在途+库存数量</td>
  6532. </tr>
  6533. </table>";
  6534. $filename = $title . ".xls";
  6535. $tail = "";
  6536. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6537. }
  6538. if (isset($_GET['excel'])) {
  6539. $warehouse = $this->input->get('warehouse', true);
  6540. $sku = $this->input->get('sku', true);
  6541. $cz = $this->input->get('cz', true);
  6542. $text = $this->input->post('text', true);
  6543. $xztime = $this->input->get('xztime', true);
  6544. $timetk = $this->input->get('timetk', true);
  6545. $timetj = $this->input->get('timetj', true);
  6546. $timetk = strtotime($timetk);
  6547. $timetj = strtotime($timetj);
  6548. $where = "time = '0' ";
  6549. if ($warehouse) {
  6550. $where .= " and warehouse = '$warehouse'";
  6551. }
  6552. if ($sku) {
  6553. $where .= " and sku = '$sku'";
  6554. }
  6555. if ($text) {
  6556. $where .= " and text like '%$text%'";
  6557. }
  6558. if ($cz != '') {
  6559. $where .= " and cz = '$cz'";
  6560. }
  6561. if ($timetk && $timetj) {
  6562. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6563. }
  6564. //数据排序
  6565. $order_str = $xztime . " desc";
  6566. //取得信息列表
  6567. $zh = array();
  6568. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6569. foreach ($info_list as $v) {
  6570. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6571. $warehouse = $this->warehouse->read($v['warehouse']);
  6572. $v['warehouse'] = $warehouse['title'];
  6573. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6574. $v['stime'] = date('Y-m-d', $v['stime']);
  6575. if (isset($zh[$v['features']])) {
  6576. $zh[$v['features']]['num'] += $v['num'];
  6577. } else {
  6578. $zh[$v['features']] = $v;
  6579. }
  6580. $zh[$v['features']]['features'] = $c;
  6581. }
  6582. $title = "在途数据" . date('Y-m-d', time());
  6583. $titlename = "<table border=1>
  6584. <tr align='center'>
  6585. <td>仓库</td>
  6586. <td>SKU</td>
  6587. <td>名称</td>
  6588. <td>在途数量</td>
  6589. <td>库存数量</td>
  6590. <td>添加在途日期</td>
  6591. <td>预达日期</td>
  6592. <td>备注</td>
  6593. </tr>
  6594. </table>";
  6595. $filename = $title . ".xls";
  6596. $tail = "";
  6597. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6598. }
  6599. }
  6600. public function _fc()
  6601. {
  6602. $vip = 0;
  6603. if (isset($_SESSION['api'])) {
  6604. $user = $this->user->get_api($_SESSION['api']);
  6605. if ($user['vip'] == 1) {
  6606. $vip = 1;
  6607. }
  6608. } else {
  6609. header('Location: /');
  6610. exit;
  6611. }
  6612. $post = $this->input->post(NULL, TRUE);
  6613. if (isset($post['page'])) {
  6614. $page = $this->input->post('page', true);
  6615. $perpage = $this->input->post('perpage', true);
  6616. $category = $this->input->post('category', true);
  6617. $size = $this->input->post('size', true);
  6618. $grade = $this->input->post('grade', true);
  6619. $color = $this->input->post('color', true);
  6620. $lowe = $this->input->post('lowe', true);
  6621. $sku = $this->input->post('sku');
  6622. $title = $this->input->post('title');
  6623. $warehouse = $this->input->post('warehouse', true);
  6624. $usa = $this->input->post('usa', true);
  6625. $purchase = $this->input->post('purchase', true);
  6626. $lacetype = $this->input->post('lacetype', true);
  6627. $haircap = $this->input->post('haircap', true);
  6628. $density = $this->input->post('density', true);
  6629. $details = $this->input->post('details', true);
  6630. $state = $this->input->post('state', true);
  6631. $ktime = $this->input->post('ktime', true);
  6632. $jtime = $this->input->post('jtime', true);
  6633. $ktime = strtotime($ktime);
  6634. $jtime = strtotime($jtime);
  6635. $where = "state = '11'";
  6636. $gj = "";
  6637. $ck = "";
  6638. if ($lacetype) {
  6639. $where .= " and features like '%-$lacetype-%'";
  6640. }
  6641. if ($category) {
  6642. $where .= " and features like '%-$category-%'";
  6643. }
  6644. if ($size) {
  6645. $where .= " and features like '%-$size-%'";
  6646. }
  6647. if ($grade) {
  6648. $where .= " and features like '%-$grade-%'";
  6649. }
  6650. if ($color) {
  6651. $where .= " and features like '%-$color-%'";
  6652. }
  6653. if ($lowe) {
  6654. $where .= " and features like '%-$lowe-%'";
  6655. }
  6656. if ($haircap) {
  6657. $where .= " and features like '%-$haircap-%'";
  6658. }
  6659. if ($density) {
  6660. $where .= " and features like '%-$density-%'";
  6661. }
  6662. if ($usa) {
  6663. if (!$warehouse) {
  6664. $where .= " and (warehouse = '5' or warehouse = '8')";
  6665. }
  6666. }
  6667. if ($warehouse) {
  6668. $where .= " and warehouse = '$warehouse'";
  6669. }
  6670. if ($details) {
  6671. $where .= " and details = '$details'";
  6672. }
  6673. if ($purchase) {
  6674. $where .= " and purchase = '$purchase'";
  6675. }
  6676. if ($state) {
  6677. $where .= " and state = '$state'";
  6678. }
  6679. if ($ktime && $jtime) {
  6680. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6681. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6682. }
  6683. //数据排序
  6684. $order_str = "id desc";
  6685. if (empty($page)) {
  6686. $start = 0;
  6687. $perpage = 1;
  6688. } else {
  6689. $start = ($page - 1) * $perpage;
  6690. }
  6691. if ($sku) {
  6692. $sku = trim($sku, ' ');
  6693. $sku = trim($sku, ' ');
  6694. $where .= " and sku like '%$sku%'";
  6695. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6696. } else if ($title) {
  6697. $title = trim($title, ' ');
  6698. $title = trim($title, ' ');
  6699. $where .= " and title like '%$title%'";
  6700. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6701. } else {
  6702. //$where .= " and time > '$ktime' and time < '$jtime'";
  6703. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6704. }
  6705. //取得信息列表
  6706. $rows = array();
  6707. $list = array();
  6708. foreach ($info_list as $key => $value) {
  6709. $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'] . '"');
  6710. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6711. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6712. $warehouse = $this->warehouse->read($value['warehouse']);
  6713. $info_list[$key]['warehouse'] = $warehouse['title'];
  6714. $info_list[$key]['number'] = $g;
  6715. $info_list[$key]['features'] = $x;
  6716. $info_list[$key]['x'] = $s;
  6717. }
  6718. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6719. $pagenum = ceil($total / $perpage);
  6720. $over = $total - ($start + $perpage);
  6721. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6722. echo json_encode($rows);
  6723. exit;
  6724. }
  6725. $this->data['vip'] = $vip;
  6726. $this->_Template('whlabel_fc', $this->data);
  6727. }
  6728. public function _fcmb()
  6729. {
  6730. $where = "sku != 'Preset'";
  6731. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6732. foreach ($rows as $k => $v) {
  6733. $warehouse = $this->warehouse->read($v['warehouse']);
  6734. $rows[$k]['warehouse'] = $warehouse['title'];
  6735. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6736. $rows[$k]['t'] = '';
  6737. $rows[$k]['n'] = '';
  6738. }
  6739. $title = "封货产品数据导入模板";
  6740. $titlename = "<table border=1>
  6741. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6742. <tr align='center'>
  6743. <td>仓库</td>
  6744. <td>SKU</td>
  6745. <td>产品</td>
  6746. <td>封存产品总数量</td>
  6747. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6748. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6749. </tr>
  6750. </table>";
  6751. $filename = $title . ".xls";
  6752. $tail = "";
  6753. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6754. }
  6755. public function _fcexcel()
  6756. {
  6757. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6758. $config['upload_path'] = '.' . $dir;
  6759. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6760. $config['allowed_types'] = 'xls|xlsx|csv';
  6761. $config['max_size'] = 10240;
  6762. $this->load->library('upload', $config);
  6763. $this->upload->initialize($config);
  6764. if ($this->upload->do_upload('userfile')) {
  6765. $full_path = $dir . $this->upload->data('file_name');
  6766. $fileName = '.' . $full_path;
  6767. if (!file_exists($fileName)) {
  6768. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6769. exit;
  6770. } else {
  6771. libxml_use_internal_errors(true);
  6772. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6773. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6774. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6775. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6776. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6777. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6778. ++$column; //如果列数大于26行
  6779. $list = array();
  6780. for ($i = 2; $i <= $row; $i++) // 行数循环
  6781. {
  6782. $data = array();
  6783. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6784. {
  6785. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6786. }
  6787. $list[] = $data;
  6788. }
  6789. }
  6790. $i = 0;
  6791. $j = 0;
  6792. $ed = array();
  6793. foreach ($list as $key => $value) {
  6794. $time = time();
  6795. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6796. continue;
  6797. }
  6798. $warehouse = $this->warehouse->get_title($value['0']);
  6799. $sku = $value['1'];
  6800. $type = $value['4']; //调整方式0扣减1删除
  6801. $num = $value['5']; //调整数量
  6802. //$text = $value['4'];//扣减说明
  6803. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6804. if (!$d) //如果没有这个SKU
  6805. {
  6806. $ed[] = array($sku . '-库存中不存在此SKU');
  6807. $j++;
  6808. continue;
  6809. }
  6810. if (!isset($warehouse['id'])) {
  6811. $ed[] = array($sku . '-仓库名错误!');
  6812. $j++;
  6813. continue;
  6814. }
  6815. if ($type == 1 || $type == 2) //扣减库存
  6816. {
  6817. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6818. if (count($data) < abs($num)) {
  6819. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6820. $j++;
  6821. continue;
  6822. }
  6823. if ($type == 1) //转入库存
  6824. {
  6825. for ($i = 0; $i < abs($num); $i++) {
  6826. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6827. }
  6828. } else if ($type == 2) //删除
  6829. {
  6830. for ($i = 0; $i < abs($num); $i++) {
  6831. $this->whlabel->remove($data[$i]['id']);
  6832. }
  6833. }
  6834. } else if ($type == 0) //增加库存
  6835. {
  6836. $post['sku'] = $d['sku'];
  6837. $post['shop'] = '';
  6838. $post['warehouse'] = $warehouse['id'];
  6839. $post['purchase'] = $d['purchase'];
  6840. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6841. $post['state'] = 11;
  6842. $post['title'] = $d['title'];
  6843. $post['number'] = $d['number'];
  6844. $post['features'] = $d['features'];
  6845. $post['enter'] = $time;
  6846. $post['time'] = $time; //操作时间
  6847. for ($i = 0; $i < $num; $i++) {
  6848. $post['label'] = time() . rand(100, 999) . $i;
  6849. $this->whlabel->insert($post);
  6850. }
  6851. }
  6852. sleep(1); //防止入库时间一样,需要延迟1秒
  6853. }
  6854. if ($j > 0) {
  6855. $tt = date('Ymd', time());
  6856. $title = '库存导入错误信息-' . $tt;
  6857. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6858. $tail = "\n";
  6859. $filename = $title . ".xls";
  6860. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6861. $dir = '/data/excel/' . $time . '/';
  6862. $file_name = 'error_' . $time . rand(1000, 9999);
  6863. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6864. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6865. fwrite($myfile, $ecl);
  6866. fclose($myfile);
  6867. $error = $dir . $file_name . '.xls';
  6868. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6869. exit;
  6870. } else {
  6871. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6872. exit;
  6873. }
  6874. }
  6875. }
  6876. public function _fcjxc($arg_array)
  6877. {
  6878. if (isset($_GET['excel'])) {
  6879. $category = $this->input->get('category', true);
  6880. $size = $this->input->get('size', true);
  6881. $grade = $this->input->get('grade', true);
  6882. $color = $this->input->get('color', true);
  6883. $lowe = $this->input->get('lowe', true);
  6884. $sku = $this->input->get('sku');
  6885. $title = $this->input->get('title');
  6886. $warehouse = $arg_array[0];
  6887. $usa = $this->input->get('usa', true);
  6888. $purchase = $this->input->get('purchase', true);
  6889. $lacetype = $this->input->get('lacetype', true);
  6890. $haircap = $this->input->get('haircap', true);
  6891. $density = $this->input->get('density', true);
  6892. $title = $this->input->get('title', true);
  6893. $state = $this->input->get('state', true);
  6894. $ktime = $this->input->get('ktime', true);
  6895. $jtime = $this->input->get('jtime', true);
  6896. $where = "state=11";
  6897. $gj = "";
  6898. $ck = "";
  6899. if ($lacetype) {
  6900. $where .= " and features like '%-$lacetype-%'";
  6901. }
  6902. if ($category) {
  6903. $where .= " and features like '%-$category-%'";
  6904. }
  6905. if ($size) {
  6906. $where .= " and features like '%-$size-%'";
  6907. }
  6908. if ($grade) {
  6909. $where .= " and features like '%-$grade-%'";
  6910. }
  6911. if ($color) {
  6912. $where .= " and features like '%-$color-%'";
  6913. }
  6914. if ($lowe) {
  6915. $where .= " and features like '%-$lowe-%'";
  6916. }
  6917. if ($haircap) {
  6918. $where .= " and features like '%-$haircap-%'";
  6919. }
  6920. if ($density) {
  6921. $where .= " and features like '%-$density-%'";
  6922. }
  6923. if ($usa) {
  6924. if (!$warehouse) {
  6925. $where .= " and (warehouse = '5' or warehouse = '8')";
  6926. }
  6927. }
  6928. if ($warehouse) {
  6929. $where .= " and warehouse = '$warehouse'";
  6930. }
  6931. if ($purchase) {
  6932. $where .= " and purchase = '$purchase'";
  6933. }
  6934. if ($state) {
  6935. $where .= " and state = '$state'";
  6936. }
  6937. $order_str = "id desc";
  6938. if ($sku) {
  6939. $sku = trim($sku, ' ');
  6940. $sku = trim($sku, ' ');
  6941. $where .= " and sku like '%$sku%'";
  6942. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6943. } else if ($title) {
  6944. $title = trim($title, ' ');
  6945. $title = trim($title, ' ');
  6946. $where .= " and title like '%$title%'";
  6947. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6948. } else {
  6949. //$where .= " and time > '$ktime' and time < '$jtime'";
  6950. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6951. }
  6952. //取得信息列表
  6953. $rows = array();
  6954. $list = array();
  6955. foreach ($info_list as $key => $value) {
  6956. $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'] . '"');
  6957. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6958. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6959. $rows[$key] = $value;
  6960. $warehouse = $this->warehouse->read($value['warehouse']);
  6961. $rows[$key]['warehouse'] = $warehouse['title'];
  6962. $rows[$key]['features'] = $g;
  6963. $rows[$key]['a'] = $x;
  6964. $rows[$key]['b'] = $s;
  6965. }
  6966. $title = "总统计表";
  6967. $titlename = "<table border=1>
  6968. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6969. <tr align='center'>
  6970. <td>仓库</td>
  6971. <td>SKU</td>
  6972. <td>产品名称</td>
  6973. <td>录入总量</td>
  6974. <td>取出总量</td>
  6975. <td>剩余总量</td>
  6976. </tr>
  6977. </table>";
  6978. $filename = $title . ".xls";
  6979. $tail = "";
  6980. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6981. }
  6982. $vip = 0;
  6983. if (isset($_SESSION['api'])) {
  6984. $user = $this->user->get_api($_SESSION['api']);
  6985. if ($user['vip'] == 1) {
  6986. $vip = 1;
  6987. }
  6988. } else {
  6989. header('Location: /');
  6990. exit;
  6991. }
  6992. $post = $this->input->post(NULL, TRUE);
  6993. if (isset($post['page'])) {
  6994. $page = $this->input->post('page', true);
  6995. $perpage = $this->input->post('perpage', true);
  6996. $category = $this->input->post('category', true);
  6997. $size = $this->input->post('size', true);
  6998. $grade = $this->input->post('grade', true);
  6999. $color = $this->input->post('color', true);
  7000. $lowe = $this->input->post('lowe', true);
  7001. $sku = $this->input->post('sku');
  7002. $title = $this->input->post('title');
  7003. $warehouse = $arg_array[0];
  7004. $usa = $this->input->post('usa', true);
  7005. $purchase = $this->input->post('purchase', true);
  7006. $lacetype = $this->input->post('lacetype', true);
  7007. $haircap = $this->input->post('haircap', true);
  7008. $density = $this->input->post('density', true);
  7009. $title = $this->input->post('title', true);
  7010. $state = $this->input->post('state', true);
  7011. $ktime = $this->input->post('ktime', true);
  7012. $jtime = $this->input->post('jtime', true);
  7013. $ktime = strtotime($ktime);
  7014. $jtime = strtotime($jtime);
  7015. $where = "state=11";
  7016. $gj = "";
  7017. $ck = "";
  7018. if ($lacetype) {
  7019. $where .= " and features like '%-$lacetype-%'";
  7020. }
  7021. if ($category) {
  7022. $where .= " and features like '%-$category-%'";
  7023. }
  7024. if ($size) {
  7025. $where .= " and features like '%-$size-%'";
  7026. }
  7027. if ($grade) {
  7028. $where .= " and features like '%-$grade-%'";
  7029. }
  7030. if ($color) {
  7031. $where .= " and features like '%-$color-%'";
  7032. }
  7033. if ($lowe) {
  7034. $where .= " and features like '%-$lowe-%'";
  7035. }
  7036. if ($haircap) {
  7037. $where .= " and features like '%-$haircap-%'";
  7038. }
  7039. if ($density) {
  7040. $where .= " and features like '%-$density-%'";
  7041. }
  7042. if ($usa) {
  7043. if (!$warehouse) {
  7044. $where .= " and (warehouse = '5' or warehouse = '8')";
  7045. }
  7046. }
  7047. if ($warehouse) {
  7048. $where .= " and warehouse = '$warehouse'";
  7049. }
  7050. if ($purchase) {
  7051. $where .= " and purchase = '$purchase'";
  7052. }
  7053. if ($state) {
  7054. $where .= " and state = '$state'";
  7055. }
  7056. if ($ktime && $jtime) {
  7057. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7058. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7059. }
  7060. //数据排序
  7061. $order_str = "id desc";
  7062. $xs = 0;
  7063. $rows = array();
  7064. $list = array();
  7065. if (empty($page)) {
  7066. $start = 0;
  7067. $perpage = 1;
  7068. } else {
  7069. $start = ($page - 1) * $perpage;
  7070. }
  7071. if ($sku || $title) {
  7072. if ($title) {
  7073. $title = trim($title, ' ');
  7074. $title = trim($title, ' ');
  7075. $where .= " and title like '%$title%'";
  7076. } else {
  7077. $sku = trim($sku, ' ');
  7078. $sku = trim($sku, ' ');
  7079. $where .= " and sku like '%$sku%'";
  7080. }
  7081. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7082. foreach ($info_list as $key => $value) {
  7083. $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'] . '"');
  7084. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7085. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7086. $rows[$key] = $value;
  7087. $warehouse = $this->warehouse->read($value['warehouse']);
  7088. $rows[$key]['warehouse'] = $warehouse['title'];
  7089. $rows[$key]['features'] = $g;
  7090. $rows[$key]['a'] = $x;
  7091. $rows[$key]['b'] = $s;
  7092. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7093. $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天销量
  7094. $yj = $c / ($xl / 30);
  7095. if ($yj < 7) {
  7096. $rows[$key]['y'] = round($yj) . '天销量';
  7097. } else {
  7098. $rows[$key]['y'] = '正常';
  7099. }
  7100. }
  7101. } else {
  7102. //$where .= " and time > '$ktime' and time < '$jtime'";
  7103. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7104. foreach ($info_list as $key => $value) {
  7105. $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'] . '"');
  7106. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7107. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7108. $zs[$key] = $value;
  7109. $warehouse = $this->warehouse->read($value['warehouse']);
  7110. $zs[$key]['warehouse'] = $warehouse['title'];
  7111. $zs[$key]['features'] = $g;
  7112. $zs[$key]['a'] = $x;
  7113. $zs[$key]['b'] = $s;
  7114. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7115. $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天销量
  7116. $yj = $c / ($xl / 30);
  7117. if ($yj < 7) {
  7118. $zs[$key]['y'] = round($yj) . '天销量';
  7119. $rows[$key] = $zs[$key];
  7120. }
  7121. }
  7122. }
  7123. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7124. $pagenum = ceil($total / $perpage);
  7125. $over = $total - ($start + $perpage);
  7126. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7127. echo json_encode($rows);
  7128. exit;
  7129. }
  7130. $this->data['arg_array'] = $arg_array[0];
  7131. $this->_Template('whlabel_fcjxc', $this->data);
  7132. }
  7133. public function _0kcdel()
  7134. {
  7135. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7136. $config['upload_path'] = '.' . $dir;
  7137. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7138. $config['allowed_types'] = 'xls|xlsx|csv';
  7139. $config['max_size'] = 10240;
  7140. $this->load->library('upload', $config);
  7141. $this->upload->initialize($config);
  7142. if ($this->upload->do_upload('userfile')) {
  7143. $full_path = $dir . $this->upload->data('file_name');
  7144. $fileName = '.' . $full_path;
  7145. if (!file_exists($fileName)) {
  7146. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7147. exit;
  7148. } else {
  7149. require_once "./data/excel/PHPExcel/IOFactory.php";
  7150. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7151. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7152. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7153. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7154. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7155. ++$column; //如果列数大于26行
  7156. $list = array();
  7157. for ($i = 2; $i <= $row; $i++) // 行数循环
  7158. {
  7159. $data = array();
  7160. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7161. {
  7162. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7163. }
  7164. $list[] = $data;
  7165. }
  7166. }
  7167. $i = 0;
  7168. $j = 0;
  7169. $ed = array();
  7170. foreach ($list as $key => $value) {
  7171. $time = time();
  7172. if ($value['0'] == "" || $value['1'] == "") {
  7173. continue;
  7174. }
  7175. $warehouse = $this->warehouse->get_title($value['0']);
  7176. $sku = $value['1'];
  7177. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7178. if (!$d) //如果没有这个SKU
  7179. {
  7180. $ed[] = array($sku . '-库存中不存在此SKU');
  7181. $j++;
  7182. continue;
  7183. }
  7184. if (!isset($warehouse['id'])) {
  7185. $ed[] = array($sku . '-仓库名错误!');
  7186. $j++;
  7187. continue;
  7188. }
  7189. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7190. if ($z < 1) {
  7191. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7192. foreach ($z as $v) {
  7193. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7194. if (count($zt) > 0) {
  7195. $ed[] = array($sku . '-有在途库存无法删除!');
  7196. $j++;
  7197. continue;
  7198. }
  7199. $this->whlabel->remove($v['id']);
  7200. }
  7201. } else {
  7202. $ed[] = array($sku . '-非0库存!');
  7203. $j++;
  7204. continue;
  7205. }
  7206. }
  7207. if ($j > 0) {
  7208. $tt = date('Ymd', time());
  7209. $title = '删除0库存错误信息-' . $tt;
  7210. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7211. $tail = "\n";
  7212. $filename = $title . ".xls";
  7213. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7214. $dir = '/data/excel/' . $time . '/';
  7215. $file_name = 'error_' . $time . rand(1000, 9999);
  7216. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7217. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7218. fwrite($myfile, $ecl);
  7219. fclose($myfile);
  7220. $error = $dir . $file_name . '.xls';
  7221. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7222. exit;
  7223. } else {
  7224. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7225. exit;
  7226. }
  7227. }
  7228. }
  7229. public function _gbhtype()
  7230. {
  7231. $post = $this->input->post(NULL, TRUE);
  7232. if (isset($post['s'])) {
  7233. $n = $this->input->post('n');
  7234. $d = $this->input->post('s');
  7235. if (!$d) {
  7236. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7237. exit;
  7238. }
  7239. $d = explode(',', trim($d, ','));
  7240. $t = $this->whlabel_type->read($n);
  7241. //循环删除记录
  7242. foreach ($d as $v) {
  7243. $u = $this->whlabel->read($v);
  7244. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7245. foreach ($data as $val) {
  7246. $this->whlabel->save(array('type' => $n), $val['id']);
  7247. }
  7248. }
  7249. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7250. }
  7251. }
  7252. //出库、退库导出
  7253. public function _dccrtype()
  7254. {
  7255. $classid = $this->classid->sku();
  7256. $pm = $classid;
  7257. $typeclass = array();
  7258. $tc = $this->typeclass->find_all();
  7259. foreach ($tc as $v) {
  7260. $typeclass[$v['id']] = $v;
  7261. }
  7262. $prc = array();
  7263. $purchase = $this->purchase->find_all();
  7264. foreach ($purchase as $k => $v) {
  7265. $prc[$v['id']] = $v['title'];
  7266. }
  7267. if (isset($_GET['sid'])) {
  7268. $wh = array();
  7269. $w = $this->warehouse->find_all('1=1', 'id,title');
  7270. foreach ($w as $v) {
  7271. $wh[$v['id']] = $v['title'];
  7272. }
  7273. $type = $this->input->get('excel', true);
  7274. $category = $this->input->get('category', true);
  7275. $size = $this->input->get('size', true);
  7276. $grade = $this->input->get('grade', true);
  7277. $color = $this->input->get('color', true);
  7278. $lowe = $this->input->get('lowe', true);
  7279. $sku = $this->input->get('sku', true);
  7280. $warehouse = $this->input->get('warehouse', true);
  7281. $lacetype = $this->input->get('lacetype', true);
  7282. $lacecolor = $this->input->get('lacecolor', true);
  7283. $density = $this->input->get('density', true);
  7284. $haircap = $this->input->get('haircap', true);
  7285. $purchase = $this->input->get('purchase', true);
  7286. $title = $this->input->get('title', true);
  7287. $state = $this->input->get('state', true);
  7288. $sid = $this->input->get('sid', true);
  7289. $ktime = $this->input->get('ktime', true);
  7290. $jtime = $this->input->get('jtime', true);
  7291. $ktime = strtotime($ktime);
  7292. $jtime = strtotime($jtime);
  7293. $where = "1=1";
  7294. $gj = "";
  7295. $ck = "";
  7296. if ($category) {
  7297. $where .= " and features like '%-$category-%'";
  7298. }
  7299. if ($size) {
  7300. $where .= " and features like '%-$size-%'";
  7301. }
  7302. if ($grade) {
  7303. $where .= " and features like '%-$grade-%'";
  7304. }
  7305. if ($color) {
  7306. $where .= " and features like '%-$color-%'";
  7307. }
  7308. if ($lowe) {
  7309. $where .= " and features like '%-$lowe-%'";
  7310. }
  7311. if ($warehouse) {
  7312. $where .= " and warehouse = '$warehouse'";
  7313. }
  7314. if ($purchase) {
  7315. $where .= " and purchase = '$purchase'";
  7316. }
  7317. if ($state) {
  7318. $where .= " and state = '$state'";
  7319. }
  7320. if ($lacetype) {
  7321. $where .= " and features like '%-$lacetype-%'";
  7322. }
  7323. if ($lacecolor) {
  7324. $where .= " and features like '%-$lacecolor-%'";
  7325. }
  7326. if ($density) {
  7327. $where .= " and features like '%-$density-%'";
  7328. }
  7329. if ($haircap) {
  7330. $where .= " and features like '%-$haircap-%'";
  7331. }
  7332. if ($title) {
  7333. $title = trim($title, ' ');
  7334. $title = trim($title, ' ');
  7335. $where .= " and title like '%$title%'";
  7336. }
  7337. if ($sku) {
  7338. $sku = trim($sku, ' ');
  7339. $sku = trim($sku, ' ');
  7340. $where .= " and sku like '%$sku%'";
  7341. }
  7342. if ($ktime && $jtime) {
  7343. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7344. }
  7345. $sidwhere = '';
  7346. if ($sid) {
  7347. $sd = "";
  7348. $s = explode(',', trim($sid, ','));
  7349. foreach ($s as $value) {
  7350. $sd .= " id = " . $value . " or";
  7351. }
  7352. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7353. }
  7354. //数据排序
  7355. $order_str = "time desc";
  7356. if (empty($page)) {
  7357. $start = 0;
  7358. $perpage = 1;
  7359. } else {
  7360. $start = ($page - 1) * $perpage;
  7361. }
  7362. $wh = array();
  7363. $w = $this->warehouse->find_all('1=1', 'id,title');
  7364. foreach ($w as $v) {
  7365. $wh[$v['id']] = $v['title'];
  7366. }
  7367. $wt = array();
  7368. $whlabel_type = $this->whlabel_type->find_all();
  7369. foreach ($whlabel_type as $v) {
  7370. $wt[$v['id']] = $v['title'];
  7371. }
  7372. $classid = $this->classid->sku();
  7373. $list = array();
  7374. $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');
  7375. foreach ($rows_r as $key => $value) {
  7376. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7377. $pm = $classid;
  7378. $jm = $classid;
  7379. $rows_r[$key]['enter'] = '入库';
  7380. $rows_r[$key]['time'] = $value['enter'];
  7381. if ($value['rktype'] == 1) {
  7382. $rows_r[$key]['rktype'] = '采购入库';
  7383. } else if ($value['rktype'] == 2) {
  7384. $rows_r[$key]['rktype'] = '盘盈调整';
  7385. } else if ($value['rktype'] == 3) {
  7386. $rows_r[$key]['rktype'] = '其他调整入库';
  7387. } else if ($value['rktype'] == 4) {
  7388. $rows_r[$key]['rktype'] = '其他调整入库';
  7389. } else if ($value['rktype'] == 5) {
  7390. $rows_r[$key]['rktype'] = '退库入库';
  7391. } else if ($value['rktype'] == 6) {
  7392. $rows_r[$key]['rktype'] = '退货可用入库';
  7393. } else if ($value['rktype'] == 7) {
  7394. $rows_r[$key]['rktype'] = '形态转换入库';
  7395. } else {
  7396. $rows_r[$key]['rktype'] = '';
  7397. }
  7398. $features = explode('-', trim($value['features'], '-'));
  7399. foreach ($features as $v) {
  7400. if (isset($typeclass[$v])) {
  7401. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7402. $pm[$typeclass[$v]['classid']] = $zh[0];
  7403. }
  7404. if (isset($typeclass[$v])) {
  7405. if (isset($jm[$typeclass[$v]['classid']])) {
  7406. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7407. }
  7408. }
  7409. }
  7410. $zh = implode(" ", $pm);
  7411. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7412. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7413. $rows_r[$key]['zh'] = $zh;
  7414. $jm = array_filter($jm);
  7415. $rows_r[$key]['features'] = implode("-", $jm);
  7416. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7417. }
  7418. $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');
  7419. foreach ($rows_c as $key => $value) {
  7420. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7421. $pm = $classid;
  7422. $jm = $classid;
  7423. $rows_c[$key]['time'] = $value['outk'];
  7424. $rows_c[$key]['outk'] = '出库';
  7425. if ($value['cktype'] == 1) {
  7426. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7427. } else if ($value['cktype'] == 2) {
  7428. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7429. } else if ($value['cktype'] == 3) {
  7430. $rows_c[$key]['cktype'] = '盘亏调整';
  7431. } else if ($value['cktype'] == 4) {
  7432. $rows_c[$key]['cktype'] = '其他调整出库';
  7433. } else if ($value['cktype'] == 5) {
  7434. $rows_c[$key]['cktype'] = '形态转换出库';
  7435. } else {
  7436. $rows_c[$key]['cktype'] = '';
  7437. }
  7438. unset($rows_c[$key]['state']);
  7439. $features = explode('-', trim($value['features'], '-'));
  7440. foreach ($features as $v) {
  7441. if (isset($typeclass[$v])) {
  7442. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7443. $pm[$typeclass[$v]['classid']] = $zh[0];
  7444. }
  7445. if (isset($typeclass[$v])) {
  7446. if (isset($jm[$typeclass[$v]['classid']])) {
  7447. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7448. }
  7449. }
  7450. }
  7451. $zh = implode(" ", $pm);
  7452. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7453. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7454. $rows_c[$key]['zh'] = $zh;
  7455. $jm = array_filter($jm);
  7456. $rows_c[$key]['features'] = implode("-", $jm);
  7457. $rows_c[$key]['number'] = 1;
  7458. }
  7459. $merged = $rows_r;
  7460. foreach ($rows_c as $key => $value) {
  7461. if (isset($merged[$key])) {
  7462. $merged[] = $value;
  7463. } else {
  7464. $merged[$key] = $value;
  7465. }
  7466. }
  7467. usort($merged, function ($a, $b) {
  7468. return $a['time'] - $b['time'];
  7469. });
  7470. foreach ($merged as $key => $value) {
  7471. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7472. }
  7473. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7474. $titlename = "<table border=1>
  7475. <tr align='center'>
  7476. <td>仓库</td>
  7477. <td>SKU</td>
  7478. <td>商品名称</td>
  7479. <td>仓库品名</td>
  7480. <td>料号</td>
  7481. <td>时间</td>
  7482. <td>操作</td>
  7483. <td>类型</td>
  7484. <td>数量</td>
  7485. <td>备注</td>
  7486. </tr>
  7487. </table>";
  7488. $filename = $title . ".xlsx";
  7489. $tail = "";
  7490. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7491. }
  7492. }
  7493. /*************************************处理exceljs导出****************************************************/
  7494. public function _excelrjs(){
  7495. if (isset($_GET['excel'])) {
  7496. $category = $this->input->get('category', true);
  7497. $size = $this->input->get('size', true);
  7498. $grade = $this->input->get('grade', true);
  7499. $color = $this->input->get('color', true);
  7500. $lowe = $this->input->get('lowe', true);
  7501. $sku = $this->input->get('sku', true);
  7502. $warehouse = $this->input->get('warehouse', true);
  7503. $purchase = $this->input->get('purchase', true);
  7504. $ktime = $this->input->get('ktime', true);
  7505. $jtime = $this->input->get('jtime', true);
  7506. $ktime = strtotime($ktime);
  7507. $jtime = strtotime($jtime);
  7508. $where = "1=1";
  7509. $gj = "";
  7510. $ck = "";
  7511. if ($category) {
  7512. $where .= " and features like '%-$category-%'";
  7513. }
  7514. if ($size) {
  7515. $where .= " and features like '%-$size-%'";
  7516. }
  7517. if ($grade) {
  7518. $where .= " and features like '%-$grade-%'";
  7519. }
  7520. if ($color) {
  7521. $where .= " and features like '%-$color-%'";
  7522. }
  7523. if ($lowe) {
  7524. $where .= " and features like '%-$lowe-%'";
  7525. }
  7526. if ($warehouse) {
  7527. $where .= " and warehouse = '$warehouse'";
  7528. }
  7529. if ($purchase) {
  7530. $where .= " and purchase = '$purchase'";
  7531. }
  7532. if ($sku) {
  7533. $where .= " and sku = '$sku'";
  7534. }
  7535. if ($ktime && $jtime) {
  7536. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7537. }
  7538. //数据排序
  7539. $order_str = "id desc";
  7540. if (empty($page)) {
  7541. $start = 0;
  7542. $perpage = 1;
  7543. } else {
  7544. $start = ($page - 1) * $perpage;
  7545. }
  7546. $list = array();
  7547. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7548. foreach ($rows as $value) {
  7549. $ck = $this->warehouse->read($value['warehouse']);
  7550. $warehouse = $ck['title'];
  7551. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7552. $retreatwarehouse = $tkck['title'];
  7553. $gy = $this->purchase->read($value['purchase']);
  7554. $purchase = $gy['title'];
  7555. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7556. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7557. }
  7558. if(empty($list)){
  7559. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7560. }else{
  7561. $final_list = [];
  7562. foreach($list as $v){
  7563. $final_list[] = array_values($v);
  7564. }
  7565. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7566. array_unshift($final_list,[
  7567. "仓库","SKU","商品名称","时间","数量"
  7568. ]);
  7569. array_unshift($final_list,[
  7570. $title,"","","",""
  7571. ]);
  7572. $merges = [
  7573. [
  7574. "s"=>["r"=>0,"c"=>0],
  7575. "e"=>["r"=>0,"c"=>4]
  7576. ]
  7577. ];
  7578. $cols = [
  7579. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7580. ];
  7581. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7582. }
  7583. }
  7584. }
  7585. //出库、退库导出
  7586. public function _excelctjs()
  7587. {
  7588. $classid = $this->classid->sku();
  7589. $pm = $classid;
  7590. $typeclass = array();
  7591. $tc = $this->typeclass->find_all();
  7592. foreach ($tc as $v) {
  7593. $typeclass[$v['id']] = $v;
  7594. }
  7595. $prc = array();
  7596. $purchase = $this->purchase->find_all();
  7597. foreach ($purchase as $k => $v) {
  7598. $prc[$v['id']] = $v['title'];
  7599. }
  7600. if (isset($_GET['excel'])) {
  7601. $wh = array();
  7602. $w = $this->warehouse->find_all('1=1', 'id,title');
  7603. foreach ($w as $v) {
  7604. $wh[$v['id']] = $v['title'];
  7605. }
  7606. $type = $this->input->get('excel', true);
  7607. $category = $this->input->get('category', true);
  7608. $size = $this->input->get('size', true);
  7609. $grade = $this->input->get('grade', true);
  7610. $color = $this->input->get('color', true);
  7611. $lowe = $this->input->get('lowe', true);
  7612. $sku = $this->input->get('sku', true);
  7613. $title = $this->input->get('title', true);
  7614. $warehouse = $this->input->get('warehouse', true);
  7615. $purchase = $this->input->get('purchase', true);
  7616. $lacetype = $this->input->get('lacetype', true);
  7617. $haircap = $this->input->get('haircap', true);
  7618. $lacecolor = $this->input->get('lacecolor', true);
  7619. $density = $this->input->get('density', true);
  7620. $details = $this->input->get('details', true);
  7621. $state = $this->input->get('state', true);
  7622. $shop = $this->input->get('shop', true);
  7623. $hairnumber = $this->input->get('hairnumber', true);
  7624. $type_leixi = $this->input->get('type', true);
  7625. $cpbz = $this->input->get('cpbz', true);
  7626. $sm = $this->input->get('sm', true);
  7627. $sid = $this->input->get('sid', true);
  7628. $ktime = $this->input->get('ktime', true);
  7629. $jtime = $this->input->get('jtime', true);
  7630. $ktime = strtotime($ktime);
  7631. $jtime = strtotime($jtime);
  7632. //$where = " 1=1 ";
  7633. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7634. $where = " sku != '' ";
  7635. $gj = "";
  7636. $ck = "";
  7637. if ($category) {
  7638. $where .= " and features like '%-$category-%'";
  7639. }
  7640. if ($size) {
  7641. $where .= " and features like '%-$size-%'";
  7642. }
  7643. if ($grade) {
  7644. $where .= " and features like '%-$grade-%'";
  7645. }
  7646. if ($color) {
  7647. $where .= " and features like '%-$color-%'";
  7648. }
  7649. if ($lowe) {
  7650. $where .= " and features like '%-$lowe-%'";
  7651. }
  7652. if ($warehouse) {
  7653. $where .= " and warehouse = '$warehouse'";
  7654. }
  7655. if ($purchase) {
  7656. $where .= " and purchase = '$purchase'";
  7657. }
  7658. if ($state) {
  7659. $where .= " and state = '$state'";
  7660. }
  7661. if ($lacetype) {
  7662. $where .= " and features like '%-$lacetype-%'";
  7663. }
  7664. if ($lacecolor) {
  7665. $where .= " and features like '%-$lacecolor-%'";
  7666. }
  7667. if ($density) {
  7668. $where .= " and features like '%-$density-%'";
  7669. }
  7670. if ($haircap) {
  7671. $where .= " and features like '%-$haircap-%'";
  7672. }
  7673. if ($details) {
  7674. $where .= " and details = '$details'";
  7675. }
  7676. if ($shop) {
  7677. $where .= " and shop like '%$shop%'";
  7678. }
  7679. if ($title) {
  7680. $title = trim($title, ' ');
  7681. $title = trim($title, ' ');
  7682. $where .= " and title like '%$title%'";
  7683. }
  7684. if (!empty($hairnumber)) {
  7685. $where .= " and features like '%-128-%' ";
  7686. if ($hairnumber < 0) {
  7687. $class_list = $this->typeclass->find_all('classid = 43');
  7688. foreach ($class_list as $v) {
  7689. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7690. }
  7691. } else {
  7692. $where .= " and features like '%-$hairnumber-%'";
  7693. }
  7694. }
  7695. if ($type_leixi) {
  7696. $where .= " and type = '$type_leixi'";
  7697. }
  7698. if ($cpbz) {
  7699. $where .= " and cpbz like '%$cpbz%' ";
  7700. }
  7701. if ($sm) {
  7702. $where .= " and sm like '%$sm%' ";
  7703. }
  7704. if ($sku) {
  7705. $sku = trim($sku, ' ');
  7706. $sku = trim($sku, ' ');
  7707. $where .= " and sku like '%$sku%'";
  7708. }
  7709. if ($ktime && $jtime) {
  7710. if ($type == 1) {
  7711. $tl = '出库';
  7712. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7713. } else if ($type == 2) {
  7714. $tl = '退库';
  7715. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7716. } else if ($type == 3) {
  7717. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7718. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7719. } else if ($type == 4) {
  7720. $tl = '出库+零售';
  7721. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7722. } else if ($type == 5) {
  7723. $tl = '零售';
  7724. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7725. }
  7726. }
  7727. $sidwhere = '';
  7728. if ($sid) {
  7729. $sd = "";
  7730. $s = explode(',', trim($sid, ','));
  7731. foreach ($s as $value) {
  7732. $sd .= " id = " . $value . " or";
  7733. }
  7734. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7735. }
  7736. //数据排序
  7737. $order_str = "time desc";
  7738. if (empty($page)) {
  7739. $start = 0;
  7740. $perpage = 1;
  7741. } else {
  7742. $start = ($page - 1) * $perpage;
  7743. }
  7744. //取得信息列表
  7745. if ($type != 3 && $type != 5) {
  7746. if ($type == 1 || $type == 4) {
  7747. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7748. foreach ($info_list as $key => $value) {
  7749. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7750. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7751. $warehouse = $this->warehouse->read($value['warehouse']);
  7752. $info_list[$key]['warehouse'] = $warehouse['title'];
  7753. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7754. $features = explode('-', trim($features, '-'));
  7755. $pm = $classid;
  7756. foreach ($features as $k => $v) {
  7757. if ($v != 0) {
  7758. if (!isset($typeclass[$v])) {
  7759. continue;
  7760. }
  7761. if (isset($pm[$typeclass[$v]['classid']])) {
  7762. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7763. $tz = explode('|', $typeclass[$v]['zh']);
  7764. $pm[$typeclass[$v]['classid']] = $tz[0];
  7765. } else {
  7766. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7767. }
  7768. }
  7769. }
  7770. }
  7771. $zh = implode(" ", $pm);
  7772. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7773. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7774. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7775. $info_list[$key]['features'] = $zh;
  7776. }
  7777. $final_list = [];
  7778. foreach($info_list as $k=>$v){
  7779. $number = "";
  7780. if(!empty($v['orderinfo'])){
  7781. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7782. if(!empty($tmp_info['number'])){
  7783. $number = $tmp_info['number'];
  7784. }
  7785. }
  7786. $final_list[] = [
  7787. 'warehouse'=>$v['warehouse'],
  7788. 'purchase'=>$v['purchase'],
  7789. 'sku'=>$v['sku'],
  7790. 'title'=>$v['title'],
  7791. 'features'=>$v['features'],
  7792. 'label'=>$v['label'],
  7793. 'orderinfo'=>$v['orderinfo'],
  7794. 'number'=>$number,
  7795. 'waybill'=>$v['waybill'],
  7796. 'outk'=>$v['outk'],
  7797. ];
  7798. }
  7799. } else {
  7800. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7801. foreach ($info_list as $key => $value) {
  7802. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7803. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7804. $warehouse = $this->warehouse->read($value['warehouse']);
  7805. $info_list[$key]['warehouse'] = $warehouse['title'];
  7806. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7807. $features = explode('-', trim($features, '-'));
  7808. $pm = $classid;
  7809. foreach ($features as $k => $v) {
  7810. if ($v != 0) {
  7811. if (!isset($typeclass[$v])) {
  7812. continue;
  7813. }
  7814. if (isset($pm[$typeclass[$v]['classid']])) {
  7815. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7816. $tz = explode('|', $typeclass[$v]['zh']);
  7817. $pm[$typeclass[$v]['classid']] = $tz[0];
  7818. } else {
  7819. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7820. }
  7821. }
  7822. }
  7823. }
  7824. $zh = implode(" ", $pm);
  7825. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7826. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7827. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7828. $info_list[$key]['features'] = $zh;
  7829. }
  7830. $final_list = [];
  7831. foreach($info_list as $k=>$v){
  7832. $number = "";
  7833. if(!empty($v['orderinfo'])){
  7834. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7835. if(!empty($tmp_info['number'])){
  7836. $number = $tmp_info['number'];
  7837. }
  7838. }
  7839. $final_list[] = [
  7840. 'warehouse'=>$v['warehouse'],
  7841. 'purchase'=>$v['purchase'],
  7842. 'sku'=>$v['sku'],
  7843. 'title'=>$v['title'],
  7844. 'features'=>$v['features'],
  7845. 'label'=>$v['label'],
  7846. 'orderinfo'=>$v['orderinfo'],
  7847. 'number'=>$number,
  7848. 'waybill'=>$v['waybill'],
  7849. 'retreat'=>$v['retreat'],
  7850. ];
  7851. }
  7852. }
  7853. if(empty($final_list)){
  7854. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7855. }else{
  7856. $end_list = [];
  7857. foreach($final_list as $v){
  7858. $end_list[] = array_values($v);
  7859. }
  7860. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7861. array_unshift($end_list,[
  7862. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7863. ]);
  7864. array_unshift($end_list,[
  7865. $title,"","","","","","","","",""
  7866. ]);
  7867. $merges = [
  7868. [
  7869. "s"=>["r"=>0,"c"=>0],
  7870. "e"=>["r"=>0,"c"=>9]
  7871. ]
  7872. ];
  7873. $cols = [
  7874. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  7875. ];
  7876. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  7877. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  7878. ] )));
  7879. }
  7880. } else if ($type == 5) {
  7881. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  7882. foreach ($info_list as $key => $value) {
  7883. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7884. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7885. $warehouse = $this->warehouse->read($value['warehouse']);
  7886. $info_list[$key]['warehouse'] = $warehouse['title'];
  7887. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7888. $features = explode('-', trim($features, '-'));
  7889. $pm = $classid;
  7890. foreach ($features as $k => $v) {
  7891. if ($v != 0) {
  7892. if (!isset($typeclass[$v])) {
  7893. continue;
  7894. }
  7895. if (isset($pm[$typeclass[$v]['classid']])) {
  7896. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7897. $tz = explode('|', $typeclass[$v]['zh']);
  7898. $pm[$typeclass[$v]['classid']] = $tz[0];
  7899. } else {
  7900. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7901. }
  7902. }
  7903. }
  7904. }
  7905. $zh = implode(" ", $pm);
  7906. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7907. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7908. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7909. $info_list[$key]['features'] = $zh;
  7910. }
  7911. if(empty($info_list)){
  7912. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7913. }else{
  7914. $final_list = [];
  7915. foreach($info_list as $v){
  7916. $final_list[] = array_values($v);
  7917. }
  7918. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  7919. array_unshift($final_list,[
  7920. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  7921. ]);
  7922. array_unshift($final_list,[
  7923. $title,"","","","","","",
  7924. ]);
  7925. $merges = [
  7926. [
  7927. "s"=>["r"=>0,"c"=>0],
  7928. "e"=>["r"=>0,"c"=>6]
  7929. ]
  7930. ];
  7931. $cols = [
  7932. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  7933. ];
  7934. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  7935. }
  7936. } else {
  7937. $wh = array();
  7938. $w = $this->warehouse->find_all('1=1', 'id,title');
  7939. foreach ($w as $v) {
  7940. $wh[$v['id']] = $v['title'];
  7941. }
  7942. $wt = array();
  7943. $whlabel_type = $this->whlabel_type->find_all();
  7944. foreach ($whlabel_type as $v) {
  7945. $wt[$v['id']] = $v['title'];
  7946. }
  7947. $classid = $this->classid->sku();
  7948. $list = array();
  7949. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  7950. foreach ($rows as $key => $value) {
  7951. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7952. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7953. $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');
  7954. $details = array();
  7955. $cpid = array();
  7956. $cpbz = array();
  7957. $c = 0;
  7958. $g = 0;
  7959. $x = 0;
  7960. $t = 0;
  7961. $s = 0;
  7962. $q = 0;
  7963. foreach ($sd as $k => $v) {
  7964. if ($v['state'] == 0) {
  7965. $c++;
  7966. }
  7967. if ($v['state'] != 9) {
  7968. $g++;
  7969. }
  7970. if ($v['outk'] > 1) {
  7971. $x++;
  7972. }
  7973. if ($v['retreat'] > 0) {
  7974. $t++;
  7975. }
  7976. if ($v['state'] == 8) {
  7977. $s++;
  7978. }
  7979. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  7980. $q++;
  7981. }
  7982. $details[$v['details']] = $v['details'];
  7983. if ($v['cpid'] != 0) {
  7984. $cpid[$v['cpid']] = $v['cpid'];
  7985. }
  7986. if ($v['cpbz'] != '') {
  7987. $cpbz[$v['cpbz']] = $v['cpbz'];
  7988. }
  7989. }
  7990. if (isset($wt[$value['type']])) {
  7991. $rows[$key]['type'] = $wt[$value['type']];
  7992. } else {
  7993. $rows[$key]['type'] = '未设置';
  7994. }
  7995. $rows[$key]['details'] = implode("、", $details);
  7996. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  7997. $ftime = time() - 15 * 24 * 3600;
  7998. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  7999. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8000. $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);
  8001. $rows[$key]['c'] = $c;
  8002. $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);
  8003. $rows[$key]['t'] = $t;
  8004. $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'] . '"');
  8005. $rows[$key]['z'] = $z;
  8006. // $jm = $classid;
  8007. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8008. $features = explode('-', trim($features, '-'));
  8009. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8010. }
  8011. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8012. $final_list =[];
  8013. foreach($tmp_list as $k=>$v){
  8014. $final_list[] = [
  8015. "warehouse"=>$v['warehouse'],
  8016. "purchase"=>$v['purchase'],
  8017. "details"=>$v['details'],
  8018. "cpid"=>$v['cpid'],
  8019. "sku"=>$v['sku'],
  8020. "title"=>$v['title'],
  8021. "features"=>$v['pm'],
  8022. "cpbz"=>$v['cpbz'],
  8023. "sm"=>$v['sm'],
  8024. "type"=>$v['type'],
  8025. "g"=>$v["g"],
  8026. "c"=>$v["c"],
  8027. "x"=>$v["x"],
  8028. "t"=>$v["t"],
  8029. "z"=>$v["z"],
  8030. "jm"=>$v["jm"],
  8031. "weight"=>$v["weight"],
  8032. "asd"=>$v["asd"],
  8033. ];
  8034. }
  8035. if(empty($final_list)){
  8036. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8037. }else{
  8038. $end_list = [];
  8039. foreach($final_list as $v){
  8040. $end_list[] = array_values($v);
  8041. }
  8042. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8043. array_unshift($end_list,[
  8044. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8045. ]);
  8046. array_unshift($end_list,[
  8047. $title,"","","","","","","","","","","","","","","","","",""
  8048. ]);
  8049. $merges = [
  8050. [
  8051. "s"=>["r"=>0,"c"=>0],
  8052. "e"=>["r"=>0,"c"=>6]
  8053. ]
  8054. ];
  8055. $cols = [
  8056. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8057. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8058. ];
  8059. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8060. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8061. ])));
  8062. }
  8063. }
  8064. }
  8065. }
  8066. public function _exceljxcjs(){
  8067. $classid = $this->classid->sku();
  8068. $pm = $classid;
  8069. $typeclass = array();
  8070. $tc = $this->typeclass->find_all();
  8071. foreach ($tc as $v) {
  8072. $typeclass[$v['id']] = $v;
  8073. }
  8074. $prc = array();
  8075. $purchase = $this->purchase->find_all();
  8076. foreach ($purchase as $k => $v) {
  8077. $prc[$v['id']] = $v['title'];
  8078. }
  8079. if(!isset($_GET['excel'])){
  8080. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8081. }
  8082. $where = "sku != 'Preset'";
  8083. //数据排序
  8084. $order_str = "id desc";
  8085. if (empty($page)) {
  8086. $start = 0;
  8087. $perpage = 1;
  8088. } else {
  8089. $start = ($page - 1) * $perpage;
  8090. }
  8091. $category = $this->input->get('category', true);
  8092. $warehouse = $this->input->get('warehouse', true);
  8093. $excelid = $this->input->get('sid', true);
  8094. if ($category) {
  8095. $where .= " and features like '%-$category-%'";
  8096. }
  8097. if ($warehouse) {
  8098. $where .= " and warehouse = '$warehouse'";
  8099. }
  8100. $xzid = '';
  8101. if ($excelid) {
  8102. $excelid = explode(',', trim($excelid, ','));
  8103. foreach ($excelid as $key => $value) {
  8104. $xzid .= " id = " . $value . " or";
  8105. }
  8106. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8107. }
  8108. $wt = array();
  8109. $whlabel_type = $this->whlabel_type->find_all();
  8110. foreach ($whlabel_type as $v) {
  8111. $wt[$v['id']] = $v['title'];
  8112. }
  8113. $wh = array();
  8114. $w = $this->warehouse->find_all('1=1', 'id,title');
  8115. foreach ($w as $v) {
  8116. $wh[$v['id']] = $v['title'];
  8117. }
  8118. $list = array();
  8119. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8120. foreach ($rows as $key => $value) {
  8121. if (isset($wt[$value['type']])) {
  8122. $rows[$key]['type'] = $wt[$value['type']];
  8123. } else {
  8124. $rows[$key]['type'] = '未设置';
  8125. }
  8126. $bm = '03';
  8127. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8128. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8129. $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');
  8130. $details = array();
  8131. $cpid = array();
  8132. $cpbz = array();
  8133. $c = 0;
  8134. $g = 0;
  8135. $x = 0;
  8136. $t = 0;
  8137. $s = 0;
  8138. $q = 0;
  8139. foreach ($sd as $k => $v) {
  8140. if ($v['state'] == 0) {
  8141. $c++;
  8142. if ($v['cpid'] != 0) {
  8143. $cpid[$v['cpid']] = $v['cpid'];
  8144. }
  8145. if ($v['cpbz'] != '') {
  8146. $cpbz[$v['cpbz']] = $v['cpbz'];
  8147. }
  8148. }
  8149. if ($v['state'] != 9) {
  8150. $g++;
  8151. }
  8152. if ($v['state'] == 1) {
  8153. $x++;
  8154. }
  8155. if ($v['state'] == 2) {
  8156. $t++;
  8157. }
  8158. if ($v['state'] == 8) {
  8159. $s++;
  8160. }
  8161. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8162. $q++;
  8163. }
  8164. $details[$v['details']] = $v['details'];
  8165. }
  8166. $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'] . '"');
  8167. $rows[$key]['details'] = implode("、", $details);
  8168. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8169. $number = $value['number'];
  8170. $ftime = time() - 15 * 24 * 3600;
  8171. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8172. $rows[$key]['number'] = $g;
  8173. $rows[$key]['c'] = $c;
  8174. $rows[$key]['x'] = $x;
  8175. $rows[$key]['t'] = $t;
  8176. $rows[$key]['s'] = $s;
  8177. $rows[$key]['q'] = $q;
  8178. $rows[$key]['z'] = $z;
  8179. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8180. $features = explode('-', trim($features, '-'));
  8181. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8182. }
  8183. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8184. $final_list = [];
  8185. foreach ($list as $k => $v) {
  8186. if (empty($v['sku'])) {
  8187. continue;
  8188. }
  8189. $final_list[] = [
  8190. $v["warehouse"],
  8191. $v["purchase"],
  8192. $v["details"],
  8193. $v["cpid"],
  8194. $v["dbcontent"],
  8195. $v["sku"],
  8196. $v["bm"],
  8197. $v["jm"],
  8198. $v["title"],
  8199. $v["pm"],
  8200. $v["cpbz"],
  8201. $v["sm"],
  8202. $v["type"],
  8203. $v["number"],
  8204. $v["c"],
  8205. $v["x"],
  8206. $v["t"],
  8207. $v["s"],
  8208. $v["q"],
  8209. $v["z"],
  8210. $v['weight'],
  8211. ];
  8212. }
  8213. if(empty($final_list)){
  8214. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8215. }
  8216. $title = "总进销存统计表";
  8217. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8218. $merges = [
  8219. [
  8220. "s"=>["r"=>0,"c"=>0],
  8221. "e"=>["r"=>0,"c"=>21]
  8222. ]
  8223. ];
  8224. $cols = [
  8225. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8226. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8227. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8228. ];
  8229. array_unshift($final_list, $first_row);
  8230. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8231. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8232. }
  8233. public function _summaryjs($arg_array)
  8234. {
  8235. $prc = array();
  8236. $purchase = $this->purchase->find_all();
  8237. foreach ($purchase as $k => $v) {
  8238. $prc[$v['id']] = $v['title'];
  8239. }
  8240. if (isset($_GET['excel'])) {
  8241. $ktime = $this->input->get('ktime', true);
  8242. $jtime = $this->input->get('jtime', true);
  8243. $ktime = strtotime($ktime);
  8244. $jtime = strtotime($jtime);
  8245. $where = "1=1";
  8246. if ($ktime && $jtime) {
  8247. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8248. }
  8249. //数据排序
  8250. $order_str = "time desc";
  8251. if (empty($page)) {
  8252. $start = 0;
  8253. $perpage = 1;
  8254. } else {
  8255. $start = ($page - 1) * $perpage;
  8256. }
  8257. //取得信息列表
  8258. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8259. foreach ($info_list as $key => $value) {
  8260. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8261. $warehouse = $this->warehouse->read($value['warehouse']);
  8262. $info_list[$key]['warehouse'] = $warehouse['title'];
  8263. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8264. $details = array();
  8265. $cpid = array();
  8266. foreach ($x as $k => $v) {
  8267. if ($v['details'] != '') {
  8268. $details[$v['details']] = $v['details'];
  8269. }
  8270. if ($v['cpid'] != 0) {
  8271. $cpid[$v['cpid']] = $v['cpid'];
  8272. }
  8273. }
  8274. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8275. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8276. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8277. $info_list[$key]['s'] = $s;
  8278. $info_list[$key]['x'] = count($x);
  8279. }
  8280. if(empty($info_list)){
  8281. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8282. }
  8283. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8284. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8285. $merges = [
  8286. [
  8287. "s"=>["r"=>0,"c"=>0],
  8288. "e"=>["r"=>0,"c"=>7]
  8289. ]
  8290. ];
  8291. $cols = [
  8292. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8293. ];
  8294. $final_list = [];
  8295. foreach($info_list as $k => $v){
  8296. $final_list[] = array_values($v);
  8297. }
  8298. array_unshift($final_list, $first_row);
  8299. array_unshift($final_list,[
  8300. $title,"","","","","","","","",
  8301. ]);
  8302. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8303. $titlename = "<table border=1>
  8304. <tr align='center'>
  8305. <td>仓库</td>
  8306. <td>供应商</td>
  8307. <td>出库位置</td>
  8308. <td>出库编码</td>
  8309. <td>SKU</td>
  8310. <td>产品名</td>
  8311. <td>总剩余库存</td>
  8312. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8313. </tr>
  8314. </table>";
  8315. $filename = $title . ".xls";
  8316. $tail = "";
  8317. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8318. }
  8319. }
  8320. public function _uckjs()
  8321. {
  8322. if (isset($_GET['excel'])) {
  8323. $tc = array();
  8324. $typeclass = $this->typeclass->find_all();
  8325. foreach ($typeclass as $v) {
  8326. $tc[$v['id']] = $v['zh'];
  8327. }
  8328. $first_row = [
  8329. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8330. ];
  8331. $t = array();
  8332. $rq = '';
  8333. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8334. $ts = $ts / (24 * 3600);
  8335. for ($i = 0; $i < $ts; $i++) {
  8336. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8337. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8338. }
  8339. $day_len = count($t);
  8340. $first_row[] = "本月出库";
  8341. $merges = [
  8342. ];
  8343. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8344. $excel_key = 1;
  8345. $final_list = [];
  8346. foreach ($info_list as $k => $v) {
  8347. $features = explode('-', trim($v['features'], '-'));
  8348. if (!isset($features[3]) || !isset($features[4])) {
  8349. continue;
  8350. }
  8351. $tmp = [];
  8352. $tmp[0] = $tc[$features[0]]; //类型
  8353. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8354. $tmp[2] = $tc[$features[4]]; //曲度
  8355. $tmp[3] = '';
  8356. if (isset($data[$k][1])) {
  8357. $tmp[3] .=$tmp[1];
  8358. }
  8359. if (isset($data[$k][2])) {
  8360. $tmp[3] .= $tmp[2];
  8361. }
  8362. if (isset($features[5])) {
  8363. $tmp[3] .= $tc[$features[5]];
  8364. }
  8365. if (isset($features[2])) {
  8366. $tmp[3] .= $tc[$features[2]];
  8367. }
  8368. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8369. $tmp[4] = $v['sku'];
  8370. $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())) . '))'); //月初库存
  8371. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8372. $tmp[7] ="";
  8373. $tmp[8] ="";
  8374. $byck = 0;
  8375. foreach ($t as $vv) {
  8376. $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));
  8377. $tmp[] = ($sl > 0) ? $sl : '';
  8378. $byck += $sl;
  8379. }
  8380. $tmp[] = ($byck > 0) ? $byck : '';
  8381. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8382. // $ztrq = '';
  8383. // $ztsl = '';
  8384. // if (count($zt) > 0) {
  8385. // foreach ($zt as $vv) {
  8386. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8387. // $ztsl .= $vv['num'] . '<br>';
  8388. // }
  8389. // }
  8390. if(empty($zt)){
  8391. $final_list[] = $tmp;
  8392. $excel_key = $excel_key + 1;
  8393. }else{
  8394. $len = count($zt);
  8395. if($len == 1){
  8396. $tmp[7] = $zt[0]['num'] ;
  8397. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8398. $final_list[] = $tmp;
  8399. $excel_key = $excel_key + 1;
  8400. }else{
  8401. foreach($zt as $vv){
  8402. $tmp[7] = "";
  8403. $tmp[8] = "";
  8404. $tmp[7] = $vv['num'];
  8405. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8406. $final_list[] = $tmp;
  8407. }
  8408. $merges[] = [
  8409. "s"=>["r"=>$excel_key,"c"=>0],
  8410. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8411. ];
  8412. $merges[] = [
  8413. "s"=>["r"=>$excel_key,"c"=>1],
  8414. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8415. ];
  8416. $merges[] = [
  8417. "s"=>["r"=>$excel_key,"c"=>2],
  8418. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8419. ];
  8420. $merges[] = [
  8421. "s"=>["r"=>$excel_key,"c"=>3],
  8422. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8423. ];
  8424. $merges[] = [
  8425. "s"=>["r"=>$excel_key,"c"=>4],
  8426. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8427. ];
  8428. $merges[] = [
  8429. "s"=>["r"=>$excel_key,"c"=>5],
  8430. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8431. ];
  8432. $merges[] = [
  8433. "s"=>["r"=>$excel_key,"c"=>6],
  8434. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8435. ];
  8436. for($i=1;$i<=$day_len;$i++){
  8437. $merges[] = [
  8438. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8439. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8440. ];
  8441. }
  8442. $merges[] = [
  8443. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8444. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8445. ];
  8446. $excel_key = $excel_key + $len;
  8447. }
  8448. }
  8449. }
  8450. $title = "详情 " . date("Y-m-d", time());
  8451. if(empty($final_list)){
  8452. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8453. }
  8454. $cols = [
  8455. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8456. ];
  8457. array_unshift($final_list, $first_row);
  8458. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8459. }
  8460. }
  8461. public function _whlabelexcelzhjs(){
  8462. if(empty($_GET['excel'])){
  8463. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8464. }
  8465. $where = "sku != 'Preset' and sku != '' ";
  8466. //数据排序
  8467. $order_str = "id desc";
  8468. if (empty($page)) {
  8469. $start = 0;
  8470. $perpage = 1;
  8471. } else {
  8472. $start = ($page - 1) * $perpage;
  8473. }
  8474. $category = $this->input->get('category', true);
  8475. $warehouse = $this->input->get('warehouse', true);
  8476. $excelid = $this->input->get('sid', true);
  8477. if ($category) {
  8478. $where .= " and features like '%-$category-%'";
  8479. }
  8480. if ($warehouse) {
  8481. $where .= " and warehouse = '$warehouse'";
  8482. }
  8483. $xzid = '';
  8484. if ($excelid) {
  8485. $excelid = explode(',', trim($excelid, ','));
  8486. foreach ($excelid as $key => $value) {
  8487. $xzid .= " id = " . $value . " or";
  8488. }
  8489. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8490. }
  8491. $merges = [
  8492. [
  8493. "s"=>["r"=>0,"c"=>0],
  8494. "e"=>["r"=>0,"c"=>6]
  8495. ]
  8496. ];
  8497. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8498. $excel_index = 2;
  8499. $final_list = [];
  8500. foreach ($rows as $key => $value) {
  8501. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8502. $zh = '';
  8503. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8504. // foreach ($zt_list as $v) {
  8505. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8506. // }
  8507. $zt = array_sum(array_column($zt_list, 'num'));
  8508. $number = $value['number'];
  8509. $ftime = time() - 15 * 24 * 3600;
  8510. $warehouse = $this->warehouse->read($value['warehouse']);
  8511. // $rows[$key]['warehouse'] = $warehouse['title'];
  8512. // $rows[$key]['number'] = $c;
  8513. // $rows[$key]['features'] = $zh;
  8514. //$rows[$key]['hb'] = $c + $zt;
  8515. $tmp = [];
  8516. $tmp[0] = $warehouse['title'];
  8517. $tmp[1] = $value['sku'];
  8518. $tmp[2] = $value['title'];
  8519. $tmp[3] = $c;
  8520. $tmp[4] = "";
  8521. $tmp[5] = $c + $zt;
  8522. if(empty($zt_list)){
  8523. $tmp[4] = "";
  8524. $final_list[] = $tmp;
  8525. $excel_index = $excel_index + 1;
  8526. }else{
  8527. if(count($zt_list) == 1){
  8528. $tmp[4] = "";
  8529. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8530. $final_list[] = $tmp;
  8531. $excel_index = $excel_index + 1;
  8532. }else{
  8533. $len = count($zt_list);
  8534. foreach ($zt_list as $v){
  8535. $tmp[4] = "";
  8536. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8537. $final_list[] = $tmp;
  8538. }
  8539. $merges[] = [
  8540. "s"=>["r"=>$excel_index,"c"=>0],
  8541. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8542. ];
  8543. $merges[] = [
  8544. "s"=>["r"=>$excel_index,"c"=>1],
  8545. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8546. ];
  8547. $merges[] = [
  8548. "s"=>["r"=>$excel_index,"c"=>2],
  8549. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8550. ];
  8551. $merges[] = [
  8552. "s"=>["r"=>$excel_index,"c"=>3],
  8553. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8554. ];
  8555. $merges[] = [
  8556. "s"=>["r"=>$excel_index,"c"=>5],
  8557. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8558. ];
  8559. $excel_index = $excel_index + $len;
  8560. }
  8561. }
  8562. }
  8563. $first_row = [
  8564. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8565. ];
  8566. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8567. if(empty($final_list)){
  8568. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8569. }
  8570. $cols = [
  8571. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8572. ];
  8573. array_unshift($final_list, $first_row);
  8574. array_unshift($final_list, [
  8575. $title,"","","","",""
  8576. ]);
  8577. $end_list = [];
  8578. foreach ($final_list as $key => $value) {
  8579. $end_list[] = array_values($value);
  8580. }
  8581. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8582. }
  8583. //出库、退库导出
  8584. public function _dccrtypejs()
  8585. {
  8586. $classid = $this->classid->sku();
  8587. $pm = $classid;
  8588. $typeclass = array();
  8589. $tc = $this->typeclass->find_all();
  8590. foreach ($tc as $v) {
  8591. $typeclass[$v['id']] = $v;
  8592. }
  8593. $prc = array();
  8594. $purchase = $this->purchase->find_all();
  8595. foreach ($purchase as $k => $v) {
  8596. $prc[$v['id']] = $v['title'];
  8597. }
  8598. if (isset($_GET['sid'])) {
  8599. $wh = array();
  8600. $w = $this->warehouse->find_all('1=1', 'id,title');
  8601. foreach ($w as $v) {
  8602. $wh[$v['id']] = $v['title'];
  8603. }
  8604. $type = $this->input->get('excel', true);
  8605. $category = $this->input->get('category', true);
  8606. $size = $this->input->get('size', true);
  8607. $grade = $this->input->get('grade', true);
  8608. $color = $this->input->get('color', true);
  8609. $lowe = $this->input->get('lowe', true);
  8610. $sku = $this->input->get('sku', true);
  8611. $warehouse = $this->input->get('warehouse', true);
  8612. $lacetype = $this->input->get('lacetype', true);
  8613. $lacecolor = $this->input->get('lacecolor', true);
  8614. $density = $this->input->get('density', true);
  8615. $haircap = $this->input->get('haircap', true);
  8616. $purchase = $this->input->get('purchase', true);
  8617. $title = $this->input->get('title', true);
  8618. $state = $this->input->get('state', true);
  8619. $sid = $this->input->get('sid', true);
  8620. $ktime = $this->input->get('ktime', true);
  8621. $jtime = $this->input->get('jtime', true);
  8622. $ktime = strtotime($ktime);
  8623. $jtime = strtotime($jtime);
  8624. $where = "1=1";
  8625. $gj = "";
  8626. $ck = "";
  8627. if ($category) {
  8628. $where .= " and features like '%-$category-%'";
  8629. }
  8630. if ($size) {
  8631. $where .= " and features like '%-$size-%'";
  8632. }
  8633. if ($grade) {
  8634. $where .= " and features like '%-$grade-%'";
  8635. }
  8636. if ($color) {
  8637. $where .= " and features like '%-$color-%'";
  8638. }
  8639. if ($lowe) {
  8640. $where .= " and features like '%-$lowe-%'";
  8641. }
  8642. if ($warehouse) {
  8643. $where .= " and warehouse = '$warehouse'";
  8644. }
  8645. if ($purchase) {
  8646. $where .= " and purchase = '$purchase'";
  8647. }
  8648. if ($state) {
  8649. $where .= " and state = '$state'";
  8650. }
  8651. if ($lacetype) {
  8652. $where .= " and features like '%-$lacetype-%'";
  8653. }
  8654. if ($lacecolor) {
  8655. $where .= " and features like '%-$lacecolor-%'";
  8656. }
  8657. if ($density) {
  8658. $where .= " and features like '%-$density-%'";
  8659. }
  8660. if ($haircap) {
  8661. $where .= " and features like '%-$haircap-%'";
  8662. }
  8663. if ($title) {
  8664. $title = trim($title, ' ');
  8665. $title = trim($title, ' ');
  8666. $where .= " and title like '%$title%'";
  8667. }
  8668. if ($sku) {
  8669. $sku = trim($sku, ' ');
  8670. $sku = trim($sku, ' ');
  8671. $where .= " and sku like '%$sku%'";
  8672. }
  8673. if ($ktime && $jtime) {
  8674. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8675. }
  8676. $sidwhere = '';
  8677. if ($sid) {
  8678. $sd = "";
  8679. $s = explode(',', trim($sid, ','));
  8680. foreach ($s as $value) {
  8681. $sd .= " id = " . $value . " or";
  8682. }
  8683. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8684. }
  8685. //数据排序
  8686. $order_str = "time desc";
  8687. if (empty($page)) {
  8688. $start = 0;
  8689. $perpage = 1;
  8690. } else {
  8691. $start = ($page - 1) * $perpage;
  8692. }
  8693. $wh = array();
  8694. $w = $this->warehouse->find_all('1=1', 'id,title');
  8695. foreach ($w as $v) {
  8696. $wh[$v['id']] = $v['title'];
  8697. }
  8698. $wt = array();
  8699. $whlabel_type = $this->whlabel_type->find_all();
  8700. foreach ($whlabel_type as $v) {
  8701. $wt[$v['id']] = $v['title'];
  8702. }
  8703. $classid = $this->classid->sku();
  8704. $list = array();
  8705. $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');
  8706. foreach ($rows_r as $key => $value) {
  8707. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8708. $pm = $classid;
  8709. $jm = $classid;
  8710. $rows_r[$key]['enter'] = '入库';
  8711. $rows_r[$key]['time'] = $value['enter'];
  8712. if ($value['rktype'] == 1) {
  8713. $rows_r[$key]['rktype'] = '采购入库';
  8714. } else if ($value['rktype'] == 2) {
  8715. $rows_r[$key]['rktype'] = '盘盈调整';
  8716. } else if ($value['rktype'] == 3) {
  8717. $rows_r[$key]['rktype'] = '其他调整入库';
  8718. } else if ($value['rktype'] == 4) {
  8719. $rows_r[$key]['rktype'] = '其他调整入库';
  8720. } else if ($value['rktype'] == 5) {
  8721. $rows_r[$key]['rktype'] = '退库入库';
  8722. } else if ($value['rktype'] == 6) {
  8723. $rows_r[$key]['rktype'] = '退货可用入库';
  8724. } else if ($value['rktype'] == 7) {
  8725. $rows_r[$key]['rktype'] = '形态转换入库';
  8726. } else {
  8727. $rows_r[$key]['rktype'] = '';
  8728. }
  8729. $features = explode('-', trim($value['features'], '-'));
  8730. foreach ($features as $v) {
  8731. if (isset($typeclass[$v])) {
  8732. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8733. $pm[$typeclass[$v]['classid']] = $zh[0];
  8734. }
  8735. if (isset($typeclass[$v])) {
  8736. if (isset($jm[$typeclass[$v]['classid']])) {
  8737. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8738. }
  8739. }
  8740. }
  8741. $zh = implode(" ", $pm);
  8742. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8743. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8744. $rows_r[$key]['zh'] = $zh;
  8745. $jm = array_filter($jm);
  8746. $rows_r[$key]['features'] = implode("-", $jm);
  8747. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8748. }
  8749. $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');
  8750. foreach ($rows_c as $key => $value) {
  8751. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8752. $pm = $classid;
  8753. $jm = $classid;
  8754. $rows_c[$key]['time'] = $value['outk'];
  8755. $rows_c[$key]['outk'] = '出库';
  8756. if ($value['cktype'] == 1) {
  8757. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8758. } else if ($value['cktype'] == 2) {
  8759. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8760. } else if ($value['cktype'] == 3) {
  8761. $rows_c[$key]['cktype'] = '盘亏调整';
  8762. } else if ($value['cktype'] == 4) {
  8763. $rows_c[$key]['cktype'] = '其他调整出库';
  8764. } else if ($value['cktype'] == 5) {
  8765. $rows_c[$key]['cktype'] = '形态转换出库';
  8766. } else {
  8767. $rows_c[$key]['cktype'] = '';
  8768. }
  8769. unset($rows_c[$key]['state']);
  8770. $features = explode('-', trim($value['features'], '-'));
  8771. foreach ($features as $v) {
  8772. if (isset($typeclass[$v])) {
  8773. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8774. $pm[$typeclass[$v]['classid']] = $zh[0];
  8775. }
  8776. if (isset($typeclass[$v])) {
  8777. if (isset($jm[$typeclass[$v]['classid']])) {
  8778. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8779. }
  8780. }
  8781. }
  8782. $zh = implode(" ", $pm);
  8783. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8784. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8785. $rows_c[$key]['zh'] = $zh;
  8786. $jm = array_filter($jm);
  8787. $rows_c[$key]['features'] = implode("-", $jm);
  8788. $rows_c[$key]['number'] = 1;
  8789. }
  8790. $merged = $rows_r;
  8791. foreach ($rows_c as $key => $value) {
  8792. if (isset($merged[$key])) {
  8793. $merged[] = $value;
  8794. } else {
  8795. $merged[$key] = $value;
  8796. }
  8797. }
  8798. usort($merged, function ($a, $b) {
  8799. return $a['time'] - $b['time'];
  8800. });
  8801. foreach ($merged as $key => $value) {
  8802. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8803. }
  8804. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8805. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8806. $cols = [
  8807. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8808. ];
  8809. $final_list= [];
  8810. foreach($merged as $key => $value){
  8811. $final_list[] = array_values($value) ;
  8812. }
  8813. if(empty($merged)){
  8814. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8815. }
  8816. array_unshift($final_list, $first_row);
  8817. $end_list = [];
  8818. foreach ($final_list as $key => $value) {
  8819. $end_list[] = array_values($value);
  8820. }
  8821. $merges = [];
  8822. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8823. }
  8824. }
  8825. public function _errorexceljs()
  8826. {
  8827. $post = $this->input->post(NULL, TRUE);
  8828. if (isset($_GET['page'])) {
  8829. $page = $this->input->get('page', true);
  8830. $perpage = $this->input->get('perpage', true);
  8831. $sku = $this->input->get('sku', true);
  8832. $warehouse = $this->input->get('warehouse', true);
  8833. $ktime = $this->input->get('ktime', true);
  8834. $jtime = $this->input->get('jtime', true);
  8835. $ktime = strtotime($ktime);
  8836. $jtime = strtotime($jtime);
  8837. $where = "sku != 'Preset'";
  8838. $gj = '';
  8839. if ($sku) {
  8840. $where .= " and sku like '%$sku%'";
  8841. } else {
  8842. if ($ktime && $jtime) {
  8843. $gj = " and time > '$ktime' and time < '$jtime'";
  8844. }
  8845. }
  8846. if ($warehouse) {
  8847. $where .= " and warehouse = '$warehouse'";
  8848. }
  8849. //数据排序
  8850. $order_str = "id desc";
  8851. if (empty($page)) {
  8852. $start = 0;
  8853. $perpage = 1;
  8854. } else {
  8855. $start = ($page - 1) * $perpage;
  8856. }
  8857. //取得信息列表
  8858. $rows = array();
  8859. $list = array();
  8860. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  8861. foreach ($info_list as $value) {
  8862. $warehouse = $this->warehouse->read($value['warehouse']);
  8863. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  8864. $number = $value['number'];
  8865. $ftime = time() - 15 * 24 * 3600;
  8866. if ($c < 1) {
  8867. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  8868. }
  8869. }
  8870. $title = "0库存汇总";
  8871. $first_row = ["仓库","SKU","产品","当前库存"];
  8872. $cols = [
  8873. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  8874. ];
  8875. $final_list= [];
  8876. foreach($list as $key => $value){
  8877. $final_list[] = array_values($value) ;
  8878. }
  8879. if(empty($final_list)){
  8880. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8881. }
  8882. array_unshift($final_list, $first_row);
  8883. $merges = [];
  8884. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8885. }
  8886. }
  8887. }