Whlabel.php 267 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel','whlabel');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_power','power');
  36. $this->load->_model('Model_whlabel_type','whlabel_type');
  37. $this->load->_model('Model_company','company');
  38. $this->load->_model('Model_whlabel_list','whlabel_list');
  39. $this->load->_model("Model_logic_whlabel","logic_whlabel");
  40. }
  41. //定义方法的调用规则 获取URI第二段值
  42. public function _remap($arg,$arg_array)
  43. {
  44. if($arg == 'existence')//在库标签
  45. {
  46. $this->_existence();
  47. }
  48. else if($arg == 'cpbqdc')//在库标签
  49. {
  50. $this->_cpbqdc();
  51. }
  52. else if($arg == 'type')//进销存浏览
  53. {
  54. $this->_type();
  55. }
  56. else if($arg == 'typedy')//进销存浏览店员页面
  57. {
  58. $this->_typedy($arg_array);
  59. }
  60. else if($arg == 'typedy_ck')//进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. }
  64. else if($arg == 'typeck')
  65. {
  66. $this->_typeck($arg_array);
  67. }
  68. else if($arg == 'whlabeckdc')
  69. {
  70. $this->_whlabeckdc($arg_array);
  71. }
  72. else if($arg == 'usatype')//美仓进销存浏览
  73. {
  74. $this->_usatype();
  75. }
  76. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  77. {
  78. $this->_usatypeapp();
  79. }
  80. else if($arg == 'enteradd')//入库操作
  81. {
  82. $this->_enteradd();
  83. }
  84. else if($arg == 'enteredit')//修改
  85. {
  86. $this->_enteredit($arg_array);
  87. }
  88. else if($arg == 'enter')//入库浏览
  89. {
  90. $this->_enter();
  91. }
  92. else if($arg == 'out')//出库浏览
  93. {
  94. $this->_out();
  95. }
  96. else if($arg == 'label')//出库标签浏览
  97. {
  98. $this->_label();
  99. }
  100. else if($arg == 'outorder')//独立站出库订单
  101. {
  102. $this->_outorder();
  103. }
  104. else if($arg == 'soutorder')//速卖通出库订单
  105. {
  106. $this->_soutorder();
  107. }
  108. else if($arg == 'toutorder')//TT出库订单
  109. {
  110. $this->_toutorder();
  111. }
  112. else if($arg == 'retreat')//退库订单
  113. {
  114. $this->_retreat();
  115. }
  116. else if($arg == 'retreatlk')//退库订单
  117. {
  118. $this->_retreatlk();
  119. }
  120. else if($arg == 'change')//更换标签
  121. {
  122. $this->_change();
  123. }
  124. else if($arg == 'del')//删除
  125. {
  126. $this->_del();
  127. }
  128. else if($arg == 'exceljxc')//进销存信息导出
  129. {
  130. $this->_exceljxc();
  131. }
  132. else if($arg == 'excelr')//入库信息导出
  133. {
  134. $this->_excelr();
  135. }
  136. else if($arg == 'excelct')//出库、退库信息导出
  137. {
  138. $this->_excelct();
  139. }
  140. else if($arg == 'dccrtype')//根据出入库类型导出
  141. {
  142. $this->_dccrtype();
  143. }
  144. else if($arg == 'excelcr')//出库、退库信息导出
  145. {
  146. $this->_excelcr();
  147. }
  148. else if($arg == 'kcyz')//库存验证
  149. {
  150. $this->_kcyz();
  151. }
  152. else if($arg == 'kj')//库存扣减
  153. {
  154. $this->_kj($arg_array);
  155. }
  156. else if($arg == 'presetout')//预设库存导入
  157. {
  158. $this->_presetout($arg_array);
  159. }
  160. else if($arg == 'presetedit')//预设库存导入
  161. {
  162. $this->_presetedit($arg_array);
  163. }
  164. else if($arg == 'summary')//汇总导出
  165. {
  166. $this->_summary($arg_array);
  167. }
  168. else if($arg == 'manifest')//usps发货清单
  169. {
  170. $this->_manifest();
  171. }
  172. else if($arg == 'abnormal')//占单异常
  173. {
  174. $this->_abnormal();
  175. }
  176. else if($arg == 'error')//0库存SKU
  177. {
  178. $this->_error();
  179. }
  180. else if($arg == 'errorexcel')//0库存SKU导出
  181. {
  182. $this->_errorexcel();
  183. }
  184. else if($arg == 'db')
  185. {
  186. $this->_db();
  187. }
  188. else if($arg == 'dbrk')
  189. {
  190. $this->_dbrk();
  191. }
  192. else if($arg == 'whlabelczdc')
  193. {
  194. $this->_whlabelczdc();
  195. }
  196. else if($arg == 'print')
  197. {
  198. $this->_print($arg_array);
  199. }
  200. else if($arg == 'usaprint')
  201. {
  202. $this->_usaprint($arg_array);
  203. }
  204. else if($arg == 'printck')
  205. {
  206. $this->_printck($arg_array);
  207. }
  208. else if($arg == 'printrk')
  209. {
  210. $this->_printrk($arg_array);
  211. }
  212. else if($arg == 'printxzrk')
  213. {
  214. $this->_printxzrk($arg_array);
  215. }
  216. else if($arg == 'printexcel')
  217. {
  218. $this->_printexcel($arg_array);
  219. }
  220. else if($arg == 'uck')
  221. {
  222. $this->_uck();
  223. }
  224. else if($arg == 'whlabelexcelzh')
  225. {
  226. $this->_whlabelexcelzh();
  227. }
  228. else if($arg == 'fc')
  229. {
  230. $this->_fc();
  231. }
  232. else if($arg == 'fcmb')
  233. {
  234. $this->_fcmb();
  235. }
  236. else if($arg == 'fcexcel')
  237. {
  238. $this->_fcexcel();
  239. }
  240. else if($arg == 'fcjxc')
  241. {
  242. $this->_fcjxc($arg_array);
  243. }
  244. else if($arg == '0kcdel')
  245. {
  246. $this->_0kcdel();//导表删除0库存
  247. }
  248. else if($arg == 'gbhtype')
  249. {
  250. $this->_gbhtype();//更改备货状态
  251. }
  252. else
  253. {
  254. $this->_index();
  255. }
  256. }
  257. //管理
  258. public function _index()
  259. {
  260. $post = $this->input->post(NULL, TRUE);
  261. if(isset($post['page']))
  262. {
  263. $page = $this->input->post('page',true);
  264. $perpage = $this->input->post('perpage',true);
  265. $sku = $this->input->post('sku',true);
  266. $number = $this->input->post('number',true);
  267. $warehouse = $this->input->post('warehouse',true);
  268. $purchase = $this->input->post('purchase',true);
  269. $orderinfo = $this->input->post('orderinfo',true);
  270. $waybill = $this->input->post('waybill',true);
  271. $category = $this->input->post('category',true);
  272. $size = $this->input->post('size',true);
  273. $grade = $this->input->post('grade',true);
  274. $color = $this->input->post('color',true);
  275. $lowe = $this->input->post('lowe',true);
  276. $state = $this->input->post('state',true);
  277. $label = $this->input->post('label',true);
  278. $timetk = $this->input->post('timetkk',true);
  279. $timetj = $this->input->post('timetjj',true);
  280. $timetk = strtotime($timetk);
  281. $timetj = strtotime($timetj);
  282. $where = "1=1 ";
  283. if($timetk && $timetj)
  284. {
  285. $where .= " and time > '$timetk' and time < '$timetj'";
  286. }
  287. if($sku)
  288. {
  289. $where .= " and sku = '$sku'";
  290. }
  291. if($number)
  292. {
  293. $where .= " and number = '$number'";
  294. }
  295. if($warehouse)
  296. {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if($purchase)
  300. {
  301. $where .= " and purchase = '$purchase'";
  302. }
  303. if($orderinfo)
  304. {
  305. $where .= " and orderinfo = '$orderinfo'";
  306. }
  307. if($waybill)
  308. {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if($category)
  312. {
  313. $where .= " and features like '%-$category-%'";
  314. }
  315. if($size)
  316. {
  317. $where .= " and features like '%-$size-%'";
  318. }
  319. if($grade)
  320. {
  321. $where .= " and features like '%-$grade-%'";
  322. }
  323. if($color)
  324. {
  325. $where .= " and features like '%-$color-%'";
  326. }
  327. if($lowe)
  328. {
  329. $where .= " and features like '%-$lowe-%'";
  330. }
  331. if($label)
  332. {
  333. $where .= " and label = '$label'";
  334. }
  335. if($state != '')
  336. {
  337. $where .= " and state = '$state'";
  338. }
  339. //数据排序
  340. $order_str = "time desc";
  341. if(empty($page))
  342. {
  343. $start = 0;
  344. $perpage = 1;
  345. }
  346. else
  347. {
  348. $start = ($page - 1)*$perpage;
  349. }
  350. //取得信息列表
  351. $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);
  352. foreach ($info_list as $key=>$value)
  353. {
  354. $warehouse = $this->warehouse->read($value['warehouse']);
  355. $info_list[$key]['warehouse'] = $warehouse['title'];
  356. $purchase = $this->purchase->read($value['purchase']);
  357. $info_list[$key]['purchase'] = $purchase['title'];
  358. if($value['enter'] != 0)
  359. {
  360. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  361. }
  362. else
  363. {
  364. $info_list[$key]['enter'] = "";
  365. }
  366. if($value['outk'] != 0)
  367. {
  368. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  369. }
  370. else
  371. {
  372. $info_list[$key]['outk'] = "";
  373. }
  374. if($value['printing'] != 0)
  375. {
  376. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  377. }
  378. else
  379. {
  380. $info_list[$key]['printing'] = "";
  381. }
  382. if($value['orderinfo'] == 0)
  383. {
  384. $info_list[$key]['orderinfo'] = "";
  385. }
  386. if($value['waybill'] == 0)
  387. {
  388. $info_list[$key]['waybill'] = "";
  389. }
  390. if($value['state'] == 0)
  391. {
  392. $info_list[$key]['state'] = "在库";
  393. }
  394. else if($value['state'] == 1)
  395. {
  396. $info_list[$key]['state'] = "出库";
  397. }
  398. else if($value['state'] == 2)
  399. {
  400. $info_list[$key]['state'] = "退库";
  401. }
  402. else if($value['state'] == 3)
  403. {
  404. $info_list[$key]['state'] = "调拨中";
  405. }
  406. else if($value['state'] == 4)
  407. {
  408. $info_list[$key]['state'] = "再加工";
  409. }
  410. else if($value['state'] == 5)
  411. {
  412. $info_list[$key]['state'] = "维修中";
  413. }
  414. else if($value['state'] == 6)
  415. {
  416. $info_list[$key]['state'] = "盘亏";
  417. }
  418. else if($value['state'] == 7)
  419. {
  420. $info_list[$key]['state'] = "更换标签";
  421. }
  422. else if($value['state'] == 8)
  423. {
  424. $info_list[$key]['state'] = "其它";
  425. }
  426. else if($value['state'] == 9)
  427. {
  428. $info_list[$key]['state'] = "预设";
  429. }
  430. else if($value['state'] == 10)
  431. {
  432. $info_list[$key]['state'] = "美店零售";
  433. }
  434. if($value['text'] == "")
  435. {
  436. $info_list[$key]['text'] = "";
  437. }
  438. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  439. }
  440. $total = $this->whlabel->find_count($where);
  441. $pagenum = ceil($total/$perpage);
  442. $over = $total-($start+$perpage);
  443. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  444. echo json_encode($rows);exit;
  445. }
  446. if(isset($post['outsku']))
  447. {
  448. $cz = $this->input->post('cz',true);
  449. if($cz == '1')
  450. {
  451. $sku = $this->input->post('outsku',true);
  452. if($sku)
  453. {
  454. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  455. if(count($data) < 1)
  456. {
  457. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  458. }
  459. $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time(),'cktype'=>1),$data[0]['id']);
  460. echo json_encode(array('success'=>true));exit;
  461. }
  462. }
  463. else
  464. {
  465. $sku = $this->input->post('outsku',true);
  466. if($sku)
  467. {
  468. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  469. if(count($data) < 1)
  470. {
  471. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  472. }
  473. $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  474. echo json_encode(array('success'=>true));exit;
  475. }
  476. }
  477. }
  478. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  479. $this->_Template('whlabel',$this->data);
  480. }
  481. //在库标签
  482. public function _existence()
  483. {
  484. $post = $this->input->post(NULL, TRUE);
  485. if(isset($post['s']))
  486. {
  487. $id_arr = $this->input->post('s');
  488. $id_arr = explode(',',$id_arr);
  489. if(!$id_arr)
  490. {
  491. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  492. }
  493. //循环删除记录
  494. foreach ($id_arr as $v)
  495. {
  496. $sid = $this->whlabel->read($v);
  497. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  498. if($count > 0)
  499. {
  500. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  501. }
  502. $zt = $this->whlabeltransport->find_all('sku = "'.$sid['sku'].'" and warehouse = "'.$sid['warehouse'].'" and features = "'.$sid['features'].'" and cz = "0"');
  503. if(count($zt) > 0)
  504. {
  505. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  506. }
  507. $this->whlabel->remove($v);
  508. }
  509. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  510. }
  511. if(isset($post['page']))
  512. {
  513. $page = $this->input->post('page',true);
  514. $perpage = $this->input->post('perpage',true);
  515. $warehouse = $this->input->post('warehouse',true);
  516. $label = $this->input->post('label',true);
  517. $where = "1=1 and state = 0";
  518. if($warehouse)
  519. {
  520. $where .= " and warehouse = '$warehouse'";
  521. }
  522. if($label)
  523. {
  524. $where .= " and label = '$label'";
  525. }
  526. //数据排序
  527. $order_str = "time asc";
  528. if(empty($page))
  529. {
  530. $start = 0;
  531. $perpage = 1;
  532. }
  533. else
  534. {
  535. $start = ($page - 1)*$perpage;
  536. }
  537. //取得信息列表
  538. $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  539. foreach ($info_list as $key=>$value)
  540. {
  541. if($value['enter'] != 0)
  542. {
  543. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  544. }
  545. else
  546. {
  547. $info_list[$key]['enter'] = "";
  548. }
  549. if($value['printing'] != 0)
  550. {
  551. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  552. }
  553. else
  554. {
  555. $info_list[$key]['printing'] = "";
  556. }
  557. }
  558. $total = $this->whlabel->find_count($where);
  559. $pagenum = ceil($total/$perpage);
  560. $over = $total-($start+$perpage);
  561. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  562. echo json_encode($rows);exit;
  563. }
  564. $this->_Template('whlabel_existence',$this->data);
  565. }
  566. //进销存浏览
  567. public function _typedy($arg_array)
  568. {
  569. $prc = array();
  570. $purchase = $this->purchase->find_all();
  571. foreach($purchase as $k=>$v)
  572. {
  573. $prc[$v['id']] = $v['title'];
  574. }
  575. $post = $this->input->post(NULL, TRUE);
  576. if(isset($post['page']))
  577. {
  578. $page = $this->input->post('page',true);
  579. $perpage = $this->input->post('perpage',true);
  580. $category = $this->input->post('category',true);
  581. $size = $this->input->post('size',true);
  582. $grade = $this->input->post('grade',true);
  583. $color = $this->input->post('color',true);
  584. $lowe = $this->input->post('lowe',true);
  585. $sku = $this->input->post('sku');
  586. $title = $this->input->post('title');
  587. $warehouse = $this->input->post('warehouse',true);
  588. $usa = $this->input->post('usa',true);
  589. $purchase = $this->input->post('purchase',true);
  590. $lacetype = $this->input->post('lacetype',true);
  591. $haircap = $this->input->post('haircap',true);
  592. $density = $this->input->post('density',true);
  593. $details = $this->input->post('details',true);
  594. $state = $this->input->post('state',true);
  595. $lacecolor = $this->input->post('lacecolor',true);
  596. $hairnumber = $this->input->post('hairnumber',true);
  597. $cklx = $this->input->post('cklx',true);
  598. $ktime = $this->input->post('ktime',true);
  599. $jtime = $this->input->post('jtime',true);
  600. $ktime = strtotime($ktime);
  601. $jtime = strtotime($jtime);
  602. $where = "1=1";$gj = "";$ck = "";
  603. if($usa)
  604. {
  605. if(!$warehouse)
  606. {
  607. $where .= " and (warehouse = '5' or warehouse = '8')";
  608. }
  609. }
  610. if($warehouse)
  611. {
  612. $where .= " and warehouse = '$warehouse'";
  613. }
  614. if($details)
  615. {
  616. $where .= " and details = '$details'";
  617. }
  618. if($purchase)
  619. {
  620. $where .= " and purchase = '$purchase'";
  621. }
  622. if($state)
  623. {
  624. $where .= " and state = '$state'";
  625. }
  626. if($lacetype)
  627. {
  628. $where .= " and features like '%-$lacetype-%'";
  629. }
  630. if($category)
  631. {
  632. $where .= " and features like '%-$category-%'";
  633. }
  634. if($size)
  635. {
  636. $where .= " and features like '%-$size-%'";
  637. }
  638. if($grade)
  639. {
  640. $where .= " and features like '%-$grade-%'";
  641. }
  642. if($color)
  643. {
  644. $where .= " and features like '%-$color-%'";
  645. }
  646. if($lowe)
  647. {
  648. $where .= " and features like '%-$lowe-%'";
  649. }
  650. if($haircap)
  651. {
  652. $where .= " and features like '%-$haircap-%'";
  653. }
  654. if($density)
  655. {
  656. $where .= " and features like '%-$density-%'";
  657. }
  658. if($lacecolor)
  659. {
  660. $where .= " and features like '%-$lacecolor-%'";
  661. }
  662. if(!empty($hairnumber)){
  663. $where .= " and features like '%-128-%' ";
  664. if($hairnumber < 0){
  665. $class_list = $this->typeclass->find_all('classid = 43');
  666. foreach($class_list as $v){
  667. $where .= " and features not like '%-".$v['id']."-%'";
  668. }
  669. }else{
  670. $where .= " and features like '%-$hairnumber-%'";
  671. }
  672. }
  673. $where_add = '';
  674. if($cklx)
  675. {
  676. $shop = $this->shop->read($cklx);
  677. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  678. }
  679. if($ktime && $jtime)
  680. {
  681. $gj = " and enter > '$ktime' and enter < '$jtime'";
  682. $ck = " and outk > '$ktime' and outk < '$jtime'";
  683. }
  684. //数据排序
  685. $order_str = "id desc";
  686. if(empty($page))
  687. {
  688. $start = 0;
  689. $perpage = 1;
  690. }
  691. else
  692. {
  693. $start = ($page - 1)*$perpage;
  694. }
  695. if($sku)
  696. {
  697. $sku = trim($sku,' ');
  698. $sku = trim($sku,' ');
  699. $where .= " and sku like '%$sku%'";
  700. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  701. }
  702. else if($title)
  703. {
  704. $title = trim($title,' ');
  705. $title = trim($title,' ');
  706. $where .= " and title like '%$title%'";
  707. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  708. }
  709. else
  710. {
  711. //$where .= " and time > '$ktime' and time < '$jtime'";
  712. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  713. }
  714. //取得信息列表
  715. $rows = array();$list = array();
  716. foreach ($info_list as $key=>$value)
  717. {
  718. $warehouse = $this->warehouse->read($value['warehouse']);
  719. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  720. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  721. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  722. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  723. $number = $value['number'];$ftime = time()-15*24*3600;
  724. $info_list[$key]['warehouse'] = $warehouse['title'];
  725. $info_list[$key]['features'] = count($c);
  726. $z = count($z);//查看订单号
  727. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  728. $ztdata = '';
  729. if(count($zt) > 0)
  730. {
  731. foreach ($zt as $vv)
  732. {
  733. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  734. }
  735. }
  736. $info_list[$key]['number'] = $ztdata;
  737. $info_list[$key]['sm'] = $z;
  738. $details = array();
  739. $cpid = array();
  740. foreach ($c as $k=>$v)
  741. {
  742. $details[$v['details']] = $v['details'];
  743. if($v['cpid'] != 0)
  744. {
  745. $cpid[$v['cpid']] = $v['cpid'];
  746. }
  747. }
  748. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  749. if($value['shop'] != '')
  750. {
  751. $shop = explode(',',trim($value['shop'],','));
  752. $shop = $this->shop->read($shop[0]);
  753. $info_list[$key]['shop'] = $shop['shopname'];
  754. }
  755. }
  756. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  757. $pagenum = ceil($total/$perpage);
  758. $over = $total-($start+$perpage);
  759. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  760. echo json_encode($rows);exit;
  761. }
  762. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  763. $this->_Template('whlabel_typedy',$this->data);
  764. }
  765. //进销存浏览
  766. public function _typedy_ck($arg_array)
  767. {
  768. $prc = array();
  769. $purchase = $this->purchase->find_all();
  770. foreach($purchase as $k=>$v)
  771. {
  772. $prc[$v['id']] = $v['title'];
  773. }
  774. $post = $this->input->post(NULL, TRUE);
  775. if(isset($post['page']))
  776. {
  777. $page = $this->input->post('page',true);
  778. $perpage = $this->input->post('perpage',true);
  779. $category = $this->input->post('category',true);
  780. $size = $this->input->post('size',true);
  781. $grade = $this->input->post('grade',true);
  782. $color = $this->input->post('color',true);
  783. $lowe = $this->input->post('lowe',true);
  784. $sku = $this->input->post('sku');
  785. $title = $this->input->post('title');
  786. $warehouse = $this->input->post('warehouse',true);
  787. $usa = $this->input->post('usa',true);
  788. $purchase = $this->input->post('purchase',true);
  789. $lacetype = $this->input->post('lacetype',true);
  790. $haircap = $this->input->post('haircap',true);
  791. $density = $this->input->post('density',true);
  792. $details = $this->input->post('details',true);
  793. $state = $this->input->post('state',true);
  794. $lacecolor = $this->input->post('lacecolor',true);
  795. $cklx = $this->input->post('cklx',true);
  796. $ktime = $this->input->post('ktime',true);
  797. $jtime = $this->input->post('jtime',true);
  798. $ktime = strtotime($ktime);
  799. $jtime = strtotime($jtime);
  800. $where = "1=1";$gj = "";$ck = "";
  801. if($lacetype)
  802. {
  803. $where .= " and features like '%-$lacetype-%'";
  804. }
  805. if($category)
  806. {
  807. $where .= " and features like '%-$category-%'";
  808. }
  809. if($size)
  810. {
  811. $where .= " and features like '%-$size-%'";
  812. }
  813. if($grade)
  814. {
  815. $where .= " and features like '%-$grade-%'";
  816. }
  817. if($color)
  818. {
  819. $where .= " and features like '%-$color-%'";
  820. }
  821. if($lowe)
  822. {
  823. $where .= " and features like '%-$lowe-%'";
  824. }
  825. if($haircap)
  826. {
  827. $where .= " and features like '%-$haircap-%'";
  828. }
  829. if($density)
  830. {
  831. $where .= " and features like '%-$density-%'";
  832. }
  833. if($lacecolor)
  834. {
  835. $where .= " and features like '%-$lacecolor-%'";
  836. }
  837. if($usa)
  838. {
  839. if(!$warehouse)
  840. {
  841. $where .= " and (warehouse = '5' or warehouse = '8')";
  842. }
  843. }
  844. if($warehouse)
  845. {
  846. $where .= " and warehouse = '$warehouse'";
  847. }
  848. if($details)
  849. {
  850. $where .= " and details = '$details'";
  851. }
  852. if($purchase)
  853. {
  854. $where .= " and purchase = '$purchase'";
  855. }
  856. if($state)
  857. {
  858. $where .= " and state = '$state'";
  859. }
  860. $where_add = '';
  861. if($cklx)
  862. {
  863. $shop = $this->shop->read($cklx);
  864. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  865. }
  866. if($ktime && $jtime)
  867. {
  868. $gj = " and enter > '$ktime' and enter < '$jtime'";
  869. $ck = " and outk > '$ktime' and outk < '$jtime'";
  870. }
  871. //数据排序
  872. $order_str = "id desc";
  873. if(empty($page))
  874. {
  875. $start = 0;
  876. $perpage = 1;
  877. }
  878. else
  879. {
  880. $start = ($page - 1)*$perpage;
  881. }
  882. if($sku)
  883. {
  884. $sku = trim($sku,' ');
  885. $sku = trim($sku,' ');
  886. $where .= " and sku like '%$sku%'";
  887. $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);
  888. }
  889. else if($title)
  890. {
  891. $title = trim($title,' ');
  892. $title = trim($title,' ');
  893. $where .= " and title like '%$title%'";
  894. $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);
  895. }
  896. else
  897. {
  898. //$where .= " and time > '$ktime' and time < '$jtime'";
  899. $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);
  900. }
  901. //取得信息列表
  902. $rows = array();$list = array();
  903. foreach ($info_list as $key=>$value)
  904. {
  905. $warehouse = $this->warehouse->read($value['warehouse']);
  906. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  907. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
  908. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  909. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
  910. $ftime = time()-15*24*3600;
  911. $info_list[$key]['warehouse'] = $warehouse['title'];
  912. $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
  913. //$z = count($z);//查看订单号
  914. //$info_list[$key]['zd'] = $z;
  915. $details = array();
  916. $cpid = array();
  917. foreach ($c as $k=>$v)
  918. {
  919. $details[$v['details']] = $v['details'];
  920. if($v['cpid'] != 0)
  921. {
  922. $cpid[$v['cpid']] = $v['cpid'];
  923. }
  924. }
  925. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  926. if($value['shop'] != '')
  927. {
  928. $shop = explode(',',trim($value['shop'],','));
  929. $shop = $this->shop->read($shop[0]);
  930. $info_list[$key]['shop'] = $shop['shopname'];
  931. }
  932. }
  933. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  934. $pagenum = ceil($total/$perpage);
  935. $over = $total-($start+$perpage);
  936. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  937. echo json_encode($rows);exit;
  938. }
  939. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  940. $this->_Template('whlabel_typedy_ck',$this->data);
  941. }
  942. public function _typeck($arg_array)
  943. {
  944. $prc = array();
  945. $purchase = $this->purchase->find_all();
  946. foreach($purchase as $k=>$v)
  947. {
  948. $prc[$v['id']] = $v['title'];
  949. }
  950. $post = $this->input->post(NULL, TRUE);
  951. if(isset($post['page']))
  952. {
  953. $page = $this->input->post('page',true);
  954. $perpage = $this->input->post('perpage',true);
  955. $category = $this->input->post('category',true);
  956. $size = $this->input->post('size',true);
  957. $grade = $this->input->post('grade',true);
  958. $color = $this->input->post('color',true);
  959. $lacecolor = $this->input->post('lacecolor',true);
  960. $lowe = $this->input->post('lowe',true);
  961. $sku = $this->input->post('sku');
  962. $title = $this->input->post('title');
  963. $warehouse = 13;
  964. $usa = $this->input->post('usa',true);
  965. $purchase = $this->input->post('purchase',true);
  966. $lacetype = $this->input->post('lacetype',true);
  967. $haircap = $this->input->post('haircap',true);
  968. $density = $this->input->post('density',true);
  969. $details = $this->input->post('details',true);
  970. $state = $this->input->post('state',true);
  971. $ktime = $this->input->post('ktime',true);
  972. $jtime = $this->input->post('jtime',true);
  973. $ktime = strtotime($ktime);
  974. $jtime = strtotime($jtime);
  975. $where = "1=1";$gj = "";$ck = "";
  976. if($lacetype)
  977. {
  978. $where .= " and features like '%-$lacetype-%'";
  979. }
  980. if($category)
  981. {
  982. $where .= " and features like '%-$category-%'";
  983. }
  984. if($size)
  985. {
  986. $where .= " and features like '%-$size-%'";
  987. }
  988. if($grade)
  989. {
  990. $where .= " and features like '%-$grade-%'";
  991. }
  992. if($color)
  993. {
  994. $where .= " and features like '%-$color-%'";
  995. }
  996. if($lacecolor)
  997. {
  998. $where .= " and features like '%-$lacecolor-%'";
  999. }
  1000. if($lowe)
  1001. {
  1002. $where .= " and features like '%-$lowe-%'";
  1003. }
  1004. if($haircap)
  1005. {
  1006. $where .= " and features like '%-$haircap-%'";
  1007. }
  1008. if($density)
  1009. {
  1010. $where .= " and features like '%-$density-%'";
  1011. }
  1012. if($warehouse)
  1013. {
  1014. $where .= " and warehouse = '$warehouse'";
  1015. }
  1016. if($details)
  1017. {
  1018. $where .= " and details = '$details'";
  1019. }
  1020. if($purchase)
  1021. {
  1022. $where .= " and purchase = '$purchase'";
  1023. }
  1024. if($state)
  1025. {
  1026. $where .= " and state = '$state'";
  1027. }
  1028. if($ktime && $jtime)
  1029. {
  1030. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1031. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1032. }
  1033. //数据排序
  1034. $order_str = "id desc";
  1035. if(empty($page))
  1036. {
  1037. $start = 0;
  1038. $perpage = 1;
  1039. }
  1040. else
  1041. {
  1042. $start = ($page - 1)*$perpage;
  1043. }
  1044. if($sku)
  1045. {
  1046. $sku = trim($sku,' ');
  1047. $sku = trim($sku,' ');
  1048. $where .= " and sku like '%$sku%'";
  1049. }
  1050. else if($title)
  1051. {
  1052. $title = trim($title,' ');
  1053. $title = trim($title,' ');
  1054. $where .= " and title like '%$title%'";
  1055. }
  1056. $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
  1057. //取得信息列表
  1058. $t = array();
  1059. $typeclass = $this->typeclass->find_all();
  1060. foreach ($typeclass as $v)
  1061. {
  1062. $t[$v['id']] = $v;
  1063. }
  1064. $rows = array();$list = array();
  1065. foreach ($info_list as $key=>$value)
  1066. {
  1067. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1068. $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
  1069. $warehouse = $this->warehouse->read($value['warehouse']);
  1070. $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');
  1071. $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'].'"');
  1072. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1073. $number = $value['number'];$ftime = time()-15*24*3600;
  1074. $z = count($z);//查看订单号
  1075. $info_list[$key]['warehouse'] = $warehouse['title'];
  1076. $info_list[$key]['features'] = count($c);
  1077. $info_list[$key]['number'] = $z;
  1078. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  1079. $details = array();
  1080. $cpid = array();
  1081. foreach ($c as $k=>$v)
  1082. {
  1083. $details[$v['details']] = $v['details'];
  1084. if($v['cpid'] != 0)
  1085. {
  1086. $cpid[$v['cpid']] = $v['cpid'];
  1087. }
  1088. }
  1089. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1090. $classid = $this->classid->sku();
  1091. $pm = $classid;
  1092. $features = explode('-',trim($value['features'],'-'));
  1093. foreach($features as $v)
  1094. {
  1095. $zh = explode('|',trim($t[$v]['zh'],'|'));
  1096. $pm[$t[$v]['classid']] = $zh[0];
  1097. }
  1098. $zh = implode(" ",$pm);
  1099. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1100. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1101. $info_list[$key]['sm'] = $zh;
  1102. }
  1103. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1104. $pagenum = ceil($total/$perpage);
  1105. $over = $total-($start+$perpage);
  1106. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1107. echo json_encode($rows);exit;
  1108. }
  1109. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  1110. $this->_Template('whlabel_typeck',$this->data);
  1111. }
  1112. //进销存导出
  1113. public function _whlabeckdc()
  1114. {
  1115. $prc = array();
  1116. $purchase = $this->purchase->find_all();
  1117. foreach($purchase as $k=>$v)
  1118. {
  1119. $prc[$v['id']] = $v['title'];
  1120. }
  1121. if(isset($_GET['excel']))
  1122. {
  1123. $where = "sku != 'Preset'";
  1124. //数据排序
  1125. $order_str = "id desc";
  1126. if(empty($page))
  1127. {
  1128. $start = 0;
  1129. $perpage = 1;
  1130. }
  1131. else
  1132. {
  1133. $start = ($page - 1)*$perpage;
  1134. }
  1135. $category = $this->input->get('category',true);
  1136. $color = $this->input->get('color',true);
  1137. $lowe = $this->input->get('lowe',true);
  1138. $lacetype = $this->input->get('lacetype',true);
  1139. $size = $this->input->get('size',true);
  1140. $density = $this->input->get('density',true);
  1141. $haircap = $this->input->get('haircap',true);
  1142. $sku = $this->input->get('sku',true);
  1143. $details = $this->input->get('details',true);
  1144. $warehouse = 13;
  1145. $excelid = $this->input->get('sid',true);
  1146. if($category)
  1147. {
  1148. $where .= " and features like '%-$category-%'";
  1149. }
  1150. if($color)
  1151. {
  1152. $where .= " and features like '%-$color-%'";
  1153. }
  1154. if($lowe)
  1155. {
  1156. $where .= " and features like '%-$lowe-%'";
  1157. }
  1158. if($lacetype)
  1159. {
  1160. $where .= " and features like '%-$lacetype-%'";
  1161. }
  1162. if($size)
  1163. {
  1164. $where .= " and features like '%-$size-%'";
  1165. }
  1166. if($density)
  1167. {
  1168. $where .= " and features like '%-$density-%'";
  1169. }
  1170. if($haircap)
  1171. {
  1172. $where .= " and features like '%-$haircap-%'";
  1173. }
  1174. if($warehouse)
  1175. {
  1176. $where .= " and warehouse = '$warehouse'";
  1177. }
  1178. if($sku)
  1179. {
  1180. $where .= " and sku like '%$sku%'";
  1181. }
  1182. if($details)
  1183. {
  1184. $where .= " and details = '$details'";
  1185. }
  1186. $xzid = '';
  1187. if($excelid)
  1188. {
  1189. $excelid = explode(',',trim($excelid,','));
  1190. foreach ($excelid as $key=>$value)
  1191. {
  1192. $xzid .= " id = ".$value." or";
  1193. }
  1194. $xzid = " and (".rtrim($xzid,'or').")";;
  1195. }
  1196. //取得信息列表
  1197. /**
  1198. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1199. $rows = array();$list = array();
  1200. foreach ($info_list as $key=>$value)
  1201. {
  1202. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1203. }
  1204. **/
  1205. $wh = array();
  1206. $w = $this->warehouse->find_all('1=1','id,title');
  1207. foreach ($w as $v)
  1208. {
  1209. $wh[$v['id']] = $v['title'];
  1210. }
  1211. $tc = array();$tcdata = array();
  1212. $typeclass = $this->typeclass->find_all();
  1213. foreach ($typeclass as $v)
  1214. {
  1215. $tc[$v['id']] = $v;
  1216. }
  1217. $list = array();
  1218. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1219. foreach ($rows as $key=>$value)
  1220. {
  1221. $bm = '03';
  1222. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1223. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1224. $classid = $this->classid->sku();
  1225. $pm = $classid;
  1226. $jm = $classid;
  1227. $features = explode('-',trim($value['features'],'-'));
  1228. foreach($features as $v)
  1229. {
  1230. if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
  1231. {
  1232. if($tc[$v]['bm'] != '')
  1233. {
  1234. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1235. }
  1236. }
  1237. if(isset($tc[$v]))
  1238. {
  1239. $zh = explode('|',trim($tc[$v]['zh'],'|'));
  1240. $pm[$tc[$v]['classid']] = $zh[0];
  1241. }
  1242. if(isset($tc[$v]))
  1243. {
  1244. if(isset($jm[$tc[$v]['classid']]))
  1245. {
  1246. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1247. }
  1248. }
  1249. }
  1250. $zh = implode(" ",$pm);
  1251. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1252. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1253. $rows[$key]['dbcontent'] = $zh;
  1254. $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
  1255. $jm = array_filter($jm);
  1256. $rows[$key]['cs'] = implode("-",$jm);
  1257. $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
  1258. $details = array();
  1259. $cpid = array();
  1260. $cpbz = array();
  1261. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  1262. foreach ($sd as $k=>$v)
  1263. {
  1264. if($v['state'] == 0)
  1265. {
  1266. $c++;
  1267. }
  1268. if($v['state'] != 9)
  1269. {
  1270. $g++;
  1271. }
  1272. if($v['state'] == 1)
  1273. {
  1274. $x++;
  1275. }
  1276. if($v['state'] == 2)
  1277. {
  1278. $t++;
  1279. }
  1280. if($v['state'] == 8)
  1281. {
  1282. $s++;
  1283. }
  1284. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  1285. {
  1286. $q++;
  1287. }
  1288. $details[$v['details']] = $v['details'];
  1289. if($v['cpid'] != 0)
  1290. {
  1291. $cpid[$v['cpid']] = $v['cpid'];
  1292. }
  1293. if($v['cpbz'] != '')
  1294. {
  1295. $cpbz[$v['cpbz']] = $v['cpbz'];
  1296. }
  1297. }
  1298. $rows[$key]['details'] = implode("、",$details);
  1299. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  1300. $number = $value['number'];
  1301. $ftime = time()-15*24*3600;
  1302. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1303. $rows[$key]['number'] = $g;
  1304. $rows[$key]['features'] = $c;
  1305. $rows[$key]['x'] = $x;
  1306. $rows[$key]['t'] = $t;
  1307. $rows[$key]['s'] = $s;
  1308. $rows[$key]['q'] = $q;
  1309. $rows[$key]['wzsl'] = count($details);
  1310. }
  1311. $title = "进销存统计表".date('Y-m-d',time());
  1312. $titlename = "<table border=1>
  1313. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  1314. <tr align='center'>
  1315. <td>仓库</td>
  1316. <td>供应商</td>
  1317. <td>位置</td>
  1318. <td>库存编码</td>
  1319. <td>SKU</td>
  1320. <td>用友编码</td>
  1321. <td>用友料号</td>
  1322. <td>产品英文名</td>
  1323. <td>产品中文名</td>
  1324. <td>入库总量</td>
  1325. <td>库存数量</td>
  1326. <td>销售数量</td>
  1327. <td>退货数量</td>
  1328. <td>删除数量</td>
  1329. <td>其它操作</td>
  1330. <td>位置数量</td>
  1331. </tr>
  1332. </table>";
  1333. $filename = $title.".xls";
  1334. $tail = "";
  1335. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1336. }
  1337. }
  1338. public function _type()
  1339. {
  1340. $vip = 0;
  1341. if(isset($_SESSION['api']))
  1342. {
  1343. $user = $this->user->get_api($_SESSION['api']);
  1344. $fgshop = "";$sid = "";
  1345. $usersp = explode('|',trim($user['shop'],'|'));
  1346. foreach ($usersp as $value)
  1347. {
  1348. $fgshop .= " shop = ".$value." or";
  1349. $sid .= " id = ".$value." or";
  1350. }
  1351. if($user['vip'] == 1)
  1352. {
  1353. $vip = 1;
  1354. }
  1355. }
  1356. else
  1357. {
  1358. header('Location: /');exit;
  1359. }
  1360. $prc = array();
  1361. $purchase = $this->purchase->find_all();
  1362. foreach($purchase as $k=>$v)
  1363. {
  1364. $prc[$v['id']] = $v['title'];
  1365. }
  1366. $company = array();
  1367. $ct = $this->company->find_all();
  1368. foreach($ct as $k=>$v)
  1369. {
  1370. $company[$v['id']] = $v['title'];
  1371. }
  1372. $sp = array();
  1373. $s = $this->shop->find_all('1=1','id,shopname');
  1374. foreach ($s as $v)
  1375. {
  1376. $sp[$v['id']] = $v['shopname'];
  1377. }
  1378. $wh = array();
  1379. $w = $this->warehouse->find_all('1=1','id,title');
  1380. foreach ($w as $v)
  1381. {
  1382. $wh[$v['id']] = $v['title'];
  1383. }
  1384. $post = $this->input->post(NULL, TRUE);
  1385. if(isset($post['page']))
  1386. {
  1387. $page = $this->input->post('page',true);
  1388. $perpage = $this->input->post('perpage',true);
  1389. $category = $this->input->post('category',true);
  1390. $size = $this->input->post('size',true);
  1391. $grade = $this->input->post('grade',true);
  1392. $color = $this->input->post('color',true);
  1393. $lowe = $this->input->post('lowe',true);
  1394. $sku = $this->input->post('sku');
  1395. $title = $this->input->post('title');
  1396. $warehouse = $this->input->post('warehouse',true);
  1397. $usa = $this->input->post('usa',true);
  1398. $purchase = $this->input->post('purchase',true);
  1399. $lacetype = $this->input->post('lacetype',true);
  1400. $haircap = $this->input->post('haircap',true);
  1401. $density = $this->input->post('density',true);
  1402. $details = $this->input->post('details',true);
  1403. $state = $this->input->post('state',true);
  1404. $shop = $this->input->post('shop',true);
  1405. $lacecolor = $this->input->post('lacecolor',true);
  1406. $hairnumber = $this->input->post('hairnumber',true);
  1407. $type = $this->input->post('type',true);
  1408. $ktime = $this->input->post('ktime',true);
  1409. $jtime = $this->input->post('jtime',true);
  1410. $ktime = strtotime($ktime);
  1411. $jtime = strtotime($jtime);
  1412. $cpbz = $this->input->post('cpbz',true);
  1413. $where = "1=1";$gj = "";$ck = "";
  1414. if($usa)
  1415. {
  1416. if(!$warehouse)
  1417. {
  1418. $where .= " and (warehouse = '5' or warehouse = '8')";
  1419. }
  1420. }
  1421. if($warehouse)
  1422. {
  1423. $where .= " and warehouse = '$warehouse'";
  1424. }
  1425. if($details)
  1426. {
  1427. $where .= " and details = '$details'";
  1428. }
  1429. if($purchase)
  1430. {
  1431. $where .= " and purchase = '$purchase'";
  1432. }
  1433. if($state)
  1434. {
  1435. $where .= " and state = '$state'";
  1436. }
  1437. if($shop)
  1438. {
  1439. $where .= " and shop like '%$shop%'";
  1440. }
  1441. if($type)
  1442. {
  1443. $where .= " and type = '$type'";
  1444. }
  1445. if($ktime && $jtime)
  1446. {
  1447. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1448. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1449. }
  1450. if($cpbz){
  1451. $where .= " and cpbz like '%$cpbz%' ";
  1452. }
  1453. if($lacecolor)
  1454. {
  1455. $where .= " and features like '%-$lacecolor-%'";
  1456. }
  1457. if($lacetype)
  1458. {
  1459. $where .= " and features like '%-$lacetype-%'";
  1460. }
  1461. if($category)
  1462. {
  1463. $where .= " and features like '%-$category-%'";
  1464. }
  1465. if($size)
  1466. {
  1467. $where .= " and features like '%-$size-%'";
  1468. }
  1469. if($grade)
  1470. {
  1471. $where .= " and features like '%-$grade-%'";
  1472. }
  1473. if($color)
  1474. {
  1475. $where .= " and features like '%-$color-%'";
  1476. }
  1477. if($lowe)
  1478. {
  1479. $where .= " and features like '%-$lowe-%'";
  1480. }
  1481. if($haircap)
  1482. {
  1483. $where .= " and features like '%-$haircap-%'";
  1484. }
  1485. if($density)
  1486. {
  1487. $where .= " and features like '%-$density-%'";
  1488. }
  1489. if(!empty($hairnumber)){
  1490. $where .= " and features like '%-128-%' ";
  1491. if($hairnumber < 0){
  1492. $class_list = $this->typeclass->find_all('classid = 43');
  1493. foreach($class_list as $v){
  1494. $where .= " and features not like '%-".$v['id']."-%'";
  1495. }
  1496. }else{
  1497. $where .= " and features like '%-$hairnumber-%'";
  1498. }
  1499. }
  1500. //数据排序
  1501. $order_str = "id desc";
  1502. if(empty($page))
  1503. {
  1504. $start = 0;
  1505. $perpage = 1;
  1506. }
  1507. else
  1508. {
  1509. $start = ($page - 1)*$perpage;
  1510. }
  1511. $fjnr = '';
  1512. if($sku)
  1513. {
  1514. $sku = trim($sku,' ');
  1515. $sku = trim($sku,' ');
  1516. $fjnr .= " and sku like '%$sku%'";
  1517. }
  1518. if($title)
  1519. {
  1520. $title = trim($title,' ');
  1521. $title = trim($title,' ');
  1522. $fjnr .= " and title like '%$title%'";
  1523. }
  1524. $wt = array();
  1525. $whlabel_type = $this->whlabel_type->find_all();
  1526. foreach ($whlabel_type as $v)
  1527. {
  1528. $wt[$v['id']] = $v['title'];
  1529. }
  1530. //$where .= " and time > '$ktime' and time < '$jtime'";
  1531. $info_list = $this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm',$order_str,$start,$perpage);//改这需要修改_gbhtype
  1532. //取得信息列表
  1533. $info_list = $this->logic_whlabel->dataTran($info_list,['pm']);
  1534. $rows = array();$list = array();
  1535. foreach ($info_list as $key=>$value)
  1536. {
  1537. if(isset($wt[$value['type']]))
  1538. {
  1539. $info_list[$key]['type'] = $wt[$value['type']];
  1540. }
  1541. else
  1542. {
  1543. $info_list[$key]['type'] = '未设置';
  1544. }
  1545. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1546. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1547. $ztdata = '';
  1548. if(count($zt) > 0)
  1549. {
  1550. foreach ($zt as $vv)
  1551. {
  1552. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1553. }
  1554. }
  1555. $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1556. $cdata = array_filter($qbdata, function($item) {
  1557. return $item['state'] < 1;
  1558. });
  1559. $c = array_sum(array_column($cdata, 'jnum'));
  1560. $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1561. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1562. });
  1563. $g = array_sum(array_column($gdata, 'jnum'));
  1564. $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1565. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1566. });
  1567. $x = array_sum(array_column($xdata, 'jnum'));
  1568. $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1569. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1570. });
  1571. $t = array_sum(array_column($tdata, 'jnum'));
  1572. $zdata = array_filter($qbdata, function($item) {
  1573. return $item['zd'] != "" && $item['state'] < 1;
  1574. });
  1575. $z = array_sum(array_column($zdata, 'jnum'));
  1576. $zdata = array_filter($qbdata, function($item) {
  1577. return $item['zd'] != "" && $item['state'] < 1;
  1578. });
  1579. $z = array_sum(array_column($zdata, 'jnum'));
  1580. //$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');
  1581. //$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'].'"');
  1582. //$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'].'"');
  1583. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1584. //$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'].'"');
  1585. $details = array();
  1586. $cpid = array();
  1587. $od = array();$odid = '';
  1588. $companytitle = '';
  1589. foreach ($qbdata as $v)
  1590. {
  1591. if($v['zd'] != "" && $v['state'] < 1)
  1592. {
  1593. if(!isset($od[$v['zd']]))
  1594. {
  1595. $od[$v['zd']] = 1;//所有数据sku
  1596. }
  1597. else
  1598. {
  1599. $od[$v['zd']] = $od[$v['zd']]+1;
  1600. }
  1601. }
  1602. if($v['state'] < 1)
  1603. {
  1604. $details[$v['details']] = $v['details'];
  1605. if($v['cpid'] != 0)
  1606. {
  1607. $cpid[$v['cpid']] = $v['cpid'];
  1608. }
  1609. }
  1610. if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
  1611. {
  1612. $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
  1613. }
  1614. }
  1615. foreach ($od as $k=>$vv)
  1616. {
  1617. $odid .= $k.'数量'.$vv;
  1618. }
  1619. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1620. $number = $value['number'];$ftime = time()-15*24*3600;
  1621. $z = $z.'('.$odid.')';//查看订单号
  1622. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1623. $info_list[$key]['features'] = $c;
  1624. $info_list[$key]['number'] = $ztdata;
  1625. $info_list[$key]['sm'] = $g;
  1626. $info_list[$key]['x'] = $x;
  1627. $info_list[$key]['t'] = $t;
  1628. $info_list[$key]['z'] = $z;
  1629. /**
  1630. foreach ($cdata as $k=>$v)
  1631. {
  1632. $details[$v['details']] = $v['details'];
  1633. if($v['cpid'] != 0)
  1634. {
  1635. $cpid[$v['cpid']] = $v['cpid'];
  1636. }
  1637. }
  1638. **/
  1639. $info_list[$key]['shop'] = '';
  1640. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1641. if($value['shop'] != '')
  1642. {
  1643. $shop = explode(',',trim($value['shop'],','));
  1644. $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
  1645. }
  1646. $info_list[$key]['shop'] .= $companytitle;
  1647. /**
  1648. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1649. if(isset($companytitle[0]))
  1650. {
  1651. foreach ($companytitle as $k=>$v)
  1652. {
  1653. if($v['companytitle'] != '')
  1654. {
  1655. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1656. }
  1657. }
  1658. }
  1659. **/
  1660. }
  1661. $final_all_list = [];
  1662. foreach($info_list as $k=>$v){
  1663. $final_all_list[] = [
  1664. 'id'=>$v['id'],
  1665. "warehouse"=>$v["warehouse"],
  1666. "purchase"=>$v["purchase"],
  1667. "sku"=>$v["sku"],
  1668. "title"=>$v["title"]."<br/>".$v["pm"],
  1669. "details"=>$v["details"],
  1670. "shop"=>$v["shop"],
  1671. "cpbz"=>$v["cpbz"],
  1672. "type"=>$v["type"],
  1673. "features"=>$v["features"],
  1674. "number"=>$v["number"],
  1675. "sm"=>$v["sm"],
  1676. "x"=>$v["x"],
  1677. "t"=>$v["t"],
  1678. "z"=>$v["z"]
  1679. ];
  1680. }
  1681. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1682. $pagenum = ceil($total/$perpage);
  1683. $over = $total-($start+$perpage);
  1684. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_all_list));
  1685. echo json_encode($rows);exit;
  1686. }
  1687. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1688. $this->data['shop'] = $wlshop;
  1689. $this->data['vip'] = $vip;
  1690. $this->_Template('whlabel_type',$this->data);
  1691. }
  1692. //美仓进销存浏览
  1693. public function _usatype()
  1694. {
  1695. if(isset($_SESSION['api']))
  1696. {
  1697. $user = $this->user->get_api($_SESSION['api']);
  1698. $usp = $user;
  1699. $fgshop = "";$sid = "";$wid="";$wtype="";
  1700. $userwh = explode('|',trim($user['warehouse'],'|'));
  1701. foreach ($userwh as $value)
  1702. {
  1703. $wid .= " id = ".$value." or";
  1704. $wtype .= " type = ".$value." or";
  1705. }
  1706. }
  1707. $prc = array();
  1708. $purchase = $this->purchase->find_all();
  1709. foreach($purchase as $k=>$v)
  1710. {
  1711. $prc[$v['id']] = $v['title'];
  1712. }
  1713. $post = $this->input->post(NULL, TRUE);
  1714. if(isset($post['page']))
  1715. {
  1716. $page = $this->input->post('page',true);
  1717. $perpage = $this->input->post('perpage',true);
  1718. $category = $this->input->post('category',true);
  1719. $size = $this->input->post('size',true);
  1720. $grade = $this->input->post('grade',true);
  1721. $color = $this->input->post('color',true);
  1722. $lowe = $this->input->post('lowe',true);
  1723. $sku = $this->input->post('sku');
  1724. $title = $this->input->post('title');
  1725. $warehouse = $this->input->post('warehouse',true);
  1726. $usa = $this->input->post('usa',true);
  1727. $purchase = $this->input->post('purchase',true);
  1728. $lacetype = $this->input->post('lacetype',true);
  1729. $haircap = $this->input->post('haircap',true);
  1730. $density = $this->input->post('density',true);
  1731. $details = $this->input->post('details',true);
  1732. $state = $this->input->post('state',true);
  1733. $lacecolor = $this->input->post('lacecolor',true);
  1734. $cklx = $this->input->post('cklx',true);
  1735. $ktime = $this->input->post('ktime',true);
  1736. $jtime = $this->input->post('jtime',true);
  1737. $ktime = strtotime($ktime);
  1738. $jtime = strtotime($jtime);
  1739. $where = "1=1";$gj = "";$ck = "";
  1740. if($lacetype)
  1741. {
  1742. $where .= " and features like '%-$lacetype-%'";
  1743. }
  1744. if($category)
  1745. {
  1746. $where .= " and features like '%-$category-%'";
  1747. }
  1748. if($size)
  1749. {
  1750. $where .= " and features like '%-$size-%'";
  1751. }
  1752. if($grade)
  1753. {
  1754. $where .= " and features like '%-$grade-%'";
  1755. }
  1756. if($color)
  1757. {
  1758. $where .= " and features like '%-$color-%'";
  1759. }
  1760. if($lowe)
  1761. {
  1762. $where .= " and features like '%-$lowe-%'";
  1763. }
  1764. if($haircap)
  1765. {
  1766. $where .= " and features like '%-$haircap-%'";
  1767. }
  1768. if($density)
  1769. {
  1770. $where .= " and features like '%-$density-%'";
  1771. }
  1772. if($lacecolor)
  1773. {
  1774. $where .= " and features like '%-$lacecolor-%'";
  1775. }
  1776. if($usa)
  1777. {
  1778. if(!$warehouse)
  1779. {
  1780. $where .= " and (warehouse = '5' or warehouse = '8')";
  1781. }
  1782. }
  1783. if($warehouse)
  1784. {
  1785. $where .= " and warehouse = '$warehouse'";
  1786. }
  1787. if($details)
  1788. {
  1789. $where .= " and details = '$details'";
  1790. }
  1791. if($purchase)
  1792. {
  1793. $where .= " and purchase = '$purchase'";
  1794. }
  1795. if($state)
  1796. {
  1797. $where .= " and state = '$state'";
  1798. }
  1799. $where_add = '';
  1800. if($cklx)
  1801. {
  1802. $shop = $this->shop->read($cklx);
  1803. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1804. }
  1805. if($ktime && $jtime)
  1806. {
  1807. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1808. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1809. }
  1810. //数据排序
  1811. $order_str = "id desc";
  1812. if(empty($page))
  1813. {
  1814. $start = 0;
  1815. $perpage = 1;
  1816. }
  1817. else
  1818. {
  1819. $start = ($page - 1)*$perpage;
  1820. }
  1821. if($sku)
  1822. {
  1823. $sku = trim($sku,' ');
  1824. $sku = trim($sku,' ');
  1825. $where .= " and sku like '%$sku%'";
  1826. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1827. }
  1828. else if($title)
  1829. {
  1830. $title = trim($title,' ');
  1831. $title = trim($title,' ');
  1832. $where .= " and title like '%$title%'";
  1833. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1834. }
  1835. else
  1836. {
  1837. //$where .= " and time > '$ktime' and time < '$jtime'";
  1838. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1839. }
  1840. //取得信息列表
  1841. $rows = array();$list = array();
  1842. foreach ($info_list as $key=>$value)
  1843. {
  1844. $warehouse = $this->warehouse->read($value['warehouse']);
  1845. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1846. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1847. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1848. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1849. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1850. $od = array();$odid = '';
  1851. foreach ($z as $v)
  1852. {
  1853. if(!isset($od[$v['zd']]))
  1854. {
  1855. $od[$v['zd']] = 1;//所有数据sku
  1856. }
  1857. else
  1858. {
  1859. $od[$v['zd']] = $od[$v['zd']]+1;
  1860. }
  1861. }
  1862. foreach ($od as $k=>$vv)
  1863. {
  1864. $odid .= $k.'数量'.$vv.' ';
  1865. }
  1866. $z = count($z).'('.$odid.')';//查看订单号
  1867. $info_list[$key]['features'] = $c;
  1868. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1869. $ztdata = '';
  1870. if(count($zt) > 0)
  1871. {
  1872. foreach ($zt as $vv)
  1873. {
  1874. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1875. }
  1876. }
  1877. $info_list[$key]['warehouse'] = $ztdata;
  1878. $info_list[$key]['g'] = $g;
  1879. $info_list[$key]['x'] = $x;
  1880. $info_list[$key]['t'] = $t;
  1881. $info_list[$key]['z'] = $z;
  1882. }
  1883. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1884. $pagenum = ceil($total/$perpage);
  1885. $over = $total-($start+$perpage);
  1886. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1887. echo json_encode($rows);exit;
  1888. }
  1889. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1890. $this->data['warehouse'] = $warehouse;
  1891. $this->_Template('whlabel_typeusa',$this->data);
  1892. }
  1893. //美仓进销存浏览
  1894. public function _usatypeapp()
  1895. {
  1896. $post = $this->input->post(NULL, TRUE);
  1897. if(isset($post['page']))
  1898. {
  1899. $page = $this->input->post('page',true);
  1900. $perpage = $this->input->post('perpage',true);
  1901. $sku = $this->input->post('sku',true);
  1902. $warehouse = 5;
  1903. $title = $this->input->post('title',true);
  1904. $state = $this->input->post('state',true);
  1905. $ktime = $this->input->post('ktime',true);
  1906. $jtime = $this->input->post('jtime',true);
  1907. $ktime = strtotime($ktime);
  1908. $jtime = strtotime($jtime);
  1909. $where = "1=1";$gj = "";$ck = "";
  1910. if($title)
  1911. {
  1912. $st = explode(' ',trim($title,' '));
  1913. foreach ($st as $v)
  1914. {
  1915. $where .= " and title like '%$v%'";
  1916. }
  1917. }
  1918. if($warehouse)
  1919. {
  1920. $where .= " and warehouse = '$warehouse'";
  1921. }
  1922. if($state)
  1923. {
  1924. $where .= " and state = '$state'";
  1925. }
  1926. if($sku)
  1927. {
  1928. $where .= " and sku like '%$sku%'";
  1929. }
  1930. if($ktime && $jtime)
  1931. {
  1932. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1933. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1934. }
  1935. //数据排序
  1936. $order_str = "id desc";
  1937. if(empty($page))
  1938. {
  1939. $start = 0;
  1940. $perpage = 1;
  1941. }
  1942. else
  1943. {
  1944. $start = ($page - 1)*$perpage;
  1945. }
  1946. //取得信息列表
  1947. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1948. $rows = array();$list = array();
  1949. foreach ($info_list as $key=>$value)
  1950. {
  1951. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1952. }
  1953. $rowsdq = array_slice($rows,$start,$perpage);
  1954. foreach ($rowsdq as $value)
  1955. {
  1956. $warehouse = $this->warehouse->read($value['warehouse']);
  1957. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1958. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1959. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1960. $od = array();$odid = '';
  1961. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1962. }
  1963. $total = count($rows);
  1964. $pagenum = ceil($total/$perpage);
  1965. $over = $total-($start+$perpage);
  1966. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1967. echo json_encode($rows);exit;
  1968. }
  1969. $this->_Template('phone/p_usatypeapp',$this->data);
  1970. }
  1971. //入库操作
  1972. public function _enteradd()
  1973. {
  1974. $dt = 0;
  1975. if(isset($_SESSION['api']))
  1976. {
  1977. $user = $this->user->get_api($_SESSION['api']);
  1978. $usp = $user;
  1979. $fgshop = "";$sid = "";
  1980. $user = explode('|',trim($user['shop'],'|'));
  1981. foreach ($user as $value)
  1982. {
  1983. $fgshop .= " shop = ".$value." or";
  1984. $sid .= " id = ".$value." or";
  1985. }
  1986. }
  1987. $tc = $this->typeclass->find_all();
  1988. $typeclass = array();
  1989. foreach ($tc as $v)
  1990. {
  1991. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1992. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  1993. }
  1994. $post = $this->input->post(NULL, TRUE);
  1995. if(isset($post['sku']))
  1996. {
  1997. $list = array();$num = "";$title = "";$features = "";
  1998. $order = $this->input->post('order',true);
  1999. $shop = $this->input->post('shop',true);
  2000. $post['shop'] = ($shop!="")?','.$shop:"";
  2001. $sku = $this->input->post('sku',true);
  2002. $post['sm'] = $this->input->post('sm',true);
  2003. $post['warehouse'] = $this->input->post('warehouse',true);
  2004. $post['purchase'] = $this->input->post('purchase',true);
  2005. $post['retreatwarehouse'] = $post['warehouse'];
  2006. $post['state'] = $this->input->post('state',true);
  2007. $post['rktype'] = $this->input->post('rktype',true);
  2008. $post['text'] = $this->input->post('text',true);
  2009. $category = $this->input->post('category',true);
  2010. $list['category'] = $category;
  2011. $list['hairtype'] = $this->input->post('hairtype',true);
  2012. $list['grade'] = $this->input->post('grade',true);
  2013. $size = $this->input->post('size',true);
  2014. $xzsku = $this->input->post('xzsku',true);
  2015. $list['size'] = rtrim($size,',');
  2016. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2017. $list['extension'] = $this->input->post('extension',true);
  2018. if($category == 1297)
  2019. {
  2020. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2021. }
  2022. if($category == 1702)
  2023. {
  2024. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2025. $list['syother'] = $this->input->post('syother',true);
  2026. }
  2027. if($category == 133)
  2028. {
  2029. $list['fittype'] = $this->input->post('fittype',true);
  2030. $list['acother'] = $this->input->post('acother',true);
  2031. }
  2032. $list['color'] = $this->input->post('color',true);
  2033. $list['lowe'] = $this->input->post('lowe',true);
  2034. if(!$post['purchase'])
  2035. {
  2036. $post['purchase'] = 1;
  2037. }
  2038. if($category == 127)
  2039. {
  2040. $list['type'] = $this->input->post('type',true);
  2041. $list['headroad'] = $this->input->post('headroad',true);
  2042. $list['density'] = $this->input->post('density',true);
  2043. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2044. {
  2045. $list['lacesize'] = $this->input->post('lacesize',true);
  2046. }
  2047. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2048. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2049. }
  2050. if($category == 128)
  2051. {
  2052. $list['lacetype'] = $this->input->post('lacetype',true);
  2053. $list['haircap'] = $this->input->post('haircap',true);
  2054. $list['density'] = $this->input->post('density',true);
  2055. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2056. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2057. $list['wigother'] = $this->input->post('wigother',true);
  2058. $list['wigother2'] = $this->input->post('wigother2',true);
  2059. }
  2060. if($category == 129)
  2061. {
  2062. $list['wide'] = $this->input->post('wide',true);
  2063. }
  2064. if($category == 131)
  2065. {
  2066. $list['gifttype'] = $this->input->post('gifttype',true);
  2067. $list['giftother'] = $this->input->post('giftother',true);
  2068. }
  2069. if($category == 134)
  2070. {
  2071. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2072. }
  2073. if($category == 1297)
  2074. {
  2075. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2076. $list['sywigother'] = $this->input->post('sywigother',true);
  2077. }
  2078. if($category == 130 || $category == 133 || $category == 1702)
  2079. {
  2080. $list['items'] = $this->input->post('items',true);
  2081. $list['weight'] = $this->input->post('weight',true);
  2082. }
  2083. if($category == 1702)
  2084. {
  2085. $list['syhairther'] = $this->input->post('syhairther',true);
  2086. }
  2087. $classid = $this->classid->sku();
  2088. $scsku = $classid;
  2089. $pm = $classid;
  2090. foreach($list as $k=>$v)
  2091. {
  2092. if($v != 0)
  2093. {
  2094. $num .=$v;
  2095. $features .=$v.'-';
  2096. $post[$k] = $v;
  2097. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2098. if($k != 'size')
  2099. {
  2100. $title .= $typeclass[$v]['title']." ";
  2101. }
  2102. if(isset($pm[$typeclass[$v]['classid']]))
  2103. {
  2104. if($typeclass[$v]['title'] == '9A')
  2105. {
  2106. $pm[$typeclass[$v]['classid']] = '9A';
  2107. }
  2108. else if($typeclass[$v]['title'] == '10A')
  2109. {
  2110. $pm[$typeclass[$v]['classid']] = '10A';
  2111. }
  2112. else
  2113. {
  2114. $clzh = $typeclass[$v]['zh'];
  2115. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2116. {
  2117. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2118. $clzh = $clzh[0];
  2119. }
  2120. $pm[$typeclass[$v]['classid']] = $clzh;
  2121. }
  2122. }
  2123. }
  2124. }
  2125. $zh = implode(" ",$pm);
  2126. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2127. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2128. if($list['size'])
  2129. {
  2130. $typeclass = $this->typeclass->read($list['size']);
  2131. $title .= $typeclass['title'];
  2132. }
  2133. $time = time();
  2134. if($xzsku)
  2135. {
  2136. $scsku = implode("-",$scsku);
  2137. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2138. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2139. $post['sku'] = trim($scsku,' ');
  2140. }
  2141. else
  2142. {
  2143. $post['sku'] = $sku;
  2144. }
  2145. //$post['sku'] = trim($sku,' ');
  2146. $post['title'] = rtrim($title,' ');
  2147. $post['number'] = $num;
  2148. $post['features'] = '-'.$features;
  2149. $post['enter'] = $time;
  2150. $post['time'] = $time;//操作时间
  2151. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2152. if($yza)
  2153. {
  2154. if($post['features'] != $yza[0]['features'])
  2155. {
  2156. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2157. }
  2158. }
  2159. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2160. if($yzb)
  2161. {
  2162. if($post['sku'] != $yzb[0]['sku'])
  2163. {
  2164. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2165. }
  2166. }
  2167. if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2168. {
  2169. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2170. }
  2171. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2172. {
  2173. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2174. }
  2175. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2176. {
  2177. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2178. }
  2179. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2180. if(isset($yz[0]['type']))
  2181. {
  2182. $post['type'] = $yz[0]['type'];
  2183. }
  2184. if($post['state'] == 9)//如果选择预设库存
  2185. {
  2186. $this->whlabel->insert($post);
  2187. }
  2188. else
  2189. {
  2190. /**
  2191. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2192. if($ljg == 1)
  2193. {
  2194. for($i=0;$i<$order;$i++)
  2195. {
  2196. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2197. $this->whlabel->insert($post);
  2198. }
  2199. }
  2200. **/
  2201. //if($post['warehouse'] == '5')
  2202. //{
  2203. //}
  2204. $yydata = $post;
  2205. $yydata['zh'] = $zh;
  2206. /**
  2207. $wl = $this->apiyy->get_cjlp($yydata);
  2208. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2209. {
  2210. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2211. }
  2212. if($wl['Data'][0]['m_isSucess'] != 1)
  2213. {
  2214. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2215. }
  2216. **/
  2217. for($i=0;$i<$order;$i++)
  2218. {
  2219. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2220. $this->whlabel->insert($post);
  2221. }
  2222. }
  2223. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2224. }
  2225. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2226. $this->data['wlshop'] = $wlshop;
  2227. $this->_Template('whlabel_enteradd',$this->data);
  2228. }
  2229. //修改产品
  2230. public function _enteredit($arg_array)
  2231. {
  2232. $dt = 0;
  2233. if(isset($_SESSION['api']))
  2234. {
  2235. $user = $this->user->get_api($_SESSION['api']);
  2236. $usp = $user;
  2237. $fgshop = "";$sid = "";
  2238. $user = explode('|',trim($user['shop'],'|'));
  2239. foreach ($user as $value)
  2240. {
  2241. $fgshop .= " shop = ".$value." or";
  2242. $sid .= " id = ".$value." or";
  2243. }
  2244. }
  2245. $post = $this->input->post(NULL, TRUE);
  2246. if(isset($post['sku']))
  2247. {
  2248. $list = array();$num = "";$title = "";$features = "";
  2249. $id = $this->input->post('id',true);
  2250. $order = $this->input->post('order',true);
  2251. $shop = $this->input->post('shop',true);
  2252. $post['shop'] = ($shop!="")?','.$shop:"";
  2253. $post['sku'] = $this->input->post('sku',true);
  2254. $post['sm'] = $this->input->post('sm',true);
  2255. $post['warehouse'] = $this->input->post('warehouse',true);
  2256. $post['purchase'] = $this->input->post('purchase',true);
  2257. $post['retreatwarehouse'] = $post['warehouse'];
  2258. $category = $this->input->post('category',true);
  2259. $list['category'] = $category;
  2260. $list['hairtype'] = $this->input->post('hairtype',true);
  2261. $list['grade'] = $this->input->post('grade',true);
  2262. $size = $this->input->post('size',true);
  2263. $list['size'] = rtrim($size,',');
  2264. $post['rktype'] = $this->input->post('rktype',true);
  2265. $post['text'] = $this->input->post('text',true);
  2266. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2267. $list['extension'] = $this->input->post('extension',true);
  2268. if($category == 1297)
  2269. {
  2270. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2271. }
  2272. if($category == 1702)
  2273. {
  2274. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2275. $list['syother'] = $this->input->post('syother',true);
  2276. }
  2277. if($category == 133)
  2278. {
  2279. $list['fittype'] = $this->input->post('fittype',true);
  2280. $list['acother'] = $this->input->post('acother',true);
  2281. }
  2282. $list['color'] = $this->input->post('color',true);
  2283. $list['lowe'] = $this->input->post('lowe',true);
  2284. if(!$post['purchase'])
  2285. {
  2286. $post['purchase'] = 1;
  2287. }
  2288. if($category == 127)
  2289. {
  2290. $list['type'] = $this->input->post('type',true);
  2291. $list['headroad'] = $this->input->post('headroad',true);
  2292. $list['density'] = $this->input->post('density',true);
  2293. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2294. {
  2295. $list['lacesize'] = $this->input->post('lacesize',true);
  2296. }
  2297. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2298. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2299. }
  2300. if($category == 128)
  2301. {
  2302. $list['lacetype'] = $this->input->post('lacetype',true);
  2303. $list['haircap'] = $this->input->post('haircap',true);
  2304. $list['density'] = $this->input->post('density',true);
  2305. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2306. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2307. $list['wigother'] = $this->input->post('wigother',true);
  2308. $list['wigother2'] = $this->input->post('wigother2',true);
  2309. }
  2310. if($category == 129)
  2311. {
  2312. $list['wide'] = $this->input->post('wide',true);
  2313. }
  2314. if($category == 131)
  2315. {
  2316. $list['gifttype'] = $this->input->post('gifttype',true);
  2317. $list['giftother'] = $this->input->post('giftother',true);
  2318. }
  2319. if($category == 134)
  2320. {
  2321. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2322. }
  2323. if($category == 1297)
  2324. {
  2325. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2326. $list['sywigother'] = $this->input->post('sywigother',true);
  2327. }
  2328. if($category == 130 || $category == 133 || $category == 1702)
  2329. {
  2330. $list['items'] = $this->input->post('items',true);
  2331. $list['weight'] = $this->input->post('weight',true);
  2332. }
  2333. if($category == 1702)
  2334. {
  2335. $list['syhairther'] = $this->input->post('syhairther',true);
  2336. }
  2337. foreach($list as $k=>$v)
  2338. {
  2339. if($v != 0)
  2340. {
  2341. $num .=$v;
  2342. $features .=$v.'-';
  2343. $typeclass = $this->typeclass->read($v);
  2344. if($k != 'size')
  2345. {
  2346. $title .= $typeclass['title']." ";
  2347. }
  2348. }
  2349. }
  2350. $typeclass = $this->typeclass->read($list['size']);
  2351. $title .= $typeclass['title'];
  2352. $time = time();
  2353. $post['title'] = rtrim($title,' ');
  2354. $post['number'] = $num;
  2355. $post['features'] = '-'.$features;
  2356. $post['time'] = $time;//操作时间
  2357. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2358. {
  2359. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2360. }
  2361. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2362. {
  2363. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2364. }
  2365. $uid = $this->whlabel->read($id);
  2366. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2367. if($datanum > 0)
  2368. {
  2369. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2370. }
  2371. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2372. {
  2373. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2374. if($yza)
  2375. {
  2376. if($post['features'] != $yza[0]['features'])
  2377. {
  2378. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2379. }
  2380. }
  2381. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2382. if($yzb)
  2383. {
  2384. if($post['sku'] != $yzb[0]['sku'])
  2385. {
  2386. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2387. }
  2388. }
  2389. if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2390. {
  2391. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2392. }
  2393. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2394. foreach ($data as $v)
  2395. {
  2396. $post['id'] = $v['id'];
  2397. $this->whlabel->save($post,$v['id']);
  2398. }
  2399. }
  2400. else
  2401. {
  2402. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2403. if($data > 0)
  2404. {
  2405. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2406. }
  2407. else
  2408. {
  2409. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2410. foreach ($data as $v)
  2411. {
  2412. $post['id'] = $v['id'];
  2413. $this->whlabel->save($post,$v['id']);
  2414. }
  2415. }
  2416. }
  2417. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2418. }
  2419. $uid = $this->whlabel->read($arg_array[0]);
  2420. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2421. $this->data['enter'] = $uid ;
  2422. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2423. $this->data['wlshop'] = $wlshop;
  2424. $this->_Template('whlabel_enteredit',$this->data);
  2425. }
  2426. //入库浏览
  2427. public function _enter()
  2428. {
  2429. $post = $this->input->post(NULL, TRUE);
  2430. if(isset($post['s']))
  2431. {
  2432. $id_arr = $this->input->post('s');
  2433. $id_arr = explode(',',$id_arr);
  2434. if(!$id_arr)
  2435. {
  2436. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2437. }
  2438. //循环删除记录
  2439. foreach ($id_arr as $v)
  2440. {
  2441. $sid = $this->whlabel->read($v);
  2442. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2443. if($count > 0)
  2444. {
  2445. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2446. }
  2447. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2448. foreach ($info_list as $va)
  2449. {
  2450. $this->whlabel->remove($va['id']);
  2451. }
  2452. }
  2453. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2454. }
  2455. $sp = array();
  2456. $s = $this->shop->find_all('1=1','id,shopname');
  2457. foreach ($s as $v)
  2458. {
  2459. $sp[$v['id']] = $v['shopname'];
  2460. }
  2461. $wh = array();
  2462. $w = $this->warehouse->find_all('1=1','id,title');
  2463. foreach ($w as $v)
  2464. {
  2465. $wh[$v['id']] = $v['title'];
  2466. }
  2467. if(isset($post['page']))
  2468. {
  2469. $page = $this->input->post('page',true);
  2470. $perpage = $this->input->post('perpage',true);
  2471. $category = $this->input->post('category',true);
  2472. $size = $this->input->post('size',true);
  2473. $grade = $this->input->post('grade',true);
  2474. $color = $this->input->post('color',true);
  2475. $lowe = $this->input->post('lowe',true);
  2476. $sku = $this->input->post('sku',true);
  2477. $warehouse = $this->input->post('warehouse',true);
  2478. $purchase = $this->input->post('purchase',true);
  2479. $ktime = $this->input->post('ktime',true);
  2480. $jtime = $this->input->post('jtime',true);
  2481. $ktime = strtotime($ktime);
  2482. $jtime = strtotime($jtime);
  2483. $where = "1=1";$gj = "";$ck = "";
  2484. if($category)
  2485. {
  2486. $where .= " and features like '%-$category-%'";
  2487. }
  2488. if($size)
  2489. {
  2490. $where .= " and features like '%-$size-%'";
  2491. }
  2492. if($grade)
  2493. {
  2494. $where .= " and features like '%-$grade-%'";
  2495. }
  2496. if($color)
  2497. {
  2498. $where .= " and features like '%-$color-%'";
  2499. }
  2500. if($lowe)
  2501. {
  2502. $where .= " and features like '%-$lowe-%'";
  2503. }
  2504. if($warehouse)
  2505. {
  2506. $where .= " and warehouse = '$warehouse'";
  2507. }
  2508. if($purchase)
  2509. {
  2510. $where .= " and purchase = '$purchase'";
  2511. }
  2512. if($sku)
  2513. {
  2514. $where .= " and sku like '%$sku%'";
  2515. }
  2516. if($ktime && $jtime)
  2517. {
  2518. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2519. }
  2520. //数据排序
  2521. $order_str = "enter desc";
  2522. if(empty($page))
  2523. {
  2524. $start = 0;
  2525. $perpage = 1;
  2526. }
  2527. else
  2528. {
  2529. $start = ($page - 1)*$perpage;
  2530. }
  2531. //取得信息列表
  2532. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2533. foreach ($info_list as $k=>$v)
  2534. {
  2535. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2536. if($v['shop']=='')
  2537. {
  2538. $s = '通用';
  2539. }
  2540. else
  2541. {
  2542. $info_list[$k]['shop'] = '';
  2543. foreach (explode(',',trim($v['shop'],',')) as $val)
  2544. {
  2545. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2546. }
  2547. }
  2548. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2549. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2550. $info_list[$k]['g'] = $g;
  2551. }
  2552. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2553. $pagenum = ceil($total/$perpage);
  2554. $over = $total-($start+$perpage);
  2555. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2556. echo json_encode($rows);exit;
  2557. }
  2558. $this->_Template('whlabel_enter',$this->data);
  2559. }
  2560. //出库浏览
  2561. public function _out()
  2562. {
  2563. $post = $this->input->post(NULL, TRUE);
  2564. if(isset($post['page']))
  2565. {
  2566. $page = $this->input->post('page',true);
  2567. $perpage = $this->input->post('perpage',true);
  2568. $category = $this->input->post('category',true);
  2569. $size = $this->input->post('size',true);
  2570. $grade = $this->input->post('grade',true);
  2571. $color = $this->input->post('color',true);
  2572. $lowe = $this->input->post('lowe',true);
  2573. $sku = $this->input->post('sku',true);
  2574. $warehouse = $this->input->post('warehouse',true);
  2575. $purchase = $this->input->post('purchase',true);
  2576. $state = $this->input->post('state',true);
  2577. $ktime = $this->input->post('ktime',true);
  2578. $jtime = $this->input->post('jtime',true);
  2579. $ktime = strtotime($ktime);
  2580. $jtime = strtotime($jtime);
  2581. $where = "state=3";$gj = "";$ck = "";
  2582. if($category)
  2583. {
  2584. $where .= " and features like '%-$category-%'";
  2585. }
  2586. if($size)
  2587. {
  2588. $where .= " and features like '%-$size-%'";
  2589. }
  2590. if($grade)
  2591. {
  2592. $where .= " and features like '%-$grade-%'";
  2593. }
  2594. if($color)
  2595. {
  2596. $where .= " and features like '%-$color-%'";
  2597. }
  2598. if($lowe)
  2599. {
  2600. $where .= " and features like '%-$lowe-%'";
  2601. }
  2602. if($state)
  2603. {
  2604. $where .= " and state = '$state'";
  2605. }
  2606. if($warehouse)
  2607. {
  2608. $where .= " and warehouse = '$warehouse'";
  2609. }
  2610. if($purchase)
  2611. {
  2612. $where .= " and purchase = '$purchase'";
  2613. }
  2614. if($sku)
  2615. {
  2616. $where .= " and sku = '$sku'";
  2617. }
  2618. if($ktime && $jtime)
  2619. {
  2620. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2621. }
  2622. //数据排序
  2623. $order_str = "id desc";
  2624. if(empty($page))
  2625. {
  2626. $start = 0;
  2627. $perpage = 1;
  2628. }
  2629. else
  2630. {
  2631. $start = ($page - 1)*$perpage;
  2632. }
  2633. //取得信息列表
  2634. $info_list = $this->whlabel->find_all($where,'sku');
  2635. $rows = array();$list = array();
  2636. foreach ($info_list as $key=>$value)
  2637. {
  2638. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2639. }
  2640. $rows = array_unique($rows);//删除重复记录
  2641. foreach ($rows as $key=>$value)
  2642. {
  2643. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2644. $ck = $this->warehouse->read($data['warehouse']);
  2645. $warehouse = $ck['title'];
  2646. $gy = $this->purchase->read($data['purchase']);
  2647. $purchase = $gy['purchase'];
  2648. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2649. $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);
  2650. }
  2651. $total = count($list);
  2652. $pagenum = ceil($total/$perpage);
  2653. $over = $total-($start+$perpage);
  2654. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2655. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2656. echo json_encode($rows);exit;
  2657. }
  2658. $this->_Template('whlabel_out',$this->data);
  2659. }
  2660. //出库标签浏览
  2661. public function _label()
  2662. {
  2663. $post = $this->input->post(NULL, TRUE);
  2664. if(isset($post['page']))
  2665. {
  2666. $page = $this->input->post('page',true);
  2667. $perpage = $this->input->post('perpage',true);
  2668. $sku = $this->input->post('sku',true);
  2669. $warehouse = $this->input->post('warehouse',true);
  2670. $purchase = $this->input->post('purchase',true);
  2671. $orderinfo = $this->input->post('orderinfo',true);
  2672. $waybill = $this->input->post('waybill',true);
  2673. $category = $this->input->post('category',true);
  2674. $size = $this->input->post('size',true);
  2675. $grade = $this->input->post('grade',true);
  2676. $color = $this->input->post('color',true);
  2677. $lowe = $this->input->post('lowe',true);
  2678. $where = "state=1";
  2679. if($sku)
  2680. {
  2681. $where .= " and sku = '$sku'";
  2682. }
  2683. if($warehouse)
  2684. {
  2685. $where .= " and warehouse = '$warehouse'";
  2686. }
  2687. if($purchase)
  2688. {
  2689. $where .= " and purchase = '$purchase'";
  2690. }
  2691. if($orderinfo)
  2692. {
  2693. $where .= " and orderinfo = '$orderinfo'";
  2694. }
  2695. if($waybill)
  2696. {
  2697. $where .= " and waybill = '$waybill'";
  2698. }
  2699. if($category)
  2700. {
  2701. $where .= " and features like '%-$category-%'";
  2702. }
  2703. if($size)
  2704. {
  2705. $where .= " and features like '%-$size-%'";
  2706. }
  2707. if($grade)
  2708. {
  2709. $where .= " and features like '%-$grade-%'";
  2710. }
  2711. if($color)
  2712. {
  2713. $where .= " and features like '%-$color-%'";
  2714. }
  2715. if($lowe)
  2716. {
  2717. $where .= " and features like '%-$lowe-%'";
  2718. }
  2719. //数据排序
  2720. $order_str = "outk desc";
  2721. if(empty($page))
  2722. {
  2723. $start = 0;
  2724. $perpage = 1;
  2725. }
  2726. else
  2727. {
  2728. $start = ($page - 1)*$perpage;
  2729. }
  2730. //取得信息列表
  2731. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2732. foreach ($info_list as $key=>$value)
  2733. {
  2734. $warehouse = $this->warehouse->read($value['warehouse']);
  2735. $info_list[$key]['warehouse'] = $warehouse['title'];
  2736. $purchase = $this->purchase->read($value['purchase']);
  2737. $info_list[$key]['purchase'] = $purchase['title'];
  2738. if($value['outk'] != 0)
  2739. {
  2740. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2741. }
  2742. else
  2743. {
  2744. $info_list[$key]['outk'] = "";
  2745. }
  2746. if($value['orderinfo'] == 0)
  2747. {
  2748. $info_list[$key]['orderinfo'] = "";
  2749. }
  2750. if($value['waybill'] == 0)
  2751. {
  2752. $info_list[$key]['waybill'] = "";
  2753. }
  2754. }
  2755. $total = $this->whlabel->find_count($where);
  2756. $pagenum = ceil($total/$perpage);
  2757. $over = $total-($start+$perpage);
  2758. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2759. echo json_encode($rows);exit;
  2760. }
  2761. $this->_Template('whlabel_label',$this->data);
  2762. }
  2763. //独立站出库订单
  2764. public function _outorder()
  2765. {
  2766. if(isset($_SESSION['api']))
  2767. {
  2768. $user = $this->user->get_api($_SESSION['api']);
  2769. $usp = $user;
  2770. $fgshop = "";$sid = "";
  2771. $user = explode('|',trim($user['shop'],'|'));
  2772. foreach ($user as $value)
  2773. {
  2774. $fgshop .= " shop = ".$value." or";
  2775. $sid .= " id = ".$value." or";
  2776. }
  2777. }
  2778. else
  2779. {
  2780. echo "请重新登录";
  2781. }
  2782. $post = $this->input->post(NULL, TRUE);
  2783. if(isset($post['page']))
  2784. {
  2785. $page = $this->input->post('page',true);
  2786. $perpage = $this->input->post('perpage',true);
  2787. $warehouse = $this->input->post('warehouse',true);
  2788. $xztime = $this->input->post('xztime',true);
  2789. $timetk = $this->input->post('timetkk',true);
  2790. $timetj = $this->input->post('timetjj',true);
  2791. $shop = $this->input->post('shop',true);
  2792. $source = $this->input->post('source',true);
  2793. $orderinfo = $this->input->post('orderinfo',true);
  2794. $number = $this->input->post('number',true);
  2795. $sfxh = $this->input->post('sfxh',true);
  2796. $express = $this->input->post('express',true);
  2797. $waybill = $this->input->post('waybill',true);
  2798. $library = $this->input->post('library',true);
  2799. $country = $this->input->post('country',true);
  2800. $so = $this->input->post('so',true);
  2801. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2802. $print = $this->input->post('print',true);
  2803. $state = $this->input->post('state',true);
  2804. $orderurl = $this->input->post('orderurl',true);
  2805. $timetk = strtotime($timetk);
  2806. $timetj = strtotime($timetj);
  2807. /**
  2808. $sj = $this->input->post('sj',true);
  2809. if($sj)
  2810. {
  2811. $sj = $this->input->post('sj',true);
  2812. }
  2813. else
  2814. {
  2815. $sj = "fullorder";
  2816. }
  2817. **/
  2818. $sj = "fullorder";
  2819. $where = "1=1";
  2820. if($warehouse)
  2821. {
  2822. $where .= " and type = '$warehouse'";
  2823. }
  2824. if($timetk && $timetj)
  2825. {
  2826. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2827. }
  2828. if($orderinfo)
  2829. {
  2830. $where .= " and orderinfo = '$orderinfo'";
  2831. }
  2832. if($number)
  2833. {
  2834. $where .= " and number = '$number'";
  2835. }
  2836. if($express)
  2837. {
  2838. $where .= " and express = '$express'";
  2839. }
  2840. if($waybill)
  2841. {
  2842. $where .= " and waybill = '$waybill'";
  2843. }
  2844. if($library)
  2845. {
  2846. $where .= " and library = '$library'";
  2847. }
  2848. if($print)
  2849. {
  2850. $where .= " and print = '$print'";
  2851. }
  2852. if($libraryconfirm)
  2853. {
  2854. $where .= " and libraryconfirm = '$libraryconfirm'";
  2855. }
  2856. if($state)
  2857. {
  2858. $where .= " and state = '$state'";
  2859. }
  2860. if($shop)
  2861. {
  2862. $where .= " and shop = '$shop'";
  2863. }
  2864. if($country)
  2865. {
  2866. $where .= " and country = '$country'";
  2867. }
  2868. if($sfxh != '')
  2869. {
  2870. $where .= " and sfxh = '$sfxh'";
  2871. }
  2872. if($so)
  2873. {
  2874. $where .= " and shipremarks like '%$so%'";
  2875. }
  2876. if($source)
  2877. {
  2878. if($source == '2d')
  2879. {
  2880. $where .= " and source >= '2'";
  2881. }
  2882. else
  2883. {
  2884. $where .= " and source = '$source'";
  2885. }
  2886. }
  2887. if(isset($_SESSION['api']))
  2888. {
  2889. foreach ($user as $value)
  2890. {
  2891. $fgshop .= " shop = ".$value." or";
  2892. }
  2893. $where .= " and (".rtrim($fgshop,'or').")";
  2894. }
  2895. if($orderurl)
  2896. {
  2897. $url = $this->orderurl->read($orderurl);
  2898. $where .= " and link like '%".$url['url']."%'";
  2899. }
  2900. //数据排序
  2901. $order_str = "librarytime desc";
  2902. if(empty($page))
  2903. {
  2904. $start = 0;
  2905. $perpage = 1;
  2906. }
  2907. else
  2908. {
  2909. $start = ($page - 1)*$perpage;
  2910. }
  2911. //取得信息列表
  2912. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2913. //格式化数据
  2914. foreach ($info_list as $key=>$value)
  2915. {
  2916. $shop = $this->shop->read($value['shop']);
  2917. $info_list[$key]['shop'] = $shop['shopname'];
  2918. $express = $this->express->read($value['express']);
  2919. $info_list[$key]['express'] = $express['servicename'];
  2920. $warehouse = $this->warehouse->read($value['type']);
  2921. $info_list[$key]['type'] = $warehouse['title'];
  2922. if($value['librarytime'] == '0')
  2923. {
  2924. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2925. }
  2926. else
  2927. {
  2928. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2929. }
  2930. }
  2931. $total = $this->$sj->find_count($where);
  2932. $pagenum = ceil($total/$perpage);
  2933. $over = $total-($start+$perpage);
  2934. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2935. echo json_encode($rows);exit;
  2936. }
  2937. $this->data['express'] = $this->express->find_all();
  2938. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2939. $this->data['wlshop'] = $wlshop;
  2940. $user = $this->user->get_api($_SESSION['api']);
  2941. $powerid = $this->power->read($user['power']);
  2942. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2943. $pid = '';
  2944. foreach ($powertext as $v)
  2945. {
  2946. $pid .= " id = ".$v." or";
  2947. }
  2948. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2949. $this->data['fullorderexcel'] = $fullorderexcel;
  2950. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2951. $this->data['orderurl'] = $orderurl;
  2952. $this->_Template('whlabel_outorder',$this->data);
  2953. }
  2954. //tt出库
  2955. public function _toutorder()
  2956. {
  2957. if(isset($_SESSION['api']))
  2958. {
  2959. $user = $this->user->get_api($_SESSION['api']);
  2960. $usp = $user;
  2961. $fgshop = "";$sid = "";
  2962. $user = explode('|',trim($user['shop'],'|'));
  2963. foreach ($user as $value)
  2964. {
  2965. $fgshop .= " shop = ".$value." or";
  2966. $sid .= " id = ".$value." or";
  2967. }
  2968. }
  2969. else
  2970. {
  2971. echo "请重新登录";
  2972. }
  2973. $post = $this->input->post(NULL, TRUE);
  2974. if(isset($post['page']))
  2975. {
  2976. $page = $this->input->post('page',true);
  2977. $perpage = $this->input->post('perpage',true);
  2978. $warehouse = $this->input->post('warehouse',true);
  2979. $xztime = $this->input->post('xztime',true);
  2980. $timetk = $this->input->post('timetkk',true);
  2981. $timetj = $this->input->post('timetjj',true);
  2982. $shop = $this->input->post('shop',true);
  2983. $source = $this->input->post('source',true);
  2984. $orderinfo = $this->input->post('orderinfo',true);
  2985. $number = $this->input->post('number',true);
  2986. $sfxh = $this->input->post('sfxh',true);
  2987. $express = $this->input->post('express',true);
  2988. $waybill = $this->input->post('waybill',true);
  2989. $library = $this->input->post('library',true);
  2990. $country = $this->input->post('country',true);
  2991. $so = $this->input->post('so',true);
  2992. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2993. $print = $this->input->post('print',true);
  2994. $state = $this->input->post('state',true);
  2995. $orderurl = $this->input->post('orderurl',true);
  2996. $timetk = strtotime($timetk);
  2997. $timetj = strtotime($timetj);
  2998. /**
  2999. $sj = $this->input->post('sj',true);
  3000. if($sj)
  3001. {
  3002. $sj = $this->input->post('sj',true);
  3003. }
  3004. else
  3005. {
  3006. $sj = "fullorder";
  3007. }
  3008. **/
  3009. $sj = "fullordertt";
  3010. $where = "1=1";
  3011. if($warehouse)
  3012. {
  3013. $where .= " and type = '$warehouse'";
  3014. }
  3015. if($timetk && $timetj)
  3016. {
  3017. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3018. }
  3019. if($orderinfo)
  3020. {
  3021. $where .= " and orderinfo = '$orderinfo'";
  3022. }
  3023. if($number)
  3024. {
  3025. $where .= " and number = '$number'";
  3026. }
  3027. if($express)
  3028. {
  3029. $where .= " and express = '$express'";
  3030. }
  3031. if($waybill)
  3032. {
  3033. $where .= " and waybill = '$waybill'";
  3034. }
  3035. if($library)
  3036. {
  3037. $where .= " and library = '$library'";
  3038. }
  3039. if($print)
  3040. {
  3041. $where .= " and print = '$print'";
  3042. }
  3043. if($libraryconfirm)
  3044. {
  3045. $where .= " and libraryconfirm = '$libraryconfirm'";
  3046. }
  3047. if($state)
  3048. {
  3049. $where .= " and state = '$state'";
  3050. }
  3051. if($shop)
  3052. {
  3053. $where .= " and shop = '$shop'";
  3054. }
  3055. if($country)
  3056. {
  3057. $where .= " and country = '$country'";
  3058. }
  3059. if($sfxh != '')
  3060. {
  3061. $where .= " and sfxh = '$sfxh'";
  3062. }
  3063. if($so)
  3064. {
  3065. $where .= " and shipremarks like '%$so%'";
  3066. }
  3067. if($source)
  3068. {
  3069. if($source == '2d')
  3070. {
  3071. $where .= " and source >= '2'";
  3072. }
  3073. else
  3074. {
  3075. $where .= " and source = '$source'";
  3076. }
  3077. }
  3078. if(isset($_SESSION['api']))
  3079. {
  3080. foreach ($user as $value)
  3081. {
  3082. $fgshop .= " shop = ".$value." or";
  3083. }
  3084. $where .= " and (".rtrim($fgshop,'or').")";
  3085. }
  3086. if($orderurl)
  3087. {
  3088. $url = $this->orderurl->read($orderurl);
  3089. $where .= " and link like '%".$url['url']."%'";
  3090. }
  3091. //数据排序
  3092. $order_str = "librarytime desc";
  3093. if(empty($page))
  3094. {
  3095. $start = 0;
  3096. $perpage = 1;
  3097. }
  3098. else
  3099. {
  3100. $start = ($page - 1)*$perpage;
  3101. }
  3102. //取得信息列表
  3103. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3104. //格式化数据
  3105. foreach ($info_list as $key=>$value)
  3106. {
  3107. $shop = $this->shop->read($value['shop']);
  3108. $info_list[$key]['shop'] = $shop['shopname'];
  3109. $express = $this->express->read($value['express']);
  3110. $info_list[$key]['express'] = $express['servicename'];
  3111. $warehouse = $this->warehouse->read($value['type']);
  3112. $info_list[$key]['type'] = $warehouse['title'];
  3113. if($value['librarytime'] == '0')
  3114. {
  3115. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3116. }
  3117. else
  3118. {
  3119. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3120. }
  3121. }
  3122. $total = $this->$sj->find_count($where);
  3123. $pagenum = ceil($total/$perpage);
  3124. $over = $total-($start+$perpage);
  3125. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3126. echo json_encode($rows);exit;
  3127. }
  3128. $this->data['express'] = $this->express->find_all();
  3129. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3130. $this->data['wlshop'] = $wlshop;
  3131. $user = $this->user->get_api($_SESSION['api']);
  3132. $powerid = $this->power->read($user['power']);
  3133. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3134. $pid = '';
  3135. foreach ($powertext as $v)
  3136. {
  3137. $pid .= " id = ".$v." or";
  3138. }
  3139. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3140. $this->data['fullorderexcel'] = $fullorderexcel;
  3141. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  3142. $this->data['orderurl'] = $orderurl;
  3143. $this->_Template('whlabel_toutorder',$this->data);
  3144. }
  3145. //速卖通出库订单
  3146. public function _soutorder()
  3147. {
  3148. if(isset($_SESSION['api']))
  3149. {
  3150. $user = $this->user->get_api($_SESSION['api']);
  3151. $usp = $user;
  3152. $fgshop = "";$sid = "";
  3153. $user = explode('|',trim($user['shop'],'|'));
  3154. foreach ($user as $value)
  3155. {
  3156. $sid .= " id = ".$value." or";
  3157. }
  3158. }
  3159. $post = $this->input->post(NULL, TRUE);
  3160. if(isset($post['page']))
  3161. {
  3162. $page = $this->input->post('page',true);
  3163. $perpage = $this->input->post('perpage',true);
  3164. $warehouse = $this->input->post('warehouse',true);
  3165. $xztime = $this->input->post('xztime',true);
  3166. $timetk = $this->input->post('timetkk',true);
  3167. $timetj = $this->input->post('timetjj',true);
  3168. $shop = $this->input->post('shop',true);
  3169. $source = $this->input->post('source',true);
  3170. $orderinfo = $this->input->post('orderinfo',true);
  3171. $number = $this->input->post('number',true);
  3172. $express = $this->input->post('express',true);
  3173. $waybill = $this->input->post('waybill',true);
  3174. $library = $this->input->post('library',true);
  3175. $country = $this->input->post('country',true);
  3176. $sfxh = $this->input->post('sfxh',true);
  3177. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3178. $print = $this->input->post('print',true);
  3179. $state = $this->input->post('state',true);
  3180. $so = $this->input->post('so',true);
  3181. $timetk = strtotime($timetk);
  3182. $timetj = strtotime($timetj);
  3183. /**
  3184. $sj = $this->input->post('sj',true);
  3185. if($sj)
  3186. {
  3187. $sj = $this->input->post('sj',true);
  3188. }
  3189. else
  3190. {
  3191. $sj = "fullorder";
  3192. }
  3193. **/
  3194. $sj = "fullordersmt";
  3195. $where = "1=1";
  3196. if($warehouse)
  3197. {
  3198. $where .= " and type = '$warehouse'";
  3199. }
  3200. if($timetk && $timetj)
  3201. {
  3202. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3203. }
  3204. if($orderinfo)
  3205. {
  3206. $where .= " and orderinfo = '$orderinfo'";
  3207. }
  3208. if($number)
  3209. {
  3210. $where .= " and number = '$number'";
  3211. }
  3212. if($express)
  3213. {
  3214. $where .= " and express = '$express'";
  3215. }
  3216. if($waybill)
  3217. {
  3218. $where .= " and waybill = '$waybill'";
  3219. }
  3220. if($library)
  3221. {
  3222. $where .= " and library = '$library'";
  3223. }
  3224. if($print)
  3225. {
  3226. $where .= " and print = '$print'";
  3227. }
  3228. if($libraryconfirm)
  3229. {
  3230. $where .= " and libraryconfirm = '$libraryconfirm'";
  3231. }
  3232. if($state)
  3233. {
  3234. $where .= " and state = '$state'";
  3235. }
  3236. if($shop)
  3237. {
  3238. $where .= " and shop = '$shop'";
  3239. }
  3240. if($sfxh != '')
  3241. {
  3242. $where .= " and sfxh = '$sfxh'";
  3243. }
  3244. if($so)
  3245. {
  3246. $where .= " and shipremarks like '%$so%'";
  3247. }
  3248. if($source)
  3249. {
  3250. $where .= " and source = '$source'";
  3251. }
  3252. if($country)
  3253. {
  3254. $where .= " and country = '$country'";
  3255. }
  3256. else
  3257. {
  3258. if(isset($_SESSION['api']))
  3259. {
  3260. foreach ($user as $value)
  3261. {
  3262. $fgshop .= " shop = ".$value." or";
  3263. }
  3264. $where .= " and (".rtrim($fgshop,'or').")";
  3265. }
  3266. }
  3267. //数据排序
  3268. $order_str = "librarytime desc";
  3269. if(empty($page))
  3270. {
  3271. $start = 0;
  3272. $perpage = 1;
  3273. }
  3274. else
  3275. {
  3276. $start = ($page - 1)*$perpage;
  3277. }
  3278. //取得信息列表
  3279. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3280. //格式化数据
  3281. foreach ($info_list as $key=>$value)
  3282. {
  3283. $shop = $this->shop->read($value['shop']);
  3284. $info_list[$key]['shop'] = $shop['shopname'];
  3285. $express = $this->express->read($value['express']);
  3286. $info_list[$key]['express'] = $express['servicename'];
  3287. $warehouse = $this->warehouse->read($value['type']);
  3288. $info_list[$key]['type'] = $warehouse['title'];
  3289. if($value['librarytime'] == '0')
  3290. {
  3291. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3292. }
  3293. else
  3294. {
  3295. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3296. }
  3297. }
  3298. $total = $this->$sj->find_count($where);
  3299. $pagenum = ceil($total/$perpage);
  3300. $over = $total-($start+$perpage);
  3301. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3302. echo json_encode($rows);exit;
  3303. }
  3304. $this->data['express'] = $this->express->find_all();
  3305. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3306. $this->data['wlshop'] = $wlshop;
  3307. $user = $this->user->get_api($_SESSION['api']);
  3308. $powerid = $this->power->read($user['power']);
  3309. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3310. $pid = '';
  3311. foreach ($powertext as $v)
  3312. {
  3313. $pid .= " id = ".$v." or";
  3314. }
  3315. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3316. $this->data['fullorderexcel'] = $fullorderexcel;
  3317. $this->_Template('whlabel_soutorder',$this->data);
  3318. }
  3319. //订单退库
  3320. public function _retreat()
  3321. {
  3322. $post = $this->input->post(NULL, TRUE);
  3323. if(isset($post['page']))
  3324. {
  3325. $page = $this->input->post('page',true);
  3326. $perpage = $this->input->post('perpage',true);
  3327. $warehouse = $this->input->post('warehouse',true);
  3328. $timetk = $this->input->post('timetk',true);
  3329. $timetj = $this->input->post('timetj',true);
  3330. $shop = $this->input->post('shop',true);
  3331. $source = $this->input->post('source',true);
  3332. $state = $this->input->post('state',true);
  3333. $review = $this->input->post('review',true);
  3334. $state = $this->input->post('state',true);
  3335. $express = $this->input->post('express',true);
  3336. $orderinfo = $this->input->post('orderinfo',true);
  3337. $user = $this->input->post('user',true);
  3338. $name = $this->input->post('name',true);
  3339. $waybill = $this->input->post('waybill',true);
  3340. $timetk = strtotime($timetk);
  3341. $timetj = strtotime($timetj);
  3342. $where = "(state=206 or state=210) and mergeid = 0";
  3343. if($warehouse)
  3344. {
  3345. $where .= " and state = '$warehouse'";
  3346. }
  3347. if($timetk && $timetj)
  3348. {
  3349. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3350. }
  3351. if($shop)
  3352. {
  3353. $where .= " and shop = '$shop'";
  3354. }
  3355. if($source)
  3356. {
  3357. $where .= " and source = '$source'";
  3358. }
  3359. if($state)
  3360. {
  3361. $where .= " and state = '$state'";
  3362. }
  3363. if($review)
  3364. {
  3365. $where .= " and review = '$review'";
  3366. }
  3367. if($state)
  3368. {
  3369. $where .= " and state = '$state'";
  3370. }
  3371. if($express)
  3372. {
  3373. $where .= " and express = '$express'";
  3374. }
  3375. if($orderinfo)
  3376. {
  3377. $where .= " and orderinfo = '$orderinfo'";
  3378. }
  3379. if($user)
  3380. {
  3381. $where .= " and user = '$user'";
  3382. }
  3383. if($name)
  3384. {
  3385. $where .= " and name = '$name'";
  3386. }
  3387. if($waybill)
  3388. {
  3389. $where .= " and waybill = '$waybill'";
  3390. }
  3391. //数据排序
  3392. $order_str = "id desc";
  3393. if(empty($page))
  3394. {
  3395. $start = 0;
  3396. $perpage = 1;
  3397. }
  3398. else
  3399. {
  3400. $start = ($page - 1)*$perpage;
  3401. }
  3402. //取得信息列表
  3403. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3404. //格式化数据
  3405. foreach ($info_list as $key=>$value)
  3406. {
  3407. $shop = $this->shop->read($value['shop']);
  3408. $info_list[$key]['shop'] = $shop['shopname'];
  3409. $warehouse = $this->warehouse->read($value['warehouse']);
  3410. $info_list[$key]['warehouse'] = $warehouse['title'];
  3411. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3412. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3413. if($value['waybill'] == 0)
  3414. {
  3415. $info_list[$key]['waybill'] = "";
  3416. }
  3417. $express = $this->express->read($value['express']);
  3418. $info_list[$key]['express'] = $express['title'];
  3419. $typeclass = $this->typeclass->read($value['state']);
  3420. $info_list[$key]['state'] = $typeclass['title'];
  3421. }
  3422. $total = $this->fullorder->find_count($where);
  3423. $pagenum = ceil($total/$perpage);
  3424. $over = $total-($start+$perpage);
  3425. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3426. echo json_encode($rows);exit;
  3427. }
  3428. $this->data['express'] = $this->express->find_all();
  3429. $this->_Template('whlabel_retreat',$this->data);
  3430. }
  3431. //退库标签浏览
  3432. public function _retreatlk()
  3433. {
  3434. $post = $this->input->post(NULL, TRUE);
  3435. if(isset($post['page']))
  3436. {
  3437. $page = $this->input->post('page',true);
  3438. $perpage = $this->input->post('perpage',true);
  3439. $timetk = $this->input->post('timetk',true);
  3440. $timetj = $this->input->post('timetj',true);
  3441. $sku = $this->input->post('sku',true);
  3442. $warehouse = $this->input->post('warehouse',true);
  3443. $purchase = $this->input->post('purchase',true);
  3444. $orderinfo = $this->input->post('orderinfo',true);
  3445. $waybill = $this->input->post('waybill',true);
  3446. $category = $this->input->post('category',true);
  3447. $size = $this->input->post('size',true);
  3448. $grade = $this->input->post('grade',true);
  3449. $color = $this->input->post('color',true);
  3450. $lowe = $this->input->post('lowe',true);
  3451. $state = $this->input->post('state',true);
  3452. $timetk = strtotime($timetk);
  3453. $timetj = strtotime($timetj);
  3454. $where = "state=2";
  3455. if($timetk && $timetj)
  3456. {
  3457. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3458. }
  3459. if($sku)
  3460. {
  3461. $where .= " and sku = '$sku'";
  3462. }
  3463. if($warehouse)
  3464. {
  3465. $where .= " and warehouse = '$warehouse'";
  3466. }
  3467. if($purchase)
  3468. {
  3469. $where .= " and purchase = '$purchase'";
  3470. }
  3471. if($orderinfo)
  3472. {
  3473. $where .= " and orderinfo = '$orderinfo'";
  3474. }
  3475. if($waybill)
  3476. {
  3477. $where .= " and waybill = '$waybill'";
  3478. }
  3479. if($category)
  3480. {
  3481. $where .= " and features like '%-$category-%'";
  3482. }
  3483. if($size)
  3484. {
  3485. $where .= " and features like '%-$size-%'";
  3486. }
  3487. if($grade)
  3488. {
  3489. $where .= " and features like '%-$grade-%'";
  3490. }
  3491. if($color)
  3492. {
  3493. $where .= " and features like '%-$color-%'";
  3494. }
  3495. if($lowe)
  3496. {
  3497. $where .= " and features like '%-$lowe-%'";
  3498. }
  3499. //数据排序
  3500. $order_str = "time desc";
  3501. if(empty($page))
  3502. {
  3503. $start = 0;
  3504. $perpage = 1;
  3505. }
  3506. else
  3507. {
  3508. $start = ($page - 1)*$perpage;
  3509. }
  3510. //取得信息列表
  3511. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3512. foreach ($info_list as $key=>$value)
  3513. {
  3514. $warehouse = $this->warehouse->read($value['warehouse']);
  3515. $info_list[$key]['warehouse'] = $warehouse['title'];
  3516. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3517. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3518. $purchase = $this->purchase->read($value['purchase']);
  3519. $info_list[$key]['purchase'] = $purchase['title'];
  3520. if($value['outk'] != 0)
  3521. {
  3522. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3523. }
  3524. else
  3525. {
  3526. $info_list[$key]['outk'] = "";
  3527. }
  3528. if($value['retreat'] != 0)
  3529. {
  3530. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3531. }
  3532. else
  3533. {
  3534. $info_list[$key]['retreat'] = "";
  3535. }
  3536. if($value['orderinfo'] == 0)
  3537. {
  3538. $info_list[$key]['orderinfo'] = "";
  3539. }
  3540. if($value['waybill'] == 0)
  3541. {
  3542. $info_list[$key]['waybill'] = "";
  3543. }
  3544. }
  3545. $total = $this->whlabel->find_count($where);
  3546. $pagenum = ceil($total/$perpage);
  3547. $over = $total-($start+$perpage);
  3548. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3549. echo json_encode($rows);exit;
  3550. }
  3551. $this->_Template('whlabel_retreatlk',$this->data);
  3552. }
  3553. //更换标签及浏览
  3554. public function _change()
  3555. {
  3556. $post = $this->input->post(NULL, TRUE);
  3557. if(isset($post['page']))
  3558. {
  3559. $page = $this->input->post('page',true);
  3560. $perpage = $this->input->post('perpage',true);
  3561. $timetk = $this->input->post('timetk',true);
  3562. $timetj = $this->input->post('timetj',true);
  3563. $label = $this->input->post('label',true);
  3564. $oldlabel = $this->input->post('oldlabel',true);
  3565. $timetk = strtotime($timetk);
  3566. $timetj = strtotime($timetj);
  3567. $where = "state=10 ";
  3568. if($timetk && $timetj)
  3569. {
  3570. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3571. }
  3572. if($label)
  3573. {
  3574. $where .= " and label = '$label'";
  3575. }
  3576. if($oldlabel)
  3577. {
  3578. $where .= " and oldlabel = '$oldlabel'";
  3579. }
  3580. //数据排序
  3581. $order_str = "time asc";
  3582. if(empty($page))
  3583. {
  3584. $start = 0;
  3585. $perpage = 1;
  3586. }
  3587. else
  3588. {
  3589. $start = ($page - 1)*$perpage;
  3590. }
  3591. //取得信息列表
  3592. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3593. foreach ($info_list as $key=>$value)
  3594. {
  3595. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3596. }
  3597. $total = $this->whlabel->find_count($where);
  3598. $pagenum = ceil($total/$perpage);
  3599. $over = $total-($start+$perpage);
  3600. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3601. echo json_encode($rows);exit;
  3602. }
  3603. $this->_Template('whlabel_change',$this->data);
  3604. }
  3605. //产品标签
  3606. public function _cpbqdc()
  3607. {
  3608. if(isset($_GET['excel']))
  3609. {
  3610. $where = "1=1";
  3611. //数据排序
  3612. $order_str = "id desc";
  3613. if(empty($page))
  3614. {
  3615. $start = 0;
  3616. $perpage = 1;
  3617. }
  3618. else
  3619. {
  3620. $start = ($page - 1)*$perpage;
  3621. }
  3622. $warehouse = $this->input->get('warehouse',true);
  3623. $state = $this->input->get('state',true);
  3624. $timetk = $this->input->get('timetkk',true);
  3625. $timetj = $this->input->get('timetjj',true);
  3626. $timetk = strtotime($timetk);
  3627. $timetj = strtotime($timetj);
  3628. if($warehouse)
  3629. {
  3630. $where .= " and warehouse = '$warehouse'";
  3631. }
  3632. if($state || $state == 0)
  3633. {
  3634. $where .= " and state = '$state'";
  3635. }
  3636. if($timetk && $timetj)
  3637. {
  3638. $where .= " and time > '$timetk' and time < '$timetj'";
  3639. }
  3640. //取得信息列表
  3641. $info_list = $this->whlabel->find_all($where,'*');
  3642. $rows = array();$list = array();
  3643. foreach ($info_list as $key=>$value)
  3644. {
  3645. $rows[$value['time']] = $value;//所有数据sku
  3646. }
  3647. foreach ($rows as $value)
  3648. {
  3649. $warehouse = $this->warehouse->read($value['warehouse']);
  3650. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3651. $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);
  3652. }
  3653. $title = "产品标签统计表";
  3654. $titlename = "<table border=1>
  3655. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3656. <tr align='center'>
  3657. <td>仓库</td>
  3658. <td>SKU</td>
  3659. <td>产品</td>
  3660. <td>入库时间</td>
  3661. <td>操作时间</td>
  3662. <td>备注</td>
  3663. <td>数量</td>
  3664. </tr>
  3665. </table>";
  3666. $filename = $title.".xls";
  3667. $tail = "";
  3668. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3669. }
  3670. }
  3671. //进销存导出
  3672. public function _exceljxc()
  3673. {
  3674. $classid = $this->classid->sku();
  3675. $pm = $classid;
  3676. $typeclass = array();
  3677. $tc = $this->typeclass->find_all();
  3678. foreach ($tc as $v)
  3679. {
  3680. $typeclass[$v['id']] = $v;
  3681. }
  3682. $prc = array();
  3683. $purchase = $this->purchase->find_all();
  3684. foreach($purchase as $k=>$v)
  3685. {
  3686. $prc[$v['id']] = $v['title'];
  3687. }
  3688. if(isset($_GET['excel']))
  3689. {
  3690. $where = "sku != 'Preset'";
  3691. //数据排序
  3692. $order_str = "id desc";
  3693. if(empty($page))
  3694. {
  3695. $start = 0;
  3696. $perpage = 1;
  3697. }
  3698. else
  3699. {
  3700. $start = ($page - 1)*$perpage;
  3701. }
  3702. $category = $this->input->get('category',true);
  3703. $warehouse = $this->input->get('warehouse',true);
  3704. $excelid = $this->input->get('sid',true);
  3705. if($category)
  3706. {
  3707. $where .= " and features like '%-$category-%'";
  3708. }
  3709. if($warehouse)
  3710. {
  3711. $where .= " and warehouse = '$warehouse'";
  3712. }
  3713. $xzid = '';
  3714. if($excelid)
  3715. {
  3716. $excelid = explode(',',trim($excelid,','));
  3717. foreach ($excelid as $key=>$value)
  3718. {
  3719. $xzid .= " id = ".$value." or";
  3720. }
  3721. $xzid = " and (".rtrim($xzid,'or').")";;
  3722. }
  3723. //取得信息列表
  3724. /**
  3725. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3726. $rows = array();$list = array();
  3727. foreach ($info_list as $key=>$value)
  3728. {
  3729. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3730. }
  3731. **/
  3732. $wt = array();
  3733. $whlabel_type = $this->whlabel_type->find_all();
  3734. foreach ($whlabel_type as $v)
  3735. {
  3736. $wt[$v['id']] = $v['title'];
  3737. }
  3738. $wh = array();
  3739. $w = $this->warehouse->find_all('1=1','id,title');
  3740. foreach ($w as $v)
  3741. {
  3742. $wh[$v['id']] = $v['title'];
  3743. }
  3744. $list = array();
  3745. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3746. foreach ($rows as $key=>$value)
  3747. {
  3748. if(isset($wt[$value['type']]))
  3749. {
  3750. $rows[$key]['type'] = $wt[$value['type']];
  3751. }
  3752. else
  3753. {
  3754. $rows[$key]['type'] = '未设置';
  3755. }
  3756. $bm = '03';
  3757. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3758. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3759. $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');
  3760. $details = array();
  3761. $cpid = array();
  3762. $cpbz = array();
  3763. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3764. foreach ($sd as $k=>$v)
  3765. {
  3766. if($v['state'] == 0)
  3767. {
  3768. $c++;
  3769. if($v['cpid'] != 0)
  3770. {
  3771. $cpid[$v['cpid']] = $v['cpid'];
  3772. }
  3773. if($v['cpbz'] != '')
  3774. {
  3775. $cpbz[$v['cpbz']] = $v['cpbz'];
  3776. }
  3777. }
  3778. if($v['state'] != 9)
  3779. {
  3780. $g++;
  3781. }
  3782. if($v['state'] == 1)
  3783. {
  3784. $x++;
  3785. }
  3786. if($v['state'] == 2)
  3787. {
  3788. $t++;
  3789. }
  3790. if($v['state'] == 8)
  3791. {
  3792. $s++;
  3793. }
  3794. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3795. {
  3796. $q++;
  3797. }
  3798. $details[$v['details']] = $v['details'];
  3799. }
  3800. $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'].'"');
  3801. $rows[$key]['details'] = implode("、",$details);
  3802. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3803. $number = $value['number'];
  3804. $ftime = time()-15*24*3600;
  3805. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3806. $rows[$key]['number'] = $g;
  3807. $rows[$key]['c'] = $c;
  3808. $rows[$key]['x'] = $x;
  3809. $rows[$key]['t'] = $t;
  3810. $rows[$key]['s'] = $s;
  3811. $rows[$key]['q'] = $q;
  3812. $rows[$key]['z'] = $z;
  3813. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3814. $features = explode('-',trim($features,'-'));
  3815. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3816. $pm = $classid;
  3817. $jm = $classid;
  3818. foreach($features as $k=>$v)
  3819. {
  3820. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3821. {
  3822. if($typeclass[$v]['bm'] != '')
  3823. {
  3824. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3825. }
  3826. }
  3827. if($v != 0)
  3828. {
  3829. if(!isset($typeclass[$v]))
  3830. {
  3831. continue;
  3832. }
  3833. if(isset($pm[$typeclass[$v]['classid']]))
  3834. {
  3835. if(stripos($typeclass[$v]['zh'],'|') !== false)
  3836. {
  3837. $tz = explode('|',$typeclass[$v]['zh']);
  3838. $pm[$typeclass[$v]['classid']] = $tz[0];
  3839. }
  3840. else
  3841. {
  3842. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3843. }
  3844. }
  3845. if(isset($jm[$typeclass[$v]['classid']]))
  3846. {
  3847. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3848. }
  3849. }
  3850. }
  3851. $jm = array_filter($jm);
  3852. $rows[$key]['bs'] = implode("-",$jm);
  3853. $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3854. $zh = implode(" ",$pm);
  3855. $zh = str_replace('自然色 ','',trim($zh,' '));
  3856. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3857. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3858. $rows[$key]['features'] = $zh;
  3859. }
  3860. $title = "总进销存统计表";
  3861. $titlename = "<table border=1>
  3862. <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
  3863. <tr align='center'>
  3864. <td>仓库</td>
  3865. <td>供应商</td>
  3866. <td>位置</td>
  3867. <td>库存编码</td>
  3868. <td>类目</td>
  3869. <td>SKU</td>
  3870. <td>用友编码</td>
  3871. <td>用友料号</td>
  3872. <td>商品名称</td>
  3873. <td>商品中文</td>
  3874. <td>产品备注</td>
  3875. <td>说明</td>
  3876. <td>类型</td>
  3877. <td>入库总量</td>
  3878. <td>库存数量</td>
  3879. <td>销售数量</td>
  3880. <td>退货数量</td>
  3881. <td>删除数量</td>
  3882. <td>其它操作</td>
  3883. <td>占单数量</td>
  3884. </tr>
  3885. </table>";
  3886. $filename = $title.".xls";
  3887. $tail = "";
  3888. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  3889. }
  3890. }
  3891. //入库导出
  3892. public function _excelr()
  3893. {
  3894. if(isset($_GET['excel']))
  3895. {
  3896. $category = $this->input->get('category',true);
  3897. $size = $this->input->get('size',true);
  3898. $grade = $this->input->get('grade',true);
  3899. $color = $this->input->get('color',true);
  3900. $lowe = $this->input->get('lowe',true);
  3901. $sku = $this->input->get('sku',true);
  3902. $warehouse = $this->input->get('warehouse',true);
  3903. $purchase = $this->input->get('purchase',true);
  3904. $ktime = $this->input->get('ktime',true);
  3905. $jtime = $this->input->get('jtime',true);
  3906. $ktime = strtotime($ktime);
  3907. $jtime = strtotime($jtime);
  3908. $where = "1=1";$gj = "";$ck = "";
  3909. if($category)
  3910. {
  3911. $where .= " and features like '%-$category-%'";
  3912. }
  3913. if($size)
  3914. {
  3915. $where .= " and features like '%-$size-%'";
  3916. }
  3917. if($grade)
  3918. {
  3919. $where .= " and features like '%-$grade-%'";
  3920. }
  3921. if($color)
  3922. {
  3923. $where .= " and features like '%-$color-%'";
  3924. }
  3925. if($lowe)
  3926. {
  3927. $where .= " and features like '%-$lowe-%'";
  3928. }
  3929. if($warehouse)
  3930. {
  3931. $where .= " and warehouse = '$warehouse'";
  3932. }
  3933. if($purchase)
  3934. {
  3935. $where .= " and purchase = '$purchase'";
  3936. }
  3937. if($sku)
  3938. {
  3939. $where .= " and sku = '$sku'";
  3940. }
  3941. if($ktime && $jtime)
  3942. {
  3943. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3944. }
  3945. //数据排序
  3946. $order_str = "id desc";
  3947. if(empty($page))
  3948. {
  3949. $start = 0;
  3950. $perpage = 1;
  3951. }
  3952. else
  3953. {
  3954. $start = ($page - 1)*$perpage;
  3955. }
  3956. $list = array();
  3957. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3958. foreach ($rows as $value)
  3959. {
  3960. $ck = $this->warehouse->read($value['warehouse']);
  3961. $warehouse = $ck['title'];
  3962. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3963. $retreatwarehouse = $tkck['title'];
  3964. $gy = $this->purchase->read($value['purchase']);
  3965. $purchase = $gy['title'];
  3966. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3967. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3968. }
  3969. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3970. $titlename = "<table border=1>
  3971. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  3972. <tr align='center'>
  3973. <td>仓库</td>
  3974. <td>SKU</td>
  3975. <td>产品</td>
  3976. <td>时间</td>
  3977. <td>数量</td>
  3978. </tr>
  3979. </table>";
  3980. $filename = $title.".xls";
  3981. $tail = "";
  3982. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3983. }
  3984. }
  3985. //出库、退库导出
  3986. public function _excelct()
  3987. {
  3988. $classid = $this->classid->sku();
  3989. $pm = $classid;
  3990. $typeclass = array();
  3991. $tc = $this->typeclass->find_all();
  3992. foreach ($tc as $v)
  3993. {
  3994. $typeclass[$v['id']] = $v;
  3995. }
  3996. $prc = array();
  3997. $purchase = $this->purchase->find_all();
  3998. foreach($purchase as $k=>$v)
  3999. {
  4000. $prc[$v['id']] = $v['title'];
  4001. }
  4002. if(isset($_GET['excel']))
  4003. {
  4004. $wh = array();
  4005. $w = $this->warehouse->find_all('1=1','id,title');
  4006. foreach ($w as $v)
  4007. {
  4008. $wh[$v['id']] = $v['title'];
  4009. }
  4010. $type = $this->input->get('excel',true);
  4011. $category = $this->input->get('category',true);
  4012. $size = $this->input->get('size',true);
  4013. $grade = $this->input->get('grade',true);
  4014. $color = $this->input->get('color',true);
  4015. $lowe = $this->input->get('lowe',true);
  4016. $sku = $this->input->get('sku',true);
  4017. $warehouse = $this->input->get('warehouse',true);
  4018. $lacetype = $this->input->get('lacetype',true);
  4019. $lacecolor = $this->input->get('lacecolor',true);
  4020. $density = $this->input->get('density',true);
  4021. $haircap = $this->input->get('haircap',true);
  4022. $purchase = $this->input->get('purchase',true);
  4023. $title = $this->input->get('title',true);
  4024. $state = $this->input->get('state',true);
  4025. $sid = $this->input->get('sid',true);
  4026. $ktime = $this->input->get('ktime',true);
  4027. $jtime = $this->input->get('jtime',true);
  4028. $ktime = strtotime($ktime);
  4029. $jtime = strtotime($jtime);
  4030. $where = "1=1";$gj = "";$ck = "";
  4031. if($category)
  4032. {
  4033. $where .= " and features like '%-$category-%'";
  4034. }
  4035. if($size)
  4036. {
  4037. $where .= " and features like '%-$size-%'";
  4038. }
  4039. if($grade)
  4040. {
  4041. $where .= " and features like '%-$grade-%'";
  4042. }
  4043. if($color)
  4044. {
  4045. $where .= " and features like '%-$color-%'";
  4046. }
  4047. if($lowe)
  4048. {
  4049. $where .= " and features like '%-$lowe-%'";
  4050. }
  4051. if($warehouse)
  4052. {
  4053. $where .= " and warehouse = '$warehouse'";
  4054. }
  4055. if($purchase)
  4056. {
  4057. $where .= " and purchase = '$purchase'";
  4058. }
  4059. if($state)
  4060. {
  4061. $where .= " and state = '$state'";
  4062. }
  4063. if($lacetype)
  4064. {
  4065. $where .= " and features like '%-$lacetype-%'";
  4066. }
  4067. if($lacecolor)
  4068. {
  4069. $where .= " and features like '%-$lacecolor-%'";
  4070. }
  4071. if($density)
  4072. {
  4073. $where .= " and features like '%-$density-%'";
  4074. }
  4075. if($haircap)
  4076. {
  4077. $where .= " and features like '%-$haircap-%'";
  4078. }
  4079. if($title)
  4080. {
  4081. $title = trim($title,' ');
  4082. $title = trim($title,' ');
  4083. $where .= " and title like '%$title%'";
  4084. }
  4085. if($sku)
  4086. {
  4087. $sku = trim($sku,' ');
  4088. $sku = trim($sku,' ');
  4089. $where .= " and sku like '%$sku%'";
  4090. }
  4091. if($ktime && $jtime)
  4092. {
  4093. if($type == 1)
  4094. {
  4095. $tl = '出库';
  4096. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4097. }
  4098. else if($type == 2)
  4099. {
  4100. $tl = '退库';
  4101. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4102. }
  4103. else if($type == 3)
  4104. {
  4105. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4106. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4107. }
  4108. else if($type == 4)
  4109. {
  4110. $tl = '出库+零售';
  4111. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4112. }
  4113. else if($type == 5)
  4114. {
  4115. $tl = '零售';
  4116. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4117. }
  4118. }
  4119. $sidwhere = '';
  4120. if($sid)
  4121. {
  4122. $sd = "";
  4123. $s = explode(',',trim($sid,','));
  4124. foreach ($s as $value)
  4125. {
  4126. $sd .= " id = ".$value." or";
  4127. }
  4128. $sidwhere = " and (".rtrim($sd,'or').")";
  4129. }
  4130. //数据排序
  4131. $order_str = "time desc";
  4132. if(empty($page))
  4133. {
  4134. $start = 0;
  4135. $perpage = 1;
  4136. }
  4137. else
  4138. {
  4139. $start = ($page - 1)*$perpage;
  4140. }
  4141. //取得信息列表
  4142. if($type != 3 && $type != 5)
  4143. {
  4144. if($type == 1 || $type == 4)
  4145. {
  4146. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4147. foreach ($info_list as $key=>$value)
  4148. {
  4149. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4150. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4151. $warehouse = $this->warehouse->read($value['warehouse']);
  4152. $info_list[$key]['warehouse'] = $warehouse['title'];
  4153. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4154. $features = explode('-',trim($features,'-'));
  4155. $pm = $classid;
  4156. foreach($features as $k=>$v)
  4157. {
  4158. if($v != 0)
  4159. {
  4160. if(!isset($typeclass[$v]))
  4161. {
  4162. continue;
  4163. }
  4164. if(isset($pm[$typeclass[$v]['classid']]))
  4165. {
  4166. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4167. {
  4168. $tz = explode('|',$typeclass[$v]['zh']);
  4169. $pm[$typeclass[$v]['classid']] = $tz[0];
  4170. }
  4171. else
  4172. {
  4173. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4174. }
  4175. }
  4176. }
  4177. }
  4178. $zh = implode(" ",$pm);
  4179. $zh = str_replace('自然色 ','',trim($zh,' '));
  4180. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4181. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4182. $info_list[$key]['features'] = $zh;
  4183. }
  4184. }
  4185. else
  4186. {
  4187. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4188. foreach ($info_list as $key=>$value)
  4189. {
  4190. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4191. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4192. $warehouse = $this->warehouse->read($value['warehouse']);
  4193. $info_list[$key]['warehouse'] = $warehouse['title'];
  4194. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4195. $features = explode('-',trim($features,'-'));
  4196. $pm = $classid;
  4197. foreach($features as $k=>$v)
  4198. {
  4199. if($v != 0)
  4200. {
  4201. if(!isset($typeclass[$v]))
  4202. {
  4203. continue;
  4204. }
  4205. if(isset($pm[$typeclass[$v]['classid']]))
  4206. {
  4207. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4208. {
  4209. $tz = explode('|',$typeclass[$v]['zh']);
  4210. $pm[$typeclass[$v]['classid']] = $tz[0];
  4211. }
  4212. else
  4213. {
  4214. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4215. }
  4216. }
  4217. }
  4218. }
  4219. $zh = implode(" ",$pm);
  4220. $zh = str_replace('自然色 ','',trim($zh,' '));
  4221. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4222. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4223. $info_list[$key]['features'] = $zh;
  4224. }
  4225. }
  4226. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4227. $titlename = "<table border=1>
  4228. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4229. <tr align='center'>
  4230. <td>仓库</td>
  4231. <td>供应商</td>
  4232. <td>SKU</td>
  4233. <td>商品名称</td>
  4234. <td>商品中文</td>
  4235. <td>标签</td>
  4236. <td>订单号</td>
  4237. <td>运单号</td>
  4238. <td>".$tl."时间(中国时间)</td>
  4239. </tr>
  4240. </table>";
  4241. $filename = $title.".xls";
  4242. $tail = "";
  4243. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4244. }
  4245. else if($type == 5)
  4246. {
  4247. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4248. foreach ($info_list as $key=>$value)
  4249. {
  4250. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4251. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4252. $warehouse = $this->warehouse->read($value['warehouse']);
  4253. $info_list[$key]['warehouse'] = $warehouse['title'];
  4254. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4255. $features = explode('-',trim($features,'-'));
  4256. $pm = $classid;
  4257. foreach($features as $k=>$v)
  4258. {
  4259. if($v != 0)
  4260. {
  4261. if(!isset($typeclass[$v]))
  4262. {
  4263. continue;
  4264. }
  4265. if(isset($pm[$typeclass[$v]['classid']]))
  4266. {
  4267. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4268. {
  4269. $tz = explode('|',$typeclass[$v]['zh']);
  4270. $pm[$typeclass[$v]['classid']] = $tz[0];
  4271. }
  4272. else
  4273. {
  4274. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4275. }
  4276. }
  4277. }
  4278. }
  4279. $zh = implode(" ",$pm);
  4280. $zh = str_replace('自然色 ','',trim($zh,' '));
  4281. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4282. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4283. $info_list[$key]['features'] = $zh;
  4284. }
  4285. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4286. $titlename = "<table border=1>
  4287. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4288. <tr align='center'>
  4289. <td>仓库</td>
  4290. <td>供应商</td>
  4291. <td>SKU</td>
  4292. <td>商品名称</td>
  4293. <td>商品中文</td>
  4294. <td>标签</td>
  4295. <td>".$tl."时间(中国时间)</td>
  4296. </tr>
  4297. </table>";
  4298. $filename = $title.".xls";
  4299. $tail = "";
  4300. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4301. }
  4302. else
  4303. {
  4304. /**
  4305. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4306. $rows = array();$list = array();
  4307. foreach ($info_list as $key=>$value)
  4308. {
  4309. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4310. }
  4311. **/
  4312. $wh = array();
  4313. $w = $this->warehouse->find_all('1=1','id,title');
  4314. foreach ($w as $v)
  4315. {
  4316. $wh[$v['id']] = $v['title'];
  4317. }
  4318. $wt = array();
  4319. $whlabel_type = $this->whlabel_type->find_all();
  4320. foreach ($whlabel_type as $v)
  4321. {
  4322. $wt[$v['id']] = $v['title'];
  4323. }
  4324. $classid = $this->classid->sku();
  4325. $list = array();
  4326. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4327. foreach ($rows as $key=>$value)
  4328. {
  4329. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4330. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4331. $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');
  4332. $details = array();
  4333. $cpid = array();
  4334. $cpbz = array();
  4335. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4336. foreach ($sd as $k=>$v)
  4337. {
  4338. if($v['state'] == 0)
  4339. {
  4340. $c++;
  4341. }
  4342. if($v['state'] != 9)
  4343. {
  4344. $g++;
  4345. }
  4346. if($v['outk'] > 1)
  4347. {
  4348. $x++;
  4349. }
  4350. if($v['retreat'] > 0)
  4351. {
  4352. $t++;
  4353. }
  4354. if($v['state'] == 8)
  4355. {
  4356. $s++;
  4357. }
  4358. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4359. {
  4360. $q++;
  4361. }
  4362. $details[$v['details']] = $v['details'];
  4363. if($v['cpid'] != 0)
  4364. {
  4365. $cpid[$v['cpid']] = $v['cpid'];
  4366. }
  4367. if($v['cpbz'] != '')
  4368. {
  4369. $cpbz[$v['cpbz']] = $v['cpbz'];
  4370. }
  4371. }
  4372. if(isset($wt[$value['type']]))
  4373. {
  4374. $rows[$key]['type'] = $wt[$value['type']];
  4375. }
  4376. else
  4377. {
  4378. $rows[$key]['type'] = '未设置';
  4379. }
  4380. $rows[$key]['details'] = implode("、",$details);
  4381. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4382. $ftime = time()-15*24*3600;
  4383. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4384. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4385. $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);
  4386. $rows[$key]['c'] = $c;
  4387. $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);
  4388. $rows[$key]['t'] = $t;
  4389. $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'].'"');
  4390. $rows[$key]['z'] = $z;
  4391. $jm = $classid;
  4392. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4393. $features = explode('-',trim($features,'-'));
  4394. $pm = $classid;
  4395. foreach($features as $k=>$v)
  4396. {
  4397. if($v != 0)
  4398. {
  4399. if(!isset($typeclass[$v]))
  4400. {
  4401. continue;
  4402. }
  4403. if(isset($pm[$typeclass[$v]['classid']]))
  4404. {
  4405. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4406. {
  4407. $tz = explode('|',$typeclass[$v]['zh']);
  4408. $pm[$typeclass[$v]['classid']] = $tz[0];
  4409. }
  4410. else
  4411. {
  4412. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4413. }
  4414. if(isset($jm[$typeclass[$v]['classid']]))
  4415. {
  4416. if($typeclass[$v]['jm'])
  4417. {
  4418. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4419. }
  4420. }
  4421. }
  4422. }
  4423. }
  4424. $zh = implode(" ",$pm);
  4425. $zh = str_replace('自然色 ','',trim($zh,' '));
  4426. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4427. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4428. $rows[$key]['features'] = $zh;
  4429. $jm = array_filter($jm);//去除空值
  4430. $jm = implode("-",$jm);
  4431. $rows[$key]['jm'] = $jm;
  4432. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4433. }
  4434. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4435. $titlename = "<table border=1>
  4436. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4437. <tr align='center'>
  4438. <td>仓库</td>
  4439. <td>供应商</td>
  4440. <td>位置</td>
  4441. <td>库存编码</td>
  4442. <td>SKU</td>
  4443. <td>商品名称</td>
  4444. <td>商品中文</td>
  4445. <td>产品备注</td>
  4446. <td>说明</td>
  4447. <td>类型</td>
  4448. <td>入库总量</td>
  4449. <td>库存数量</td>
  4450. <td>销售数量</td>
  4451. <td>退货数量</td>
  4452. <td>占单数量</td>
  4453. <td>料号</td>
  4454. <td>类目</td>
  4455. </tr>
  4456. </table>";
  4457. $filename = $title.".xls";
  4458. $tail = "";
  4459. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4460. }
  4461. }
  4462. }
  4463. //出库+入库数据整合
  4464. public function _excelcr()
  4465. {
  4466. if(isset($_GET['excel']))
  4467. {
  4468. $type = $this->input->get('excel',true);
  4469. $category = $this->input->get('category',true);
  4470. $size = $this->input->get('size',true);
  4471. $grade = $this->input->get('grade',true);
  4472. $color = $this->input->get('color',true);
  4473. $lowe = $this->input->get('lowe',true);
  4474. $sku = $this->input->get('sku',true);
  4475. $warehouse = $this->input->get('warehouse',true);
  4476. $purchase = $this->input->get('purchase',true);
  4477. $state = $this->input->get('state',true);
  4478. $sid = $this->input->get('sid',true);
  4479. $ktime = $this->input->get('ktime',true);
  4480. $jtime = $this->input->get('jtime',true);
  4481. $ktime = strtotime($ktime);
  4482. $jtime = strtotime($jtime);
  4483. $where = "1=1";$gj = "";$ck = "";
  4484. if($category)
  4485. {
  4486. $where .= " and features like '%-$category-%'";
  4487. }
  4488. if($size)
  4489. {
  4490. $where .= " and features like '%-$size-%'";
  4491. }
  4492. if($grade)
  4493. {
  4494. $where .= " and features like '%-$grade-%'";
  4495. }
  4496. if($color)
  4497. {
  4498. $where .= " and features like '%-$color-%'";
  4499. }
  4500. if($lowe)
  4501. {
  4502. $where .= " and features like '%-$lowe-%'";
  4503. }
  4504. if($warehouse)
  4505. {
  4506. $where .= " and warehouse = '$warehouse'";
  4507. }
  4508. if($purchase)
  4509. {
  4510. $where .= " and purchase = '$purchase'";
  4511. }
  4512. if($state)
  4513. {
  4514. $where .= " and state = '$state'";
  4515. }
  4516. if($sku)
  4517. {
  4518. $where .= " and sku like '%$sku%'";
  4519. }
  4520. if($ktime && $jtime)
  4521. {
  4522. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4523. }
  4524. $sidwhere = '';
  4525. if($sid)
  4526. {
  4527. $sd = "";
  4528. $s = explode(',',trim($sid,','));
  4529. foreach ($s as $value)
  4530. {
  4531. $sd .= " id = ".$value." or";
  4532. }
  4533. $sidwhere .= " and (".rtrim($sd,'or').")";
  4534. }
  4535. //取得信息列表
  4536. $timeread = $ktime;
  4537. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4538. $timelist = array();
  4539. for($i=0;$i<$timenum;$i++)
  4540. {
  4541. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4542. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4543. }
  4544. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4545. //echo "<pre>";
  4546. //print_r($info_list);
  4547. //exit();
  4548. $rows = array();$list = array();
  4549. foreach ($info_list as $key=>$value)
  4550. {
  4551. $thistime = $timelist;
  4552. if(isset($rows[strtolower($value['sku'])]))
  4553. {
  4554. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4555. {
  4556. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4557. }
  4558. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4559. {
  4560. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4561. }
  4562. }
  4563. else
  4564. {
  4565. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4566. {
  4567. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4568. }
  4569. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4570. {
  4571. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4572. }
  4573. $rows[strtolower($value['sku'])] = $thistime;
  4574. }
  4575. }
  4576. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4577. <head>
  4578. <!--[if gte mso 9]><xml>
  4579. <x:ExcelWorkbook>
  4580. <x:ExcelWorksheets>
  4581. <x:ExcelWorksheet>
  4582. <x:Name>EXCEL</x:Name>
  4583. <x:WorksheetOptions>
  4584. <x:Print>
  4585. <x:ValidPrinterInfo />
  4586. </x:Print>
  4587. </x:WorksheetOptions>
  4588. </x:ExcelWorksheet>
  4589. </x:ExcelWorksheets>
  4590. </x:ExcelWorkbook>
  4591. </xml>
  4592. <![endif]-->
  4593. </head><body>";
  4594. $str .= "<table border=1><tr><td>SKU</td>";
  4595. foreach ($timelist as $k=>$v)
  4596. {
  4597. $str .="<td>".$k."出库</td>";
  4598. $str .="<td>".$k."入库</td>";
  4599. }
  4600. $str .= "</tr></table>";
  4601. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4602. foreach ($rows as $key=>$val)
  4603. {
  4604. $str .= "<tr><td>".strtoupper($key)."</td>";
  4605. foreach ($val as $k=>$v)
  4606. {
  4607. $str .= "<td>".$val[$k]['c']."</td>";
  4608. if($val[$k]['r'] > 0)
  4609. {
  4610. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4611. }
  4612. else
  4613. {
  4614. $str .= "<td>".$val[$k]['r']."</td>";
  4615. }
  4616. }
  4617. $str .= "</tr>";
  4618. }
  4619. $str .= "</table>";
  4620. $str .= "</body></html>";
  4621. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4622. header( "Content-type: application/octet-stream" );
  4623. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4624. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4625. header( "Pragma: no-cache" );
  4626. header( "Expires: 0" );
  4627. exit($str);
  4628. }
  4629. }
  4630. //数量调整模板导出
  4631. public function _presetout()
  4632. {
  4633. if(isset($_GET['excel']))
  4634. {
  4635. $where = "sku != 'Preset' and purchase != 0";
  4636. //数据排序
  4637. $order_str = "id desc";
  4638. if(empty($page))
  4639. {
  4640. $start = 0;
  4641. $perpage = 1;
  4642. }
  4643. else
  4644. {
  4645. $start = ($page - 1)*$perpage;
  4646. }
  4647. //取得信息列表
  4648. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4649. $rows = array();$list = array();
  4650. foreach ($info_list as $value)
  4651. {
  4652. $warehouse = $this->warehouse->read($value['warehouse']);
  4653. $number = $value['number'];$ftime = time()-15*24*3600;
  4654. $purchase = $this->purchase->read($value['purchase']);
  4655. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4656. }
  4657. $title = "库存模板";
  4658. $titlename = "<table border=1>
  4659. <tr align='center'>
  4660. <td>仓库</td>
  4661. <td>供应商编码</td>
  4662. <td>SKU</td>
  4663. <td>增减数量(正数或负数)</td>
  4664. <td>增减备注</td>
  4665. <td>扣减方式:0减少库存1删除库存</td>
  4666. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4667. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4668. </tr>
  4669. </table>";
  4670. $filename = $title.".xls";
  4671. $tail = "";
  4672. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4673. }
  4674. }
  4675. //数量调整模板导入
  4676. public function _presetedit()
  4677. {
  4678. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4679. $config['upload_path'] = '.'.$dir ;
  4680. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4681. $config['allowed_types'] = 'xls|xlsx|csv';
  4682. $config['max_size'] = 10240;
  4683. $this->load->library('upload', $config);
  4684. $this->upload->initialize($config);
  4685. if ($this->upload->do_upload('userfile'))
  4686. {
  4687. $full_path = $dir.$this->upload->data('file_name');
  4688. $fileName = '.' . $full_path;
  4689. if (!file_exists($fileName))
  4690. {
  4691. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4692. }
  4693. else
  4694. {
  4695. require_once "./data/excel/PHPExcel/IOFactory.php";
  4696. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4697. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4698. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4699. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4700. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4701. ++$column;//如果列数大于26行
  4702. $list = array();
  4703. for ($i = 2; $i <= $row; $i++) // 行数循环
  4704. {
  4705. $data = array();
  4706. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4707. {
  4708. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4709. }
  4710. $list[] = $data;
  4711. }
  4712. }
  4713. $i = 0;$j = 0;$ed = array();
  4714. foreach ($list as $key=>$value)
  4715. {
  4716. $time = time();
  4717. if($value['0'] == "")
  4718. {
  4719. continue;
  4720. }
  4721. $warehouse = $this->warehouse->get_title($value['0']);
  4722. $purchase = $this->purchase->get_bm($value['1']);
  4723. $sku = $value['2'];
  4724. $num = $value['3'];//调整数量
  4725. $text = $value['4'];//扣减说明
  4726. $type = $value['5'];//调整方式0扣减1删除
  4727. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4728. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4729. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4730. if(!$purchase)//如果没有这个SKU
  4731. {
  4732. $ed[] = array($purchase.'-不存在此供应商编码');
  4733. $j++;
  4734. continue;
  4735. }
  4736. if(!$d)//如果没有这个SKU
  4737. {
  4738. $ed[] = array($sku.'-库存中不存在此SKU');
  4739. $j++;
  4740. continue;
  4741. }
  4742. if(!isset($warehouse['id']))
  4743. {
  4744. $ed[] = array($sku.'-仓库名错误!');
  4745. $j++;
  4746. continue;
  4747. }
  4748. if($type != '0' && $type != '1')
  4749. {
  4750. $ed[] = array($sku.'-扣减方式填写错误!');
  4751. $j++;
  4752. continue;
  4753. }
  4754. if($num < 0)//扣减库存
  4755. {
  4756. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4757. {
  4758. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4759. $j++;
  4760. continue;
  4761. }
  4762. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4763. if(count($data) < abs($num))
  4764. {
  4765. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4766. $j++;
  4767. continue;
  4768. }
  4769. if($type == 0)//如果扣减方式为 扣减库存
  4770. {
  4771. for($i=0;$i<abs($num);$i++)
  4772. {
  4773. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4774. }
  4775. }
  4776. else if($type == 1)
  4777. {
  4778. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4779. if(count($zt) > 0)
  4780. {
  4781. $ed[] = array($sku.'-有在途库存无法删除!');
  4782. $j++;
  4783. continue;
  4784. }
  4785. for($i=0;$i<abs($num);$i++)
  4786. {
  4787. $this->whlabel->remove($data[$i]['id']);
  4788. }
  4789. }
  4790. }
  4791. else if($num > 0)//增加库存
  4792. {
  4793. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4794. {
  4795. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4796. $j++;
  4797. continue;
  4798. }
  4799. $post['sku'] = $d['sku'];
  4800. $post['shop'] = $d['shop'];
  4801. $post['warehouse'] = $warehouse['id'];
  4802. $post['purchase'] = $purchase['id'];
  4803. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4804. $post['state'] = 0;
  4805. $post['title'] = $d['title'];
  4806. $post['number'] = $d['number'];
  4807. $post['features'] = $d['features'];
  4808. $post['enter'] = $time;
  4809. $post['time'] = $time;//操作时间
  4810. $post['rktype'] = $rktype;
  4811. for($i=0;$i<$num;$i++)
  4812. {
  4813. $post['label'] = time().rand(100,999).$i;
  4814. $this->whlabel->insert($post);
  4815. }
  4816. }
  4817. sleep(1);//防止入库时间一样,需要延迟1秒
  4818. }
  4819. if($j > 0)
  4820. {
  4821. $tt = date('Ymd',time());
  4822. $title = '库存导入错误信息-'.$tt;
  4823. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4824. $tail = "\n";
  4825. $filename = $title.".xls";
  4826. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4827. $dir = '/data/excel/'.$time.'/';
  4828. $file_name = 'error_'.$time.rand(1000,9999);
  4829. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4830. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4831. fwrite($myfile,$ecl);
  4832. fclose($myfile);
  4833. $error = $dir.$file_name.'.xls';
  4834. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4835. }
  4836. else
  4837. {
  4838. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4839. }
  4840. }
  4841. }
  4842. //笛卡儿积
  4843. function cp($ps,$sets,$list)
  4844. {
  4845. $result = array();$j=0;
  4846. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4847. {
  4848. if($i==0)
  4849. {
  4850. $result = $sets[$i];
  4851. }
  4852. $tmp = array();
  4853. foreach($result as $res)
  4854. {
  4855. foreach($sets[$i+1] as $set)
  4856. {
  4857. $tmp[] = $res.','.$set;
  4858. }
  4859. }
  4860. $result = $tmp;
  4861. }
  4862. $this->db->trans_begin();
  4863. foreach ($result as $v)
  4864. {
  4865. $post = array();$title = "";$num="";
  4866. $data = explode(',',$v);
  4867. for($i=0;$i<count($list); $i++)
  4868. {
  4869. $post[$list[$i]] = $data[$i];
  4870. $typeclass = $this->typeclass->read($data[$i]);
  4871. $title = $title.$typeclass['title']." ";
  4872. if($data[$i] != 0)
  4873. {
  4874. $num .=$data[$i];//所有数据ID拼接
  4875. }
  4876. }
  4877. foreach ($ps as $kp=>$vp)
  4878. {
  4879. $post[$kp] = $vp;
  4880. }
  4881. $post['number'] = $num;
  4882. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4883. if($info_list)
  4884. {
  4885. $j++;
  4886. }
  4887. else
  4888. {
  4889. $skunum = $this->whlabel->find_count();
  4890. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4891. $post['title'] = rtrim($title,' ');
  4892. $this->whlabel->insert($post);
  4893. }
  4894. }
  4895. if ($this->db->trans_status() === FALSE)
  4896. {
  4897. $this->db->trans_commit();
  4898. return NULL;
  4899. }
  4900. else
  4901. {
  4902. $this->db->trans_commit();
  4903. return $j;
  4904. }
  4905. }
  4906. public function _kj($arg_array)
  4907. {
  4908. if(isset($_POST['sku']))
  4909. {
  4910. $time = time();
  4911. $sku = $this->input->post('sku',true);
  4912. $warehouse = $this->input->post('warehouse',true);
  4913. $num = $this->input->post('num',true);
  4914. $text = $this->input->post('text',true);
  4915. $purchase = $this->input->post('purchase',true);
  4916. $cktype = $this->input->post('cktype',true);
  4917. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4918. if($cktype != 1 && $text == '')
  4919. {
  4920. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4921. }
  4922. if($num > count($order))
  4923. {
  4924. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4925. }
  4926. else
  4927. {
  4928. for($i=0;$i<$num;$i++)
  4929. {
  4930. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4931. }
  4932. }
  4933. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4934. }
  4935. $uid = $this->whlabel->read($arg_array[0]);
  4936. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4937. $this->data['data'] = $uid ;
  4938. $this->_Template('whlabel_kj',$this->data);
  4939. }
  4940. public function _summary($arg_array)
  4941. {
  4942. $prc = array();
  4943. $purchase = $this->purchase->find_all();
  4944. foreach($purchase as $k=>$v)
  4945. {
  4946. $prc[$v['id']] = $v['title'];
  4947. }
  4948. if(isset($_GET['excel']))
  4949. {
  4950. $ktime = $this->input->get('ktime',true);
  4951. $jtime = $this->input->get('jtime',true);
  4952. $ktime = strtotime($ktime);
  4953. $jtime = strtotime($jtime);
  4954. $where = "1=1";
  4955. if($ktime && $jtime)
  4956. {
  4957. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4958. }
  4959. //数据排序
  4960. $order_str = "time desc";
  4961. if(empty($page))
  4962. {
  4963. $start = 0;
  4964. $perpage = 1;
  4965. }
  4966. else
  4967. {
  4968. $start = ($page - 1)*$perpage;
  4969. }
  4970. //取得信息列表
  4971. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  4972. foreach ($info_list as $key=>$value)
  4973. {
  4974. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4975. $warehouse = $this->warehouse->read($value['warehouse']);
  4976. $info_list[$key]['warehouse'] = $warehouse['title'];
  4977. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  4978. $details = array();
  4979. $cpid = array();
  4980. foreach ($x as $k=>$v)
  4981. {
  4982. if($v['details'] != '')
  4983. {
  4984. $details[$v['details']] = $v['details'];
  4985. }
  4986. if($v['cpid'] != 0)
  4987. {
  4988. $cpid[$v['cpid']] = $v['cpid'];
  4989. }
  4990. }
  4991. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  4992. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4993. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  4994. $info_list[$key]['s'] = $s;
  4995. $info_list[$key]['x'] = count($x);
  4996. }
  4997. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  4998. $titlename = "<table border=1>
  4999. <tr align='center'>
  5000. <td>仓库</td>
  5001. <td>供应商</td>
  5002. <td>出库位置</td>
  5003. <td>出库编码</td>
  5004. <td>SKU</td>
  5005. <td>产品名</td>
  5006. <td>总剩余库存</td>
  5007. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  5008. </tr>
  5009. </table>";
  5010. $filename = $title.".xls";
  5011. $tail = "";
  5012. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5013. }
  5014. }
  5015. //usps发货清单
  5016. public function _manifest()
  5017. {
  5018. if(isset($_POST['manifest']))
  5019. {
  5020. $wltext = $this->input->post('wltext',true);
  5021. $time = time()-16*3600;
  5022. $ptime = strtotime(date('Y-m-d',$time));
  5023. $waybill = array();
  5024. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5025. foreach ($fullorder as $v)
  5026. {
  5027. $waybill[$v['waybill']] = $v['waybill'];
  5028. }
  5029. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5030. foreach ($fullordersmt as $v)
  5031. {
  5032. $waybill[$v['waybill']] = $v['waybill'];
  5033. }
  5034. $wltext = explode(';',$wltext);
  5035. foreach ($wltext as $v)
  5036. {
  5037. if(isset($waybill[$v]))
  5038. {
  5039. unset($waybill[$v]);
  5040. }
  5041. }
  5042. $data = $this->usps->get_manifest($waybill);
  5043. if(isset($data['Description']))
  5044. {
  5045. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  5046. }
  5047. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  5048. {
  5049. $bctime = date('Ymd',time());
  5050. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5051. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5052. }
  5053. else
  5054. {
  5055. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5056. }
  5057. }
  5058. }
  5059. public function _pdf($pdf,$title,$bctime)
  5060. {
  5061. $pdf_path = './data/pdf/'.$bctime.'/';
  5062. $file_base64 = $pdf;
  5063. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5064. $file_base64 = base64_decode($file_base64);
  5065. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5066. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5067. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5068. }
  5069. /**
  5070. *
  5071. *
  5072. *
  5073. 进销存占单异常索引
  5074. *
  5075. *
  5076. *
  5077. **/
  5078. public function _abnormal()
  5079. {
  5080. $post = $this->input->post(NULL, TRUE);
  5081. if(isset($post['page']))
  5082. {
  5083. $page = $this->input->post('page',true);
  5084. $perpage = $this->input->post('perpage',true);
  5085. $sku = $this->input->post('sku',true);
  5086. $where = "1=1";
  5087. //数据排序
  5088. $order_str = "id desc";
  5089. if(empty($page))
  5090. {
  5091. $start = 0;
  5092. $perpage = 1;
  5093. }
  5094. else
  5095. {
  5096. $start = ($page - 1)*$perpage;
  5097. }
  5098. //取得信息列表
  5099. $info_list = $this->whlabel->find_all($where,'*');
  5100. $rows = array();$list = array();
  5101. foreach ($info_list as $key=>$value)
  5102. {
  5103. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5104. }
  5105. foreach ($rows as $value)
  5106. {
  5107. $warehouse = $this->warehouse->read($value['warehouse']);
  5108. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5109. $number = $value['number'];$ftime = time()-15*24*3600;
  5110. if($value['shop'] != '')
  5111. {
  5112. $shop = $value['shop'];
  5113. $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');
  5114. $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');
  5115. $order = array_merge($orderdlz,$ordersmt);
  5116. $od = 0;$a = '';$orid = '';
  5117. foreach ($order as $v)
  5118. {
  5119. $or = explode('|',ltrim($v['whlabel'],'|'));
  5120. for($i=0;$i<count($or);$i++)
  5121. {
  5122. $orod = explode('-',$or[$i]);
  5123. if($orod[0] == $number)
  5124. {
  5125. $od += $orod[1];
  5126. }
  5127. }
  5128. $orid .= $v['number'].'-';
  5129. }
  5130. }
  5131. else
  5132. {
  5133. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5134. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5135. $order = array_merge($orderdlz,$ordersmt);
  5136. $od = 0;$a = '';$orid = '';$qt = array();
  5137. foreach ($order as $v)
  5138. {
  5139. $or = explode('|',ltrim($v['whlabel'],'|'));
  5140. for($i=0;$i<count($or);$i++)
  5141. {
  5142. $orod = explode('-',$or[$i]);
  5143. if($orod[0] == $number)
  5144. {
  5145. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5146. if($czzs > 0)
  5147. {
  5148. if(isset($qt[$v['shop']]))
  5149. {
  5150. if($qt[$v['shop']] < $orod[1])
  5151. {
  5152. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5153. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5154. }
  5155. else
  5156. {
  5157. $qt[$v['shop']] -= $orod[1];
  5158. }
  5159. }
  5160. else
  5161. {
  5162. $qt[$v['shop']] = $czzs;
  5163. }
  5164. }
  5165. else
  5166. {
  5167. $od += $orod[1];
  5168. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5169. }
  5170. }
  5171. }
  5172. }
  5173. }
  5174. $z = $od.'('.$orid.')';//查看订单号
  5175. //$z = $od;
  5176. if($od > $c)
  5177. {
  5178. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5179. }
  5180. }
  5181. $listdata = array_slice($list,$start,$perpage);
  5182. $total = count($list);
  5183. $pagenum = ceil($total/$perpage);
  5184. $over = $total-($start+$perpage);
  5185. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5186. echo json_encode($rows);exit;
  5187. }
  5188. $this->_Template('whlabel_abnormal',$this->data);
  5189. }
  5190. /**
  5191. *
  5192. *
  5193. *
  5194. 进销存占单异常索引
  5195. *
  5196. *
  5197. *
  5198. **/
  5199. public function _error()
  5200. {
  5201. $post = $this->input->post(NULL, TRUE);
  5202. if(isset($post['page']))
  5203. {
  5204. $page = $this->input->post('page',true);
  5205. $perpage = $this->input->post('perpage',true);
  5206. $sku = $this->input->post('sku',true);
  5207. $warehouse = $this->input->post('warehouse',true);
  5208. $ktime = $this->input->post('ktime',true);
  5209. $jtime = $this->input->post('jtime',true);
  5210. $ktime = strtotime($ktime);
  5211. $jtime = strtotime($jtime);
  5212. $where = "sku != 'Preset'";
  5213. $gj = '';
  5214. if($sku)
  5215. {
  5216. $where .= " and sku like '%$sku%'";
  5217. }
  5218. else
  5219. {
  5220. if($ktime && $jtime)
  5221. {
  5222. $gj = " and time > '$ktime' and time < '$jtime'";
  5223. }
  5224. }
  5225. if($warehouse)
  5226. {
  5227. $where .= " and warehouse = '$warehouse'";
  5228. }
  5229. //数据排序
  5230. $order_str = "id desc";
  5231. if(empty($page))
  5232. {
  5233. $start = 0;
  5234. $perpage = 1;
  5235. }
  5236. else
  5237. {
  5238. $start = ($page - 1)*$perpage;
  5239. }
  5240. //取得信息列表
  5241. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5242. $rows = array();$list = array();
  5243. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5244. // foreach ($info_list as $value)
  5245. // {
  5246. // $warehouse = $this->warehouse->read($value['warehouse']);
  5247. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5248. // $number = $value['number'];$ftime = time()-15*24*3600;
  5249. // if($c < 1)
  5250. // {
  5251. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5252. // }
  5253. // }
  5254. $warehouse_list = $this->warehouse->find_all();
  5255. $warehouse_list = array_column($warehouse_list,null,'id');
  5256. foreach ($info_list as $value)
  5257. {
  5258. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5259. 'title'=>"",
  5260. ];
  5261. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5262. $number = $value['number'];$ftime = time()-15*24*3600;
  5263. if($c < 1)
  5264. {
  5265. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5266. }
  5267. }
  5268. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5269. // $query = $this->db->query($sql);
  5270. // $info_list = $query->result_array();
  5271. // $sql_two = "select title,id from crowd_warehouse";
  5272. // $query_two = $this->db->query($sql_two);
  5273. // $warehouse_list = $query_two->result_array();
  5274. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5275. // foreach ($info_list as $value)
  5276. // {
  5277. // if(isset($warehouse_arr[$value['warehouse']])){
  5278. // $warehouse = $warehouse_arr[$value['warehouse']];
  5279. // }else{
  5280. // $warehouse = [
  5281. // 'id'=>0,
  5282. // 'title'=>"异常",
  5283. // ];
  5284. // }
  5285. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5286. // $number = $value['number'];$ftime = time()-15*24*3600;
  5287. // if($c < 1)
  5288. // {
  5289. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5290. // }
  5291. // }
  5292. $listdata = array_slice($list,$start,$perpage);
  5293. $total = count($list);
  5294. $pagenum = ceil($total/$perpage);
  5295. $over = $total-($start+$perpage);
  5296. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5297. echo json_encode($rows);exit;
  5298. }
  5299. if(isset($post['s']))
  5300. {
  5301. $id_arr = $this->input->post('s');
  5302. $id_arr = explode(',',trim($id_arr,','));
  5303. if(!$id_arr)
  5304. {
  5305. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5306. }
  5307. //循环删除记录
  5308. foreach ($id_arr as $v)
  5309. {
  5310. $dd = $this->whlabel->read($v);
  5311. if(!isset($dd['id']))
  5312. {
  5313. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5314. }
  5315. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5316. if(isset($zt[0]))
  5317. {
  5318. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5319. }
  5320. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5321. foreach ($deldd as $vv)
  5322. {
  5323. $this->whlabel->remove($vv['id']);
  5324. }
  5325. }
  5326. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5327. }
  5328. $this->_Template('whlabel_error',$this->data);
  5329. }
  5330. public function _errorexcel()
  5331. {
  5332. $post = $this->input->post(NULL, TRUE);
  5333. if(isset($_GET['page']))
  5334. {
  5335. $page = $this->input->get('page',true);
  5336. $perpage = $this->input->get('perpage',true);
  5337. $sku = $this->input->get('sku',true);
  5338. $warehouse = $this->input->get('warehouse',true);
  5339. $ktime = $this->input->get('ktime',true);
  5340. $jtime = $this->input->get('jtime',true);
  5341. $ktime = strtotime($ktime);
  5342. $jtime = strtotime($jtime);
  5343. $where = "sku != 'Preset'";
  5344. $gj = '';
  5345. if($sku)
  5346. {
  5347. $where .= " and sku like '%$sku%'";
  5348. }
  5349. else
  5350. {
  5351. if($ktime && $jtime)
  5352. {
  5353. $gj = " and time > '$ktime' and time < '$jtime'";
  5354. }
  5355. }
  5356. if($warehouse)
  5357. {
  5358. $where .= " and warehouse = '$warehouse'";
  5359. }
  5360. //数据排序
  5361. $order_str = "id desc";
  5362. if(empty($page))
  5363. {
  5364. $start = 0;
  5365. $perpage = 1;
  5366. }
  5367. else
  5368. {
  5369. $start = ($page - 1)*$perpage;
  5370. }
  5371. //取得信息列表
  5372. $rows = array();$list = array();
  5373. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5374. foreach ($info_list as $value)
  5375. {
  5376. $warehouse = $this->warehouse->read($value['warehouse']);
  5377. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5378. $number = $value['number'];$ftime = time()-15*24*3600;
  5379. if($c < 1)
  5380. {
  5381. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5382. }
  5383. }
  5384. $title = "0库存汇总";
  5385. $titlename = "<table border=1>
  5386. <tr align='center'>
  5387. <td>仓库</td>
  5388. <td>SKU</td>
  5389. <td>产品</td>
  5390. <td>当前库存</td>
  5391. </tr>
  5392. </table>";
  5393. $filename = $title.".xls";
  5394. $tail = "";
  5395. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5396. }
  5397. }
  5398. /**
  5399. *
  5400. *
  5401. * 占单
  5402. *
  5403. *
  5404. **/
  5405. public function _kcyz()
  5406. {
  5407. $post = $this->input->post(NULL, TRUE);
  5408. if(isset($post['warehouse']))
  5409. {
  5410. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5411. $warehouse = $this->input->post('warehouse',true);
  5412. $whlabel = $this->input->post('whlabel',true);
  5413. $id = $this->input->post('id',true);
  5414. $shop = $this->input->post('shop',true);
  5415. $number = $this->input->post('number',true);
  5416. if(!$whlabel || $whlabel == '|')
  5417. {
  5418. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5419. }
  5420. $pp = explode('|',trim($whlabel,'|'));
  5421. $x = 0;$save = array();
  5422. foreach ($pp as $va)
  5423. {
  5424. $num = explode('-',$va);
  5425. if($number)
  5426. {
  5427. $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 = '')");//通用
  5428. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5429. }
  5430. else
  5431. {
  5432. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5433. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5434. }
  5435. $x++;
  5436. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5437. {
  5438. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5439. }
  5440. }
  5441. if(isset($save[0]))
  5442. {
  5443. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5444. }
  5445. else
  5446. {
  5447. echo json_encode(array('success'=>true));exit;
  5448. }
  5449. }
  5450. }
  5451. public function _db()
  5452. {
  5453. $post = $this->input->post(NULL, TRUE);
  5454. if(isset($post['page']))
  5455. {
  5456. $page = $this->input->post('page',true);
  5457. $perpage = $this->input->post('perpage',true);
  5458. $sku = $this->input->post('sku',true);
  5459. $number = $this->input->post('number',true);
  5460. $warehouse = $this->input->post('warehouse',true);
  5461. $purchase = $this->input->post('purchase',true);
  5462. $orderinfo = $this->input->post('orderinfo',true);
  5463. $waybill = $this->input->post('waybill',true);
  5464. $category = $this->input->post('category',true);
  5465. $size = $this->input->post('size',true);
  5466. $grade = $this->input->post('grade',true);
  5467. $color = $this->input->post('color',true);
  5468. $lowe = $this->input->post('lowe',true);
  5469. $state = $this->input->post('state',true);
  5470. $label = $this->input->post('label',true);
  5471. $timetk = $this->input->post('timetkk',true);
  5472. $timetj = $this->input->post('timetjj',true);
  5473. $timetk = strtotime($timetk);
  5474. $timetj = strtotime($timetj);
  5475. $where = "dbtime > 0";
  5476. if($timetk && $timetj)
  5477. {
  5478. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5479. }
  5480. if($sku)
  5481. {
  5482. $where .= " and sku = '$sku'";
  5483. }
  5484. if($warehouse)
  5485. {
  5486. $where .= " and warehouse = '$warehouse'";
  5487. if($warehouse == 12)
  5488. {
  5489. $w = 'specialstock';
  5490. }
  5491. else
  5492. {
  5493. $w = 'whlabel';
  5494. }
  5495. }
  5496. if($purchase)
  5497. {
  5498. $where .= " and purchase = '$purchase'";
  5499. }
  5500. if($category)
  5501. {
  5502. $where .= " and features like '%-$category-%'";
  5503. }
  5504. if($size)
  5505. {
  5506. $where .= " and features like '%-$size-%'";
  5507. }
  5508. if($grade)
  5509. {
  5510. $where .= " and features like '%-$grade-%'";
  5511. }
  5512. if($color)
  5513. {
  5514. $where .= " and features like '%-$color-%'";
  5515. }
  5516. if($lowe)
  5517. {
  5518. $where .= " and features like '%-$lowe-%'";
  5519. }
  5520. if($state != '')
  5521. {
  5522. $where .= " and state = '$state'";
  5523. }
  5524. //数据排序
  5525. $order_str = "dbtime desc";
  5526. if(empty($page))
  5527. {
  5528. $start = 0;
  5529. $perpage = 1;
  5530. }
  5531. else
  5532. {
  5533. $start = ($page - 1)*$perpage;
  5534. }
  5535. //取得信息列表
  5536. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5537. foreach ($info_list as $key=>$value)
  5538. {
  5539. $warehouse = $this->$w->read($value['warehouse']);
  5540. $info_list[$key]['warehouse'] = $warehouse['title'];
  5541. $purchase = $this->purchase->read($value['purchase']);
  5542. $info_list[$key]['purchase'] = $purchase['title'];
  5543. if($value['enter'] != 0)
  5544. {
  5545. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5546. }
  5547. else
  5548. {
  5549. $info_list[$key]['enter'] = "";
  5550. }
  5551. if($value['dbtime'] != 0)
  5552. {
  5553. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5554. }
  5555. else
  5556. {
  5557. $info_list[$key]['dbtime'] = "";
  5558. }
  5559. if($value['state'] == 0)
  5560. {
  5561. $info_list[$key]['state'] = "在库";
  5562. }
  5563. else if($value['state'] == 1)
  5564. {
  5565. $info_list[$key]['state'] = "出库";
  5566. }
  5567. else if($value['state'] == 2)
  5568. {
  5569. $info_list[$key]['state'] = "退库";
  5570. }
  5571. else if($value['state'] == 3)
  5572. {
  5573. $info_list[$key]['state'] = "调拨中";
  5574. }
  5575. else if($value['state'] == 4)
  5576. {
  5577. $info_list[$key]['state'] = "再加工";
  5578. }
  5579. else if($value['state'] == 5)
  5580. {
  5581. $info_list[$key]['state'] = "维修中";
  5582. }
  5583. else if($value['state'] == 6)
  5584. {
  5585. $info_list[$key]['state'] = "盘亏";
  5586. }
  5587. else if($value['state'] == 7)
  5588. {
  5589. $info_list[$key]['state'] = "更换标签";
  5590. }
  5591. else if($value['state'] == 8)
  5592. {
  5593. $info_list[$key]['state'] = "其它";
  5594. }
  5595. else if($value['state'] == 9)
  5596. {
  5597. $info_list[$key]['state'] = "预设";
  5598. }
  5599. }
  5600. $total = $this->whlabel->find_count($where);
  5601. $pagenum = ceil($total/$perpage);
  5602. $over = $total-($start+$perpage);
  5603. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5604. echo json_encode($rows);exit;
  5605. }
  5606. if(isset($post['outsku']))
  5607. {
  5608. $time = time();
  5609. $cz = $this->input->post('cz',true);
  5610. $label = $this->input->post('outsku',true);
  5611. $sl = $this->input->post('sl',true);
  5612. $num = $this->input->post('num',true);
  5613. //$warehouse = $this->input->post('warehouse',true);
  5614. if(!$sl)
  5615. {
  5616. $sl = 1;
  5617. }
  5618. if(!$warehouse)
  5619. {
  5620. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5621. }
  5622. $dblabel = $this->whlabellabel->get_label($label);
  5623. if($dblabel)
  5624. {
  5625. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5626. if(count($data) < 1)
  5627. {
  5628. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5629. }
  5630. if(count($data) < $num)
  5631. {
  5632. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5633. }
  5634. for($i=0;$i<$sl;$i++)
  5635. {
  5636. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5637. }
  5638. echo json_encode(array('success'=>true));exit;
  5639. }
  5640. else
  5641. {
  5642. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5643. }
  5644. }
  5645. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5646. $this->_Template('whlabel_db',$this->data);
  5647. }
  5648. public function _dbrk()
  5649. {
  5650. $post = $this->input->post(NULL, TRUE);
  5651. if(isset($post['page']))
  5652. {
  5653. $page = $this->input->post('page',true);
  5654. $perpage = $this->input->post('perpage',true);
  5655. $sku = $this->input->post('sku',true);
  5656. $number = $this->input->post('number',true);
  5657. $warehouse = $this->input->post('warehouse',true);
  5658. $purchase = $this->input->post('purchase',true);
  5659. $orderinfo = $this->input->post('orderinfo',true);
  5660. $waybill = $this->input->post('waybill',true);
  5661. $category = $this->input->post('category',true);
  5662. $size = $this->input->post('size',true);
  5663. $grade = $this->input->post('grade',true);
  5664. $color = $this->input->post('color',true);
  5665. $lowe = $this->input->post('lowe',true);
  5666. $state = $this->input->post('state',true);
  5667. $label = $this->input->post('label',true);
  5668. $ctime = $this->input->post('ctime',true);
  5669. $timetk = $this->input->post('timetkk',true);
  5670. $timetj = $this->input->post('timetjj',true);
  5671. $timetk = strtotime($timetk);
  5672. $timetj = strtotime($timetj);
  5673. $where = "dbtime > 0";
  5674. if($timetk && $timetj)
  5675. {
  5676. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5677. }
  5678. if($sku)
  5679. {
  5680. $where .= " and sku = '$sku'";
  5681. }
  5682. if($warehouse)
  5683. {
  5684. $where .= " and warehouse = '$warehouse'";
  5685. }
  5686. if($purchase)
  5687. {
  5688. $where .= " and purchase = '$purchase'";
  5689. }
  5690. if($category)
  5691. {
  5692. $where .= " and features like '%-$category-%'";
  5693. }
  5694. if($size)
  5695. {
  5696. $where .= " and features like '%-$size-%'";
  5697. }
  5698. if($grade)
  5699. {
  5700. $where .= " and features like '%-$grade-%'";
  5701. }
  5702. if($color)
  5703. {
  5704. $where .= " and features like '%-$color-%'";
  5705. }
  5706. if($lowe)
  5707. {
  5708. $where .= " and features like '%-$lowe-%'";
  5709. }
  5710. if($state != '')
  5711. {
  5712. $where .= " and state = '$state'";
  5713. }
  5714. //数据排序
  5715. $order_str = "dbtime desc";
  5716. if(empty($page))
  5717. {
  5718. $start = 0;
  5719. $perpage = 1;
  5720. }
  5721. else
  5722. {
  5723. $start = ($page - 1)*$perpage;
  5724. }
  5725. //取得信息列表
  5726. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5727. foreach ($info_list as $key=>$value)
  5728. {
  5729. $warehouse = $this->warehouse->read($value['warehouse']);
  5730. $info_list[$key]['warehouse'] = $warehouse['title'];
  5731. $purchase = $this->purchase->read($value['purchase']);
  5732. $info_list[$key]['purchase'] = $purchase['title'];
  5733. if($value['enter'] != 0)
  5734. {
  5735. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5736. }
  5737. else
  5738. {
  5739. $info_list[$key]['enter'] = "";
  5740. }
  5741. if($value['dbtime'] != 0)
  5742. {
  5743. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5744. }
  5745. else
  5746. {
  5747. $info_list[$key]['dbtime'] = "";
  5748. }
  5749. if($value['state'] == 0)
  5750. {
  5751. $info_list[$key]['state'] = "在库";
  5752. }
  5753. else if($value['state'] == 1)
  5754. {
  5755. $info_list[$key]['state'] = "出库";
  5756. }
  5757. else if($value['state'] == 2)
  5758. {
  5759. $info_list[$key]['state'] = "退库";
  5760. }
  5761. else if($value['state'] == 3)
  5762. {
  5763. $info_list[$key]['state'] = "调拨中";
  5764. }
  5765. else if($value['state'] == 4)
  5766. {
  5767. $info_list[$key]['state'] = "再加工";
  5768. }
  5769. else if($value['state'] == 5)
  5770. {
  5771. $info_list[$key]['state'] = "维修中";
  5772. }
  5773. else if($value['state'] == 6)
  5774. {
  5775. $info_list[$key]['state'] = "盘亏";
  5776. }
  5777. else if($value['state'] == 7)
  5778. {
  5779. $info_list[$key]['state'] = "更换标签";
  5780. }
  5781. else if($value['state'] == 8)
  5782. {
  5783. $info_list[$key]['state'] = "其它";
  5784. }
  5785. else if($value['state'] == 9)
  5786. {
  5787. $info_list[$key]['state'] = "预设";
  5788. }
  5789. }
  5790. $total = $this->whlabel->find_count($where);
  5791. $pagenum = ceil($total/$perpage);
  5792. $over = $total-($start+$perpage);
  5793. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5794. echo json_encode($rows);exit;
  5795. }
  5796. if(isset($post['rsku']))
  5797. {
  5798. $cz = $this->input->post('cz',true);
  5799. $label = $this->input->post('rsku',true);
  5800. $sl = $this->input->post('sl',true);
  5801. $warehouse = $this->input->post('warehouse',true);
  5802. if(!$sl)
  5803. {
  5804. $sl = 1;
  5805. }
  5806. if(!$warehouse)
  5807. {
  5808. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5809. }
  5810. $dblabel = $this->whlabellabel->get_label($label);
  5811. if($dblabel)
  5812. {
  5813. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5814. if(count($data) < 1)
  5815. {
  5816. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5817. }
  5818. if($sl > count($data))
  5819. {
  5820. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5821. }
  5822. $time = time();
  5823. for($i=0;$i<$sl;$i++)
  5824. {
  5825. $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']);
  5826. }
  5827. echo json_encode(array('success'=>true));exit;
  5828. }
  5829. else
  5830. {
  5831. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5832. }
  5833. }
  5834. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5835. $this->_Template('whlabel_dbrk',$this->data);
  5836. }
  5837. public function _whlabelczdc()
  5838. {
  5839. if(isset($_GET['excel']))
  5840. {
  5841. //数据排序
  5842. $order_str = "id desc";
  5843. if(empty($page))
  5844. {
  5845. $start = 0;
  5846. $perpage = 1;
  5847. }
  5848. else
  5849. {
  5850. $start = ($page - 1)*$perpage;
  5851. }
  5852. $state = $this->input->get('state',true);
  5853. $sku = $this->input->get('sku',true);
  5854. $ctime = $this->input->get('ctime',true);
  5855. $category = $this->input->get('category',true);
  5856. $size = $this->input->get('size',true);
  5857. $grade = $this->input->get('grade',true);
  5858. $color = $this->input->get('color',true);
  5859. $lowe = $this->input->get('lowe',true);
  5860. $timetk = $this->input->get('timetkk',true);
  5861. $timetj = $this->input->get('timetjj',true);
  5862. $timetk = strtotime($timetk);
  5863. $timetj = strtotime($timetj);
  5864. $where = "dbtime > 0";
  5865. if($timetk && $timetj)
  5866. {
  5867. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5868. }
  5869. if($category)
  5870. {
  5871. $where .= " and features like '%-$category-%'";
  5872. }
  5873. if($size)
  5874. {
  5875. $where .= " and features like '%-$size-%'";
  5876. }
  5877. if($grade)
  5878. {
  5879. $where .= " and features like '%-$grade-%'";
  5880. }
  5881. if($color)
  5882. {
  5883. $where .= " and features like '%-$color-%'";
  5884. }
  5885. if($lowe)
  5886. {
  5887. $where .= " and features like '%-$lowe-%'";
  5888. }
  5889. //取得信息列表
  5890. $info_list = $this->whlabel->find_all($where,'*');
  5891. $rows = array();$list = array();
  5892. foreach ($info_list as $key=>$value)
  5893. {
  5894. $rows[$value['sku']] = $value;//所有数据sku
  5895. }
  5896. foreach ($rows as $value)
  5897. {
  5898. $warehouse = $this->warehouse->read($value['warehouse']);
  5899. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5900. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5901. if($value['orderinfo'] == 0)
  5902. {
  5903. $info_list[$key]['orderinfo'] = "";
  5904. }
  5905. if($value['waybill'] == 0)
  5906. {
  5907. $info_list[$key]['waybill'] = "";
  5908. }
  5909. if($value['state'] == 0)
  5910. {
  5911. $value['state'] = "在库";
  5912. }
  5913. else if($value['state'] == 3)
  5914. {
  5915. $value['state'] = "调拨中";
  5916. }
  5917. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5918. }
  5919. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5920. $titlename = "<table border=1>
  5921. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5922. <tr align='center'>
  5923. <td>SKU</td>
  5924. <td>产品</td>
  5925. <td>调拨数量</td>
  5926. <td>入库数量</td>
  5927. </tr>
  5928. </table>";
  5929. $filename = $title.".xls";
  5930. $tail = "";
  5931. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5932. }
  5933. }
  5934. public function _print($arg_array)
  5935. {
  5936. if(isset($_SESSION['api']))
  5937. {
  5938. $user = $this->user->get_api($_SESSION['api']);
  5939. $usp = $user;
  5940. $fgshop = "";$sid = "";$wid="";$wtype="";
  5941. $usersp = explode('|',trim($user['shop'],'|'));
  5942. $userwh = explode('|',trim($user['warehouse'],'|'));
  5943. foreach ($usersp as $value)
  5944. {
  5945. $fgshop .= " shop = ".$value." or";
  5946. $sid .= " id = ".$value." or";
  5947. }
  5948. foreach ($userwh as $value)
  5949. {
  5950. $wid .= " id = ".$value." or";
  5951. $wtype .= " type = ".$value." or";
  5952. }
  5953. }
  5954. $post = $this->input->post(NULL, TRUE);
  5955. if(isset($post['tmsku']))
  5956. {
  5957. $tmsku = $this->input->post('tmsku',true);
  5958. if(is_numeric($tmsku))
  5959. {
  5960. $yyh = $this->whlabellabel->get_label($tmsku);
  5961. }
  5962. else
  5963. {
  5964. $yyh = $this->whlabellabel->get_sku($tmsku);
  5965. }
  5966. if($yyh)
  5967. {
  5968. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5969. }
  5970. else
  5971. {
  5972. echo json_encode(array('success'=>false));exit;
  5973. }
  5974. }
  5975. $classid = $this->classid->sku();
  5976. $pm = $classid;
  5977. $scsku = $classid;
  5978. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5979. if(isset($post['warehouse']))
  5980. {
  5981. if($post['warehouse'])
  5982. {
  5983. $list = array();$num = "";$title = "";$features = "";
  5984. $order = 0;
  5985. $post['shop'] = '';
  5986. $brand = $this->input->post('brand',true);
  5987. if($brand != '0,')
  5988. {
  5989. $b = $this->brand->read(rtrim($brand,','));
  5990. if($b)
  5991. {
  5992. $post['shop'] = str_replace('|',',',$b['shop']);
  5993. }
  5994. }
  5995. $post['details'] = $this->input->post('details',true);//打印数量
  5996. $xbqnum = $this->input->post('xbqnum',true);
  5997. $post['purchase'] = $this->input->post('purchase',true);
  5998. $post['warehouse'] = $this->input->post('warehouse',true);
  5999. $post['purchase'] = $this->input->post('purchase',true);
  6000. $post['retreatwarehouse'] = $post['warehouse'];
  6001. $post['cpbz'] = $this->input->post('cpbz',true);
  6002. $post['state'] = 9;
  6003. $category = $this->input->post('category',true);
  6004. $list['category'] = $category;
  6005. $list['hairtype'] = $this->input->post('hairtype',true);
  6006. $list['grade'] = $this->input->post('grade',true);
  6007. $size = $this->input->post('size',true);
  6008. $list['size'] = rtrim($size,',');
  6009. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6010. $list['extension'] = $this->input->post('extension',true);
  6011. if($category == 1297)
  6012. {
  6013. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6014. }
  6015. if($category == 1702)
  6016. {
  6017. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6018. $list['syother'] = $this->input->post('syother',true);
  6019. }
  6020. if($category == 133)
  6021. {
  6022. $list['fittype'] = $this->input->post('fittype',true);
  6023. $list['acother'] = $this->input->post('acother',true);
  6024. }
  6025. $list['color'] = $this->input->post('color',true);
  6026. $list['lowe'] = $this->input->post('lowe',true);
  6027. if($category == 127)
  6028. {
  6029. $list['type'] = $this->input->post('type',true);
  6030. $list['headroad'] = $this->input->post('headroad',true);
  6031. $list['density'] = $this->input->post('density',true);
  6032. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6033. {
  6034. $list['lacesize'] = $this->input->post('lacesize',true);
  6035. }
  6036. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6037. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6038. }
  6039. if($category == 128)
  6040. {
  6041. $list['lacetype'] = $this->input->post('lacetype',true);
  6042. $list['haircap'] = $this->input->post('haircap',true);
  6043. $list['density'] = $this->input->post('density',true);
  6044. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6045. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6046. $list['wigother'] = $this->input->post('wigother',true);
  6047. $list['wigother2'] = $this->input->post('wigother2',true);
  6048. }
  6049. if($category == 129)
  6050. {
  6051. $list['wide'] = $this->input->post('wide',true);
  6052. }
  6053. if($category == 131)
  6054. {
  6055. $list['gifttype'] = $this->input->post('gifttype',true);
  6056. $list['giftother'] = $this->input->post('giftother',true);
  6057. }
  6058. if($category == 134)
  6059. {
  6060. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6061. }
  6062. if($category == 1297)
  6063. {
  6064. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6065. $list['sywigother'] = $this->input->post('sywigother',true);
  6066. }
  6067. if($category == 130 || $category == 133 || $category == 1702)
  6068. {
  6069. $list['items'] = $this->input->post('items',true);
  6070. $list['weight'] = $this->input->post('weight',true);
  6071. }
  6072. if($category == 1702)
  6073. {
  6074. $list['syhairther'] = $this->input->post('syhairther',true);
  6075. }
  6076. foreach($list as $k=>$v)
  6077. {
  6078. if($v != 0)
  6079. {
  6080. $num .=$v;
  6081. $features .=$v.'-';
  6082. $post[$k] = $v;
  6083. $typeclass = $this->typeclass->read($v);
  6084. if(isset($pm[$typeclass['classid']]))
  6085. {
  6086. if(stripos($typeclass['zh'],'|') !== false)
  6087. {
  6088. $exzh = explode('|',$typeclass['zh']);
  6089. $pm[$typeclass['classid']] = $exzh[0];
  6090. }
  6091. else
  6092. {
  6093. $pm[$typeclass['classid']] = $typeclass['zh'];
  6094. }
  6095. }
  6096. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6097. if($k != 'size')
  6098. {
  6099. $title .= $typeclass['title']." ";
  6100. }
  6101. }
  6102. }
  6103. $typeclass = $this->typeclass->read($list['size']);
  6104. $title .= $typeclass['title'];
  6105. $time = time();
  6106. $post['title'] = rtrim($title,' ');
  6107. $post['number'] = $num;
  6108. $post['features'] = '-'.$features;
  6109. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6110. $featurespp = explode('-',trim($featurespp,'-'));
  6111. if(isset($featurespp[5]))
  6112. {
  6113. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6114. }
  6115. else
  6116. {
  6117. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6118. }
  6119. $post['enter'] = $time;
  6120. $post['time'] = $time;//操作时间
  6121. $scsku = implode("-",$scsku);
  6122. $zh = implode(" ",$pm);
  6123. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6124. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6125. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6126. $post['sku'] = $bqsku;
  6127. $label = time().rand(0,9);
  6128. $post['label'] = $label;
  6129. $cpid = $this->whlabellabel->find_count();
  6130. $post['cpid'] = $cpid+1;
  6131. $cpid = $post['cpid'];
  6132. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6133. //if($whlabelbarcode)
  6134. //{
  6135. //$post['label'] = $whlabelbarcode['label'];
  6136. //if(!$this->whlabellabel->insert($post))
  6137. //{
  6138. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6139. //}
  6140. //}
  6141. //else
  6142. //{
  6143. $this->db->trans_begin();
  6144. $this->whlabellabel->insert($post);
  6145. //$this->whlabelbarcode->insert($post);
  6146. if ($this->db->trans_status() === TRUE)
  6147. {
  6148. $this->db->trans_commit();
  6149. }
  6150. else
  6151. {
  6152. $this->db->trans_rollback();
  6153. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6154. }
  6155. //}
  6156. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6157. $purchase = $this->purchase->read($post['purchase']);
  6158. 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));exit;//特殊仓目前不需要仓库选项
  6159. }
  6160. }
  6161. if(isset($_SESSION['api']))
  6162. {
  6163. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6164. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6165. $this->data['wlshop'] = $wlshop;
  6166. $this->data['warehouse'] = $warehouse;
  6167. }
  6168. $whlabelwz = $this->whlabelwz->find_all();
  6169. $this->data['whlabelwz'] = $whlabelwz;
  6170. $this->_Template('whlabel_print',$this->data);
  6171. }
  6172. public function _usaprint($arg_array)
  6173. {
  6174. if(isset($_SESSION['api']))
  6175. {
  6176. $user = $this->user->get_api($_SESSION['api']);
  6177. $usp = $user;
  6178. $fgshop = "";$sid = "";$wid="";$wtype="";
  6179. $usersp = explode('|',trim($user['shop'],'|'));
  6180. $userwh = explode('|',trim($user['warehouse'],'|'));
  6181. foreach ($usersp as $value)
  6182. {
  6183. $fgshop .= " shop = ".$value." or";
  6184. $sid .= " id = ".$value." or";
  6185. }
  6186. foreach ($userwh as $value)
  6187. {
  6188. $wid .= " id = ".$value." or";
  6189. $wtype .= " type = ".$value." or";
  6190. }
  6191. }
  6192. $post = $this->input->post(NULL, TRUE);
  6193. if(isset($post['tmsku']))
  6194. {
  6195. $tmsku = $this->input->post('tmsku',true);
  6196. if(is_numeric($tmsku))
  6197. {
  6198. $yyh = $this->whlabellabel->get_label($tmsku);
  6199. }
  6200. else
  6201. {
  6202. $yyh = $this->whlabellabel->get_sku($tmsku);
  6203. }
  6204. if($yyh)
  6205. {
  6206. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6207. }
  6208. else
  6209. {
  6210. echo json_encode(array('success'=>false));exit;
  6211. }
  6212. }
  6213. $classid = $this->classid->sku();
  6214. $pm = $classid;
  6215. $scsku = $classid;
  6216. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6217. if(isset($post['warehouse']))
  6218. {
  6219. if($post['warehouse'])
  6220. {
  6221. $list = array();$num = "";$title = "";$features = "";
  6222. $order = 0;
  6223. $post['shop'] = '';
  6224. $brand = $this->input->post('brand',true);
  6225. if($brand != '0,')
  6226. {
  6227. $b = $this->brand->read(rtrim($brand,','));
  6228. if($b)
  6229. {
  6230. $post['shop'] = str_replace('|',',',$b['shop']);
  6231. }
  6232. }
  6233. $post['details'] = $this->input->post('details',true);//打印数量
  6234. $xbqnum = $this->input->post('xbqnum',true);
  6235. $post['purchase'] = $this->input->post('purchase',true);
  6236. $post['warehouse'] = $this->input->post('warehouse',true);
  6237. $post['purchase'] = $this->input->post('purchase',true);
  6238. $post['retreatwarehouse'] = $post['warehouse'];
  6239. $post['cpbz'] = $this->input->post('cpbz',true);
  6240. $post['state'] = 9;
  6241. $category = $this->input->post('category',true);
  6242. $list['category'] = $category;
  6243. $list['hairtype'] = $this->input->post('hairtype',true);
  6244. $list['grade'] = $this->input->post('grade',true);
  6245. $size = $this->input->post('size',true);
  6246. $list['size'] = rtrim($size,',');
  6247. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6248. $list['extension'] = $this->input->post('extension',true);
  6249. if($category == 1297)
  6250. {
  6251. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6252. }
  6253. if($category == 1702)
  6254. {
  6255. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6256. $list['syother'] = $this->input->post('syother',true);
  6257. }
  6258. if($category == 133)
  6259. {
  6260. $list['fittype'] = $this->input->post('fittype',true);
  6261. $list['acother'] = $this->input->post('acother',true);
  6262. }
  6263. $list['color'] = $this->input->post('color',true);
  6264. $list['lowe'] = $this->input->post('lowe',true);
  6265. if($category == 127)
  6266. {
  6267. $list['type'] = $this->input->post('type',true);
  6268. $list['headroad'] = $this->input->post('headroad',true);
  6269. $list['density'] = $this->input->post('density',true);
  6270. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6271. {
  6272. $list['lacesize'] = $this->input->post('lacesize',true);
  6273. }
  6274. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6275. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6276. }
  6277. if($category == 128)
  6278. {
  6279. $list['lacetype'] = $this->input->post('lacetype',true);
  6280. $list['haircap'] = $this->input->post('haircap',true);
  6281. $list['density'] = $this->input->post('density',true);
  6282. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6283. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6284. $list['wigother'] = $this->input->post('wigother',true);
  6285. $list['wigother2'] = $this->input->post('wigother2',true);
  6286. }
  6287. if($category == 129)
  6288. {
  6289. $list['wide'] = $this->input->post('wide',true);
  6290. }
  6291. if($category == 131)
  6292. {
  6293. $list['gifttype'] = $this->input->post('gifttype',true);
  6294. $list['giftother'] = $this->input->post('giftother',true);
  6295. }
  6296. if($category == 134)
  6297. {
  6298. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6299. }
  6300. if($category == 1297)
  6301. {
  6302. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6303. $list['sywigother'] = $this->input->post('sywigother',true);
  6304. }
  6305. if($category == 130 || $category == 133 || $category == 1702)
  6306. {
  6307. $list['items'] = $this->input->post('items',true);
  6308. $list['weight'] = $this->input->post('weight',true);
  6309. }
  6310. if($category == 1702)
  6311. {
  6312. $list['syhairther'] = $this->input->post('syhairther',true);
  6313. }
  6314. foreach($list as $k=>$v)
  6315. {
  6316. if($v != 0)
  6317. {
  6318. $num .=$v;
  6319. $features .=$v.'-';
  6320. $post[$k] = $v;
  6321. $typeclass = $this->typeclass->read($v);
  6322. if(isset($pm[$typeclass['classid']]))
  6323. {
  6324. if(stripos($typeclass['zh'],'|') !== false)
  6325. {
  6326. $exzh = explode('|',$typeclass['zh']);
  6327. $pm[$typeclass['classid']] = $exzh[0];
  6328. }
  6329. else
  6330. {
  6331. $pm[$typeclass['classid']] = $typeclass['zh'];
  6332. }
  6333. }
  6334. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6335. if($k != 'size')
  6336. {
  6337. $title .= $typeclass['title']." ";
  6338. }
  6339. }
  6340. }
  6341. $typeclass = $this->typeclass->read($list['size']);
  6342. $title .= $typeclass['title'];
  6343. $time = time();
  6344. $post['title'] = rtrim($title,' ');
  6345. $post['number'] = $num;
  6346. $post['features'] = '-'.$features;
  6347. $fp = $this->whlabel->get_features($post['features']);
  6348. if(!$fp)
  6349. {
  6350. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6351. }
  6352. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6353. $featurespp = explode('-',trim($featurespp,'-'));
  6354. if(isset($featurespp[5]))
  6355. {
  6356. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6357. }
  6358. else
  6359. {
  6360. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6361. }
  6362. $post['enter'] = $time;
  6363. $post['time'] = $time;//操作时间
  6364. $scsku = implode("-",$scsku);
  6365. $zh = implode(" ",$pm);
  6366. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6367. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6368. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6369. $post['sku'] = $fp['sku'];
  6370. $post['label'] = $fp['sku'];
  6371. $cpid = $this->whlabellabel->find_count();
  6372. $post['cpid'] = $cpid+1;
  6373. $cpid = $post['cpid'];
  6374. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6375. //if($whlabelbarcode)
  6376. //{
  6377. //$post['label'] = $whlabelbarcode['label'];
  6378. //if(!$this->whlabellabel->insert($post))
  6379. //{
  6380. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6381. //}
  6382. //}
  6383. //else
  6384. //{
  6385. $this->db->trans_begin();
  6386. $this->whlabellabel->insert($post);
  6387. //$this->whlabelbarcode->insert($post);
  6388. if ($this->db->trans_status() === TRUE)
  6389. {
  6390. $this->db->trans_commit();
  6391. }
  6392. else
  6393. {
  6394. $this->db->trans_rollback();
  6395. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6396. }
  6397. //}
  6398. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6399. $purchase = $this->purchase->read($post['purchase']);
  6400. 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));exit;//特殊仓目前不需要仓库选项
  6401. }
  6402. }
  6403. if(isset($_SESSION['api']))
  6404. {
  6405. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6406. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6407. $this->data['wlshop'] = $wlshop;
  6408. $this->data['warehouse'] = $warehouse;
  6409. }
  6410. $whlabelwz = $this->whlabelwz->find_all();
  6411. $this->data['whlabelwz'] = $whlabelwz;
  6412. $this->_Template('whlabel_usaprint',$this->data);
  6413. }
  6414. public function _printrk($arg_array)
  6415. {
  6416. $prc = array();
  6417. $purchase = $this->purchase->find_all();
  6418. foreach($purchase as $k=>$v)
  6419. {
  6420. $prc[$v['id']] = $v['title'];
  6421. }
  6422. $post = $this->input->post(NULL, TRUE);
  6423. if(isset($post['page']))
  6424. {
  6425. $page = $this->input->post('page',true);
  6426. $perpage = $this->input->post('perpage',true);
  6427. $sku = $this->input->post('sku',true);
  6428. $bs = $this->input->post('bs',true);
  6429. $number = $this->input->post('number',true);
  6430. $warehouse = $this->input->post('warehouse',true);
  6431. $purchase = $this->input->post('purchase',true);
  6432. $orderinfo = $this->input->post('orderinfo',true);
  6433. $waybill = $this->input->post('waybill',true);
  6434. $category = $this->input->post('category',true);
  6435. $size = $this->input->post('size',true);
  6436. $grade = $this->input->post('grade',true);
  6437. $color = $this->input->post('color',true);
  6438. $lowe = $this->input->post('lowe',true);
  6439. $state = $this->input->post('state',true);
  6440. $label = $this->input->post('label',true);
  6441. $timetk = $this->input->post('ktime',true);
  6442. $timetj = $this->input->post('jtime',true);
  6443. $timetk = strtotime($timetk);
  6444. $timetj = strtotime($timetj);
  6445. $where = "1=1 ";
  6446. if($timetk && $timetj)
  6447. {
  6448. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6449. }
  6450. if($sku)
  6451. {
  6452. $where .= " and sku = '$sku'";
  6453. }
  6454. if($bs != '')
  6455. {
  6456. $where .= " and bs = '$bs'";
  6457. }
  6458. if($number)
  6459. {
  6460. $where .= " and number = '$number'";
  6461. }
  6462. if($warehouse)
  6463. {
  6464. $where .= " and warehouse = '$warehouse'";
  6465. }
  6466. if($purchase)
  6467. {
  6468. $where .= " and purchase = '$purchase'";
  6469. }
  6470. if($orderinfo)
  6471. {
  6472. $where .= " and orderinfo = '$orderinfo'";
  6473. }
  6474. if($waybill)
  6475. {
  6476. $where .= " and waybill = '$waybill'";
  6477. }
  6478. if($category)
  6479. {
  6480. $where .= " and features like '%-$category-%'";
  6481. }
  6482. if($size)
  6483. {
  6484. $where .= " and features like '%-$size-%'";
  6485. }
  6486. if($grade)
  6487. {
  6488. $where .= " and features like '%-$grade-%'";
  6489. }
  6490. if($color)
  6491. {
  6492. $where .= " and features like '%-$color-%'";
  6493. }
  6494. if($lowe)
  6495. {
  6496. $where .= " and features like '%-$lowe-%'";
  6497. }
  6498. if($label)
  6499. {
  6500. $where .= " and label = '$label'";
  6501. }
  6502. if($state || $state == 0)
  6503. {
  6504. $where .= " and state = '$state'";
  6505. }
  6506. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6507. //数据排序
  6508. $order_str = "enter desc";
  6509. if(empty($page))
  6510. {
  6511. $start = 0;
  6512. $perpage = 1;
  6513. }
  6514. else
  6515. {
  6516. $start = ($page - 1)*$perpage;
  6517. }
  6518. //取得信息列表
  6519. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6520. foreach ($info_list as $key=>$value)
  6521. {
  6522. $warehouse = $this->warehouse->read($value['warehouse']);
  6523. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6524. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6525. if($value['state'] == 0)
  6526. {
  6527. $info_list[$key]['state'] = "在库";
  6528. }
  6529. else if($value['state'] == 1)
  6530. {
  6531. $info_list[$key]['state'] = "出库";
  6532. }
  6533. else if($value['state'] == 2)
  6534. {
  6535. $info_list[$key]['state'] = "退库";
  6536. }
  6537. else if($value['state'] == 3)
  6538. {
  6539. $info_list[$key]['state'] = "调拨中";
  6540. }
  6541. else if($value['state'] == 4)
  6542. {
  6543. $info_list[$key]['state'] = "再加工";
  6544. }
  6545. else if($value['state'] == 5)
  6546. {
  6547. $info_list[$key]['state'] = "维修中";
  6548. }
  6549. else if($value['state'] == 6)
  6550. {
  6551. $info_list[$key]['state'] = "盘亏";
  6552. }
  6553. else if($value['state'] == 7)
  6554. {
  6555. $info_list[$key]['state'] = "更换标签";
  6556. }
  6557. else if($value['state'] == 8)
  6558. {
  6559. $info_list[$key]['state'] = "其它";
  6560. }
  6561. else if($value['state'] == 9)
  6562. {
  6563. $info_list[$key]['state'] = "预设";
  6564. }
  6565. else if($value['state'] == 10)
  6566. {
  6567. $info_list[$key]['state'] = "美店零售";
  6568. }
  6569. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6570. }
  6571. $total = $this->$ck->find_count($where);
  6572. $pagenum = ceil($total/$perpage);
  6573. $over = $total-($start+$perpage);
  6574. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6575. echo json_encode($rows);exit;
  6576. }
  6577. if(isset($post['tmsku']))
  6578. {
  6579. $time = time();
  6580. $tmsku = $this->input->post('tmsku',true);
  6581. //$post['shop'] = $this->input->post('shop',true);
  6582. $num = $this->input->post('num',true);
  6583. $rktype = $this->input->post('rktype',true);
  6584. if($num > 200)
  6585. {
  6586. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6587. }
  6588. if(!$rktype)
  6589. {
  6590. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6591. }
  6592. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6593. /**
  6594. $wz = array();
  6595. foreach ($rk as $key=>$value)
  6596. {
  6597. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6598. }
  6599. if(count($wz) > 1)
  6600. {
  6601. $wz = array_values($wz);
  6602. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6603. }
  6604. **/
  6605. if(isset($rk[0]['purchase']))
  6606. {
  6607. $rk = $rk[0];
  6608. $j = 0;
  6609. $post['purchase'] = $rk['purchase'];
  6610. $post['warehouse'] = $rk['warehouse'];
  6611. $post['retreatwarehouse'] = $rk['warehouse'];
  6612. $post['sku'] = $rk['sku'];
  6613. $post['number'] = $rk['number'];
  6614. $post['features'] = $rk['features'];
  6615. $post['title'] = $rk['title'];
  6616. $post['enter'] = $time;
  6617. $post['time'] = $time;
  6618. $post['bs'] = 1;
  6619. $post['shop'] = $rk['shop'];
  6620. $post['details'] = $rk['details'];
  6621. $post['cpid'] = $rk['cpid'];
  6622. $post['cpbz'] = $rk['cpbz'];
  6623. //$post['rktype'] = $rktype;
  6624. $warehouse = $this->warehouse->read($rk['warehouse']);
  6625. if($warehouse['bdck'] == '')
  6626. {
  6627. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6628. }
  6629. else
  6630. {
  6631. $bdck = $warehouse['bdck'];
  6632. }
  6633. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6634. if(isset($pdwz['details']))
  6635. {
  6636. if($pdwz['details'] != $post['details'])
  6637. {
  6638. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6639. }
  6640. }
  6641. $post['featurespp'] = $rk['featurespp'];
  6642. if($post['warehouse'] == '5')
  6643. {
  6644. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6645. if($yza)
  6646. {
  6647. if($post['features'] != $yza[0]['features'])
  6648. {
  6649. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6650. }
  6651. }
  6652. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6653. if($yzb)
  6654. {
  6655. if($post['sku'] != $yzb[0]['sku'])
  6656. {
  6657. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6658. }
  6659. }
  6660. }
  6661. for($i=0;$i<$num;$i++)
  6662. {
  6663. $post['label'] = time().rand(100,999).$i;
  6664. if($this->$bdck->insert($post))
  6665. {
  6666. $j++;
  6667. }
  6668. }
  6669. /**
  6670. if($post['warehouse'] != 12)
  6671. {
  6672. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6673. }
  6674. **/
  6675. if($j == $num)
  6676. {
  6677. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6678. }
  6679. else
  6680. {
  6681. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6682. }
  6683. }
  6684. else
  6685. {
  6686. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6687. }
  6688. }
  6689. $this->_Template('whlabel_printrk',$this->data);
  6690. }
  6691. public function _printxzrk($arg_array)
  6692. {
  6693. $post = $this->input->post(NULL, TRUE);
  6694. if(isset($post['wzid']))
  6695. {
  6696. $time = time();
  6697. $id = $this->input->post('wzid',true);
  6698. //$post['shop'] = $this->input->post('shop',true);
  6699. $num = 1;
  6700. $rk = $this->whlabellabel->read($id);
  6701. if(isset($rk['purchase']))
  6702. {
  6703. $x = 0;
  6704. $post['purchase'] = $rk['purchase'];
  6705. $post['warehouse'] = $rk['warehouse'];
  6706. $post['retreatwarehouse'] = $rk['warehouse'];
  6707. $post['sku'] = $rk['sku'];
  6708. $post['number'] = $rk['number'];
  6709. $post['features'] = $rk['features'];
  6710. $post['title'] = $rk['title'];
  6711. $post['enter'] = $time;
  6712. $post['time'] = $time;
  6713. $post['bs'] = 1;
  6714. $post['shop'] = $rk['shop'];
  6715. $post['details'] = $rk['details'];
  6716. $post['cpid'] = $rk['cpid'];
  6717. $post['cpbz'] = $rk['cpbz'];
  6718. $warehouse = $this->warehouse->read($rk['warehouse']);
  6719. if($warehouse['bdck'] == '')
  6720. {
  6721. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6722. }
  6723. else
  6724. {
  6725. $bdck = $warehouse['bdck'];
  6726. }
  6727. $post['featurespp'] = $rk['featurespp'];
  6728. $this->db->trans_begin();
  6729. for($i=0;$i<$num;$i++)
  6730. {
  6731. $post['label'] = time().rand(100,999).$i;
  6732. $this->$bdck->insert($post);
  6733. }
  6734. /**
  6735. if($post['warehouse'] != 12)
  6736. {
  6737. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6738. }
  6739. **/
  6740. if ($this->db->trans_status() === TRUE)
  6741. {
  6742. $this->db->trans_commit();
  6743. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6744. }
  6745. else
  6746. {
  6747. $this->db->trans_rollback();
  6748. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6749. }
  6750. }
  6751. else
  6752. {
  6753. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6754. }
  6755. }
  6756. }
  6757. public function _printck($arg_array)
  6758. {
  6759. $prc = array();
  6760. $purchase = $this->purchase->find_all();
  6761. foreach($purchase as $k=>$v)
  6762. {
  6763. $prc[$v['id']] = $v['title'];
  6764. }
  6765. $post = $this->input->post(NULL, TRUE);
  6766. if(isset($post['page']))
  6767. {
  6768. $page = $this->input->post('page',true);
  6769. $perpage = $this->input->post('perpage',true);
  6770. $sku = $this->input->post('sku',true);
  6771. $bs = $this->input->post('bs',true);
  6772. $number = $this->input->post('number',true);
  6773. $warehouse = $this->input->post('warehouse',true);
  6774. $purchase = $this->input->post('purchase',true);
  6775. $orderinfo = $this->input->post('orderinfo',true);
  6776. $waybill = $this->input->post('waybill',true);
  6777. $category = $this->input->post('category',true);
  6778. $size = $this->input->post('size',true);
  6779. $grade = $this->input->post('grade',true);
  6780. $color = $this->input->post('color',true);
  6781. $lowe = $this->input->post('lowe',true);
  6782. $state = $this->input->post('state',true);
  6783. $label = $this->input->post('label',true);
  6784. $timetk = $this->input->post('ktime',true);
  6785. $timetj = $this->input->post('jtime',true);
  6786. $timetk = strtotime($timetk);
  6787. $timetj = strtotime($timetj);
  6788. $where = "state=1 ";
  6789. if($timetk && $timetj)
  6790. {
  6791. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6792. }
  6793. if($sku)
  6794. {
  6795. $where .= " and sku = '$sku'";
  6796. }
  6797. if($bs != '')
  6798. {
  6799. $where .= " and bs = '$bs'";
  6800. }
  6801. if($number)
  6802. {
  6803. $where .= " and number = '$number'";
  6804. }
  6805. if($warehouse)
  6806. {
  6807. $where .= " and warehouse = '$warehouse'";
  6808. }
  6809. if($purchase)
  6810. {
  6811. $where .= " and purchase = '$purchase'";
  6812. }
  6813. if($orderinfo)
  6814. {
  6815. $where .= " and orderinfo = '$orderinfo'";
  6816. }
  6817. if($waybill)
  6818. {
  6819. $where .= " and waybill = '$waybill'";
  6820. }
  6821. if($category)
  6822. {
  6823. $where .= " and features like '%-$category-%'";
  6824. }
  6825. if($size)
  6826. {
  6827. $where .= " and features like '%-$size-%'";
  6828. }
  6829. if($grade)
  6830. {
  6831. $where .= " and features like '%-$grade-%'";
  6832. }
  6833. if($color)
  6834. {
  6835. $where .= " and features like '%-$color-%'";
  6836. }
  6837. if($lowe)
  6838. {
  6839. $where .= " and features like '%-$lowe-%'";
  6840. }
  6841. if($label)
  6842. {
  6843. $where .= " and label = '$label'";
  6844. }
  6845. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6846. //数据排序
  6847. $order_str = "outk desc";
  6848. if(empty($page))
  6849. {
  6850. $start = 0;
  6851. $perpage = 1;
  6852. }
  6853. else
  6854. {
  6855. $start = ($page - 1)*$perpage;
  6856. }
  6857. //取得信息列表
  6858. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6859. foreach ($info_list as $key=>$value)
  6860. {
  6861. $warehouse = $this->warehouse->read($value['warehouse']);
  6862. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6863. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6864. if($value['state'] == 0)
  6865. {
  6866. $info_list[$key]['state'] = "在库";
  6867. }
  6868. else if($value['state'] == 1)
  6869. {
  6870. $info_list[$key]['state'] = "出库";
  6871. }
  6872. else if($value['state'] == 2)
  6873. {
  6874. $info_list[$key]['state'] = "退库";
  6875. }
  6876. else if($value['state'] == 3)
  6877. {
  6878. $info_list[$key]['state'] = "调拨中";
  6879. }
  6880. else if($value['state'] == 4)
  6881. {
  6882. $info_list[$key]['state'] = "再加工";
  6883. }
  6884. else if($value['state'] == 5)
  6885. {
  6886. $info_list[$key]['state'] = "维修中";
  6887. }
  6888. else if($value['state'] == 6)
  6889. {
  6890. $info_list[$key]['state'] = "盘亏";
  6891. }
  6892. else if($value['state'] == 7)
  6893. {
  6894. $info_list[$key]['state'] = "更换标签";
  6895. }
  6896. else if($value['state'] == 8)
  6897. {
  6898. $info_list[$key]['state'] = "其它";
  6899. }
  6900. else if($value['state'] == 9)
  6901. {
  6902. $info_list[$key]['state'] = "预设";
  6903. }
  6904. else if($value['state'] == 10)
  6905. {
  6906. $info_list[$key]['state'] = "美店零售";
  6907. }
  6908. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6909. }
  6910. $total = $this->$ck->find_count($where);
  6911. $pagenum = ceil($total/$perpage);
  6912. $over = $total-($start+$perpage);
  6913. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6914. echo json_encode($rows);exit;
  6915. }
  6916. if(isset($post['tmsku']))
  6917. {
  6918. $time = time();
  6919. $tmsku = $this->input->post('tmsku',true);
  6920. //$post['shop'] = $this->input->post('shop',true);
  6921. $num = $this->input->post('num',true);
  6922. $cktype = $this->input->post('cktype',true);
  6923. $label = $this->whlabellabel->get_label($tmsku);
  6924. if(!$cktype)
  6925. {
  6926. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6927. }
  6928. if(!isset($label['warehouse']))
  6929. {
  6930. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6931. }
  6932. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6933. if(stripos($label['features'],'-126-') !== false)
  6934. {
  6935. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6936. }
  6937. else
  6938. {
  6939. $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 = ''");
  6940. }
  6941. $j = 0;
  6942. if(count($ck) >= $num)
  6943. {
  6944. for($i=0;$i<$num;$i++)
  6945. {
  6946. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6947. {
  6948. $j++;
  6949. }
  6950. }
  6951. if($j == $num)
  6952. {
  6953. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6954. }
  6955. else
  6956. {
  6957. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6958. }
  6959. }
  6960. else
  6961. {
  6962. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6963. }
  6964. }
  6965. $this->_Template('whlabel_printck',$this->data);
  6966. }
  6967. public function _printexcel()
  6968. {
  6969. $dir = '/data/excel/'.date('Ymd',time()).'/';
  6970. $config['upload_path'] = '.'.$dir ;
  6971. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  6972. $config['allowed_types'] = 'xls|xlsx|csv';
  6973. $config['max_size'] = 10240;
  6974. $this->load->library('upload', $config);
  6975. $this->upload->initialize($config);
  6976. if ($this->upload->do_upload('userfile'))
  6977. {
  6978. $full_path = $dir.$this->upload->data('file_name');
  6979. $fileName = '.' . $full_path;
  6980. if (!file_exists($fileName))
  6981. {
  6982. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  6983. }
  6984. else
  6985. {
  6986. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6987. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  6988. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  6989. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  6990. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  6991. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  6992. ++$column;//如果列数大于26行
  6993. $list = array();
  6994. for ($i = 2; $i <= $row; $i++) // 行数循环
  6995. {
  6996. $data = array();
  6997. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6998. {
  6999. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7000. }
  7001. $list[] = $data;
  7002. }
  7003. }
  7004. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  7005. $cmf_arr = array_column($list, '1');
  7006. array_multisort($cmf_arr, SORT_ASC, $list);
  7007. foreach ($list as $key=>$value)
  7008. {
  7009. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  7010. if($typeclass)
  7011. {
  7012. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  7013. }
  7014. else
  7015. {
  7016. $ed[] = array($value['1'].'-系统未找到此订单信息');
  7017. $i++;
  7018. continue;
  7019. }
  7020. }
  7021. if($i > 0)
  7022. {
  7023. $yc = $i.'条异常';
  7024. }
  7025. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  7026. }
  7027. }
  7028. public function _uck()
  7029. {
  7030. if(isset($_GET['excel']))
  7031. {
  7032. $tc = array();
  7033. $typeclass = $this->typeclass->find_all();
  7034. foreach ($typeclass as $v)
  7035. {
  7036. $tc[$v['id']] = $v['zh'];
  7037. }
  7038. $data = array();$t = array();$rq = '';
  7039. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  7040. $ts = $ts/(24*3600);
  7041. for($i=0;$i<$ts;$i++)
  7042. {
  7043. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  7044. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  7045. }
  7046. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  7047. foreach ($info_list as $k=>$v)
  7048. {
  7049. $features = explode('-',trim($v['features'],'-'));
  7050. if(!isset($features[3]) || !isset($features[4]))
  7051. {
  7052. continue;
  7053. }
  7054. $data[$k][0] = $tc[$features[0]];//类型
  7055. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7056. $data[$k][2] = $tc[$features[4]];//曲度
  7057. $data[$k][3] = '';
  7058. if(isset($data[$k][1]))
  7059. {
  7060. $data[$k][3] .= $data[$k][1];
  7061. }
  7062. if(isset($data[$k][2]))
  7063. {
  7064. $data[$k][3] .= $data[$k][2];
  7065. }
  7066. if(isset($features[5]))
  7067. {
  7068. $data[$k][3] .= $tc[$features[5]];
  7069. }
  7070. if(isset($features[2]))
  7071. {
  7072. $data[$k][3] .= $tc[$features[2]];
  7073. }
  7074. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7075. $data[$k][4] = $v['sku'];
  7076. $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())).'))');//月初库存
  7077. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7078. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7079. $ztrq = '';$ztsl = '';
  7080. if(count($zt) > 0)
  7081. {
  7082. foreach ($zt as $vv)
  7083. {
  7084. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7085. $ztsl .= $vv['num'].'<br>';
  7086. }
  7087. }
  7088. $data[$k][] = trim($ztsl,'<br>');
  7089. $data[$k][] = trim($ztrq,'<br>');
  7090. $byck = 0;
  7091. foreach ($t as $vv)
  7092. {
  7093. $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));
  7094. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7095. $byck += $sl;
  7096. }
  7097. $data[$k][] = ($byck > 0)?$byck:'';
  7098. }
  7099. $title = "详情 ".date("Y-m-d",time());
  7100. $titlename = "<table border=1>
  7101. <tr align='center'>
  7102. <td>类别</td>
  7103. <td>颜色</td>
  7104. <td>曲度</td>
  7105. <td>名称</td>
  7106. <td>SKU</td>
  7107. <td>月初库存</td>
  7108. <td>剩余库存</td>
  7109. <td>在途数量</td>
  7110. <td>预达日期</td>".
  7111. $rq
  7112. ."<td>本月出库</td></tr>
  7113. </table>";
  7114. $filename = $title.".xls";
  7115. $tail = "";
  7116. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7117. }
  7118. }
  7119. public function _whlabelexcelzh()
  7120. {
  7121. if(isset($_GET['excel']))
  7122. {
  7123. $where = "sku != 'Preset'";
  7124. //数据排序
  7125. $order_str = "id desc";
  7126. if(empty($page))
  7127. {
  7128. $start = 0;
  7129. $perpage = 1;
  7130. }
  7131. else
  7132. {
  7133. $start = ($page - 1)*$perpage;
  7134. }
  7135. $category = $this->input->get('category',true);
  7136. $warehouse = $this->input->get('warehouse',true);
  7137. $excelid = $this->input->get('sid',true);
  7138. if($category)
  7139. {
  7140. $where .= " and features like '%-$category-%'";
  7141. }
  7142. if($warehouse)
  7143. {
  7144. $where .= " and warehouse = '$warehouse'";
  7145. }
  7146. $xzid = '';
  7147. if($excelid)
  7148. {
  7149. $excelid = explode(',',trim($excelid,','));
  7150. foreach ($excelid as $key=>$value)
  7151. {
  7152. $xzid .= " id = ".$value." or";
  7153. }
  7154. $xzid = " and (".rtrim($xzid,'or').")";;
  7155. }
  7156. //取得信息列表
  7157. /**
  7158. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7159. $rows = array();$list = array();
  7160. foreach ($info_list as $key=>$value)
  7161. {
  7162. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7163. }
  7164. **/
  7165. $list = array();
  7166. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7167. foreach ($rows as $key=>$value)
  7168. {
  7169. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7170. $zh = '';
  7171. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7172. foreach ($zt as $v)
  7173. {
  7174. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7175. }
  7176. $zt = array_sum(array_column($zt,'num'));
  7177. $number = $value['number'];
  7178. $ftime = time()-15*24*3600;
  7179. $warehouse = $this->warehouse->read($value['warehouse']);
  7180. $rows[$key]['warehouse'] = $warehouse['title'];
  7181. $rows[$key]['number'] = $c;
  7182. $rows[$key]['features'] = $zh;
  7183. $rows[$key]['hb'] = $c+$zt;
  7184. }
  7185. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7186. $titlename = "<table border=1>
  7187. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7188. <tr align='center'>
  7189. <td>仓库</td>
  7190. <td>SKU</td>
  7191. <td>产品</td>
  7192. <td>库存数量</td>
  7193. <td>在途数量及预达日期</td>
  7194. <td>在途+库存数量</td>
  7195. </tr>
  7196. </table>";
  7197. $filename = $title.".xls";
  7198. $tail = "";
  7199. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7200. }
  7201. if(isset($_GET['excel']))
  7202. {
  7203. $warehouse = $this->input->get('warehouse',true);
  7204. $sku = $this->input->get('sku',true);
  7205. $cz = $this->input->get('cz',true);
  7206. $text = $this->input->post('text',true);
  7207. $xztime = $this->input->get('xztime',true);
  7208. $timetk = $this->input->get('timetk',true);
  7209. $timetj = $this->input->get('timetj',true);
  7210. $timetk = strtotime($timetk);
  7211. $timetj = strtotime($timetj);
  7212. $where = "time = '0' ";
  7213. if($warehouse)
  7214. {
  7215. $where .= " and warehouse = '$warehouse'";
  7216. }
  7217. if($sku)
  7218. {
  7219. $where .= " and sku = '$sku'";
  7220. }
  7221. if($text)
  7222. {
  7223. $where .= " and text like '%$text%'";
  7224. }
  7225. if($cz != '')
  7226. {
  7227. $where .= " and cz = '$cz'";
  7228. }
  7229. if($timetk && $timetj)
  7230. {
  7231. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7232. }
  7233. //数据排序
  7234. $order_str = $xztime." desc";
  7235. //取得信息列表
  7236. $zh = array();
  7237. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7238. foreach ($info_list as $v)
  7239. {
  7240. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7241. $warehouse = $this->warehouse->read($v['warehouse']);
  7242. $v['warehouse'] = $warehouse['title'];
  7243. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7244. $v['stime'] = date('Y-m-d',$v['stime']);
  7245. if(isset($zh[$v['features']]))
  7246. {
  7247. $zh[$v['features']]['num'] += $v['num'];
  7248. }
  7249. else
  7250. {
  7251. $zh[$v['features']] = $v;
  7252. }
  7253. $zh[$v['features']]['features'] = $c;
  7254. }
  7255. $title = "在途数据".date('Y-m-d',time());
  7256. $titlename = "<table border=1>
  7257. <tr align='center'>
  7258. <td>仓库</td>
  7259. <td>SKU</td>
  7260. <td>名称</td>
  7261. <td>在途数量</td>
  7262. <td>库存数量</td>
  7263. <td>添加在途日期</td>
  7264. <td>预达日期</td>
  7265. <td>备注</td>
  7266. </tr>
  7267. </table>";
  7268. $filename = $title.".xls";
  7269. $tail = "";
  7270. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7271. }
  7272. }
  7273. public function _fc()
  7274. {
  7275. $vip = 0;
  7276. if(isset($_SESSION['api']))
  7277. {
  7278. $user = $this->user->get_api($_SESSION['api']);
  7279. if($user['vip'] == 1)
  7280. {
  7281. $vip = 1;
  7282. }
  7283. }
  7284. else
  7285. {
  7286. header('Location: /');exit;
  7287. }
  7288. $post = $this->input->post(NULL, TRUE);
  7289. if(isset($post['page']))
  7290. {
  7291. $page = $this->input->post('page',true);
  7292. $perpage = $this->input->post('perpage',true);
  7293. $category = $this->input->post('category',true);
  7294. $size = $this->input->post('size',true);
  7295. $grade = $this->input->post('grade',true);
  7296. $color = $this->input->post('color',true);
  7297. $lowe = $this->input->post('lowe',true);
  7298. $sku = $this->input->post('sku');
  7299. $title = $this->input->post('title');
  7300. $warehouse = $this->input->post('warehouse',true);
  7301. $usa = $this->input->post('usa',true);
  7302. $purchase = $this->input->post('purchase',true);
  7303. $lacetype = $this->input->post('lacetype',true);
  7304. $haircap = $this->input->post('haircap',true);
  7305. $density = $this->input->post('density',true);
  7306. $details = $this->input->post('details',true);
  7307. $state = $this->input->post('state',true);
  7308. $ktime = $this->input->post('ktime',true);
  7309. $jtime = $this->input->post('jtime',true);
  7310. $ktime = strtotime($ktime);
  7311. $jtime = strtotime($jtime);
  7312. $where = "state = '11'";$gj = "";$ck = "";
  7313. if($lacetype)
  7314. {
  7315. $where .= " and features like '%-$lacetype-%'";
  7316. }
  7317. if($category)
  7318. {
  7319. $where .= " and features like '%-$category-%'";
  7320. }
  7321. if($size)
  7322. {
  7323. $where .= " and features like '%-$size-%'";
  7324. }
  7325. if($grade)
  7326. {
  7327. $where .= " and features like '%-$grade-%'";
  7328. }
  7329. if($color)
  7330. {
  7331. $where .= " and features like '%-$color-%'";
  7332. }
  7333. if($lowe)
  7334. {
  7335. $where .= " and features like '%-$lowe-%'";
  7336. }
  7337. if($haircap)
  7338. {
  7339. $where .= " and features like '%-$haircap-%'";
  7340. }
  7341. if($density)
  7342. {
  7343. $where .= " and features like '%-$density-%'";
  7344. }
  7345. if($usa)
  7346. {
  7347. if(!$warehouse)
  7348. {
  7349. $where .= " and (warehouse = '5' or warehouse = '8')";
  7350. }
  7351. }
  7352. if($warehouse)
  7353. {
  7354. $where .= " and warehouse = '$warehouse'";
  7355. }
  7356. if($details)
  7357. {
  7358. $where .= " and details = '$details'";
  7359. }
  7360. if($purchase)
  7361. {
  7362. $where .= " and purchase = '$purchase'";
  7363. }
  7364. if($state)
  7365. {
  7366. $where .= " and state = '$state'";
  7367. }
  7368. if($ktime && $jtime)
  7369. {
  7370. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7371. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7372. }
  7373. //数据排序
  7374. $order_str = "id desc";
  7375. if(empty($page))
  7376. {
  7377. $start = 0;
  7378. $perpage = 1;
  7379. }
  7380. else
  7381. {
  7382. $start = ($page - 1)*$perpage;
  7383. }
  7384. if($sku)
  7385. {
  7386. $sku = trim($sku,' ');
  7387. $sku = trim($sku,' ');
  7388. $where .= " and sku like '%$sku%'";
  7389. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7390. }
  7391. else if($title)
  7392. {
  7393. $title = trim($title,' ');
  7394. $title = trim($title,' ');
  7395. $where .= " and title like '%$title%'";
  7396. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7397. }
  7398. else
  7399. {
  7400. //$where .= " and time > '$ktime' and time < '$jtime'";
  7401. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7402. }
  7403. //取得信息列表
  7404. $rows = array();$list = array();
  7405. foreach ($info_list as $key=>$value)
  7406. {
  7407. $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'].'"');
  7408. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7409. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7410. $warehouse = $this->warehouse->read($value['warehouse']);
  7411. $info_list[$key]['warehouse'] = $warehouse['title'];
  7412. $info_list[$key]['number'] = $g;
  7413. $info_list[$key]['features'] = $x;
  7414. $info_list[$key]['x'] = $s;
  7415. }
  7416. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7417. $pagenum = ceil($total/$perpage);
  7418. $over = $total-($start+$perpage);
  7419. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7420. echo json_encode($rows);exit;
  7421. }
  7422. $this->data['vip'] = $vip;
  7423. $this->_Template('whlabel_fc',$this->data);
  7424. }
  7425. public function _fcmb()
  7426. {
  7427. $where = "sku != 'Preset'";
  7428. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7429. foreach ($rows as $k=>$v)
  7430. {
  7431. $warehouse = $this->warehouse->read($v['warehouse']);
  7432. $rows[$k]['warehouse'] = $warehouse['title'];
  7433. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7434. $rows[$k]['t'] = '';
  7435. $rows[$k]['n'] = '';
  7436. }
  7437. $title = "封货产品数据导入模板";
  7438. $titlename = "<table border=1>
  7439. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7440. <tr align='center'>
  7441. <td>仓库</td>
  7442. <td>SKU</td>
  7443. <td>产品</td>
  7444. <td>封存产品总数量</td>
  7445. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7446. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7447. </tr>
  7448. </table>";
  7449. $filename = $title.".xls";
  7450. $tail = "";
  7451. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7452. }
  7453. public function _fcexcel()
  7454. {
  7455. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7456. $config['upload_path'] = '.'.$dir ;
  7457. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7458. $config['allowed_types'] = 'xls|xlsx|csv';
  7459. $config['max_size'] = 10240;
  7460. $this->load->library('upload', $config);
  7461. $this->upload->initialize($config);
  7462. if ($this->upload->do_upload('userfile'))
  7463. {
  7464. $full_path = $dir.$this->upload->data('file_name');
  7465. $fileName = '.' . $full_path;
  7466. if (!file_exists($fileName))
  7467. {
  7468. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7469. }
  7470. else
  7471. {
  7472. libxml_use_internal_errors(true);
  7473. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7474. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7475. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7476. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7477. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7478. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7479. ++$column;//如果列数大于26行
  7480. $list = array();
  7481. for ($i = 2; $i <= $row; $i++) // 行数循环
  7482. {
  7483. $data = array();
  7484. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7485. {
  7486. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7487. }
  7488. $list[] = $data;
  7489. }
  7490. }
  7491. $i = 0;$j = 0;$ed = array();
  7492. foreach ($list as $key=>$value)
  7493. {
  7494. $time = time();
  7495. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7496. {
  7497. continue;
  7498. }
  7499. $warehouse = $this->warehouse->get_title($value['0']);
  7500. $sku = $value['1'];
  7501. $type = $value['4'];//调整方式0扣减1删除
  7502. $num = $value['5'];//调整数量
  7503. //$text = $value['4'];//扣减说明
  7504. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7505. if(!$d)//如果没有这个SKU
  7506. {
  7507. $ed[] = array($sku.'-库存中不存在此SKU');
  7508. $j++;
  7509. continue;
  7510. }
  7511. if(!isset($warehouse['id']))
  7512. {
  7513. $ed[] = array($sku.'-仓库名错误!');
  7514. $j++;
  7515. continue;
  7516. }
  7517. if($type == 1 || $type == 2)//扣减库存
  7518. {
  7519. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7520. if(count($data) < abs($num))
  7521. {
  7522. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7523. $j++;
  7524. continue;
  7525. }
  7526. if($type == 1)//转入库存
  7527. {
  7528. for($i=0;$i<abs($num);$i++)
  7529. {
  7530. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7531. }
  7532. }
  7533. else if($type == 2)//删除
  7534. {
  7535. for($i=0;$i<abs($num);$i++)
  7536. {
  7537. $this->whlabel->remove($data[$i]['id']);
  7538. }
  7539. }
  7540. }
  7541. else if($type == 0)//增加库存
  7542. {
  7543. $post['sku'] = $d['sku'];
  7544. $post['shop'] = '';
  7545. $post['warehouse'] = $warehouse['id'];
  7546. $post['purchase'] = $d['purchase'];
  7547. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7548. $post['state'] = 11;
  7549. $post['title'] = $d['title'];
  7550. $post['number'] = $d['number'];
  7551. $post['features'] = $d['features'];
  7552. $post['enter'] = $time;
  7553. $post['time'] = $time;//操作时间
  7554. for($i=0;$i<$num;$i++)
  7555. {
  7556. $post['label'] = time().rand(100,999).$i;
  7557. $this->whlabel->insert($post);
  7558. }
  7559. }
  7560. sleep(1);//防止入库时间一样,需要延迟1秒
  7561. }
  7562. if($j > 0)
  7563. {
  7564. $tt = date('Ymd',time());
  7565. $title = '库存导入错误信息-'.$tt;
  7566. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7567. $tail = "\n";
  7568. $filename = $title.".xls";
  7569. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7570. $dir = '/data/excel/'.$time.'/';
  7571. $file_name = 'error_'.$time.rand(1000,9999);
  7572. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7573. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7574. fwrite($myfile,$ecl);
  7575. fclose($myfile);
  7576. $error = $dir.$file_name.'.xls';
  7577. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7578. }
  7579. else
  7580. {
  7581. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7582. }
  7583. }
  7584. }
  7585. public function _fcjxc($arg_array)
  7586. {
  7587. if(isset($_GET['excel']))
  7588. {
  7589. $category = $this->input->get('category',true);
  7590. $size = $this->input->get('size',true);
  7591. $grade = $this->input->get('grade',true);
  7592. $color = $this->input->get('color',true);
  7593. $lowe = $this->input->get('lowe',true);
  7594. $sku = $this->input->get('sku');
  7595. $title = $this->input->get('title');
  7596. $warehouse = $arg_array[0];
  7597. $usa = $this->input->get('usa',true);
  7598. $purchase = $this->input->get('purchase',true);
  7599. $lacetype = $this->input->get('lacetype',true);
  7600. $haircap = $this->input->get('haircap',true);
  7601. $density = $this->input->get('density',true);
  7602. $title = $this->input->get('title',true);
  7603. $state = $this->input->get('state',true);
  7604. $ktime = $this->input->get('ktime',true);
  7605. $jtime = $this->input->get('jtime',true);
  7606. $where = "state=11";$gj = "";$ck = "";
  7607. if($lacetype)
  7608. {
  7609. $where .= " and features like '%-$lacetype-%'";
  7610. }
  7611. if($category)
  7612. {
  7613. $where .= " and features like '%-$category-%'";
  7614. }
  7615. if($size)
  7616. {
  7617. $where .= " and features like '%-$size-%'";
  7618. }
  7619. if($grade)
  7620. {
  7621. $where .= " and features like '%-$grade-%'";
  7622. }
  7623. if($color)
  7624. {
  7625. $where .= " and features like '%-$color-%'";
  7626. }
  7627. if($lowe)
  7628. {
  7629. $where .= " and features like '%-$lowe-%'";
  7630. }
  7631. if($haircap)
  7632. {
  7633. $where .= " and features like '%-$haircap-%'";
  7634. }
  7635. if($density)
  7636. {
  7637. $where .= " and features like '%-$density-%'";
  7638. }
  7639. if($usa)
  7640. {
  7641. if(!$warehouse)
  7642. {
  7643. $where .= " and (warehouse = '5' or warehouse = '8')";
  7644. }
  7645. }
  7646. if($warehouse)
  7647. {
  7648. $where .= " and warehouse = '$warehouse'";
  7649. }
  7650. if($purchase)
  7651. {
  7652. $where .= " and purchase = '$purchase'";
  7653. }
  7654. if($state)
  7655. {
  7656. $where .= " and state = '$state'";
  7657. }
  7658. $order_str = "id desc";
  7659. if($sku)
  7660. {
  7661. $sku = trim($sku,' ');
  7662. $sku = trim($sku,' ');
  7663. $where .= " and sku like '%$sku%'";
  7664. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7665. }
  7666. else if($title)
  7667. {
  7668. $title = trim($title,' ');
  7669. $title = trim($title,' ');
  7670. $where .= " and title like '%$title%'";
  7671. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7672. }
  7673. else
  7674. {
  7675. //$where .= " and time > '$ktime' and time < '$jtime'";
  7676. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7677. }
  7678. //取得信息列表
  7679. $rows = array();$list = array();
  7680. foreach ($info_list as $key=>$value)
  7681. {
  7682. $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'].'"');
  7683. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7684. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7685. $rows[$key] = $value;
  7686. $warehouse = $this->warehouse->read($value['warehouse']);
  7687. $rows[$key]['warehouse'] = $warehouse['title'];
  7688. $rows[$key]['features'] = $g;
  7689. $rows[$key]['a'] = $x;
  7690. $rows[$key]['b'] = $s;
  7691. }
  7692. $title = "总统计表";
  7693. $titlename = "<table border=1>
  7694. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7695. <tr align='center'>
  7696. <td>仓库</td>
  7697. <td>SKU</td>
  7698. <td>产品名称</td>
  7699. <td>录入总量</td>
  7700. <td>取出总量</td>
  7701. <td>剩余总量</td>
  7702. </tr>
  7703. </table>";
  7704. $filename = $title.".xls";
  7705. $tail = "";
  7706. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7707. }
  7708. $vip = 0;
  7709. if(isset($_SESSION['api']))
  7710. {
  7711. $user = $this->user->get_api($_SESSION['api']);
  7712. if($user['vip'] == 1)
  7713. {
  7714. $vip = 1;
  7715. }
  7716. }
  7717. else
  7718. {
  7719. header('Location: /');exit;
  7720. }
  7721. $post = $this->input->post(NULL, TRUE);
  7722. if(isset($post['page']))
  7723. {
  7724. $page = $this->input->post('page',true);
  7725. $perpage = $this->input->post('perpage',true);
  7726. $category = $this->input->post('category',true);
  7727. $size = $this->input->post('size',true);
  7728. $grade = $this->input->post('grade',true);
  7729. $color = $this->input->post('color',true);
  7730. $lowe = $this->input->post('lowe',true);
  7731. $sku = $this->input->post('sku');
  7732. $title = $this->input->post('title');
  7733. $warehouse = $arg_array[0];
  7734. $usa = $this->input->post('usa',true);
  7735. $purchase = $this->input->post('purchase',true);
  7736. $lacetype = $this->input->post('lacetype',true);
  7737. $haircap = $this->input->post('haircap',true);
  7738. $density = $this->input->post('density',true);
  7739. $title = $this->input->post('title',true);
  7740. $state = $this->input->post('state',true);
  7741. $ktime = $this->input->post('ktime',true);
  7742. $jtime = $this->input->post('jtime',true);
  7743. $ktime = strtotime($ktime);
  7744. $jtime = strtotime($jtime);
  7745. $where = "state=11";$gj = "";$ck = "";
  7746. if($lacetype)
  7747. {
  7748. $where .= " and features like '%-$lacetype-%'";
  7749. }
  7750. if($category)
  7751. {
  7752. $where .= " and features like '%-$category-%'";
  7753. }
  7754. if($size)
  7755. {
  7756. $where .= " and features like '%-$size-%'";
  7757. }
  7758. if($grade)
  7759. {
  7760. $where .= " and features like '%-$grade-%'";
  7761. }
  7762. if($color)
  7763. {
  7764. $where .= " and features like '%-$color-%'";
  7765. }
  7766. if($lowe)
  7767. {
  7768. $where .= " and features like '%-$lowe-%'";
  7769. }
  7770. if($haircap)
  7771. {
  7772. $where .= " and features like '%-$haircap-%'";
  7773. }
  7774. if($density)
  7775. {
  7776. $where .= " and features like '%-$density-%'";
  7777. }
  7778. if($usa)
  7779. {
  7780. if(!$warehouse)
  7781. {
  7782. $where .= " and (warehouse = '5' or warehouse = '8')";
  7783. }
  7784. }
  7785. if($warehouse)
  7786. {
  7787. $where .= " and warehouse = '$warehouse'";
  7788. }
  7789. if($purchase)
  7790. {
  7791. $where .= " and purchase = '$purchase'";
  7792. }
  7793. if($state)
  7794. {
  7795. $where .= " and state = '$state'";
  7796. }
  7797. if($ktime && $jtime)
  7798. {
  7799. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7800. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7801. }
  7802. //数据排序
  7803. $order_str = "id desc";$xs=0;
  7804. $rows = array();$list = array();
  7805. if(empty($page))
  7806. {
  7807. $start = 0;
  7808. $perpage = 1;
  7809. }
  7810. else
  7811. {
  7812. $start = ($page - 1)*$perpage;
  7813. }
  7814. if($sku || $title)
  7815. {
  7816. if($title)
  7817. {
  7818. $title = trim($title,' ');
  7819. $title = trim($title,' ');
  7820. $where .= " and title like '%$title%'";
  7821. }
  7822. else
  7823. {
  7824. $sku = trim($sku,' ');
  7825. $sku = trim($sku,' ');
  7826. $where .= " and sku like '%$sku%'";
  7827. }
  7828. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7829. foreach ($info_list as $key=>$value)
  7830. {
  7831. $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'].'"');
  7832. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7833. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7834. $rows[$key] = $value;
  7835. $warehouse = $this->warehouse->read($value['warehouse']);
  7836. $rows[$key]['warehouse'] = $warehouse['title'];
  7837. $rows[$key]['features'] = $g;
  7838. $rows[$key]['a'] = $x;
  7839. $rows[$key]['b'] = $s;
  7840. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7841. $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天销量
  7842. $yj = $c/($xl/30);
  7843. if($yj < 7)
  7844. {
  7845. $rows[$key]['y'] = round($yj).'天销量';
  7846. }
  7847. else
  7848. {
  7849. $rows[$key]['y'] = '正常';
  7850. }
  7851. }
  7852. }
  7853. else
  7854. {
  7855. //$where .= " and time > '$ktime' and time < '$jtime'";
  7856. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7857. foreach ($info_list as $key=>$value)
  7858. {
  7859. $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'].'"');
  7860. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7861. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7862. $zs[$key] = $value;
  7863. $warehouse = $this->warehouse->read($value['warehouse']);
  7864. $zs[$key]['warehouse'] = $warehouse['title'];
  7865. $zs[$key]['features'] = $g;
  7866. $zs[$key]['a'] = $x;
  7867. $zs[$key]['b'] = $s;
  7868. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7869. $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天销量
  7870. $yj = $c/($xl/30);
  7871. if($yj < 7)
  7872. {
  7873. $zs[$key]['y'] = round($yj).'天销量';
  7874. $rows[$key] = $zs[$key];
  7875. }
  7876. }
  7877. }
  7878. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7879. $pagenum = ceil($total/$perpage);
  7880. $over = $total-($start+$perpage);
  7881. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7882. echo json_encode($rows);exit;
  7883. }
  7884. $this->data['arg_array'] = $arg_array[0];
  7885. $this->_Template('whlabel_fcjxc',$this->data);
  7886. }
  7887. public function _0kcdel()
  7888. {
  7889. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7890. $config['upload_path'] = '.'.$dir ;
  7891. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7892. $config['allowed_types'] = 'xls|xlsx|csv';
  7893. $config['max_size'] = 10240;
  7894. $this->load->library('upload', $config);
  7895. $this->upload->initialize($config);
  7896. if ($this->upload->do_upload('userfile'))
  7897. {
  7898. $full_path = $dir.$this->upload->data('file_name');
  7899. $fileName = '.' . $full_path;
  7900. if (!file_exists($fileName))
  7901. {
  7902. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7903. }
  7904. else
  7905. {
  7906. require_once "./data/excel/PHPExcel/IOFactory.php";
  7907. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7908. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7909. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7910. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7911. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7912. ++$column;//如果列数大于26行
  7913. $list = array();
  7914. for ($i = 2; $i <= $row; $i++) // 行数循环
  7915. {
  7916. $data = array();
  7917. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7918. {
  7919. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7920. }
  7921. $list[] = $data;
  7922. }
  7923. }
  7924. $i = 0;$j = 0;$ed = array();
  7925. foreach ($list as $key=>$value)
  7926. {
  7927. $time = time();
  7928. if($value['0'] == "" || $value['1'] == "")
  7929. {
  7930. continue;
  7931. }
  7932. $warehouse = $this->warehouse->get_title($value['0']);
  7933. $sku = $value['1'];
  7934. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7935. if(!$d)//如果没有这个SKU
  7936. {
  7937. $ed[] = array($sku.'-库存中不存在此SKU');
  7938. $j++;
  7939. continue;
  7940. }
  7941. if(!isset($warehouse['id']))
  7942. {
  7943. $ed[] = array($sku.'-仓库名错误!');
  7944. $j++;
  7945. continue;
  7946. }
  7947. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7948. if($z < 1)
  7949. {
  7950. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7951. foreach ($z as $v)
  7952. {
  7953. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7954. if(count($zt) > 0)
  7955. {
  7956. $ed[] = array($sku.'-有在途库存无法删除!');
  7957. $j++;
  7958. continue;
  7959. }
  7960. $this->whlabel->remove($v['id']);
  7961. }
  7962. }
  7963. else
  7964. {
  7965. $ed[] = array($sku.'-非0库存!');
  7966. $j++;
  7967. continue;
  7968. }
  7969. }
  7970. if($j > 0)
  7971. {
  7972. $tt = date('Ymd',time());
  7973. $title = '删除0库存错误信息-'.$tt;
  7974. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7975. $tail = "\n";
  7976. $filename = $title.".xls";
  7977. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7978. $dir = '/data/excel/'.$time.'/';
  7979. $file_name = 'error_'.$time.rand(1000,9999);
  7980. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7981. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7982. fwrite($myfile,$ecl);
  7983. fclose($myfile);
  7984. $error = $dir.$file_name.'.xls';
  7985. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7986. }
  7987. else
  7988. {
  7989. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7990. }
  7991. }
  7992. }
  7993. public function _gbhtype()
  7994. {
  7995. $post = $this->input->post(NULL, TRUE);
  7996. if(isset($post['s']))
  7997. {
  7998. $n = $this->input->post('n');
  7999. $d = $this->input->post('s');
  8000. if(!$d)
  8001. {
  8002. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  8003. }
  8004. $d = explode(',',trim($d,','));
  8005. $t = $this->whlabel_type->read($n);
  8006. //循环删除记录
  8007. foreach ($d as $v)
  8008. {
  8009. $u = $this->whlabel->read($v);
  8010. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  8011. foreach ($data as $val)
  8012. {
  8013. $this->whlabel->save(array('type'=>$n),$val['id']);
  8014. }
  8015. }
  8016. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  8017. }
  8018. }
  8019. //出库、退库导出
  8020. public function _dccrtype()
  8021. {
  8022. $classid = $this->classid->sku();
  8023. $pm = $classid;
  8024. $typeclass = array();
  8025. $tc = $this->typeclass->find_all();
  8026. foreach ($tc as $v)
  8027. {
  8028. $typeclass[$v['id']] = $v;
  8029. }
  8030. $prc = array();
  8031. $purchase = $this->purchase->find_all();
  8032. foreach($purchase as $k=>$v)
  8033. {
  8034. $prc[$v['id']] = $v['title'];
  8035. }
  8036. if(isset($_GET['sid']))
  8037. {
  8038. $wh = array();
  8039. $w = $this->warehouse->find_all('1=1','id,title');
  8040. foreach ($w as $v)
  8041. {
  8042. $wh[$v['id']] = $v['title'];
  8043. }
  8044. $type = $this->input->get('excel',true);
  8045. $category = $this->input->get('category',true);
  8046. $size = $this->input->get('size',true);
  8047. $grade = $this->input->get('grade',true);
  8048. $color = $this->input->get('color',true);
  8049. $lowe = $this->input->get('lowe',true);
  8050. $sku = $this->input->get('sku',true);
  8051. $warehouse = $this->input->get('warehouse',true);
  8052. $lacetype = $this->input->get('lacetype',true);
  8053. $lacecolor = $this->input->get('lacecolor',true);
  8054. $density = $this->input->get('density',true);
  8055. $haircap = $this->input->get('haircap',true);
  8056. $purchase = $this->input->get('purchase',true);
  8057. $title = $this->input->get('title',true);
  8058. $state = $this->input->get('state',true);
  8059. $sid = $this->input->get('sid',true);
  8060. $ktime = $this->input->get('ktime',true);
  8061. $jtime = $this->input->get('jtime',true);
  8062. $ktime = strtotime($ktime);
  8063. $jtime = strtotime($jtime);
  8064. $where = "1=1";$gj = "";$ck = "";
  8065. if($category)
  8066. {
  8067. $where .= " and features like '%-$category-%'";
  8068. }
  8069. if($size)
  8070. {
  8071. $where .= " and features like '%-$size-%'";
  8072. }
  8073. if($grade)
  8074. {
  8075. $where .= " and features like '%-$grade-%'";
  8076. }
  8077. if($color)
  8078. {
  8079. $where .= " and features like '%-$color-%'";
  8080. }
  8081. if($lowe)
  8082. {
  8083. $where .= " and features like '%-$lowe-%'";
  8084. }
  8085. if($warehouse)
  8086. {
  8087. $where .= " and warehouse = '$warehouse'";
  8088. }
  8089. if($purchase)
  8090. {
  8091. $where .= " and purchase = '$purchase'";
  8092. }
  8093. if($state)
  8094. {
  8095. $where .= " and state = '$state'";
  8096. }
  8097. if($lacetype)
  8098. {
  8099. $where .= " and features like '%-$lacetype-%'";
  8100. }
  8101. if($lacecolor)
  8102. {
  8103. $where .= " and features like '%-$lacecolor-%'";
  8104. }
  8105. if($density)
  8106. {
  8107. $where .= " and features like '%-$density-%'";
  8108. }
  8109. if($haircap)
  8110. {
  8111. $where .= " and features like '%-$haircap-%'";
  8112. }
  8113. if($title)
  8114. {
  8115. $title = trim($title,' ');
  8116. $title = trim($title,' ');
  8117. $where .= " and title like '%$title%'";
  8118. }
  8119. if($sku)
  8120. {
  8121. $sku = trim($sku,' ');
  8122. $sku = trim($sku,' ');
  8123. $where .= " and sku like '%$sku%'";
  8124. }
  8125. if($ktime && $jtime)
  8126. {
  8127. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8128. }
  8129. $sidwhere = '';
  8130. if($sid)
  8131. {
  8132. $sd = "";
  8133. $s = explode(',',trim($sid,','));
  8134. foreach ($s as $value)
  8135. {
  8136. $sd .= " id = ".$value." or";
  8137. }
  8138. $sidwhere = " and (".rtrim($sd,'or').")";
  8139. }
  8140. //数据排序
  8141. $order_str = "time desc";
  8142. if(empty($page))
  8143. {
  8144. $start = 0;
  8145. $perpage = 1;
  8146. }
  8147. else
  8148. {
  8149. $start = ($page - 1)*$perpage;
  8150. }
  8151. $wh = array();
  8152. $w = $this->warehouse->find_all('1=1','id,title');
  8153. foreach ($w as $v)
  8154. {
  8155. $wh[$v['id']] = $v['title'];
  8156. }
  8157. $wt = array();
  8158. $whlabel_type = $this->whlabel_type->find_all();
  8159. foreach ($whlabel_type as $v)
  8160. {
  8161. $wt[$v['id']] = $v['title'];
  8162. }
  8163. $classid = $this->classid->sku();
  8164. $list = array();
  8165. $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');
  8166. foreach ($rows_r as $key=>$value)
  8167. {
  8168. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8169. $pm = $classid;
  8170. $jm = $classid;
  8171. $rows_r[$key]['enter'] = '入库';
  8172. $rows_r[$key]['time'] = $value['enter'];
  8173. if($value['rktype'] == 1)
  8174. {
  8175. $rows_r[$key]['rktype'] = '采购入库';
  8176. }
  8177. else if($value['rktype'] == 2)
  8178. {
  8179. $rows_r[$key]['rktype'] = '盘盈调整';
  8180. }
  8181. else if($value['rktype'] == 3)
  8182. {
  8183. $rows_r[$key]['rktype'] = '其他调整入库';
  8184. }
  8185. else if($value['rktype'] == 4)
  8186. {
  8187. $rows_r[$key]['rktype'] = '其他调整入库';
  8188. }
  8189. else if($value['rktype'] == 5)
  8190. {
  8191. $rows_r[$key]['rktype'] = '退库入库';
  8192. }
  8193. else if($value['rktype'] == 6)
  8194. {
  8195. $rows_r[$key]['rktype'] = '退货可用入库';
  8196. }
  8197. else if($value['rktype'] == 7)
  8198. {
  8199. $rows_r[$key]['rktype'] = '形态转换入库';
  8200. }
  8201. else
  8202. {
  8203. $rows_r[$key]['rktype'] = '';
  8204. }
  8205. $features = explode('-',trim($value['features'],'-'));
  8206. foreach($features as $v)
  8207. {
  8208. if(isset($typeclass[$v]))
  8209. {
  8210. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8211. $pm[$typeclass[$v]['classid']] = $zh[0];
  8212. }
  8213. if(isset($typeclass[$v]))
  8214. {
  8215. if(isset($jm[$typeclass[$v]['classid']]))
  8216. {
  8217. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8218. }
  8219. }
  8220. }
  8221. $zh = implode(" ",$pm);
  8222. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8223. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8224. $rows_r[$key]['zh'] = $zh;
  8225. $jm = array_filter($jm);
  8226. $rows_r[$key]['features'] = implode("-",$jm);
  8227. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8228. }
  8229. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8230. foreach ($rows_c as $key=>$value)
  8231. {
  8232. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8233. $pm = $classid;
  8234. $jm = $classid;
  8235. $rows_c[$key]['time'] = $value['outk'];
  8236. $rows_c[$key]['outk'] = '出库';
  8237. if($value['cktype'] == 1)
  8238. {
  8239. $rows_c[$key]['cktype'] = '销售出库';
  8240. }
  8241. else if($value['cktype'] == 2)
  8242. {
  8243. $rows_c[$key]['cktype'] = '销售美国出库';
  8244. }
  8245. else if($value['cktype'] == 3)
  8246. {
  8247. $rows_c[$key]['cktype'] = '盘亏调整';
  8248. }
  8249. else if($value['cktype'] == 4)
  8250. {
  8251. $rows_c[$key]['cktype'] = '其他调整出库';
  8252. }
  8253. else if($value['cktype'] == 5)
  8254. {
  8255. $rows_c[$key]['cktype'] = '形态转换出库';
  8256. }
  8257. else
  8258. {
  8259. $rows_c[$key]['cktype'] = '';
  8260. }
  8261. $features = explode('-',trim($value['features'],'-'));
  8262. foreach($features as $v)
  8263. {
  8264. if(isset($typeclass[$v]))
  8265. {
  8266. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8267. $pm[$typeclass[$v]['classid']] = $zh[0];
  8268. }
  8269. if(isset($typeclass[$v]))
  8270. {
  8271. if(isset($jm[$typeclass[$v]['classid']]))
  8272. {
  8273. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8274. }
  8275. }
  8276. }
  8277. $zh = implode(" ",$pm);
  8278. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8279. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8280. $rows_c[$key]['zh'] = $zh;
  8281. $jm = array_filter($jm);
  8282. $rows_c[$key]['features'] = implode("-",$jm);
  8283. $rows_c[$key]['number'] = 1;
  8284. }
  8285. $merged = $rows_r;
  8286. foreach ($rows_c as $key => $value)
  8287. {
  8288. if (isset($merged[$key]))
  8289. {
  8290. $merged[] = $value;
  8291. }
  8292. else
  8293. {
  8294. $merged[$key] = $value;
  8295. }
  8296. }
  8297. usort($merged, function($a, $b)
  8298. {
  8299. return $a['time'] - $b['time'];
  8300. });
  8301. foreach ($merged as $key=>$value)
  8302. {
  8303. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8304. }
  8305. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8306. $titlename = "<table border=1>
  8307. <tr align='center'>
  8308. <td>仓库</td>
  8309. <td>SKU</td>
  8310. <td>商品名称</td>
  8311. <td>仓库品名</td>
  8312. <td>料号</td>
  8313. <td>时间</td>
  8314. <td>操作</td>
  8315. <td>类型</td>
  8316. <td>数量</td>
  8317. <td>备注</td>
  8318. </tr>
  8319. </table>";
  8320. $filename = $title.".xlsx";
  8321. $tail = "";
  8322. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8323. }
  8324. }
  8325. }