Whlabel.php 265 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422
  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. }
  40. //定义方法的调用规则 获取URI第二段值
  41. public function _remap($arg,$arg_array)
  42. {
  43. if($arg == 'existence')//在库标签
  44. {
  45. $this->_existence();
  46. }
  47. else if($arg == 'cpbqdc')//在库标签
  48. {
  49. $this->_cpbqdc();
  50. }
  51. else if($arg == 'type')//进销存浏览
  52. {
  53. $this->_type();
  54. }
  55. else if($arg == 'typedy')//进销存浏览店员页面
  56. {
  57. $this->_typedy($arg_array);
  58. }
  59. else if($arg == 'typedy_ck')//进销存浏览店员页面
  60. {
  61. $this->_typedy_ck($arg_array);
  62. }
  63. else if($arg == 'typeck')
  64. {
  65. $this->_typeck($arg_array);
  66. }
  67. else if($arg == 'whlabeckdc')
  68. {
  69. $this->_whlabeckdc($arg_array);
  70. }
  71. else if($arg == 'usatype')//美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. }
  75. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  76. {
  77. $this->_usatypeapp();
  78. }
  79. else if($arg == 'enteradd')//入库操作
  80. {
  81. $this->_enteradd();
  82. }
  83. else if($arg == 'enteredit')//修改
  84. {
  85. $this->_enteredit($arg_array);
  86. }
  87. else if($arg == 'enter')//入库浏览
  88. {
  89. $this->_enter();
  90. }
  91. else if($arg == 'out')//出库浏览
  92. {
  93. $this->_out();
  94. }
  95. else if($arg == 'label')//出库标签浏览
  96. {
  97. $this->_label();
  98. }
  99. else if($arg == 'outorder')//独立站出库订单
  100. {
  101. $this->_outorder();
  102. }
  103. else if($arg == 'soutorder')//速卖通出库订单
  104. {
  105. $this->_soutorder();
  106. }
  107. else if($arg == 'toutorder')//TT出库订单
  108. {
  109. $this->_toutorder();
  110. }
  111. else if($arg == 'retreat')//退库订单
  112. {
  113. $this->_retreat();
  114. }
  115. else if($arg == 'retreatlk')//退库订单
  116. {
  117. $this->_retreatlk();
  118. }
  119. else if($arg == 'change')//更换标签
  120. {
  121. $this->_change();
  122. }
  123. else if($arg == 'del')//删除
  124. {
  125. $this->_del();
  126. }
  127. else if($arg == 'exceljxc')//进销存信息导出
  128. {
  129. $this->_exceljxc();
  130. }
  131. else if($arg == 'excelr')//入库信息导出
  132. {
  133. $this->_excelr();
  134. }
  135. else if($arg == 'excelct')//出库、退库信息导出
  136. {
  137. $this->_excelct();
  138. }
  139. else if($arg == 'dccrtype')//根据出入库类型导出
  140. {
  141. $this->_dccrtype();
  142. }
  143. else if($arg == 'excelcr')//出库、退库信息导出
  144. {
  145. $this->_excelcr();
  146. }
  147. else if($arg == 'kcyz')//库存验证
  148. {
  149. $this->_kcyz();
  150. }
  151. else if($arg == 'kj')//库存扣减
  152. {
  153. $this->_kj($arg_array);
  154. }
  155. else if($arg == 'presetout')//预设库存导入
  156. {
  157. $this->_presetout($arg_array);
  158. }
  159. else if($arg == 'presetedit')//预设库存导入
  160. {
  161. $this->_presetedit($arg_array);
  162. }
  163. else if($arg == 'summary')//汇总导出
  164. {
  165. $this->_summary($arg_array);
  166. }
  167. else if($arg == 'manifest')//usps发货清单
  168. {
  169. $this->_manifest();
  170. }
  171. else if($arg == 'abnormal')//占单异常
  172. {
  173. $this->_abnormal();
  174. }
  175. else if($arg == 'error')//0库存SKU
  176. {
  177. $this->_error();
  178. }
  179. else if($arg == 'errorexcel')//0库存SKU导出
  180. {
  181. $this->_errorexcel();
  182. }
  183. else if($arg == 'db')
  184. {
  185. $this->_db();
  186. }
  187. else if($arg == 'dbrk')
  188. {
  189. $this->_dbrk();
  190. }
  191. else if($arg == 'whlabelczdc')
  192. {
  193. $this->_whlabelczdc();
  194. }
  195. else if($arg == 'print')
  196. {
  197. $this->_print($arg_array);
  198. }
  199. else if($arg == 'usaprint')
  200. {
  201. $this->_usaprint($arg_array);
  202. }
  203. else if($arg == 'printck')
  204. {
  205. $this->_printck($arg_array);
  206. }
  207. else if($arg == 'printrk')
  208. {
  209. $this->_printrk($arg_array);
  210. }
  211. else if($arg == 'printxzrk')
  212. {
  213. $this->_printxzrk($arg_array);
  214. }
  215. else if($arg == 'printexcel')
  216. {
  217. $this->_printexcel($arg_array);
  218. }
  219. else if($arg == 'uck')
  220. {
  221. $this->_uck();
  222. }
  223. else if($arg == 'whlabelexcelzh')
  224. {
  225. $this->_whlabelexcelzh();
  226. }
  227. else if($arg == 'fc')
  228. {
  229. $this->_fc();
  230. }
  231. else if($arg == 'fcmb')
  232. {
  233. $this->_fcmb();
  234. }
  235. else if($arg == 'fcexcel')
  236. {
  237. $this->_fcexcel();
  238. }
  239. else if($arg == 'fcjxc')
  240. {
  241. $this->_fcjxc($arg_array);
  242. }
  243. else if($arg == '0kcdel')
  244. {
  245. $this->_0kcdel();//导表删除0库存
  246. }
  247. else if($arg == 'gbhtype')
  248. {
  249. $this->_gbhtype();//更改备货状态
  250. }
  251. else
  252. {
  253. $this->_index();
  254. }
  255. }
  256. //管理
  257. public function _index()
  258. {
  259. $post = $this->input->post(NULL, TRUE);
  260. if(isset($post['page']))
  261. {
  262. $page = $this->input->post('page',true);
  263. $perpage = $this->input->post('perpage',true);
  264. $sku = $this->input->post('sku',true);
  265. $number = $this->input->post('number',true);
  266. $warehouse = $this->input->post('warehouse',true);
  267. $purchase = $this->input->post('purchase',true);
  268. $orderinfo = $this->input->post('orderinfo',true);
  269. $waybill = $this->input->post('waybill',true);
  270. $category = $this->input->post('category',true);
  271. $size = $this->input->post('size',true);
  272. $grade = $this->input->post('grade',true);
  273. $color = $this->input->post('color',true);
  274. $lowe = $this->input->post('lowe',true);
  275. $state = $this->input->post('state',true);
  276. $label = $this->input->post('label',true);
  277. $timetk = $this->input->post('timetkk',true);
  278. $timetj = $this->input->post('timetjj',true);
  279. $timetk = strtotime($timetk);
  280. $timetj = strtotime($timetj);
  281. $where = "1=1 ";
  282. if($timetk && $timetj)
  283. {
  284. $where .= " and time > '$timetk' and time < '$timetj'";
  285. }
  286. if($sku)
  287. {
  288. $where .= " and sku = '$sku'";
  289. }
  290. if($number)
  291. {
  292. $where .= " and number = '$number'";
  293. }
  294. if($warehouse)
  295. {
  296. $where .= " and warehouse = '$warehouse'";
  297. }
  298. if($purchase)
  299. {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if($orderinfo)
  303. {
  304. $where .= " and orderinfo = '$orderinfo'";
  305. }
  306. if($waybill)
  307. {
  308. $where .= " and waybill = '$waybill'";
  309. }
  310. if($category)
  311. {
  312. $where .= " and features like '%-$category-%'";
  313. }
  314. if($size)
  315. {
  316. $where .= " and features like '%-$size-%'";
  317. }
  318. if($grade)
  319. {
  320. $where .= " and features like '%-$grade-%'";
  321. }
  322. if($color)
  323. {
  324. $where .= " and features like '%-$color-%'";
  325. }
  326. if($lowe)
  327. {
  328. $where .= " and features like '%-$lowe-%'";
  329. }
  330. if($label)
  331. {
  332. $where .= " and label = '$label'";
  333. }
  334. if($state != '')
  335. {
  336. $where .= " and state = '$state'";
  337. }
  338. //数据排序
  339. $order_str = "time desc";
  340. if(empty($page))
  341. {
  342. $start = 0;
  343. $perpage = 1;
  344. }
  345. else
  346. {
  347. $start = ($page - 1)*$perpage;
  348. }
  349. //取得信息列表
  350. $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);
  351. foreach ($info_list as $key=>$value)
  352. {
  353. $warehouse = $this->warehouse->read($value['warehouse']);
  354. $info_list[$key]['warehouse'] = $warehouse['title'];
  355. $purchase = $this->purchase->read($value['purchase']);
  356. $info_list[$key]['purchase'] = $purchase['title'];
  357. if($value['enter'] != 0)
  358. {
  359. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  360. }
  361. else
  362. {
  363. $info_list[$key]['enter'] = "";
  364. }
  365. if($value['outk'] != 0)
  366. {
  367. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  368. }
  369. else
  370. {
  371. $info_list[$key]['outk'] = "";
  372. }
  373. if($value['printing'] != 0)
  374. {
  375. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  376. }
  377. else
  378. {
  379. $info_list[$key]['printing'] = "";
  380. }
  381. if($value['orderinfo'] == 0)
  382. {
  383. $info_list[$key]['orderinfo'] = "";
  384. }
  385. if($value['waybill'] == 0)
  386. {
  387. $info_list[$key]['waybill'] = "";
  388. }
  389. if($value['state'] == 0)
  390. {
  391. $info_list[$key]['state'] = "在库";
  392. }
  393. else if($value['state'] == 1)
  394. {
  395. $info_list[$key]['state'] = "出库";
  396. }
  397. else if($value['state'] == 2)
  398. {
  399. $info_list[$key]['state'] = "退库";
  400. }
  401. else if($value['state'] == 3)
  402. {
  403. $info_list[$key]['state'] = "调拨中";
  404. }
  405. else if($value['state'] == 4)
  406. {
  407. $info_list[$key]['state'] = "再加工";
  408. }
  409. else if($value['state'] == 5)
  410. {
  411. $info_list[$key]['state'] = "维修中";
  412. }
  413. else if($value['state'] == 6)
  414. {
  415. $info_list[$key]['state'] = "盘亏";
  416. }
  417. else if($value['state'] == 7)
  418. {
  419. $info_list[$key]['state'] = "更换标签";
  420. }
  421. else if($value['state'] == 8)
  422. {
  423. $info_list[$key]['state'] = "其它";
  424. }
  425. else if($value['state'] == 9)
  426. {
  427. $info_list[$key]['state'] = "预设";
  428. }
  429. else if($value['state'] == 10)
  430. {
  431. $info_list[$key]['state'] = "美店零售";
  432. }
  433. if($value['text'] == "")
  434. {
  435. $info_list[$key]['text'] = "";
  436. }
  437. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  438. }
  439. $total = $this->whlabel->find_count($where);
  440. $pagenum = ceil($total/$perpage);
  441. $over = $total-($start+$perpage);
  442. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  443. echo json_encode($rows);exit;
  444. }
  445. if(isset($post['outsku']))
  446. {
  447. $cz = $this->input->post('cz',true);
  448. if($cz == '1')
  449. {
  450. $sku = $this->input->post('outsku',true);
  451. if($sku)
  452. {
  453. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  454. if(count($data) < 1)
  455. {
  456. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  457. }
  458. $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time(),'cktype'=>1),$data[0]['id']);
  459. echo json_encode(array('success'=>true));exit;
  460. }
  461. }
  462. else
  463. {
  464. $sku = $this->input->post('outsku',true);
  465. if($sku)
  466. {
  467. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  468. if(count($data) < 1)
  469. {
  470. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  471. }
  472. $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  473. echo json_encode(array('success'=>true));exit;
  474. }
  475. }
  476. }
  477. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  478. $this->_Template('whlabel',$this->data);
  479. }
  480. //在库标签
  481. public function _existence()
  482. {
  483. $post = $this->input->post(NULL, TRUE);
  484. if(isset($post['s']))
  485. {
  486. $id_arr = $this->input->post('s');
  487. $id_arr = explode(',',$id_arr);
  488. if(!$id_arr)
  489. {
  490. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  491. }
  492. //循环删除记录
  493. foreach ($id_arr as $v)
  494. {
  495. $sid = $this->whlabel->read($v);
  496. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  497. if($count > 0)
  498. {
  499. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  500. }
  501. $zt = $this->whlabeltransport->find_all('sku = "'.$sid['sku'].'" and warehouse = "'.$sid['warehouse'].'" and features = "'.$sid['features'].'" and cz = "0"');
  502. if(count($zt) > 0)
  503. {
  504. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  505. }
  506. $this->whlabel->remove($v);
  507. }
  508. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  509. }
  510. if(isset($post['page']))
  511. {
  512. $page = $this->input->post('page',true);
  513. $perpage = $this->input->post('perpage',true);
  514. $warehouse = $this->input->post('warehouse',true);
  515. $label = $this->input->post('label',true);
  516. $where = "1=1 and state = 0";
  517. if($warehouse)
  518. {
  519. $where .= " and warehouse = '$warehouse'";
  520. }
  521. if($label)
  522. {
  523. $where .= " and label = '$label'";
  524. }
  525. //数据排序
  526. $order_str = "time asc";
  527. if(empty($page))
  528. {
  529. $start = 0;
  530. $perpage = 1;
  531. }
  532. else
  533. {
  534. $start = ($page - 1)*$perpage;
  535. }
  536. //取得信息列表
  537. $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  538. foreach ($info_list as $key=>$value)
  539. {
  540. if($value['enter'] != 0)
  541. {
  542. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  543. }
  544. else
  545. {
  546. $info_list[$key]['enter'] = "";
  547. }
  548. if($value['printing'] != 0)
  549. {
  550. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  551. }
  552. else
  553. {
  554. $info_list[$key]['printing'] = "";
  555. }
  556. }
  557. $total = $this->whlabel->find_count($where);
  558. $pagenum = ceil($total/$perpage);
  559. $over = $total-($start+$perpage);
  560. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  561. echo json_encode($rows);exit;
  562. }
  563. $this->_Template('whlabel_existence',$this->data);
  564. }
  565. //进销存浏览
  566. public function _typedy($arg_array)
  567. {
  568. $prc = array();
  569. $purchase = $this->purchase->find_all();
  570. foreach($purchase as $k=>$v)
  571. {
  572. $prc[$v['id']] = $v['title'];
  573. }
  574. $post = $this->input->post(NULL, TRUE);
  575. if(isset($post['page']))
  576. {
  577. $page = $this->input->post('page',true);
  578. $perpage = $this->input->post('perpage',true);
  579. $category = $this->input->post('category',true);
  580. $size = $this->input->post('size',true);
  581. $grade = $this->input->post('grade',true);
  582. $color = $this->input->post('color',true);
  583. $lowe = $this->input->post('lowe',true);
  584. $sku = $this->input->post('sku');
  585. $title = $this->input->post('title');
  586. $warehouse = $this->input->post('warehouse',true);
  587. $usa = $this->input->post('usa',true);
  588. $purchase = $this->input->post('purchase',true);
  589. $lacetype = $this->input->post('lacetype',true);
  590. $haircap = $this->input->post('haircap',true);
  591. $density = $this->input->post('density',true);
  592. $details = $this->input->post('details',true);
  593. $state = $this->input->post('state',true);
  594. $lacecolor = $this->input->post('lacecolor',true);
  595. $cklx = $this->input->post('cklx',true);
  596. $ktime = $this->input->post('ktime',true);
  597. $jtime = $this->input->post('jtime',true);
  598. $ktime = strtotime($ktime);
  599. $jtime = strtotime($jtime);
  600. $where = "1=1";$gj = "";$ck = "";
  601. if($lacetype)
  602. {
  603. $where .= " and features like '%-$lacetype-%'";
  604. }
  605. if($category)
  606. {
  607. $where .= " and features like '%-$category-%'";
  608. }
  609. if($size)
  610. {
  611. $where .= " and features like '%-$size-%'";
  612. }
  613. if($grade)
  614. {
  615. $where .= " and features like '%-$grade-%'";
  616. }
  617. if($color)
  618. {
  619. $where .= " and features like '%-$color-%'";
  620. }
  621. if($lowe)
  622. {
  623. $where .= " and features like '%-$lowe-%'";
  624. }
  625. if($haircap)
  626. {
  627. $where .= " and features like '%-$haircap-%'";
  628. }
  629. if($density)
  630. {
  631. $where .= " and features like '%-$density-%'";
  632. }
  633. if($lacecolor)
  634. {
  635. $where .= " and features like '%-$lacecolor-%'";
  636. }
  637. if($usa)
  638. {
  639. if(!$warehouse)
  640. {
  641. $where .= " and (warehouse = '5' or warehouse = '8')";
  642. }
  643. }
  644. if($warehouse)
  645. {
  646. $where .= " and warehouse = '$warehouse'";
  647. }
  648. if($details)
  649. {
  650. $where .= " and details = '$details'";
  651. }
  652. if($purchase)
  653. {
  654. $where .= " and purchase = '$purchase'";
  655. }
  656. if($state)
  657. {
  658. $where .= " and state = '$state'";
  659. }
  660. $where_add = '';
  661. if($cklx)
  662. {
  663. $shop = $this->shop->read($cklx);
  664. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  665. }
  666. if($ktime && $jtime)
  667. {
  668. $gj = " and enter > '$ktime' and enter < '$jtime'";
  669. $ck = " and outk > '$ktime' and outk < '$jtime'";
  670. }
  671. //数据排序
  672. $order_str = "id desc";
  673. if(empty($page))
  674. {
  675. $start = 0;
  676. $perpage = 1;
  677. }
  678. else
  679. {
  680. $start = ($page - 1)*$perpage;
  681. }
  682. if($sku)
  683. {
  684. $sku = trim($sku,' ');
  685. $sku = trim($sku,' ');
  686. $where .= " and sku like '%$sku%'";
  687. $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);
  688. }
  689. else if($title)
  690. {
  691. $title = trim($title,' ');
  692. $title = trim($title,' ');
  693. $where .= " and title like '%$title%'";
  694. $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);
  695. }
  696. else
  697. {
  698. //$where .= " and time > '$ktime' and time < '$jtime'";
  699. $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);
  700. }
  701. //取得信息列表
  702. $rows = array();$list = array();
  703. foreach ($info_list as $key=>$value)
  704. {
  705. $warehouse = $this->warehouse->read($value['warehouse']);
  706. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  707. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  708. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  709. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  710. $number = $value['number'];$ftime = time()-15*24*3600;
  711. $info_list[$key]['warehouse'] = $warehouse['title'];
  712. $info_list[$key]['features'] = count($c);
  713. $z = count($z);//查看订单号
  714. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  715. $ztdata = '';
  716. if(count($zt) > 0)
  717. {
  718. foreach ($zt as $vv)
  719. {
  720. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  721. }
  722. }
  723. $info_list[$key]['number'] = $ztdata;
  724. $info_list[$key]['sm'] = $z;
  725. $details = array();
  726. $cpid = array();
  727. foreach ($c as $k=>$v)
  728. {
  729. $details[$v['details']] = $v['details'];
  730. if($v['cpid'] != 0)
  731. {
  732. $cpid[$v['cpid']] = $v['cpid'];
  733. }
  734. }
  735. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  736. if($value['shop'] != '')
  737. {
  738. $shop = explode(',',trim($value['shop'],','));
  739. $shop = $this->shop->read($shop[0]);
  740. $info_list[$key]['shop'] = $shop['shopname'];
  741. }
  742. }
  743. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  744. $pagenum = ceil($total/$perpage);
  745. $over = $total-($start+$perpage);
  746. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  747. echo json_encode($rows);exit;
  748. }
  749. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  750. $this->_Template('whlabel_typedy',$this->data);
  751. }
  752. //进销存浏览
  753. public function _typedy_ck($arg_array)
  754. {
  755. $prc = array();
  756. $purchase = $this->purchase->find_all();
  757. foreach($purchase as $k=>$v)
  758. {
  759. $prc[$v['id']] = $v['title'];
  760. }
  761. $post = $this->input->post(NULL, TRUE);
  762. if(isset($post['page']))
  763. {
  764. $page = $this->input->post('page',true);
  765. $perpage = $this->input->post('perpage',true);
  766. $category = $this->input->post('category',true);
  767. $size = $this->input->post('size',true);
  768. $grade = $this->input->post('grade',true);
  769. $color = $this->input->post('color',true);
  770. $lowe = $this->input->post('lowe',true);
  771. $sku = $this->input->post('sku');
  772. $title = $this->input->post('title');
  773. $warehouse = $this->input->post('warehouse',true);
  774. $usa = $this->input->post('usa',true);
  775. $purchase = $this->input->post('purchase',true);
  776. $lacetype = $this->input->post('lacetype',true);
  777. $haircap = $this->input->post('haircap',true);
  778. $density = $this->input->post('density',true);
  779. $details = $this->input->post('details',true);
  780. $state = $this->input->post('state',true);
  781. $lacecolor = $this->input->post('lacecolor',true);
  782. $cklx = $this->input->post('cklx',true);
  783. $ktime = $this->input->post('ktime',true);
  784. $jtime = $this->input->post('jtime',true);
  785. $ktime = strtotime($ktime);
  786. $jtime = strtotime($jtime);
  787. $where = "1=1";$gj = "";$ck = "";
  788. if($lacetype)
  789. {
  790. $where .= " and features like '%-$lacetype-%'";
  791. }
  792. if($category)
  793. {
  794. $where .= " and features like '%-$category-%'";
  795. }
  796. if($size)
  797. {
  798. $where .= " and features like '%-$size-%'";
  799. }
  800. if($grade)
  801. {
  802. $where .= " and features like '%-$grade-%'";
  803. }
  804. if($color)
  805. {
  806. $where .= " and features like '%-$color-%'";
  807. }
  808. if($lowe)
  809. {
  810. $where .= " and features like '%-$lowe-%'";
  811. }
  812. if($haircap)
  813. {
  814. $where .= " and features like '%-$haircap-%'";
  815. }
  816. if($density)
  817. {
  818. $where .= " and features like '%-$density-%'";
  819. }
  820. if($lacecolor)
  821. {
  822. $where .= " and features like '%-$lacecolor-%'";
  823. }
  824. if($usa)
  825. {
  826. if(!$warehouse)
  827. {
  828. $where .= " and (warehouse = '5' or warehouse = '8')";
  829. }
  830. }
  831. if($warehouse)
  832. {
  833. $where .= " and warehouse = '$warehouse'";
  834. }
  835. if($details)
  836. {
  837. $where .= " and details = '$details'";
  838. }
  839. if($purchase)
  840. {
  841. $where .= " and purchase = '$purchase'";
  842. }
  843. if($state)
  844. {
  845. $where .= " and state = '$state'";
  846. }
  847. $where_add = '';
  848. if($cklx)
  849. {
  850. $shop = $this->shop->read($cklx);
  851. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  852. }
  853. if($ktime && $jtime)
  854. {
  855. $gj = " and enter > '$ktime' and enter < '$jtime'";
  856. $ck = " and outk > '$ktime' and outk < '$jtime'";
  857. }
  858. //数据排序
  859. $order_str = "id desc";
  860. if(empty($page))
  861. {
  862. $start = 0;
  863. $perpage = 1;
  864. }
  865. else
  866. {
  867. $start = ($page - 1)*$perpage;
  868. }
  869. if($sku)
  870. {
  871. $sku = trim($sku,' ');
  872. $sku = trim($sku,' ');
  873. $where .= " and sku like '%$sku%'";
  874. $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);
  875. }
  876. else if($title)
  877. {
  878. $title = trim($title,' ');
  879. $title = trim($title,' ');
  880. $where .= " and title like '%$title%'";
  881. $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);
  882. }
  883. else
  884. {
  885. //$where .= " and time > '$ktime' and time < '$jtime'";
  886. $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);
  887. }
  888. //取得信息列表
  889. $rows = array();$list = array();
  890. foreach ($info_list as $key=>$value)
  891. {
  892. $warehouse = $this->warehouse->read($value['warehouse']);
  893. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  894. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
  895. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  896. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
  897. $ftime = time()-15*24*3600;
  898. $info_list[$key]['warehouse'] = $warehouse['title'];
  899. $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
  900. //$z = count($z);//查看订单号
  901. //$info_list[$key]['zd'] = $z;
  902. $details = array();
  903. $cpid = array();
  904. foreach ($c as $k=>$v)
  905. {
  906. $details[$v['details']] = $v['details'];
  907. if($v['cpid'] != 0)
  908. {
  909. $cpid[$v['cpid']] = $v['cpid'];
  910. }
  911. }
  912. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  913. if($value['shop'] != '')
  914. {
  915. $shop = explode(',',trim($value['shop'],','));
  916. $shop = $this->shop->read($shop[0]);
  917. $info_list[$key]['shop'] = $shop['shopname'];
  918. }
  919. }
  920. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  921. $pagenum = ceil($total/$perpage);
  922. $over = $total-($start+$perpage);
  923. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  924. echo json_encode($rows);exit;
  925. }
  926. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  927. $this->_Template('whlabel_typedy_ck',$this->data);
  928. }
  929. public function _typeck($arg_array)
  930. {
  931. $prc = array();
  932. $purchase = $this->purchase->find_all();
  933. foreach($purchase as $k=>$v)
  934. {
  935. $prc[$v['id']] = $v['title'];
  936. }
  937. $post = $this->input->post(NULL, TRUE);
  938. if(isset($post['page']))
  939. {
  940. $page = $this->input->post('page',true);
  941. $perpage = $this->input->post('perpage',true);
  942. $category = $this->input->post('category',true);
  943. $size = $this->input->post('size',true);
  944. $grade = $this->input->post('grade',true);
  945. $color = $this->input->post('color',true);
  946. $lacecolor = $this->input->post('lacecolor',true);
  947. $lowe = $this->input->post('lowe',true);
  948. $sku = $this->input->post('sku');
  949. $title = $this->input->post('title');
  950. $warehouse = 13;
  951. $usa = $this->input->post('usa',true);
  952. $purchase = $this->input->post('purchase',true);
  953. $lacetype = $this->input->post('lacetype',true);
  954. $haircap = $this->input->post('haircap',true);
  955. $density = $this->input->post('density',true);
  956. $details = $this->input->post('details',true);
  957. $state = $this->input->post('state',true);
  958. $ktime = $this->input->post('ktime',true);
  959. $jtime = $this->input->post('jtime',true);
  960. $ktime = strtotime($ktime);
  961. $jtime = strtotime($jtime);
  962. $where = "1=1";$gj = "";$ck = "";
  963. if($lacetype)
  964. {
  965. $where .= " and features like '%-$lacetype-%'";
  966. }
  967. if($category)
  968. {
  969. $where .= " and features like '%-$category-%'";
  970. }
  971. if($size)
  972. {
  973. $where .= " and features like '%-$size-%'";
  974. }
  975. if($grade)
  976. {
  977. $where .= " and features like '%-$grade-%'";
  978. }
  979. if($color)
  980. {
  981. $where .= " and features like '%-$color-%'";
  982. }
  983. if($lacecolor)
  984. {
  985. $where .= " and features like '%-$lacecolor-%'";
  986. }
  987. if($lowe)
  988. {
  989. $where .= " and features like '%-$lowe-%'";
  990. }
  991. if($haircap)
  992. {
  993. $where .= " and features like '%-$haircap-%'";
  994. }
  995. if($density)
  996. {
  997. $where .= " and features like '%-$density-%'";
  998. }
  999. if($warehouse)
  1000. {
  1001. $where .= " and warehouse = '$warehouse'";
  1002. }
  1003. if($details)
  1004. {
  1005. $where .= " and details = '$details'";
  1006. }
  1007. if($purchase)
  1008. {
  1009. $where .= " and purchase = '$purchase'";
  1010. }
  1011. if($state)
  1012. {
  1013. $where .= " and state = '$state'";
  1014. }
  1015. if($ktime && $jtime)
  1016. {
  1017. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1018. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1019. }
  1020. //数据排序
  1021. $order_str = "id desc";
  1022. if(empty($page))
  1023. {
  1024. $start = 0;
  1025. $perpage = 1;
  1026. }
  1027. else
  1028. {
  1029. $start = ($page - 1)*$perpage;
  1030. }
  1031. if($sku)
  1032. {
  1033. $sku = trim($sku,' ');
  1034. $sku = trim($sku,' ');
  1035. $where .= " and sku like '%$sku%'";
  1036. }
  1037. else if($title)
  1038. {
  1039. $title = trim($title,' ');
  1040. $title = trim($title,' ');
  1041. $where .= " and title like '%$title%'";
  1042. }
  1043. $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
  1044. //取得信息列表
  1045. $t = array();
  1046. $typeclass = $this->typeclass->find_all();
  1047. foreach ($typeclass as $v)
  1048. {
  1049. $t[$v['id']] = $v;
  1050. }
  1051. $rows = array();$list = array();
  1052. foreach ($info_list as $key=>$value)
  1053. {
  1054. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1055. $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
  1056. $warehouse = $this->warehouse->read($value['warehouse']);
  1057. $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');
  1058. $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'].'"');
  1059. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1060. $number = $value['number'];$ftime = time()-15*24*3600;
  1061. $z = count($z);//查看订单号
  1062. $info_list[$key]['warehouse'] = $warehouse['title'];
  1063. $info_list[$key]['features'] = count($c);
  1064. $info_list[$key]['number'] = $z;
  1065. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  1066. $details = array();
  1067. $cpid = array();
  1068. foreach ($c as $k=>$v)
  1069. {
  1070. $details[$v['details']] = $v['details'];
  1071. if($v['cpid'] != 0)
  1072. {
  1073. $cpid[$v['cpid']] = $v['cpid'];
  1074. }
  1075. }
  1076. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1077. $classid = $this->classid->sku();
  1078. $pm = $classid;
  1079. $features = explode('-',trim($value['features'],'-'));
  1080. foreach($features as $v)
  1081. {
  1082. $zh = explode('|',trim($t[$v]['zh'],'|'));
  1083. $pm[$t[$v]['classid']] = $zh[0];
  1084. }
  1085. $zh = implode(" ",$pm);
  1086. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1087. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1088. $info_list[$key]['sm'] = $zh;
  1089. }
  1090. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1091. $pagenum = ceil($total/$perpage);
  1092. $over = $total-($start+$perpage);
  1093. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1094. echo json_encode($rows);exit;
  1095. }
  1096. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  1097. $this->_Template('whlabel_typeck',$this->data);
  1098. }
  1099. //进销存导出
  1100. public function _whlabeckdc()
  1101. {
  1102. $prc = array();
  1103. $purchase = $this->purchase->find_all();
  1104. foreach($purchase as $k=>$v)
  1105. {
  1106. $prc[$v['id']] = $v['title'];
  1107. }
  1108. if(isset($_GET['excel']))
  1109. {
  1110. $where = "sku != 'Preset'";
  1111. //数据排序
  1112. $order_str = "id desc";
  1113. if(empty($page))
  1114. {
  1115. $start = 0;
  1116. $perpage = 1;
  1117. }
  1118. else
  1119. {
  1120. $start = ($page - 1)*$perpage;
  1121. }
  1122. $category = $this->input->get('category',true);
  1123. $color = $this->input->get('color',true);
  1124. $lowe = $this->input->get('lowe',true);
  1125. $lacetype = $this->input->get('lacetype',true);
  1126. $size = $this->input->get('size',true);
  1127. $density = $this->input->get('density',true);
  1128. $haircap = $this->input->get('haircap',true);
  1129. $sku = $this->input->get('sku',true);
  1130. $details = $this->input->get('details',true);
  1131. $warehouse = 13;
  1132. $excelid = $this->input->get('sid',true);
  1133. if($category)
  1134. {
  1135. $where .= " and features like '%-$category-%'";
  1136. }
  1137. if($color)
  1138. {
  1139. $where .= " and features like '%-$color-%'";
  1140. }
  1141. if($lowe)
  1142. {
  1143. $where .= " and features like '%-$lowe-%'";
  1144. }
  1145. if($lacetype)
  1146. {
  1147. $where .= " and features like '%-$lacetype-%'";
  1148. }
  1149. if($size)
  1150. {
  1151. $where .= " and features like '%-$size-%'";
  1152. }
  1153. if($density)
  1154. {
  1155. $where .= " and features like '%-$density-%'";
  1156. }
  1157. if($haircap)
  1158. {
  1159. $where .= " and features like '%-$haircap-%'";
  1160. }
  1161. if($warehouse)
  1162. {
  1163. $where .= " and warehouse = '$warehouse'";
  1164. }
  1165. if($sku)
  1166. {
  1167. $where .= " and sku like '%$sku%'";
  1168. }
  1169. if($details)
  1170. {
  1171. $where .= " and details = '$details'";
  1172. }
  1173. $xzid = '';
  1174. if($excelid)
  1175. {
  1176. $excelid = explode(',',trim($excelid,','));
  1177. foreach ($excelid as $key=>$value)
  1178. {
  1179. $xzid .= " id = ".$value." or";
  1180. }
  1181. $xzid = " and (".rtrim($xzid,'or').")";;
  1182. }
  1183. //取得信息列表
  1184. /**
  1185. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1186. $rows = array();$list = array();
  1187. foreach ($info_list as $key=>$value)
  1188. {
  1189. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1190. }
  1191. **/
  1192. $wh = array();
  1193. $w = $this->warehouse->find_all('1=1','id,title');
  1194. foreach ($w as $v)
  1195. {
  1196. $wh[$v['id']] = $v['title'];
  1197. }
  1198. $tc = array();$tcdata = array();
  1199. $typeclass = $this->typeclass->find_all();
  1200. foreach ($typeclass as $v)
  1201. {
  1202. $tc[$v['id']] = $v;
  1203. }
  1204. $list = array();
  1205. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1206. foreach ($rows as $key=>$value)
  1207. {
  1208. $bm = '03';
  1209. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1210. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1211. $classid = $this->classid->sku();
  1212. $pm = $classid;
  1213. $jm = $classid;
  1214. $features = explode('-',trim($value['features'],'-'));
  1215. foreach($features as $v)
  1216. {
  1217. if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
  1218. {
  1219. if($tc[$v]['bm'] != '')
  1220. {
  1221. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1222. }
  1223. }
  1224. if(isset($tc[$v]))
  1225. {
  1226. $zh = explode('|',trim($tc[$v]['zh'],'|'));
  1227. $pm[$tc[$v]['classid']] = $zh[0];
  1228. }
  1229. if(isset($tc[$v]))
  1230. {
  1231. if(isset($jm[$tc[$v]['classid']]))
  1232. {
  1233. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1234. }
  1235. }
  1236. }
  1237. $zh = implode(" ",$pm);
  1238. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1239. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1240. $rows[$key]['dbcontent'] = $zh;
  1241. $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
  1242. $jm = array_filter($jm);
  1243. $rows[$key]['cs'] = implode("-",$jm);
  1244. $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
  1245. $details = array();
  1246. $cpid = array();
  1247. $cpbz = array();
  1248. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  1249. foreach ($sd as $k=>$v)
  1250. {
  1251. if($v['state'] == 0)
  1252. {
  1253. $c++;
  1254. }
  1255. if($v['state'] != 9)
  1256. {
  1257. $g++;
  1258. }
  1259. if($v['state'] == 1)
  1260. {
  1261. $x++;
  1262. }
  1263. if($v['state'] == 2)
  1264. {
  1265. $t++;
  1266. }
  1267. if($v['state'] == 8)
  1268. {
  1269. $s++;
  1270. }
  1271. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  1272. {
  1273. $q++;
  1274. }
  1275. $details[$v['details']] = $v['details'];
  1276. if($v['cpid'] != 0)
  1277. {
  1278. $cpid[$v['cpid']] = $v['cpid'];
  1279. }
  1280. if($v['cpbz'] != '')
  1281. {
  1282. $cpbz[$v['cpbz']] = $v['cpbz'];
  1283. }
  1284. }
  1285. $rows[$key]['details'] = implode("、",$details);
  1286. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  1287. $number = $value['number'];
  1288. $ftime = time()-15*24*3600;
  1289. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1290. $rows[$key]['number'] = $g;
  1291. $rows[$key]['features'] = $c;
  1292. $rows[$key]['x'] = $x;
  1293. $rows[$key]['t'] = $t;
  1294. $rows[$key]['s'] = $s;
  1295. $rows[$key]['q'] = $q;
  1296. $rows[$key]['wzsl'] = count($details);
  1297. }
  1298. $title = "进销存统计表".date('Y-m-d',time());
  1299. $titlename = "<table border=1>
  1300. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  1301. <tr align='center'>
  1302. <td>仓库</td>
  1303. <td>供应商</td>
  1304. <td>位置</td>
  1305. <td>库存编码</td>
  1306. <td>SKU</td>
  1307. <td>用友编码</td>
  1308. <td>用友料号</td>
  1309. <td>产品英文名</td>
  1310. <td>产品中文名</td>
  1311. <td>入库总量</td>
  1312. <td>库存数量</td>
  1313. <td>销售数量</td>
  1314. <td>退货数量</td>
  1315. <td>删除数量</td>
  1316. <td>其它操作</td>
  1317. <td>位置数量</td>
  1318. </tr>
  1319. </table>";
  1320. $filename = $title.".xls";
  1321. $tail = "";
  1322. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1323. }
  1324. }
  1325. public function _type()
  1326. {
  1327. $vip = 0;
  1328. if(isset($_SESSION['api']))
  1329. {
  1330. $user = $this->user->get_api($_SESSION['api']);
  1331. $fgshop = "";$sid = "";
  1332. $usersp = explode('|',trim($user['shop'],'|'));
  1333. foreach ($usersp as $value)
  1334. {
  1335. $fgshop .= " shop = ".$value." or";
  1336. $sid .= " id = ".$value." or";
  1337. }
  1338. if($user['vip'] == 1)
  1339. {
  1340. $vip = 1;
  1341. }
  1342. }
  1343. else
  1344. {
  1345. header('Location: /');exit;
  1346. }
  1347. $prc = array();
  1348. $purchase = $this->purchase->find_all();
  1349. foreach($purchase as $k=>$v)
  1350. {
  1351. $prc[$v['id']] = $v['title'];
  1352. }
  1353. $company = array();
  1354. $ct = $this->company->find_all();
  1355. foreach($ct as $k=>$v)
  1356. {
  1357. $company[$v['id']] = $v['title'];
  1358. }
  1359. $sp = array();
  1360. $s = $this->shop->find_all('1=1','id,shopname');
  1361. foreach ($s as $v)
  1362. {
  1363. $sp[$v['id']] = $v['shopname'];
  1364. }
  1365. $wh = array();
  1366. $w = $this->warehouse->find_all('1=1','id,title');
  1367. foreach ($w as $v)
  1368. {
  1369. $wh[$v['id']] = $v['title'];
  1370. }
  1371. $post = $this->input->post(NULL, TRUE);
  1372. if(isset($post['page']))
  1373. {
  1374. $page = $this->input->post('page',true);
  1375. $perpage = $this->input->post('perpage',true);
  1376. $category = $this->input->post('category',true);
  1377. $size = $this->input->post('size',true);
  1378. $grade = $this->input->post('grade',true);
  1379. $color = $this->input->post('color',true);
  1380. $lowe = $this->input->post('lowe',true);
  1381. $sku = $this->input->post('sku');
  1382. $title = $this->input->post('title');
  1383. $warehouse = $this->input->post('warehouse',true);
  1384. $usa = $this->input->post('usa',true);
  1385. $purchase = $this->input->post('purchase',true);
  1386. $lacetype = $this->input->post('lacetype',true);
  1387. $haircap = $this->input->post('haircap',true);
  1388. $density = $this->input->post('density',true);
  1389. $details = $this->input->post('details',true);
  1390. $state = $this->input->post('state',true);
  1391. $shop = $this->input->post('shop',true);
  1392. $lacecolor = $this->input->post('lacecolor',true);
  1393. $hairnumber = $this->input->post('hairnumber',true);
  1394. $type = $this->input->post('type',true);
  1395. $ktime = $this->input->post('ktime',true);
  1396. $jtime = $this->input->post('jtime',true);
  1397. $ktime = strtotime($ktime);
  1398. $jtime = strtotime($jtime);
  1399. $where = "1=1";$gj = "";$ck = "";
  1400. if($usa)
  1401. {
  1402. if(!$warehouse)
  1403. {
  1404. $where .= " and (warehouse = '5' or warehouse = '8')";
  1405. }
  1406. }
  1407. if($warehouse)
  1408. {
  1409. $where .= " and warehouse = '$warehouse'";
  1410. }
  1411. if($details)
  1412. {
  1413. $where .= " and details = '$details'";
  1414. }
  1415. if($purchase)
  1416. {
  1417. $where .= " and purchase = '$purchase'";
  1418. }
  1419. if($state)
  1420. {
  1421. $where .= " and state = '$state'";
  1422. }
  1423. if($shop)
  1424. {
  1425. $where .= " and shop like '%$shop%'";
  1426. }
  1427. if($type)
  1428. {
  1429. $where .= " and type = '$type'";
  1430. }
  1431. if($ktime && $jtime)
  1432. {
  1433. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1434. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1435. }
  1436. if($lacecolor)
  1437. {
  1438. $where .= " and features like '%-$lacecolor-%'";
  1439. }
  1440. if($lacetype)
  1441. {
  1442. $where .= " and features like '%-$lacetype-%'";
  1443. }
  1444. if($category)
  1445. {
  1446. $where .= " and features like '%-$category-%'";
  1447. }
  1448. if($size)
  1449. {
  1450. $where .= " and features like '%-$size-%'";
  1451. }
  1452. if($grade)
  1453. {
  1454. $where .= " and features like '%-$grade-%'";
  1455. }
  1456. if($color)
  1457. {
  1458. $where .= " and features like '%-$color-%'";
  1459. }
  1460. if($lowe)
  1461. {
  1462. $where .= " and features like '%-$lowe-%'";
  1463. }
  1464. if($haircap)
  1465. {
  1466. $where .= " and features like '%-$haircap-%'";
  1467. }
  1468. if($density)
  1469. {
  1470. $where .= " and features like '%-$density-%'";
  1471. }
  1472. if(!empty($hairnumber)){
  1473. $where .= " and features like '%-128-%' ";
  1474. if($hairnumber < 0){
  1475. $class_list = $this->typeclass->find_all('classid = 43');
  1476. foreach($class_list as $v){
  1477. $where .= " and features not like '%-".$v['id']."-%'";
  1478. }
  1479. }else{
  1480. $where .= " and features like '%-$hairnumber-%'";
  1481. }
  1482. }
  1483. //数据排序
  1484. $order_str = "id desc";
  1485. if(empty($page))
  1486. {
  1487. $start = 0;
  1488. $perpage = 1;
  1489. }
  1490. else
  1491. {
  1492. $start = ($page - 1)*$perpage;
  1493. }
  1494. $fjnr = '';
  1495. if($sku)
  1496. {
  1497. $sku = trim($sku,' ');
  1498. $sku = trim($sku,' ');
  1499. $fjnr .= " and sku like '%$sku%'";
  1500. }
  1501. if($title)
  1502. {
  1503. $title = trim($title,' ');
  1504. $title = trim($title,' ');
  1505. $fjnr .= " and title like '%$title%'";
  1506. }
  1507. $wt = array();
  1508. $whlabel_type = $this->whlabel_type->find_all();
  1509. foreach ($whlabel_type as $v)
  1510. {
  1511. $wt[$v['id']] = $v['title'];
  1512. }
  1513. //$where .= " and time > '$ktime' and time < '$jtime'";
  1514. $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
  1515. //取得信息列表
  1516. $rows = array();$list = array();
  1517. foreach ($info_list as $key=>$value)
  1518. {
  1519. if(isset($wt[$value['type']]))
  1520. {
  1521. $info_list[$key]['type'] = $wt[$value['type']];
  1522. }
  1523. else
  1524. {
  1525. $info_list[$key]['type'] = '未设置';
  1526. }
  1527. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1528. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1529. $ztdata = '';
  1530. if(count($zt) > 0)
  1531. {
  1532. foreach ($zt as $vv)
  1533. {
  1534. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1535. }
  1536. }
  1537. $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1538. $cdata = array_filter($qbdata, function($item) {
  1539. return $item['state'] < 1;
  1540. });
  1541. $c = array_sum(array_column($cdata, 'jnum'));
  1542. $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1543. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1544. });
  1545. $g = array_sum(array_column($gdata, 'jnum'));
  1546. $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1547. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1548. });
  1549. $x = array_sum(array_column($xdata, 'jnum'));
  1550. $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1551. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1552. });
  1553. $t = array_sum(array_column($tdata, 'jnum'));
  1554. $zdata = array_filter($qbdata, function($item) {
  1555. return $item['zd'] != "" && $item['state'] < 1;
  1556. });
  1557. $z = array_sum(array_column($zdata, 'jnum'));
  1558. $zdata = array_filter($qbdata, function($item) {
  1559. return $item['zd'] != "" && $item['state'] < 1;
  1560. });
  1561. $z = array_sum(array_column($zdata, 'jnum'));
  1562. //$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');
  1563. //$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'].'"');
  1564. //$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'].'"');
  1565. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1566. //$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'].'"');
  1567. $details = array();
  1568. $cpid = array();
  1569. $od = array();$odid = '';
  1570. $companytitle = '';
  1571. foreach ($qbdata as $v)
  1572. {
  1573. if($v['zd'] != "" && $v['state'] < 1)
  1574. {
  1575. if(!isset($od[$v['zd']]))
  1576. {
  1577. $od[$v['zd']] = 1;//所有数据sku
  1578. }
  1579. else
  1580. {
  1581. $od[$v['zd']] = $od[$v['zd']]+1;
  1582. }
  1583. }
  1584. if($v['state'] < 1)
  1585. {
  1586. $details[$v['details']] = $v['details'];
  1587. if($v['cpid'] != 0)
  1588. {
  1589. $cpid[$v['cpid']] = $v['cpid'];
  1590. }
  1591. }
  1592. if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
  1593. {
  1594. $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
  1595. }
  1596. }
  1597. foreach ($od as $k=>$vv)
  1598. {
  1599. $odid .= $k.'数量'.$vv;
  1600. }
  1601. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1602. $number = $value['number'];$ftime = time()-15*24*3600;
  1603. $z = $z.'('.$odid.')';//查看订单号
  1604. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1605. $info_list[$key]['features'] = $c;
  1606. $info_list[$key]['number'] = $ztdata;
  1607. $info_list[$key]['sm'] = $g;
  1608. $info_list[$key]['x'] = $x;
  1609. $info_list[$key]['t'] = $t;
  1610. $info_list[$key]['z'] = $z;
  1611. /**
  1612. foreach ($cdata as $k=>$v)
  1613. {
  1614. $details[$v['details']] = $v['details'];
  1615. if($v['cpid'] != 0)
  1616. {
  1617. $cpid[$v['cpid']] = $v['cpid'];
  1618. }
  1619. }
  1620. **/
  1621. $info_list[$key]['shop'] = '';
  1622. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1623. if($value['shop'] != '')
  1624. {
  1625. $shop = explode(',',trim($value['shop'],','));
  1626. $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
  1627. }
  1628. $info_list[$key]['shop'] .= $companytitle;
  1629. /**
  1630. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1631. if(isset($companytitle[0]))
  1632. {
  1633. foreach ($companytitle as $k=>$v)
  1634. {
  1635. if($v['companytitle'] != '')
  1636. {
  1637. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1638. }
  1639. }
  1640. }
  1641. **/
  1642. }
  1643. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1644. $pagenum = ceil($total/$perpage);
  1645. $over = $total-($start+$perpage);
  1646. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1647. echo json_encode($rows);exit;
  1648. }
  1649. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1650. $this->data['shop'] = $wlshop;
  1651. $this->data['vip'] = $vip;
  1652. $this->_Template('whlabel_type',$this->data);
  1653. }
  1654. //美仓进销存浏览
  1655. public function _usatype()
  1656. {
  1657. if(isset($_SESSION['api']))
  1658. {
  1659. $user = $this->user->get_api($_SESSION['api']);
  1660. $usp = $user;
  1661. $fgshop = "";$sid = "";$wid="";$wtype="";
  1662. $userwh = explode('|',trim($user['warehouse'],'|'));
  1663. foreach ($userwh as $value)
  1664. {
  1665. $wid .= " id = ".$value." or";
  1666. $wtype .= " type = ".$value." or";
  1667. }
  1668. }
  1669. $prc = array();
  1670. $purchase = $this->purchase->find_all();
  1671. foreach($purchase as $k=>$v)
  1672. {
  1673. $prc[$v['id']] = $v['title'];
  1674. }
  1675. $post = $this->input->post(NULL, TRUE);
  1676. if(isset($post['page']))
  1677. {
  1678. $page = $this->input->post('page',true);
  1679. $perpage = $this->input->post('perpage',true);
  1680. $category = $this->input->post('category',true);
  1681. $size = $this->input->post('size',true);
  1682. $grade = $this->input->post('grade',true);
  1683. $color = $this->input->post('color',true);
  1684. $lowe = $this->input->post('lowe',true);
  1685. $sku = $this->input->post('sku');
  1686. $title = $this->input->post('title');
  1687. $warehouse = $this->input->post('warehouse',true);
  1688. $usa = $this->input->post('usa',true);
  1689. $purchase = $this->input->post('purchase',true);
  1690. $lacetype = $this->input->post('lacetype',true);
  1691. $haircap = $this->input->post('haircap',true);
  1692. $density = $this->input->post('density',true);
  1693. $details = $this->input->post('details',true);
  1694. $state = $this->input->post('state',true);
  1695. $lacecolor = $this->input->post('lacecolor',true);
  1696. $cklx = $this->input->post('cklx',true);
  1697. $ktime = $this->input->post('ktime',true);
  1698. $jtime = $this->input->post('jtime',true);
  1699. $ktime = strtotime($ktime);
  1700. $jtime = strtotime($jtime);
  1701. $where = "1=1";$gj = "";$ck = "";
  1702. if($lacetype)
  1703. {
  1704. $where .= " and features like '%-$lacetype-%'";
  1705. }
  1706. if($category)
  1707. {
  1708. $where .= " and features like '%-$category-%'";
  1709. }
  1710. if($size)
  1711. {
  1712. $where .= " and features like '%-$size-%'";
  1713. }
  1714. if($grade)
  1715. {
  1716. $where .= " and features like '%-$grade-%'";
  1717. }
  1718. if($color)
  1719. {
  1720. $where .= " and features like '%-$color-%'";
  1721. }
  1722. if($lowe)
  1723. {
  1724. $where .= " and features like '%-$lowe-%'";
  1725. }
  1726. if($haircap)
  1727. {
  1728. $where .= " and features like '%-$haircap-%'";
  1729. }
  1730. if($density)
  1731. {
  1732. $where .= " and features like '%-$density-%'";
  1733. }
  1734. if($lacecolor)
  1735. {
  1736. $where .= " and features like '%-$lacecolor-%'";
  1737. }
  1738. if($usa)
  1739. {
  1740. if(!$warehouse)
  1741. {
  1742. $where .= " and (warehouse = '5' or warehouse = '8')";
  1743. }
  1744. }
  1745. if($warehouse)
  1746. {
  1747. $where .= " and warehouse = '$warehouse'";
  1748. }
  1749. if($details)
  1750. {
  1751. $where .= " and details = '$details'";
  1752. }
  1753. if($purchase)
  1754. {
  1755. $where .= " and purchase = '$purchase'";
  1756. }
  1757. if($state)
  1758. {
  1759. $where .= " and state = '$state'";
  1760. }
  1761. $where_add = '';
  1762. if($cklx)
  1763. {
  1764. $shop = $this->shop->read($cklx);
  1765. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1766. }
  1767. if($ktime && $jtime)
  1768. {
  1769. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1770. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1771. }
  1772. //数据排序
  1773. $order_str = "id desc";
  1774. if(empty($page))
  1775. {
  1776. $start = 0;
  1777. $perpage = 1;
  1778. }
  1779. else
  1780. {
  1781. $start = ($page - 1)*$perpage;
  1782. }
  1783. if($sku)
  1784. {
  1785. $sku = trim($sku,' ');
  1786. $sku = trim($sku,' ');
  1787. $where .= " and sku like '%$sku%'";
  1788. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1789. }
  1790. else if($title)
  1791. {
  1792. $title = trim($title,' ');
  1793. $title = trim($title,' ');
  1794. $where .= " and title like '%$title%'";
  1795. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1796. }
  1797. else
  1798. {
  1799. //$where .= " and time > '$ktime' and time < '$jtime'";
  1800. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1801. }
  1802. //取得信息列表
  1803. $rows = array();$list = array();
  1804. foreach ($info_list as $key=>$value)
  1805. {
  1806. $warehouse = $this->warehouse->read($value['warehouse']);
  1807. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1808. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1809. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1810. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1811. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1812. $od = array();$odid = '';
  1813. foreach ($z as $v)
  1814. {
  1815. if(!isset($od[$v['zd']]))
  1816. {
  1817. $od[$v['zd']] = 1;//所有数据sku
  1818. }
  1819. else
  1820. {
  1821. $od[$v['zd']] = $od[$v['zd']]+1;
  1822. }
  1823. }
  1824. foreach ($od as $k=>$vv)
  1825. {
  1826. $odid .= $k.'数量'.$vv.' ';
  1827. }
  1828. $z = count($z).'('.$odid.')';//查看订单号
  1829. $info_list[$key]['features'] = $c;
  1830. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1831. $ztdata = '';
  1832. if(count($zt) > 0)
  1833. {
  1834. foreach ($zt as $vv)
  1835. {
  1836. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1837. }
  1838. }
  1839. $info_list[$key]['warehouse'] = $ztdata;
  1840. $info_list[$key]['g'] = $g;
  1841. $info_list[$key]['x'] = $x;
  1842. $info_list[$key]['t'] = $t;
  1843. $info_list[$key]['z'] = $z;
  1844. }
  1845. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1846. $pagenum = ceil($total/$perpage);
  1847. $over = $total-($start+$perpage);
  1848. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1849. echo json_encode($rows);exit;
  1850. }
  1851. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1852. $this->data['warehouse'] = $warehouse;
  1853. $this->_Template('whlabel_typeusa',$this->data);
  1854. }
  1855. //美仓进销存浏览
  1856. public function _usatypeapp()
  1857. {
  1858. $post = $this->input->post(NULL, TRUE);
  1859. if(isset($post['page']))
  1860. {
  1861. $page = $this->input->post('page',true);
  1862. $perpage = $this->input->post('perpage',true);
  1863. $sku = $this->input->post('sku',true);
  1864. $warehouse = 5;
  1865. $title = $this->input->post('title',true);
  1866. $state = $this->input->post('state',true);
  1867. $ktime = $this->input->post('ktime',true);
  1868. $jtime = $this->input->post('jtime',true);
  1869. $ktime = strtotime($ktime);
  1870. $jtime = strtotime($jtime);
  1871. $where = "1=1";$gj = "";$ck = "";
  1872. if($title)
  1873. {
  1874. $st = explode(' ',trim($title,' '));
  1875. foreach ($st as $v)
  1876. {
  1877. $where .= " and title like '%$v%'";
  1878. }
  1879. }
  1880. if($warehouse)
  1881. {
  1882. $where .= " and warehouse = '$warehouse'";
  1883. }
  1884. if($state)
  1885. {
  1886. $where .= " and state = '$state'";
  1887. }
  1888. if($sku)
  1889. {
  1890. $where .= " and sku like '%$sku%'";
  1891. }
  1892. if($ktime && $jtime)
  1893. {
  1894. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1895. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1896. }
  1897. //数据排序
  1898. $order_str = "id desc";
  1899. if(empty($page))
  1900. {
  1901. $start = 0;
  1902. $perpage = 1;
  1903. }
  1904. else
  1905. {
  1906. $start = ($page - 1)*$perpage;
  1907. }
  1908. //取得信息列表
  1909. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1910. $rows = array();$list = array();
  1911. foreach ($info_list as $key=>$value)
  1912. {
  1913. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1914. }
  1915. $rowsdq = array_slice($rows,$start,$perpage);
  1916. foreach ($rowsdq as $value)
  1917. {
  1918. $warehouse = $this->warehouse->read($value['warehouse']);
  1919. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1920. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1921. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1922. $od = array();$odid = '';
  1923. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1924. }
  1925. $total = count($rows);
  1926. $pagenum = ceil($total/$perpage);
  1927. $over = $total-($start+$perpage);
  1928. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1929. echo json_encode($rows);exit;
  1930. }
  1931. $this->_Template('phone/p_usatypeapp',$this->data);
  1932. }
  1933. //入库操作
  1934. public function _enteradd()
  1935. {
  1936. $dt = 0;
  1937. if(isset($_SESSION['api']))
  1938. {
  1939. $user = $this->user->get_api($_SESSION['api']);
  1940. $usp = $user;
  1941. $fgshop = "";$sid = "";
  1942. $user = explode('|',trim($user['shop'],'|'));
  1943. foreach ($user as $value)
  1944. {
  1945. $fgshop .= " shop = ".$value." or";
  1946. $sid .= " id = ".$value." or";
  1947. }
  1948. }
  1949. $tc = $this->typeclass->find_all();
  1950. $typeclass = array();
  1951. foreach ($tc as $v)
  1952. {
  1953. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1954. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  1955. }
  1956. $post = $this->input->post(NULL, TRUE);
  1957. if(isset($post['sku']))
  1958. {
  1959. $list = array();$num = "";$title = "";$features = "";
  1960. $order = $this->input->post('order',true);
  1961. $shop = $this->input->post('shop',true);
  1962. $post['shop'] = ($shop!="")?','.$shop:"";
  1963. $sku = $this->input->post('sku',true);
  1964. $post['sm'] = $this->input->post('sm',true);
  1965. $post['warehouse'] = $this->input->post('warehouse',true);
  1966. $post['purchase'] = $this->input->post('purchase',true);
  1967. $post['retreatwarehouse'] = $post['warehouse'];
  1968. $post['state'] = $this->input->post('state',true);
  1969. $post['rktype'] = $this->input->post('rktype',true);
  1970. $post['text'] = $this->input->post('text',true);
  1971. $category = $this->input->post('category',true);
  1972. $list['category'] = $category;
  1973. $list['hairtype'] = $this->input->post('hairtype',true);
  1974. $list['grade'] = $this->input->post('grade',true);
  1975. $size = $this->input->post('size',true);
  1976. $xzsku = $this->input->post('xzsku',true);
  1977. $list['size'] = rtrim($size,',');
  1978. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1979. $list['extension'] = $this->input->post('extension',true);
  1980. if($category == 1297)
  1981. {
  1982. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1983. }
  1984. if($category == 1702)
  1985. {
  1986. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1987. $list['syother'] = $this->input->post('syother',true);
  1988. }
  1989. if($category == 133)
  1990. {
  1991. $list['fittype'] = $this->input->post('fittype',true);
  1992. $list['acother'] = $this->input->post('acother',true);
  1993. }
  1994. $list['color'] = $this->input->post('color',true);
  1995. $list['lowe'] = $this->input->post('lowe',true);
  1996. if(!$post['purchase'])
  1997. {
  1998. $post['purchase'] = 1;
  1999. }
  2000. if($category == 127)
  2001. {
  2002. $list['type'] = $this->input->post('type',true);
  2003. $list['headroad'] = $this->input->post('headroad',true);
  2004. $list['density'] = $this->input->post('density',true);
  2005. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2006. {
  2007. $list['lacesize'] = $this->input->post('lacesize',true);
  2008. }
  2009. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2010. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2011. }
  2012. if($category == 128)
  2013. {
  2014. $list['lacetype'] = $this->input->post('lacetype',true);
  2015. $list['haircap'] = $this->input->post('haircap',true);
  2016. $list['density'] = $this->input->post('density',true);
  2017. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2018. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2019. $list['wigother'] = $this->input->post('wigother',true);
  2020. $list['wigother2'] = $this->input->post('wigother2',true);
  2021. }
  2022. if($category == 129)
  2023. {
  2024. $list['wide'] = $this->input->post('wide',true);
  2025. }
  2026. if($category == 131)
  2027. {
  2028. $list['gifttype'] = $this->input->post('gifttype',true);
  2029. $list['giftother'] = $this->input->post('giftother',true);
  2030. }
  2031. if($category == 134)
  2032. {
  2033. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2034. }
  2035. if($category == 1297)
  2036. {
  2037. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2038. $list['sywigother'] = $this->input->post('sywigother',true);
  2039. }
  2040. if($category == 130 || $category == 133 || $category == 1702)
  2041. {
  2042. $list['items'] = $this->input->post('items',true);
  2043. $list['weight'] = $this->input->post('weight',true);
  2044. }
  2045. if($category == 1702)
  2046. {
  2047. $list['syhairther'] = $this->input->post('syhairther',true);
  2048. }
  2049. $classid = $this->classid->sku();
  2050. $scsku = $classid;
  2051. $pm = $classid;
  2052. foreach($list as $k=>$v)
  2053. {
  2054. if($v != 0)
  2055. {
  2056. $num .=$v;
  2057. $features .=$v.'-';
  2058. $post[$k] = $v;
  2059. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2060. if($k != 'size')
  2061. {
  2062. $title .= $typeclass[$v]['title']." ";
  2063. }
  2064. if(isset($pm[$typeclass[$v]['classid']]))
  2065. {
  2066. if($typeclass[$v]['title'] == '9A')
  2067. {
  2068. $pm[$typeclass[$v]['classid']] = '9A';
  2069. }
  2070. else if($typeclass[$v]['title'] == '10A')
  2071. {
  2072. $pm[$typeclass[$v]['classid']] = '10A';
  2073. }
  2074. else
  2075. {
  2076. $clzh = $typeclass[$v]['zh'];
  2077. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2078. {
  2079. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2080. $clzh = $clzh[0];
  2081. }
  2082. $pm[$typeclass[$v]['classid']] = $clzh;
  2083. }
  2084. }
  2085. }
  2086. }
  2087. $zh = implode(" ",$pm);
  2088. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2089. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2090. if($list['size'])
  2091. {
  2092. $typeclass = $this->typeclass->read($list['size']);
  2093. $title .= $typeclass['title'];
  2094. }
  2095. $time = time();
  2096. if($xzsku)
  2097. {
  2098. $scsku = implode("-",$scsku);
  2099. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2100. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2101. $post['sku'] = trim($scsku,' ');
  2102. }
  2103. else
  2104. {
  2105. $post['sku'] = $sku;
  2106. }
  2107. //$post['sku'] = trim($sku,' ');
  2108. $post['title'] = rtrim($title,' ');
  2109. $post['number'] = $num;
  2110. $post['features'] = '-'.$features;
  2111. $post['enter'] = $time;
  2112. $post['time'] = $time;//操作时间
  2113. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2114. if($yza)
  2115. {
  2116. if($post['features'] != $yza[0]['features'])
  2117. {
  2118. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2119. }
  2120. }
  2121. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2122. if($yzb)
  2123. {
  2124. if($post['sku'] != $yzb[0]['sku'])
  2125. {
  2126. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2127. }
  2128. }
  2129. if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2130. {
  2131. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2132. }
  2133. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2134. {
  2135. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2136. }
  2137. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2138. {
  2139. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2140. }
  2141. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2142. if(isset($yz[0]['type']))
  2143. {
  2144. $post['type'] = $yz[0]['type'];
  2145. }
  2146. if($post['state'] == 9)//如果选择预设库存
  2147. {
  2148. $this->whlabel->insert($post);
  2149. }
  2150. else
  2151. {
  2152. /**
  2153. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2154. if($ljg == 1)
  2155. {
  2156. for($i=0;$i<$order;$i++)
  2157. {
  2158. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2159. $this->whlabel->insert($post);
  2160. }
  2161. }
  2162. **/
  2163. //if($post['warehouse'] == '5')
  2164. //{
  2165. //}
  2166. $yydata = $post;
  2167. $yydata['zh'] = $zh;
  2168. /**
  2169. $wl = $this->apiyy->get_cjlp($yydata);
  2170. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2171. {
  2172. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2173. }
  2174. if($wl['Data'][0]['m_isSucess'] != 1)
  2175. {
  2176. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2177. }
  2178. **/
  2179. for($i=0;$i<$order;$i++)
  2180. {
  2181. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2182. $this->whlabel->insert($post);
  2183. }
  2184. }
  2185. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2186. }
  2187. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2188. $this->data['wlshop'] = $wlshop;
  2189. $this->_Template('whlabel_enteradd',$this->data);
  2190. }
  2191. //修改产品
  2192. public function _enteredit($arg_array)
  2193. {
  2194. $dt = 0;
  2195. if(isset($_SESSION['api']))
  2196. {
  2197. $user = $this->user->get_api($_SESSION['api']);
  2198. $usp = $user;
  2199. $fgshop = "";$sid = "";
  2200. $user = explode('|',trim($user['shop'],'|'));
  2201. foreach ($user as $value)
  2202. {
  2203. $fgshop .= " shop = ".$value." or";
  2204. $sid .= " id = ".$value." or";
  2205. }
  2206. }
  2207. $post = $this->input->post(NULL, TRUE);
  2208. if(isset($post['sku']))
  2209. {
  2210. $list = array();$num = "";$title = "";$features = "";
  2211. $id = $this->input->post('id',true);
  2212. $order = $this->input->post('order',true);
  2213. $shop = $this->input->post('shop',true);
  2214. $post['shop'] = ($shop!="")?','.$shop:"";
  2215. $post['sku'] = $this->input->post('sku',true);
  2216. $post['sm'] = $this->input->post('sm',true);
  2217. $post['warehouse'] = $this->input->post('warehouse',true);
  2218. $post['purchase'] = $this->input->post('purchase',true);
  2219. $post['retreatwarehouse'] = $post['warehouse'];
  2220. $category = $this->input->post('category',true);
  2221. $list['category'] = $category;
  2222. $list['hairtype'] = $this->input->post('hairtype',true);
  2223. $list['grade'] = $this->input->post('grade',true);
  2224. $size = $this->input->post('size',true);
  2225. $list['size'] = rtrim($size,',');
  2226. $post['rktype'] = $this->input->post('rktype',true);
  2227. $post['text'] = $this->input->post('text',true);
  2228. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2229. $list['extension'] = $this->input->post('extension',true);
  2230. if($category == 1297)
  2231. {
  2232. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2233. }
  2234. if($category == 1702)
  2235. {
  2236. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2237. $list['syother'] = $this->input->post('syother',true);
  2238. }
  2239. if($category == 133)
  2240. {
  2241. $list['fittype'] = $this->input->post('fittype',true);
  2242. $list['acother'] = $this->input->post('acother',true);
  2243. }
  2244. $list['color'] = $this->input->post('color',true);
  2245. $list['lowe'] = $this->input->post('lowe',true);
  2246. if(!$post['purchase'])
  2247. {
  2248. $post['purchase'] = 1;
  2249. }
  2250. if($category == 127)
  2251. {
  2252. $list['type'] = $this->input->post('type',true);
  2253. $list['headroad'] = $this->input->post('headroad',true);
  2254. $list['density'] = $this->input->post('density',true);
  2255. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2256. {
  2257. $list['lacesize'] = $this->input->post('lacesize',true);
  2258. }
  2259. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2260. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2261. }
  2262. if($category == 128)
  2263. {
  2264. $list['lacetype'] = $this->input->post('lacetype',true);
  2265. $list['haircap'] = $this->input->post('haircap',true);
  2266. $list['density'] = $this->input->post('density',true);
  2267. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2268. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2269. $list['wigother'] = $this->input->post('wigother',true);
  2270. $list['wigother2'] = $this->input->post('wigother2',true);
  2271. }
  2272. if($category == 129)
  2273. {
  2274. $list['wide'] = $this->input->post('wide',true);
  2275. }
  2276. if($category == 131)
  2277. {
  2278. $list['gifttype'] = $this->input->post('gifttype',true);
  2279. $list['giftother'] = $this->input->post('giftother',true);
  2280. }
  2281. if($category == 134)
  2282. {
  2283. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2284. }
  2285. if($category == 1297)
  2286. {
  2287. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2288. $list['sywigother'] = $this->input->post('sywigother',true);
  2289. }
  2290. if($category == 130 || $category == 133 || $category == 1702)
  2291. {
  2292. $list['items'] = $this->input->post('items',true);
  2293. $list['weight'] = $this->input->post('weight',true);
  2294. }
  2295. if($category == 1702)
  2296. {
  2297. $list['syhairther'] = $this->input->post('syhairther',true);
  2298. }
  2299. foreach($list as $k=>$v)
  2300. {
  2301. if($v != 0)
  2302. {
  2303. $num .=$v;
  2304. $features .=$v.'-';
  2305. $typeclass = $this->typeclass->read($v);
  2306. if($k != 'size')
  2307. {
  2308. $title .= $typeclass['title']." ";
  2309. }
  2310. }
  2311. }
  2312. $typeclass = $this->typeclass->read($list['size']);
  2313. $title .= $typeclass['title'];
  2314. $time = time();
  2315. $post['title'] = rtrim($title,' ');
  2316. $post['number'] = $num;
  2317. $post['features'] = '-'.$features;
  2318. $post['time'] = $time;//操作时间
  2319. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2320. {
  2321. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2322. }
  2323. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2324. {
  2325. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2326. }
  2327. $uid = $this->whlabel->read($id);
  2328. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2329. if($datanum > 0)
  2330. {
  2331. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2332. }
  2333. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2334. {
  2335. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2336. if($yza)
  2337. {
  2338. if($post['features'] != $yza[0]['features'])
  2339. {
  2340. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2341. }
  2342. }
  2343. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2344. if($yzb)
  2345. {
  2346. if($post['sku'] != $yzb[0]['sku'])
  2347. {
  2348. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2349. }
  2350. }
  2351. if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2352. {
  2353. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2354. }
  2355. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2356. foreach ($data as $v)
  2357. {
  2358. $post['id'] = $v['id'];
  2359. $this->whlabel->save($post,$v['id']);
  2360. }
  2361. }
  2362. else
  2363. {
  2364. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2365. if($data > 0)
  2366. {
  2367. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2368. }
  2369. else
  2370. {
  2371. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2372. foreach ($data as $v)
  2373. {
  2374. $post['id'] = $v['id'];
  2375. $this->whlabel->save($post,$v['id']);
  2376. }
  2377. }
  2378. }
  2379. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2380. }
  2381. $uid = $this->whlabel->read($arg_array[0]);
  2382. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2383. $this->data['enter'] = $uid ;
  2384. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2385. $this->data['wlshop'] = $wlshop;
  2386. $this->_Template('whlabel_enteredit',$this->data);
  2387. }
  2388. //入库浏览
  2389. public function _enter()
  2390. {
  2391. $post = $this->input->post(NULL, TRUE);
  2392. if(isset($post['s']))
  2393. {
  2394. $id_arr = $this->input->post('s');
  2395. $id_arr = explode(',',$id_arr);
  2396. if(!$id_arr)
  2397. {
  2398. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2399. }
  2400. //循环删除记录
  2401. foreach ($id_arr as $v)
  2402. {
  2403. $sid = $this->whlabel->read($v);
  2404. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2405. if($count > 0)
  2406. {
  2407. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2408. }
  2409. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2410. foreach ($info_list as $va)
  2411. {
  2412. $this->whlabel->remove($va['id']);
  2413. }
  2414. }
  2415. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2416. }
  2417. $sp = array();
  2418. $s = $this->shop->find_all('1=1','id,shopname');
  2419. foreach ($s as $v)
  2420. {
  2421. $sp[$v['id']] = $v['shopname'];
  2422. }
  2423. $wh = array();
  2424. $w = $this->warehouse->find_all('1=1','id,title');
  2425. foreach ($w as $v)
  2426. {
  2427. $wh[$v['id']] = $v['title'];
  2428. }
  2429. if(isset($post['page']))
  2430. {
  2431. $page = $this->input->post('page',true);
  2432. $perpage = $this->input->post('perpage',true);
  2433. $category = $this->input->post('category',true);
  2434. $size = $this->input->post('size',true);
  2435. $grade = $this->input->post('grade',true);
  2436. $color = $this->input->post('color',true);
  2437. $lowe = $this->input->post('lowe',true);
  2438. $sku = $this->input->post('sku',true);
  2439. $warehouse = $this->input->post('warehouse',true);
  2440. $purchase = $this->input->post('purchase',true);
  2441. $ktime = $this->input->post('ktime',true);
  2442. $jtime = $this->input->post('jtime',true);
  2443. $ktime = strtotime($ktime);
  2444. $jtime = strtotime($jtime);
  2445. $where = "1=1";$gj = "";$ck = "";
  2446. if($category)
  2447. {
  2448. $where .= " and features like '%-$category-%'";
  2449. }
  2450. if($size)
  2451. {
  2452. $where .= " and features like '%-$size-%'";
  2453. }
  2454. if($grade)
  2455. {
  2456. $where .= " and features like '%-$grade-%'";
  2457. }
  2458. if($color)
  2459. {
  2460. $where .= " and features like '%-$color-%'";
  2461. }
  2462. if($lowe)
  2463. {
  2464. $where .= " and features like '%-$lowe-%'";
  2465. }
  2466. if($warehouse)
  2467. {
  2468. $where .= " and warehouse = '$warehouse'";
  2469. }
  2470. if($purchase)
  2471. {
  2472. $where .= " and purchase = '$purchase'";
  2473. }
  2474. if($sku)
  2475. {
  2476. $where .= " and sku like '%$sku%'";
  2477. }
  2478. if($ktime && $jtime)
  2479. {
  2480. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2481. }
  2482. //数据排序
  2483. $order_str = "enter desc";
  2484. if(empty($page))
  2485. {
  2486. $start = 0;
  2487. $perpage = 1;
  2488. }
  2489. else
  2490. {
  2491. $start = ($page - 1)*$perpage;
  2492. }
  2493. //取得信息列表
  2494. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2495. foreach ($info_list as $k=>$v)
  2496. {
  2497. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2498. if($v['shop']=='')
  2499. {
  2500. $s = '通用';
  2501. }
  2502. else
  2503. {
  2504. $info_list[$k]['shop'] = '';
  2505. foreach (explode(',',trim($v['shop'],',')) as $val)
  2506. {
  2507. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2508. }
  2509. }
  2510. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2511. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2512. $info_list[$k]['g'] = $g;
  2513. }
  2514. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2515. $pagenum = ceil($total/$perpage);
  2516. $over = $total-($start+$perpage);
  2517. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2518. echo json_encode($rows);exit;
  2519. }
  2520. $this->_Template('whlabel_enter',$this->data);
  2521. }
  2522. //出库浏览
  2523. public function _out()
  2524. {
  2525. $post = $this->input->post(NULL, TRUE);
  2526. if(isset($post['page']))
  2527. {
  2528. $page = $this->input->post('page',true);
  2529. $perpage = $this->input->post('perpage',true);
  2530. $category = $this->input->post('category',true);
  2531. $size = $this->input->post('size',true);
  2532. $grade = $this->input->post('grade',true);
  2533. $color = $this->input->post('color',true);
  2534. $lowe = $this->input->post('lowe',true);
  2535. $sku = $this->input->post('sku',true);
  2536. $warehouse = $this->input->post('warehouse',true);
  2537. $purchase = $this->input->post('purchase',true);
  2538. $state = $this->input->post('state',true);
  2539. $ktime = $this->input->post('ktime',true);
  2540. $jtime = $this->input->post('jtime',true);
  2541. $ktime = strtotime($ktime);
  2542. $jtime = strtotime($jtime);
  2543. $where = "state=3";$gj = "";$ck = "";
  2544. if($category)
  2545. {
  2546. $where .= " and features like '%-$category-%'";
  2547. }
  2548. if($size)
  2549. {
  2550. $where .= " and features like '%-$size-%'";
  2551. }
  2552. if($grade)
  2553. {
  2554. $where .= " and features like '%-$grade-%'";
  2555. }
  2556. if($color)
  2557. {
  2558. $where .= " and features like '%-$color-%'";
  2559. }
  2560. if($lowe)
  2561. {
  2562. $where .= " and features like '%-$lowe-%'";
  2563. }
  2564. if($state)
  2565. {
  2566. $where .= " and state = '$state'";
  2567. }
  2568. if($warehouse)
  2569. {
  2570. $where .= " and warehouse = '$warehouse'";
  2571. }
  2572. if($purchase)
  2573. {
  2574. $where .= " and purchase = '$purchase'";
  2575. }
  2576. if($sku)
  2577. {
  2578. $where .= " and sku = '$sku'";
  2579. }
  2580. if($ktime && $jtime)
  2581. {
  2582. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2583. }
  2584. //数据排序
  2585. $order_str = "id desc";
  2586. if(empty($page))
  2587. {
  2588. $start = 0;
  2589. $perpage = 1;
  2590. }
  2591. else
  2592. {
  2593. $start = ($page - 1)*$perpage;
  2594. }
  2595. //取得信息列表
  2596. $info_list = $this->whlabel->find_all($where,'sku');
  2597. $rows = array();$list = array();
  2598. foreach ($info_list as $key=>$value)
  2599. {
  2600. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2601. }
  2602. $rows = array_unique($rows);//删除重复记录
  2603. foreach ($rows as $key=>$value)
  2604. {
  2605. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2606. $ck = $this->warehouse->read($data['warehouse']);
  2607. $warehouse = $ck['title'];
  2608. $gy = $this->purchase->read($data['purchase']);
  2609. $purchase = $gy['purchase'];
  2610. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2611. $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);
  2612. }
  2613. $total = count($list);
  2614. $pagenum = ceil($total/$perpage);
  2615. $over = $total-($start+$perpage);
  2616. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2617. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2618. echo json_encode($rows);exit;
  2619. }
  2620. $this->_Template('whlabel_out',$this->data);
  2621. }
  2622. //出库标签浏览
  2623. public function _label()
  2624. {
  2625. $post = $this->input->post(NULL, TRUE);
  2626. if(isset($post['page']))
  2627. {
  2628. $page = $this->input->post('page',true);
  2629. $perpage = $this->input->post('perpage',true);
  2630. $sku = $this->input->post('sku',true);
  2631. $warehouse = $this->input->post('warehouse',true);
  2632. $purchase = $this->input->post('purchase',true);
  2633. $orderinfo = $this->input->post('orderinfo',true);
  2634. $waybill = $this->input->post('waybill',true);
  2635. $category = $this->input->post('category',true);
  2636. $size = $this->input->post('size',true);
  2637. $grade = $this->input->post('grade',true);
  2638. $color = $this->input->post('color',true);
  2639. $lowe = $this->input->post('lowe',true);
  2640. $where = "state=1";
  2641. if($sku)
  2642. {
  2643. $where .= " and sku = '$sku'";
  2644. }
  2645. if($warehouse)
  2646. {
  2647. $where .= " and warehouse = '$warehouse'";
  2648. }
  2649. if($purchase)
  2650. {
  2651. $where .= " and purchase = '$purchase'";
  2652. }
  2653. if($orderinfo)
  2654. {
  2655. $where .= " and orderinfo = '$orderinfo'";
  2656. }
  2657. if($waybill)
  2658. {
  2659. $where .= " and waybill = '$waybill'";
  2660. }
  2661. if($category)
  2662. {
  2663. $where .= " and features like '%-$category-%'";
  2664. }
  2665. if($size)
  2666. {
  2667. $where .= " and features like '%-$size-%'";
  2668. }
  2669. if($grade)
  2670. {
  2671. $where .= " and features like '%-$grade-%'";
  2672. }
  2673. if($color)
  2674. {
  2675. $where .= " and features like '%-$color-%'";
  2676. }
  2677. if($lowe)
  2678. {
  2679. $where .= " and features like '%-$lowe-%'";
  2680. }
  2681. //数据排序
  2682. $order_str = "outk desc";
  2683. if(empty($page))
  2684. {
  2685. $start = 0;
  2686. $perpage = 1;
  2687. }
  2688. else
  2689. {
  2690. $start = ($page - 1)*$perpage;
  2691. }
  2692. //取得信息列表
  2693. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2694. foreach ($info_list as $key=>$value)
  2695. {
  2696. $warehouse = $this->warehouse->read($value['warehouse']);
  2697. $info_list[$key]['warehouse'] = $warehouse['title'];
  2698. $purchase = $this->purchase->read($value['purchase']);
  2699. $info_list[$key]['purchase'] = $purchase['title'];
  2700. if($value['outk'] != 0)
  2701. {
  2702. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2703. }
  2704. else
  2705. {
  2706. $info_list[$key]['outk'] = "";
  2707. }
  2708. if($value['orderinfo'] == 0)
  2709. {
  2710. $info_list[$key]['orderinfo'] = "";
  2711. }
  2712. if($value['waybill'] == 0)
  2713. {
  2714. $info_list[$key]['waybill'] = "";
  2715. }
  2716. }
  2717. $total = $this->whlabel->find_count($where);
  2718. $pagenum = ceil($total/$perpage);
  2719. $over = $total-($start+$perpage);
  2720. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2721. echo json_encode($rows);exit;
  2722. }
  2723. $this->_Template('whlabel_label',$this->data);
  2724. }
  2725. //独立站出库订单
  2726. public function _outorder()
  2727. {
  2728. if(isset($_SESSION['api']))
  2729. {
  2730. $user = $this->user->get_api($_SESSION['api']);
  2731. $usp = $user;
  2732. $fgshop = "";$sid = "";
  2733. $user = explode('|',trim($user['shop'],'|'));
  2734. foreach ($user as $value)
  2735. {
  2736. $fgshop .= " shop = ".$value." or";
  2737. $sid .= " id = ".$value." or";
  2738. }
  2739. }
  2740. else
  2741. {
  2742. echo "请重新登录";
  2743. }
  2744. $post = $this->input->post(NULL, TRUE);
  2745. if(isset($post['page']))
  2746. {
  2747. $page = $this->input->post('page',true);
  2748. $perpage = $this->input->post('perpage',true);
  2749. $warehouse = $this->input->post('warehouse',true);
  2750. $xztime = $this->input->post('xztime',true);
  2751. $timetk = $this->input->post('timetkk',true);
  2752. $timetj = $this->input->post('timetjj',true);
  2753. $shop = $this->input->post('shop',true);
  2754. $source = $this->input->post('source',true);
  2755. $orderinfo = $this->input->post('orderinfo',true);
  2756. $number = $this->input->post('number',true);
  2757. $sfxh = $this->input->post('sfxh',true);
  2758. $express = $this->input->post('express',true);
  2759. $waybill = $this->input->post('waybill',true);
  2760. $library = $this->input->post('library',true);
  2761. $country = $this->input->post('country',true);
  2762. $so = $this->input->post('so',true);
  2763. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2764. $print = $this->input->post('print',true);
  2765. $state = $this->input->post('state',true);
  2766. $orderurl = $this->input->post('orderurl',true);
  2767. $timetk = strtotime($timetk);
  2768. $timetj = strtotime($timetj);
  2769. /**
  2770. $sj = $this->input->post('sj',true);
  2771. if($sj)
  2772. {
  2773. $sj = $this->input->post('sj',true);
  2774. }
  2775. else
  2776. {
  2777. $sj = "fullorder";
  2778. }
  2779. **/
  2780. $sj = "fullorder";
  2781. $where = "1=1";
  2782. if($warehouse)
  2783. {
  2784. $where .= " and type = '$warehouse'";
  2785. }
  2786. if($timetk && $timetj)
  2787. {
  2788. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2789. }
  2790. if($orderinfo)
  2791. {
  2792. $where .= " and orderinfo = '$orderinfo'";
  2793. }
  2794. if($number)
  2795. {
  2796. $where .= " and number = '$number'";
  2797. }
  2798. if($express)
  2799. {
  2800. $where .= " and express = '$express'";
  2801. }
  2802. if($waybill)
  2803. {
  2804. $where .= " and waybill = '$waybill'";
  2805. }
  2806. if($library)
  2807. {
  2808. $where .= " and library = '$library'";
  2809. }
  2810. if($print)
  2811. {
  2812. $where .= " and print = '$print'";
  2813. }
  2814. if($libraryconfirm)
  2815. {
  2816. $where .= " and libraryconfirm = '$libraryconfirm'";
  2817. }
  2818. if($state)
  2819. {
  2820. $where .= " and state = '$state'";
  2821. }
  2822. if($shop)
  2823. {
  2824. $where .= " and shop = '$shop'";
  2825. }
  2826. if($country)
  2827. {
  2828. $where .= " and country = '$country'";
  2829. }
  2830. if($sfxh != '')
  2831. {
  2832. $where .= " and sfxh = '$sfxh'";
  2833. }
  2834. if($so)
  2835. {
  2836. $where .= " and shipremarks like '%$so%'";
  2837. }
  2838. if($source)
  2839. {
  2840. if($source == '2d')
  2841. {
  2842. $where .= " and source >= '2'";
  2843. }
  2844. else
  2845. {
  2846. $where .= " and source = '$source'";
  2847. }
  2848. }
  2849. if(isset($_SESSION['api']))
  2850. {
  2851. foreach ($user as $value)
  2852. {
  2853. $fgshop .= " shop = ".$value." or";
  2854. }
  2855. $where .= " and (".rtrim($fgshop,'or').")";
  2856. }
  2857. if($orderurl)
  2858. {
  2859. $url = $this->orderurl->read($orderurl);
  2860. $where .= " and link like '%".$url['url']."%'";
  2861. }
  2862. //数据排序
  2863. $order_str = "librarytime desc";
  2864. if(empty($page))
  2865. {
  2866. $start = 0;
  2867. $perpage = 1;
  2868. }
  2869. else
  2870. {
  2871. $start = ($page - 1)*$perpage;
  2872. }
  2873. //取得信息列表
  2874. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2875. //格式化数据
  2876. foreach ($info_list as $key=>$value)
  2877. {
  2878. $shop = $this->shop->read($value['shop']);
  2879. $info_list[$key]['shop'] = $shop['shopname'];
  2880. $express = $this->express->read($value['express']);
  2881. $info_list[$key]['express'] = $express['servicename'];
  2882. $warehouse = $this->warehouse->read($value['type']);
  2883. $info_list[$key]['type'] = $warehouse['title'];
  2884. if($value['librarytime'] == '0')
  2885. {
  2886. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2887. }
  2888. else
  2889. {
  2890. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2891. }
  2892. }
  2893. $total = $this->$sj->find_count($where);
  2894. $pagenum = ceil($total/$perpage);
  2895. $over = $total-($start+$perpage);
  2896. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2897. echo json_encode($rows);exit;
  2898. }
  2899. $this->data['express'] = $this->express->find_all();
  2900. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2901. $this->data['wlshop'] = $wlshop;
  2902. $user = $this->user->get_api($_SESSION['api']);
  2903. $powerid = $this->power->read($user['power']);
  2904. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2905. $pid = '';
  2906. foreach ($powertext as $v)
  2907. {
  2908. $pid .= " id = ".$v." or";
  2909. }
  2910. $fullorderexcel = $this->fullorderexcel->find_all("1 = 1",'*','idorder desc');//导出模板
  2911. $this->data['fullorderexcel'] = $fullorderexcel;
  2912. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2913. $this->data['orderurl'] = $orderurl;
  2914. $this->_Template('whlabel_outorder',$this->data);
  2915. }
  2916. //tt出库
  2917. public function _toutorder()
  2918. {
  2919. if(isset($_SESSION['api']))
  2920. {
  2921. $user = $this->user->get_api($_SESSION['api']);
  2922. $usp = $user;
  2923. $fgshop = "";$sid = "";
  2924. $user = explode('|',trim($user['shop'],'|'));
  2925. foreach ($user as $value)
  2926. {
  2927. $fgshop .= " shop = ".$value." or";
  2928. $sid .= " id = ".$value." or";
  2929. }
  2930. }
  2931. else
  2932. {
  2933. echo "请重新登录";
  2934. }
  2935. $post = $this->input->post(NULL, TRUE);
  2936. if(isset($post['page']))
  2937. {
  2938. $page = $this->input->post('page',true);
  2939. $perpage = $this->input->post('perpage',true);
  2940. $warehouse = $this->input->post('warehouse',true);
  2941. $xztime = $this->input->post('xztime',true);
  2942. $timetk = $this->input->post('timetkk',true);
  2943. $timetj = $this->input->post('timetjj',true);
  2944. $shop = $this->input->post('shop',true);
  2945. $source = $this->input->post('source',true);
  2946. $orderinfo = $this->input->post('orderinfo',true);
  2947. $number = $this->input->post('number',true);
  2948. $sfxh = $this->input->post('sfxh',true);
  2949. $express = $this->input->post('express',true);
  2950. $waybill = $this->input->post('waybill',true);
  2951. $library = $this->input->post('library',true);
  2952. $country = $this->input->post('country',true);
  2953. $so = $this->input->post('so',true);
  2954. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2955. $print = $this->input->post('print',true);
  2956. $state = $this->input->post('state',true);
  2957. $orderurl = $this->input->post('orderurl',true);
  2958. $timetk = strtotime($timetk);
  2959. $timetj = strtotime($timetj);
  2960. /**
  2961. $sj = $this->input->post('sj',true);
  2962. if($sj)
  2963. {
  2964. $sj = $this->input->post('sj',true);
  2965. }
  2966. else
  2967. {
  2968. $sj = "fullorder";
  2969. }
  2970. **/
  2971. $sj = "fullordertt";
  2972. $where = "1=1";
  2973. if($warehouse)
  2974. {
  2975. $where .= " and type = '$warehouse'";
  2976. }
  2977. if($timetk && $timetj)
  2978. {
  2979. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2980. }
  2981. if($orderinfo)
  2982. {
  2983. $where .= " and orderinfo = '$orderinfo'";
  2984. }
  2985. if($number)
  2986. {
  2987. $where .= " and number = '$number'";
  2988. }
  2989. if($express)
  2990. {
  2991. $where .= " and express = '$express'";
  2992. }
  2993. if($waybill)
  2994. {
  2995. $where .= " and waybill = '$waybill'";
  2996. }
  2997. if($library)
  2998. {
  2999. $where .= " and library = '$library'";
  3000. }
  3001. if($print)
  3002. {
  3003. $where .= " and print = '$print'";
  3004. }
  3005. if($libraryconfirm)
  3006. {
  3007. $where .= " and libraryconfirm = '$libraryconfirm'";
  3008. }
  3009. if($state)
  3010. {
  3011. $where .= " and state = '$state'";
  3012. }
  3013. if($shop)
  3014. {
  3015. $where .= " and shop = '$shop'";
  3016. }
  3017. if($country)
  3018. {
  3019. $where .= " and country = '$country'";
  3020. }
  3021. if($sfxh != '')
  3022. {
  3023. $where .= " and sfxh = '$sfxh'";
  3024. }
  3025. if($so)
  3026. {
  3027. $where .= " and shipremarks like '%$so%'";
  3028. }
  3029. if($source)
  3030. {
  3031. if($source == '2d')
  3032. {
  3033. $where .= " and source >= '2'";
  3034. }
  3035. else
  3036. {
  3037. $where .= " and source = '$source'";
  3038. }
  3039. }
  3040. if(isset($_SESSION['api']))
  3041. {
  3042. foreach ($user as $value)
  3043. {
  3044. $fgshop .= " shop = ".$value." or";
  3045. }
  3046. $where .= " and (".rtrim($fgshop,'or').")";
  3047. }
  3048. if($orderurl)
  3049. {
  3050. $url = $this->orderurl->read($orderurl);
  3051. $where .= " and link like '%".$url['url']."%'";
  3052. }
  3053. //数据排序
  3054. $order_str = "librarytime desc";
  3055. if(empty($page))
  3056. {
  3057. $start = 0;
  3058. $perpage = 1;
  3059. }
  3060. else
  3061. {
  3062. $start = ($page - 1)*$perpage;
  3063. }
  3064. //取得信息列表
  3065. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3066. //格式化数据
  3067. foreach ($info_list as $key=>$value)
  3068. {
  3069. $shop = $this->shop->read($value['shop']);
  3070. $info_list[$key]['shop'] = $shop['shopname'];
  3071. $express = $this->express->read($value['express']);
  3072. $info_list[$key]['express'] = $express['servicename'];
  3073. $warehouse = $this->warehouse->read($value['type']);
  3074. $info_list[$key]['type'] = $warehouse['title'];
  3075. if($value['librarytime'] == '0')
  3076. {
  3077. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3078. }
  3079. else
  3080. {
  3081. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3082. }
  3083. }
  3084. $total = $this->$sj->find_count($where);
  3085. $pagenum = ceil($total/$perpage);
  3086. $over = $total-($start+$perpage);
  3087. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3088. echo json_encode($rows);exit;
  3089. }
  3090. $this->data['express'] = $this->express->find_all();
  3091. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3092. $this->data['wlshop'] = $wlshop;
  3093. $user = $this->user->get_api($_SESSION['api']);
  3094. $powerid = $this->power->read($user['power']);
  3095. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3096. $pid = '';
  3097. foreach ($powertext as $v)
  3098. {
  3099. $pid .= " id = ".$v." or";
  3100. }
  3101. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3102. $this->data['fullorderexcel'] = $fullorderexcel;
  3103. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  3104. $this->data['orderurl'] = $orderurl;
  3105. $this->_Template('whlabel_toutorder',$this->data);
  3106. }
  3107. //速卖通出库订单
  3108. public function _soutorder()
  3109. {
  3110. if(isset($_SESSION['api']))
  3111. {
  3112. $user = $this->user->get_api($_SESSION['api']);
  3113. $usp = $user;
  3114. $fgshop = "";$sid = "";
  3115. $user = explode('|',trim($user['shop'],'|'));
  3116. foreach ($user as $value)
  3117. {
  3118. $sid .= " id = ".$value." or";
  3119. }
  3120. }
  3121. $post = $this->input->post(NULL, TRUE);
  3122. if(isset($post['page']))
  3123. {
  3124. $page = $this->input->post('page',true);
  3125. $perpage = $this->input->post('perpage',true);
  3126. $warehouse = $this->input->post('warehouse',true);
  3127. $xztime = $this->input->post('xztime',true);
  3128. $timetk = $this->input->post('timetkk',true);
  3129. $timetj = $this->input->post('timetjj',true);
  3130. $shop = $this->input->post('shop',true);
  3131. $source = $this->input->post('source',true);
  3132. $orderinfo = $this->input->post('orderinfo',true);
  3133. $number = $this->input->post('number',true);
  3134. $express = $this->input->post('express',true);
  3135. $waybill = $this->input->post('waybill',true);
  3136. $library = $this->input->post('library',true);
  3137. $country = $this->input->post('country',true);
  3138. $sfxh = $this->input->post('sfxh',true);
  3139. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3140. $print = $this->input->post('print',true);
  3141. $state = $this->input->post('state',true);
  3142. $so = $this->input->post('so',true);
  3143. $timetk = strtotime($timetk);
  3144. $timetj = strtotime($timetj);
  3145. /**
  3146. $sj = $this->input->post('sj',true);
  3147. if($sj)
  3148. {
  3149. $sj = $this->input->post('sj',true);
  3150. }
  3151. else
  3152. {
  3153. $sj = "fullorder";
  3154. }
  3155. **/
  3156. $sj = "fullordersmt";
  3157. $where = "1=1";
  3158. if($warehouse)
  3159. {
  3160. $where .= " and type = '$warehouse'";
  3161. }
  3162. if($timetk && $timetj)
  3163. {
  3164. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3165. }
  3166. if($orderinfo)
  3167. {
  3168. $where .= " and orderinfo = '$orderinfo'";
  3169. }
  3170. if($number)
  3171. {
  3172. $where .= " and number = '$number'";
  3173. }
  3174. if($express)
  3175. {
  3176. $where .= " and express = '$express'";
  3177. }
  3178. if($waybill)
  3179. {
  3180. $where .= " and waybill = '$waybill'";
  3181. }
  3182. if($library)
  3183. {
  3184. $where .= " and library = '$library'";
  3185. }
  3186. if($print)
  3187. {
  3188. $where .= " and print = '$print'";
  3189. }
  3190. if($libraryconfirm)
  3191. {
  3192. $where .= " and libraryconfirm = '$libraryconfirm'";
  3193. }
  3194. if($state)
  3195. {
  3196. $where .= " and state = '$state'";
  3197. }
  3198. if($shop)
  3199. {
  3200. $where .= " and shop = '$shop'";
  3201. }
  3202. if($sfxh != '')
  3203. {
  3204. $where .= " and sfxh = '$sfxh'";
  3205. }
  3206. if($so)
  3207. {
  3208. $where .= " and shipremarks like '%$so%'";
  3209. }
  3210. if($source)
  3211. {
  3212. $where .= " and source = '$source'";
  3213. }
  3214. if($country)
  3215. {
  3216. $where .= " and country = '$country'";
  3217. }
  3218. else
  3219. {
  3220. if(isset($_SESSION['api']))
  3221. {
  3222. foreach ($user as $value)
  3223. {
  3224. $fgshop .= " shop = ".$value." or";
  3225. }
  3226. $where .= " and (".rtrim($fgshop,'or').")";
  3227. }
  3228. }
  3229. //数据排序
  3230. $order_str = "librarytime desc";
  3231. if(empty($page))
  3232. {
  3233. $start = 0;
  3234. $perpage = 1;
  3235. }
  3236. else
  3237. {
  3238. $start = ($page - 1)*$perpage;
  3239. }
  3240. //取得信息列表
  3241. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3242. //格式化数据
  3243. foreach ($info_list as $key=>$value)
  3244. {
  3245. $shop = $this->shop->read($value['shop']);
  3246. $info_list[$key]['shop'] = $shop['shopname'];
  3247. $express = $this->express->read($value['express']);
  3248. $info_list[$key]['express'] = $express['servicename'];
  3249. $warehouse = $this->warehouse->read($value['type']);
  3250. $info_list[$key]['type'] = $warehouse['title'];
  3251. if($value['librarytime'] == '0')
  3252. {
  3253. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3254. }
  3255. else
  3256. {
  3257. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3258. }
  3259. }
  3260. $total = $this->$sj->find_count($where);
  3261. $pagenum = ceil($total/$perpage);
  3262. $over = $total-($start+$perpage);
  3263. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3264. echo json_encode($rows);exit;
  3265. }
  3266. $this->data['express'] = $this->express->find_all();
  3267. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3268. $this->data['wlshop'] = $wlshop;
  3269. $user = $this->user->get_api($_SESSION['api']);
  3270. $powerid = $this->power->read($user['power']);
  3271. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3272. $pid = '';
  3273. foreach ($powertext as $v)
  3274. {
  3275. $pid .= " id = ".$v." or";
  3276. }
  3277. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3278. $this->data['fullorderexcel'] = $fullorderexcel;
  3279. $this->_Template('whlabel_soutorder',$this->data);
  3280. }
  3281. //订单退库
  3282. public function _retreat()
  3283. {
  3284. $post = $this->input->post(NULL, TRUE);
  3285. if(isset($post['page']))
  3286. {
  3287. $page = $this->input->post('page',true);
  3288. $perpage = $this->input->post('perpage',true);
  3289. $warehouse = $this->input->post('warehouse',true);
  3290. $timetk = $this->input->post('timetk',true);
  3291. $timetj = $this->input->post('timetj',true);
  3292. $shop = $this->input->post('shop',true);
  3293. $source = $this->input->post('source',true);
  3294. $state = $this->input->post('state',true);
  3295. $review = $this->input->post('review',true);
  3296. $state = $this->input->post('state',true);
  3297. $express = $this->input->post('express',true);
  3298. $orderinfo = $this->input->post('orderinfo',true);
  3299. $user = $this->input->post('user',true);
  3300. $name = $this->input->post('name',true);
  3301. $waybill = $this->input->post('waybill',true);
  3302. $timetk = strtotime($timetk);
  3303. $timetj = strtotime($timetj);
  3304. $where = "(state=206 or state=210) and mergeid = 0";
  3305. if($warehouse)
  3306. {
  3307. $where .= " and state = '$warehouse'";
  3308. }
  3309. if($timetk && $timetj)
  3310. {
  3311. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3312. }
  3313. if($shop)
  3314. {
  3315. $where .= " and shop = '$shop'";
  3316. }
  3317. if($source)
  3318. {
  3319. $where .= " and source = '$source'";
  3320. }
  3321. if($state)
  3322. {
  3323. $where .= " and state = '$state'";
  3324. }
  3325. if($review)
  3326. {
  3327. $where .= " and review = '$review'";
  3328. }
  3329. if($state)
  3330. {
  3331. $where .= " and state = '$state'";
  3332. }
  3333. if($express)
  3334. {
  3335. $where .= " and express = '$express'";
  3336. }
  3337. if($orderinfo)
  3338. {
  3339. $where .= " and orderinfo = '$orderinfo'";
  3340. }
  3341. if($user)
  3342. {
  3343. $where .= " and user = '$user'";
  3344. }
  3345. if($name)
  3346. {
  3347. $where .= " and name = '$name'";
  3348. }
  3349. if($waybill)
  3350. {
  3351. $where .= " and waybill = '$waybill'";
  3352. }
  3353. //数据排序
  3354. $order_str = "id desc";
  3355. if(empty($page))
  3356. {
  3357. $start = 0;
  3358. $perpage = 1;
  3359. }
  3360. else
  3361. {
  3362. $start = ($page - 1)*$perpage;
  3363. }
  3364. //取得信息列表
  3365. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3366. //格式化数据
  3367. foreach ($info_list as $key=>$value)
  3368. {
  3369. $shop = $this->shop->read($value['shop']);
  3370. $info_list[$key]['shop'] = $shop['shopname'];
  3371. $warehouse = $this->warehouse->read($value['warehouse']);
  3372. $info_list[$key]['warehouse'] = $warehouse['title'];
  3373. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3374. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3375. if($value['waybill'] == 0)
  3376. {
  3377. $info_list[$key]['waybill'] = "";
  3378. }
  3379. $express = $this->express->read($value['express']);
  3380. $info_list[$key]['express'] = $express['title'];
  3381. $typeclass = $this->typeclass->read($value['state']);
  3382. $info_list[$key]['state'] = $typeclass['title'];
  3383. }
  3384. $total = $this->fullorder->find_count($where);
  3385. $pagenum = ceil($total/$perpage);
  3386. $over = $total-($start+$perpage);
  3387. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3388. echo json_encode($rows);exit;
  3389. }
  3390. $this->data['express'] = $this->express->find_all();
  3391. $this->_Template('whlabel_retreat',$this->data);
  3392. }
  3393. //退库标签浏览
  3394. public function _retreatlk()
  3395. {
  3396. $post = $this->input->post(NULL, TRUE);
  3397. if(isset($post['page']))
  3398. {
  3399. $page = $this->input->post('page',true);
  3400. $perpage = $this->input->post('perpage',true);
  3401. $timetk = $this->input->post('timetk',true);
  3402. $timetj = $this->input->post('timetj',true);
  3403. $sku = $this->input->post('sku',true);
  3404. $warehouse = $this->input->post('warehouse',true);
  3405. $purchase = $this->input->post('purchase',true);
  3406. $orderinfo = $this->input->post('orderinfo',true);
  3407. $waybill = $this->input->post('waybill',true);
  3408. $category = $this->input->post('category',true);
  3409. $size = $this->input->post('size',true);
  3410. $grade = $this->input->post('grade',true);
  3411. $color = $this->input->post('color',true);
  3412. $lowe = $this->input->post('lowe',true);
  3413. $state = $this->input->post('state',true);
  3414. $timetk = strtotime($timetk);
  3415. $timetj = strtotime($timetj);
  3416. $where = "state=2";
  3417. if($timetk && $timetj)
  3418. {
  3419. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3420. }
  3421. if($sku)
  3422. {
  3423. $where .= " and sku = '$sku'";
  3424. }
  3425. if($warehouse)
  3426. {
  3427. $where .= " and warehouse = '$warehouse'";
  3428. }
  3429. if($purchase)
  3430. {
  3431. $where .= " and purchase = '$purchase'";
  3432. }
  3433. if($orderinfo)
  3434. {
  3435. $where .= " and orderinfo = '$orderinfo'";
  3436. }
  3437. if($waybill)
  3438. {
  3439. $where .= " and waybill = '$waybill'";
  3440. }
  3441. if($category)
  3442. {
  3443. $where .= " and features like '%-$category-%'";
  3444. }
  3445. if($size)
  3446. {
  3447. $where .= " and features like '%-$size-%'";
  3448. }
  3449. if($grade)
  3450. {
  3451. $where .= " and features like '%-$grade-%'";
  3452. }
  3453. if($color)
  3454. {
  3455. $where .= " and features like '%-$color-%'";
  3456. }
  3457. if($lowe)
  3458. {
  3459. $where .= " and features like '%-$lowe-%'";
  3460. }
  3461. //数据排序
  3462. $order_str = "time desc";
  3463. if(empty($page))
  3464. {
  3465. $start = 0;
  3466. $perpage = 1;
  3467. }
  3468. else
  3469. {
  3470. $start = ($page - 1)*$perpage;
  3471. }
  3472. //取得信息列表
  3473. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3474. foreach ($info_list as $key=>$value)
  3475. {
  3476. $warehouse = $this->warehouse->read($value['warehouse']);
  3477. $info_list[$key]['warehouse'] = $warehouse['title'];
  3478. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3479. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3480. $purchase = $this->purchase->read($value['purchase']);
  3481. $info_list[$key]['purchase'] = $purchase['title'];
  3482. if($value['outk'] != 0)
  3483. {
  3484. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3485. }
  3486. else
  3487. {
  3488. $info_list[$key]['outk'] = "";
  3489. }
  3490. if($value['retreat'] != 0)
  3491. {
  3492. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3493. }
  3494. else
  3495. {
  3496. $info_list[$key]['retreat'] = "";
  3497. }
  3498. if($value['orderinfo'] == 0)
  3499. {
  3500. $info_list[$key]['orderinfo'] = "";
  3501. }
  3502. if($value['waybill'] == 0)
  3503. {
  3504. $info_list[$key]['waybill'] = "";
  3505. }
  3506. }
  3507. $total = $this->whlabel->find_count($where);
  3508. $pagenum = ceil($total/$perpage);
  3509. $over = $total-($start+$perpage);
  3510. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3511. echo json_encode($rows);exit;
  3512. }
  3513. $this->_Template('whlabel_retreatlk',$this->data);
  3514. }
  3515. //更换标签及浏览
  3516. public function _change()
  3517. {
  3518. $post = $this->input->post(NULL, TRUE);
  3519. if(isset($post['page']))
  3520. {
  3521. $page = $this->input->post('page',true);
  3522. $perpage = $this->input->post('perpage',true);
  3523. $timetk = $this->input->post('timetk',true);
  3524. $timetj = $this->input->post('timetj',true);
  3525. $label = $this->input->post('label',true);
  3526. $oldlabel = $this->input->post('oldlabel',true);
  3527. $timetk = strtotime($timetk);
  3528. $timetj = strtotime($timetj);
  3529. $where = "state=10 ";
  3530. if($timetk && $timetj)
  3531. {
  3532. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3533. }
  3534. if($label)
  3535. {
  3536. $where .= " and label = '$label'";
  3537. }
  3538. if($oldlabel)
  3539. {
  3540. $where .= " and oldlabel = '$oldlabel'";
  3541. }
  3542. //数据排序
  3543. $order_str = "time asc";
  3544. if(empty($page))
  3545. {
  3546. $start = 0;
  3547. $perpage = 1;
  3548. }
  3549. else
  3550. {
  3551. $start = ($page - 1)*$perpage;
  3552. }
  3553. //取得信息列表
  3554. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3555. foreach ($info_list as $key=>$value)
  3556. {
  3557. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3558. }
  3559. $total = $this->whlabel->find_count($where);
  3560. $pagenum = ceil($total/$perpage);
  3561. $over = $total-($start+$perpage);
  3562. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3563. echo json_encode($rows);exit;
  3564. }
  3565. $this->_Template('whlabel_change',$this->data);
  3566. }
  3567. //产品标签
  3568. public function _cpbqdc()
  3569. {
  3570. if(isset($_GET['excel']))
  3571. {
  3572. $where = "1=1";
  3573. //数据排序
  3574. $order_str = "id desc";
  3575. if(empty($page))
  3576. {
  3577. $start = 0;
  3578. $perpage = 1;
  3579. }
  3580. else
  3581. {
  3582. $start = ($page - 1)*$perpage;
  3583. }
  3584. $warehouse = $this->input->get('warehouse',true);
  3585. $state = $this->input->get('state',true);
  3586. $timetk = $this->input->get('timetkk',true);
  3587. $timetj = $this->input->get('timetjj',true);
  3588. $timetk = strtotime($timetk);
  3589. $timetj = strtotime($timetj);
  3590. if($warehouse)
  3591. {
  3592. $where .= " and warehouse = '$warehouse'";
  3593. }
  3594. if($state || $state == 0)
  3595. {
  3596. $where .= " and state = '$state'";
  3597. }
  3598. if($timetk && $timetj)
  3599. {
  3600. $where .= " and time > '$timetk' and time < '$timetj'";
  3601. }
  3602. //取得信息列表
  3603. $info_list = $this->whlabel->find_all($where,'*');
  3604. $rows = array();$list = array();
  3605. foreach ($info_list as $key=>$value)
  3606. {
  3607. $rows[$value['time']] = $value;//所有数据sku
  3608. }
  3609. foreach ($rows as $value)
  3610. {
  3611. $warehouse = $this->warehouse->read($value['warehouse']);
  3612. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3613. $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);
  3614. }
  3615. $title = "产品标签统计表";
  3616. $titlename = "<table border=1>
  3617. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3618. <tr align='center'>
  3619. <td>仓库</td>
  3620. <td>SKU</td>
  3621. <td>产品</td>
  3622. <td>入库时间</td>
  3623. <td>操作时间</td>
  3624. <td>备注</td>
  3625. <td>数量</td>
  3626. </tr>
  3627. </table>";
  3628. $filename = $title.".xls";
  3629. $tail = "";
  3630. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3631. }
  3632. }
  3633. //进销存导出
  3634. public function _exceljxc()
  3635. {
  3636. $classid = $this->classid->sku();
  3637. $pm = $classid;
  3638. $typeclass = array();
  3639. $tc = $this->typeclass->find_all();
  3640. foreach ($tc as $v)
  3641. {
  3642. $typeclass[$v['id']] = $v;
  3643. }
  3644. $prc = array();
  3645. $purchase = $this->purchase->find_all();
  3646. foreach($purchase as $k=>$v)
  3647. {
  3648. $prc[$v['id']] = $v['title'];
  3649. }
  3650. if(isset($_GET['excel']))
  3651. {
  3652. $where = "sku != 'Preset'";
  3653. //数据排序
  3654. $order_str = "id desc";
  3655. if(empty($page))
  3656. {
  3657. $start = 0;
  3658. $perpage = 1;
  3659. }
  3660. else
  3661. {
  3662. $start = ($page - 1)*$perpage;
  3663. }
  3664. $category = $this->input->get('category',true);
  3665. $warehouse = $this->input->get('warehouse',true);
  3666. $excelid = $this->input->get('sid',true);
  3667. if($category)
  3668. {
  3669. $where .= " and features like '%-$category-%'";
  3670. }
  3671. if($warehouse)
  3672. {
  3673. $where .= " and warehouse = '$warehouse'";
  3674. }
  3675. $xzid = '';
  3676. if($excelid)
  3677. {
  3678. $excelid = explode(',',trim($excelid,','));
  3679. foreach ($excelid as $key=>$value)
  3680. {
  3681. $xzid .= " id = ".$value." or";
  3682. }
  3683. $xzid = " and (".rtrim($xzid,'or').")";;
  3684. }
  3685. //取得信息列表
  3686. /**
  3687. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3688. $rows = array();$list = array();
  3689. foreach ($info_list as $key=>$value)
  3690. {
  3691. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3692. }
  3693. **/
  3694. $wt = array();
  3695. $whlabel_type = $this->whlabel_type->find_all();
  3696. foreach ($whlabel_type as $v)
  3697. {
  3698. $wt[$v['id']] = $v['title'];
  3699. }
  3700. $wh = array();
  3701. $w = $this->warehouse->find_all('1=1','id,title');
  3702. foreach ($w as $v)
  3703. {
  3704. $wh[$v['id']] = $v['title'];
  3705. }
  3706. $list = array();
  3707. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3708. foreach ($rows as $key=>$value)
  3709. {
  3710. if(isset($wt[$value['type']]))
  3711. {
  3712. $rows[$key]['type'] = $wt[$value['type']];
  3713. }
  3714. else
  3715. {
  3716. $rows[$key]['type'] = '未设置';
  3717. }
  3718. $bm = '03';
  3719. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3720. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3721. $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');
  3722. $details = array();
  3723. $cpid = array();
  3724. $cpbz = array();
  3725. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3726. foreach ($sd as $k=>$v)
  3727. {
  3728. if($v['state'] == 0)
  3729. {
  3730. $c++;
  3731. if($v['cpid'] != 0)
  3732. {
  3733. $cpid[$v['cpid']] = $v['cpid'];
  3734. }
  3735. if($v['cpbz'] != '')
  3736. {
  3737. $cpbz[$v['cpbz']] = $v['cpbz'];
  3738. }
  3739. }
  3740. if($v['state'] != 9)
  3741. {
  3742. $g++;
  3743. }
  3744. if($v['state'] == 1)
  3745. {
  3746. $x++;
  3747. }
  3748. if($v['state'] == 2)
  3749. {
  3750. $t++;
  3751. }
  3752. if($v['state'] == 8)
  3753. {
  3754. $s++;
  3755. }
  3756. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3757. {
  3758. $q++;
  3759. }
  3760. $details[$v['details']] = $v['details'];
  3761. }
  3762. $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'].'"');
  3763. $rows[$key]['details'] = implode("、",$details);
  3764. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3765. $number = $value['number'];
  3766. $ftime = time()-15*24*3600;
  3767. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3768. $rows[$key]['number'] = $g;
  3769. $rows[$key]['c'] = $c;
  3770. $rows[$key]['x'] = $x;
  3771. $rows[$key]['t'] = $t;
  3772. $rows[$key]['s'] = $s;
  3773. $rows[$key]['q'] = $q;
  3774. $rows[$key]['z'] = $z;
  3775. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3776. $features = explode('-',trim($features,'-'));
  3777. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3778. $pm = $classid;
  3779. $jm = $classid;
  3780. foreach($features as $k=>$v)
  3781. {
  3782. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3783. {
  3784. if($typeclass[$v]['bm'] != '')
  3785. {
  3786. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3787. }
  3788. }
  3789. if($v != 0)
  3790. {
  3791. if(!isset($typeclass[$v]))
  3792. {
  3793. continue;
  3794. }
  3795. if(isset($pm[$typeclass[$v]['classid']]))
  3796. {
  3797. if(stripos($typeclass[$v]['zh'],'|') !== false)
  3798. {
  3799. $tz = explode('|',$typeclass[$v]['zh']);
  3800. $pm[$typeclass[$v]['classid']] = $tz[0];
  3801. }
  3802. else
  3803. {
  3804. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3805. }
  3806. }
  3807. if(isset($jm[$typeclass[$v]['classid']]))
  3808. {
  3809. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3810. }
  3811. }
  3812. }
  3813. $jm = array_filter($jm);
  3814. $rows[$key]['bs'] = implode("-",$jm);
  3815. $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3816. $zh = implode(" ",$pm);
  3817. $zh = str_replace('自然色 ','',trim($zh,' '));
  3818. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3819. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3820. $rows[$key]['features'] = $zh;
  3821. }
  3822. $title = "总进销存统计表";
  3823. $titlename = "<table border=1>
  3824. <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
  3825. <tr align='center'>
  3826. <td>仓库</td>
  3827. <td>供应商</td>
  3828. <td>位置</td>
  3829. <td>库存编码</td>
  3830. <td>类目</td>
  3831. <td>SKU</td>
  3832. <td>用友编码</td>
  3833. <td>用友料号</td>
  3834. <td>商品名称</td>
  3835. <td>商品中文</td>
  3836. <td>产品备注</td>
  3837. <td>说明</td>
  3838. <td>类型</td>
  3839. <td>入库总量</td>
  3840. <td>库存数量</td>
  3841. <td>销售数量</td>
  3842. <td>退货数量</td>
  3843. <td>删除数量</td>
  3844. <td>其它操作</td>
  3845. <td>占单数量</td>
  3846. </tr>
  3847. </table>";
  3848. $filename = $title.".xls";
  3849. $tail = "";
  3850. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  3851. }
  3852. }
  3853. //入库导出
  3854. public function _excelr()
  3855. {
  3856. if(isset($_GET['excel']))
  3857. {
  3858. $category = $this->input->get('category',true);
  3859. $size = $this->input->get('size',true);
  3860. $grade = $this->input->get('grade',true);
  3861. $color = $this->input->get('color',true);
  3862. $lowe = $this->input->get('lowe',true);
  3863. $sku = $this->input->get('sku',true);
  3864. $warehouse = $this->input->get('warehouse',true);
  3865. $purchase = $this->input->get('purchase',true);
  3866. $ktime = $this->input->get('ktime',true);
  3867. $jtime = $this->input->get('jtime',true);
  3868. $ktime = strtotime($ktime);
  3869. $jtime = strtotime($jtime);
  3870. $where = "1=1";$gj = "";$ck = "";
  3871. if($category)
  3872. {
  3873. $where .= " and features like '%-$category-%'";
  3874. }
  3875. if($size)
  3876. {
  3877. $where .= " and features like '%-$size-%'";
  3878. }
  3879. if($grade)
  3880. {
  3881. $where .= " and features like '%-$grade-%'";
  3882. }
  3883. if($color)
  3884. {
  3885. $where .= " and features like '%-$color-%'";
  3886. }
  3887. if($lowe)
  3888. {
  3889. $where .= " and features like '%-$lowe-%'";
  3890. }
  3891. if($warehouse)
  3892. {
  3893. $where .= " and warehouse = '$warehouse'";
  3894. }
  3895. if($purchase)
  3896. {
  3897. $where .= " and purchase = '$purchase'";
  3898. }
  3899. if($sku)
  3900. {
  3901. $where .= " and sku = '$sku'";
  3902. }
  3903. if($ktime && $jtime)
  3904. {
  3905. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3906. }
  3907. //数据排序
  3908. $order_str = "id desc";
  3909. if(empty($page))
  3910. {
  3911. $start = 0;
  3912. $perpage = 1;
  3913. }
  3914. else
  3915. {
  3916. $start = ($page - 1)*$perpage;
  3917. }
  3918. $list = array();
  3919. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3920. foreach ($rows as $value)
  3921. {
  3922. $ck = $this->warehouse->read($value['warehouse']);
  3923. $warehouse = $ck['title'];
  3924. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3925. $retreatwarehouse = $tkck['title'];
  3926. $gy = $this->purchase->read($value['purchase']);
  3927. $purchase = $gy['title'];
  3928. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3929. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3930. }
  3931. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3932. $titlename = "<table border=1>
  3933. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  3934. <tr align='center'>
  3935. <td>仓库</td>
  3936. <td>SKU</td>
  3937. <td>产品</td>
  3938. <td>时间</td>
  3939. <td>数量</td>
  3940. </tr>
  3941. </table>";
  3942. $filename = $title.".xls";
  3943. $tail = "";
  3944. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3945. }
  3946. }
  3947. //出库、退库导出
  3948. public function _excelct()
  3949. {
  3950. $classid = $this->classid->sku();
  3951. $pm = $classid;
  3952. $typeclass = array();
  3953. $tc = $this->typeclass->find_all();
  3954. foreach ($tc as $v)
  3955. {
  3956. $typeclass[$v['id']] = $v;
  3957. }
  3958. $prc = array();
  3959. $purchase = $this->purchase->find_all();
  3960. foreach($purchase as $k=>$v)
  3961. {
  3962. $prc[$v['id']] = $v['title'];
  3963. }
  3964. if(isset($_GET['excel']))
  3965. {
  3966. $wh = array();
  3967. $w = $this->warehouse->find_all('1=1','id,title');
  3968. foreach ($w as $v)
  3969. {
  3970. $wh[$v['id']] = $v['title'];
  3971. }
  3972. $type = $this->input->get('excel',true);
  3973. $category = $this->input->get('category',true);
  3974. $size = $this->input->get('size',true);
  3975. $grade = $this->input->get('grade',true);
  3976. $color = $this->input->get('color',true);
  3977. $lowe = $this->input->get('lowe',true);
  3978. $sku = $this->input->get('sku',true);
  3979. $warehouse = $this->input->get('warehouse',true);
  3980. $lacetype = $this->input->get('lacetype',true);
  3981. $lacecolor = $this->input->get('lacecolor',true);
  3982. $density = $this->input->get('density',true);
  3983. $haircap = $this->input->get('haircap',true);
  3984. $purchase = $this->input->get('purchase',true);
  3985. $title = $this->input->get('title',true);
  3986. $state = $this->input->get('state',true);
  3987. $sid = $this->input->get('sid',true);
  3988. $ktime = $this->input->get('ktime',true);
  3989. $jtime = $this->input->get('jtime',true);
  3990. $ktime = strtotime($ktime);
  3991. $jtime = strtotime($jtime);
  3992. $where = "1=1";$gj = "";$ck = "";
  3993. if($category)
  3994. {
  3995. $where .= " and features like '%-$category-%'";
  3996. }
  3997. if($size)
  3998. {
  3999. $where .= " and features like '%-$size-%'";
  4000. }
  4001. if($grade)
  4002. {
  4003. $where .= " and features like '%-$grade-%'";
  4004. }
  4005. if($color)
  4006. {
  4007. $where .= " and features like '%-$color-%'";
  4008. }
  4009. if($lowe)
  4010. {
  4011. $where .= " and features like '%-$lowe-%'";
  4012. }
  4013. if($warehouse)
  4014. {
  4015. $where .= " and warehouse = '$warehouse'";
  4016. }
  4017. if($purchase)
  4018. {
  4019. $where .= " and purchase = '$purchase'";
  4020. }
  4021. if($state)
  4022. {
  4023. $where .= " and state = '$state'";
  4024. }
  4025. if($lacetype)
  4026. {
  4027. $where .= " and features like '%-$lacetype-%'";
  4028. }
  4029. if($lacecolor)
  4030. {
  4031. $where .= " and features like '%-$lacecolor-%'";
  4032. }
  4033. if($density)
  4034. {
  4035. $where .= " and features like '%-$density-%'";
  4036. }
  4037. if($haircap)
  4038. {
  4039. $where .= " and features like '%-$haircap-%'";
  4040. }
  4041. if($title)
  4042. {
  4043. $title = trim($title,' ');
  4044. $title = trim($title,' ');
  4045. $where .= " and title like '%$title%'";
  4046. }
  4047. if($sku)
  4048. {
  4049. $sku = trim($sku,' ');
  4050. $sku = trim($sku,' ');
  4051. $where .= " and sku like '%$sku%'";
  4052. }
  4053. if($ktime && $jtime)
  4054. {
  4055. if($type == 1)
  4056. {
  4057. $tl = '出库';
  4058. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4059. }
  4060. else if($type == 2)
  4061. {
  4062. $tl = '退库';
  4063. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4064. }
  4065. else if($type == 3)
  4066. {
  4067. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4068. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4069. }
  4070. else if($type == 4)
  4071. {
  4072. $tl = '出库+零售';
  4073. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4074. }
  4075. else if($type == 5)
  4076. {
  4077. $tl = '零售';
  4078. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4079. }
  4080. }
  4081. $sidwhere = '';
  4082. if($sid)
  4083. {
  4084. $sd = "";
  4085. $s = explode(',',trim($sid,','));
  4086. foreach ($s as $value)
  4087. {
  4088. $sd .= " id = ".$value." or";
  4089. }
  4090. $sidwhere = " and (".rtrim($sd,'or').")";
  4091. }
  4092. //数据排序
  4093. $order_str = "time desc";
  4094. if(empty($page))
  4095. {
  4096. $start = 0;
  4097. $perpage = 1;
  4098. }
  4099. else
  4100. {
  4101. $start = ($page - 1)*$perpage;
  4102. }
  4103. //取得信息列表
  4104. if($type != 3 && $type != 5)
  4105. {
  4106. if($type == 1 || $type == 4)
  4107. {
  4108. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4109. foreach ($info_list as $key=>$value)
  4110. {
  4111. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4112. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4113. $warehouse = $this->warehouse->read($value['warehouse']);
  4114. $info_list[$key]['warehouse'] = $warehouse['title'];
  4115. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4116. $features = explode('-',trim($features,'-'));
  4117. $pm = $classid;
  4118. foreach($features as $k=>$v)
  4119. {
  4120. if($v != 0)
  4121. {
  4122. if(!isset($typeclass[$v]))
  4123. {
  4124. continue;
  4125. }
  4126. if(isset($pm[$typeclass[$v]['classid']]))
  4127. {
  4128. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4129. {
  4130. $tz = explode('|',$typeclass[$v]['zh']);
  4131. $pm[$typeclass[$v]['classid']] = $tz[0];
  4132. }
  4133. else
  4134. {
  4135. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4136. }
  4137. }
  4138. }
  4139. }
  4140. $zh = implode(" ",$pm);
  4141. $zh = str_replace('自然色 ','',trim($zh,' '));
  4142. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4143. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4144. $info_list[$key]['features'] = $zh;
  4145. }
  4146. }
  4147. else
  4148. {
  4149. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4150. foreach ($info_list as $key=>$value)
  4151. {
  4152. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4153. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4154. $warehouse = $this->warehouse->read($value['warehouse']);
  4155. $info_list[$key]['warehouse'] = $warehouse['title'];
  4156. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4157. $features = explode('-',trim($features,'-'));
  4158. $pm = $classid;
  4159. foreach($features as $k=>$v)
  4160. {
  4161. if($v != 0)
  4162. {
  4163. if(!isset($typeclass[$v]))
  4164. {
  4165. continue;
  4166. }
  4167. if(isset($pm[$typeclass[$v]['classid']]))
  4168. {
  4169. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4170. {
  4171. $tz = explode('|',$typeclass[$v]['zh']);
  4172. $pm[$typeclass[$v]['classid']] = $tz[0];
  4173. }
  4174. else
  4175. {
  4176. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4177. }
  4178. }
  4179. }
  4180. }
  4181. $zh = implode(" ",$pm);
  4182. $zh = str_replace('自然色 ','',trim($zh,' '));
  4183. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4184. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4185. $info_list[$key]['features'] = $zh;
  4186. }
  4187. }
  4188. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4189. $titlename = "<table border=1>
  4190. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4191. <tr align='center'>
  4192. <td>仓库</td>
  4193. <td>供应商</td>
  4194. <td>SKU</td>
  4195. <td>商品名称</td>
  4196. <td>商品中文</td>
  4197. <td>标签</td>
  4198. <td>订单号</td>
  4199. <td>运单号</td>
  4200. <td>".$tl."时间(中国时间)</td>
  4201. </tr>
  4202. </table>";
  4203. $filename = $title.".xls";
  4204. $tail = "";
  4205. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4206. }
  4207. else if($type == 5)
  4208. {
  4209. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4210. foreach ($info_list as $key=>$value)
  4211. {
  4212. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4213. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4214. $warehouse = $this->warehouse->read($value['warehouse']);
  4215. $info_list[$key]['warehouse'] = $warehouse['title'];
  4216. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4217. $features = explode('-',trim($features,'-'));
  4218. $pm = $classid;
  4219. foreach($features as $k=>$v)
  4220. {
  4221. if($v != 0)
  4222. {
  4223. if(!isset($typeclass[$v]))
  4224. {
  4225. continue;
  4226. }
  4227. if(isset($pm[$typeclass[$v]['classid']]))
  4228. {
  4229. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4230. {
  4231. $tz = explode('|',$typeclass[$v]['zh']);
  4232. $pm[$typeclass[$v]['classid']] = $tz[0];
  4233. }
  4234. else
  4235. {
  4236. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4237. }
  4238. }
  4239. }
  4240. }
  4241. $zh = implode(" ",$pm);
  4242. $zh = str_replace('自然色 ','',trim($zh,' '));
  4243. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4244. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4245. $info_list[$key]['features'] = $zh;
  4246. }
  4247. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4248. $titlename = "<table border=1>
  4249. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4250. <tr align='center'>
  4251. <td>仓库</td>
  4252. <td>供应商</td>
  4253. <td>SKU</td>
  4254. <td>商品名称</td>
  4255. <td>商品中文</td>
  4256. <td>标签</td>
  4257. <td>".$tl."时间(中国时间)</td>
  4258. </tr>
  4259. </table>";
  4260. $filename = $title.".xls";
  4261. $tail = "";
  4262. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4263. }
  4264. else
  4265. {
  4266. /**
  4267. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4268. $rows = array();$list = array();
  4269. foreach ($info_list as $key=>$value)
  4270. {
  4271. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4272. }
  4273. **/
  4274. $wh = array();
  4275. $w = $this->warehouse->find_all('1=1','id,title');
  4276. foreach ($w as $v)
  4277. {
  4278. $wh[$v['id']] = $v['title'];
  4279. }
  4280. $wt = array();
  4281. $whlabel_type = $this->whlabel_type->find_all();
  4282. foreach ($whlabel_type as $v)
  4283. {
  4284. $wt[$v['id']] = $v['title'];
  4285. }
  4286. $classid = $this->classid->sku();
  4287. $list = array();
  4288. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4289. foreach ($rows as $key=>$value)
  4290. {
  4291. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4292. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4293. $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');
  4294. $details = array();
  4295. $cpid = array();
  4296. $cpbz = array();
  4297. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4298. foreach ($sd as $k=>$v)
  4299. {
  4300. if($v['state'] == 0)
  4301. {
  4302. $c++;
  4303. }
  4304. if($v['state'] != 9)
  4305. {
  4306. $g++;
  4307. }
  4308. if($v['outk'] > 1)
  4309. {
  4310. $x++;
  4311. }
  4312. if($v['retreat'] > 0)
  4313. {
  4314. $t++;
  4315. }
  4316. if($v['state'] == 8)
  4317. {
  4318. $s++;
  4319. }
  4320. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4321. {
  4322. $q++;
  4323. }
  4324. $details[$v['details']] = $v['details'];
  4325. if($v['cpid'] != 0)
  4326. {
  4327. $cpid[$v['cpid']] = $v['cpid'];
  4328. }
  4329. if($v['cpbz'] != '')
  4330. {
  4331. $cpbz[$v['cpbz']] = $v['cpbz'];
  4332. }
  4333. }
  4334. if(isset($wt[$value['type']]))
  4335. {
  4336. $rows[$key]['type'] = $wt[$value['type']];
  4337. }
  4338. else
  4339. {
  4340. $rows[$key]['type'] = '未设置';
  4341. }
  4342. $rows[$key]['details'] = implode("、",$details);
  4343. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4344. $ftime = time()-15*24*3600;
  4345. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4346. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4347. $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);
  4348. $rows[$key]['c'] = $c;
  4349. $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);
  4350. $rows[$key]['t'] = $t;
  4351. $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'].'"');
  4352. $rows[$key]['z'] = $z;
  4353. $jm = $classid;
  4354. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4355. $features = explode('-',trim($features,'-'));
  4356. $pm = $classid;
  4357. foreach($features as $k=>$v)
  4358. {
  4359. if($v != 0)
  4360. {
  4361. if(!isset($typeclass[$v]))
  4362. {
  4363. continue;
  4364. }
  4365. if(isset($pm[$typeclass[$v]['classid']]))
  4366. {
  4367. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4368. {
  4369. $tz = explode('|',$typeclass[$v]['zh']);
  4370. $pm[$typeclass[$v]['classid']] = $tz[0];
  4371. }
  4372. else
  4373. {
  4374. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4375. }
  4376. if(isset($jm[$typeclass[$v]['classid']]))
  4377. {
  4378. if($typeclass[$v]['jm'])
  4379. {
  4380. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4381. }
  4382. }
  4383. }
  4384. }
  4385. }
  4386. $zh = implode(" ",$pm);
  4387. $zh = str_replace('自然色 ','',trim($zh,' '));
  4388. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4389. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4390. $rows[$key]['features'] = $zh;
  4391. $jm = array_filter($jm);//去除空值
  4392. $jm = implode("-",$jm);
  4393. $rows[$key]['jm'] = $jm;
  4394. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4395. }
  4396. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4397. $titlename = "<table border=1>
  4398. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4399. <tr align='center'>
  4400. <td>仓库</td>
  4401. <td>供应商</td>
  4402. <td>位置</td>
  4403. <td>库存编码</td>
  4404. <td>SKU</td>
  4405. <td>商品名称</td>
  4406. <td>商品中文</td>
  4407. <td>产品备注</td>
  4408. <td>说明</td>
  4409. <td>类型</td>
  4410. <td>入库总量</td>
  4411. <td>库存数量</td>
  4412. <td>销售数量</td>
  4413. <td>退货数量</td>
  4414. <td>占单数量</td>
  4415. <td>料号</td>
  4416. <td>类目</td>
  4417. </tr>
  4418. </table>";
  4419. $filename = $title.".xls";
  4420. $tail = "";
  4421. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4422. }
  4423. }
  4424. }
  4425. //出库+入库数据整合
  4426. public function _excelcr()
  4427. {
  4428. if(isset($_GET['excel']))
  4429. {
  4430. $type = $this->input->get('excel',true);
  4431. $category = $this->input->get('category',true);
  4432. $size = $this->input->get('size',true);
  4433. $grade = $this->input->get('grade',true);
  4434. $color = $this->input->get('color',true);
  4435. $lowe = $this->input->get('lowe',true);
  4436. $sku = $this->input->get('sku',true);
  4437. $warehouse = $this->input->get('warehouse',true);
  4438. $purchase = $this->input->get('purchase',true);
  4439. $state = $this->input->get('state',true);
  4440. $sid = $this->input->get('sid',true);
  4441. $ktime = $this->input->get('ktime',true);
  4442. $jtime = $this->input->get('jtime',true);
  4443. $ktime = strtotime($ktime);
  4444. $jtime = strtotime($jtime);
  4445. $where = "1=1";$gj = "";$ck = "";
  4446. if($category)
  4447. {
  4448. $where .= " and features like '%-$category-%'";
  4449. }
  4450. if($size)
  4451. {
  4452. $where .= " and features like '%-$size-%'";
  4453. }
  4454. if($grade)
  4455. {
  4456. $where .= " and features like '%-$grade-%'";
  4457. }
  4458. if($color)
  4459. {
  4460. $where .= " and features like '%-$color-%'";
  4461. }
  4462. if($lowe)
  4463. {
  4464. $where .= " and features like '%-$lowe-%'";
  4465. }
  4466. if($warehouse)
  4467. {
  4468. $where .= " and warehouse = '$warehouse'";
  4469. }
  4470. if($purchase)
  4471. {
  4472. $where .= " and purchase = '$purchase'";
  4473. }
  4474. if($state)
  4475. {
  4476. $where .= " and state = '$state'";
  4477. }
  4478. if($sku)
  4479. {
  4480. $where .= " and sku like '%$sku%'";
  4481. }
  4482. if($ktime && $jtime)
  4483. {
  4484. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4485. }
  4486. $sidwhere = '';
  4487. if($sid)
  4488. {
  4489. $sd = "";
  4490. $s = explode(',',trim($sid,','));
  4491. foreach ($s as $value)
  4492. {
  4493. $sd .= " id = ".$value." or";
  4494. }
  4495. $sidwhere .= " and (".rtrim($sd,'or').")";
  4496. }
  4497. //取得信息列表
  4498. $timeread = $ktime;
  4499. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4500. $timelist = array();
  4501. for($i=0;$i<$timenum;$i++)
  4502. {
  4503. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4504. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4505. }
  4506. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4507. //echo "<pre>";
  4508. //print_r($info_list);
  4509. //exit();
  4510. $rows = array();$list = array();
  4511. foreach ($info_list as $key=>$value)
  4512. {
  4513. $thistime = $timelist;
  4514. if(isset($rows[strtolower($value['sku'])]))
  4515. {
  4516. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4517. {
  4518. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4519. }
  4520. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4521. {
  4522. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4523. }
  4524. }
  4525. else
  4526. {
  4527. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4528. {
  4529. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4530. }
  4531. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4532. {
  4533. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4534. }
  4535. $rows[strtolower($value['sku'])] = $thistime;
  4536. }
  4537. }
  4538. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4539. <head>
  4540. <!--[if gte mso 9]><xml>
  4541. <x:ExcelWorkbook>
  4542. <x:ExcelWorksheets>
  4543. <x:ExcelWorksheet>
  4544. <x:Name>EXCEL</x:Name>
  4545. <x:WorksheetOptions>
  4546. <x:Print>
  4547. <x:ValidPrinterInfo />
  4548. </x:Print>
  4549. </x:WorksheetOptions>
  4550. </x:ExcelWorksheet>
  4551. </x:ExcelWorksheets>
  4552. </x:ExcelWorkbook>
  4553. </xml>
  4554. <![endif]-->
  4555. </head><body>";
  4556. $str .= "<table border=1><tr><td>SKU</td>";
  4557. foreach ($timelist as $k=>$v)
  4558. {
  4559. $str .="<td>".$k."出库</td>";
  4560. $str .="<td>".$k."入库</td>";
  4561. }
  4562. $str .= "</tr></table>";
  4563. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4564. foreach ($rows as $key=>$val)
  4565. {
  4566. $str .= "<tr><td>".strtoupper($key)."</td>";
  4567. foreach ($val as $k=>$v)
  4568. {
  4569. $str .= "<td>".$val[$k]['c']."</td>";
  4570. if($val[$k]['r'] > 0)
  4571. {
  4572. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4573. }
  4574. else
  4575. {
  4576. $str .= "<td>".$val[$k]['r']."</td>";
  4577. }
  4578. }
  4579. $str .= "</tr>";
  4580. }
  4581. $str .= "</table>";
  4582. $str .= "</body></html>";
  4583. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4584. header( "Content-type: application/octet-stream" );
  4585. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4586. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4587. header( "Pragma: no-cache" );
  4588. header( "Expires: 0" );
  4589. exit($str);
  4590. }
  4591. }
  4592. //数量调整模板导出
  4593. public function _presetout()
  4594. {
  4595. if(isset($_GET['excel']))
  4596. {
  4597. $where = "sku != 'Preset' and purchase != 0";
  4598. //数据排序
  4599. $order_str = "id desc";
  4600. if(empty($page))
  4601. {
  4602. $start = 0;
  4603. $perpage = 1;
  4604. }
  4605. else
  4606. {
  4607. $start = ($page - 1)*$perpage;
  4608. }
  4609. //取得信息列表
  4610. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4611. $rows = array();$list = array();
  4612. foreach ($info_list as $value)
  4613. {
  4614. $warehouse = $this->warehouse->read($value['warehouse']);
  4615. $number = $value['number'];$ftime = time()-15*24*3600;
  4616. $purchase = $this->purchase->read($value['purchase']);
  4617. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4618. }
  4619. $title = "库存模板";
  4620. $titlename = "<table border=1>
  4621. <tr align='center'>
  4622. <td>仓库</td>
  4623. <td>供应商编码</td>
  4624. <td>SKU</td>
  4625. <td>增减数量(正数或负数)</td>
  4626. <td>增减备注</td>
  4627. <td>扣减方式:0减少库存1删除库存</td>
  4628. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4629. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4630. </tr>
  4631. </table>";
  4632. $filename = $title.".xls";
  4633. $tail = "";
  4634. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4635. }
  4636. }
  4637. //数量调整模板导入
  4638. public function _presetedit()
  4639. {
  4640. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4641. $config['upload_path'] = '.'.$dir ;
  4642. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4643. $config['allowed_types'] = 'xls|xlsx|csv';
  4644. $config['max_size'] = 10240;
  4645. $this->load->library('upload', $config);
  4646. $this->upload->initialize($config);
  4647. if ($this->upload->do_upload('userfile'))
  4648. {
  4649. $full_path = $dir.$this->upload->data('file_name');
  4650. $fileName = '.' . $full_path;
  4651. if (!file_exists($fileName))
  4652. {
  4653. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4654. }
  4655. else
  4656. {
  4657. require_once "./data/excel/PHPExcel/IOFactory.php";
  4658. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4659. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4660. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4661. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4662. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4663. ++$column;//如果列数大于26行
  4664. $list = array();
  4665. for ($i = 2; $i <= $row; $i++) // 行数循环
  4666. {
  4667. $data = array();
  4668. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4669. {
  4670. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4671. }
  4672. $list[] = $data;
  4673. }
  4674. }
  4675. $i = 0;$j = 0;$ed = array();
  4676. foreach ($list as $key=>$value)
  4677. {
  4678. $time = time();
  4679. if($value['0'] == "")
  4680. {
  4681. continue;
  4682. }
  4683. $warehouse = $this->warehouse->get_title($value['0']);
  4684. $purchase = $this->purchase->get_bm($value['1']);
  4685. $sku = $value['2'];
  4686. $num = $value['3'];//调整数量
  4687. $text = $value['4'];//扣减说明
  4688. $type = $value['5'];//调整方式0扣减1删除
  4689. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4690. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4691. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4692. if(!$purchase)//如果没有这个SKU
  4693. {
  4694. $ed[] = array($purchase.'-不存在此供应商编码');
  4695. $j++;
  4696. continue;
  4697. }
  4698. if(!$d)//如果没有这个SKU
  4699. {
  4700. $ed[] = array($sku.'-库存中不存在此SKU');
  4701. $j++;
  4702. continue;
  4703. }
  4704. if(!isset($warehouse['id']))
  4705. {
  4706. $ed[] = array($sku.'-仓库名错误!');
  4707. $j++;
  4708. continue;
  4709. }
  4710. if($type != '0' && $type != '1')
  4711. {
  4712. $ed[] = array($sku.'-扣减方式填写错误!');
  4713. $j++;
  4714. continue;
  4715. }
  4716. if($num < 0)//扣减库存
  4717. {
  4718. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4719. {
  4720. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4721. $j++;
  4722. continue;
  4723. }
  4724. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4725. if(count($data) < abs($num))
  4726. {
  4727. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4728. $j++;
  4729. continue;
  4730. }
  4731. if($type == 0)//如果扣减方式为 扣减库存
  4732. {
  4733. for($i=0;$i<abs($num);$i++)
  4734. {
  4735. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4736. }
  4737. }
  4738. else if($type == 1)
  4739. {
  4740. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4741. if(count($zt) > 0)
  4742. {
  4743. $ed[] = array($sku.'-有在途库存无法删除!');
  4744. $j++;
  4745. continue;
  4746. }
  4747. for($i=0;$i<abs($num);$i++)
  4748. {
  4749. $this->whlabel->remove($data[$i]['id']);
  4750. }
  4751. }
  4752. }
  4753. else if($num > 0)//增加库存
  4754. {
  4755. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4756. {
  4757. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4758. $j++;
  4759. continue;
  4760. }
  4761. $post['sku'] = $d['sku'];
  4762. $post['shop'] = $d['shop'];
  4763. $post['warehouse'] = $warehouse['id'];
  4764. $post['purchase'] = $purchase['id'];
  4765. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4766. $post['state'] = 0;
  4767. $post['title'] = $d['title'];
  4768. $post['number'] = $d['number'];
  4769. $post['features'] = $d['features'];
  4770. $post['enter'] = $time;
  4771. $post['time'] = $time;//操作时间
  4772. $post['rktype'] = $rktype;
  4773. for($i=0;$i<$num;$i++)
  4774. {
  4775. $post['label'] = time().rand(100,999).$i;
  4776. $this->whlabel->insert($post);
  4777. }
  4778. }
  4779. sleep(1);//防止入库时间一样,需要延迟1秒
  4780. }
  4781. if($j > 0)
  4782. {
  4783. $tt = date('Ymd',time());
  4784. $title = '库存导入错误信息-'.$tt;
  4785. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4786. $tail = "\n";
  4787. $filename = $title.".xls";
  4788. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4789. $dir = '/data/excel/'.$time.'/';
  4790. $file_name = 'error_'.$time.rand(1000,9999);
  4791. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4792. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4793. fwrite($myfile,$ecl);
  4794. fclose($myfile);
  4795. $error = $dir.$file_name.'.xls';
  4796. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4797. }
  4798. else
  4799. {
  4800. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4801. }
  4802. }
  4803. }
  4804. //笛卡儿积
  4805. function cp($ps,$sets,$list)
  4806. {
  4807. $result = array();$j=0;
  4808. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4809. {
  4810. if($i==0)
  4811. {
  4812. $result = $sets[$i];
  4813. }
  4814. $tmp = array();
  4815. foreach($result as $res)
  4816. {
  4817. foreach($sets[$i+1] as $set)
  4818. {
  4819. $tmp[] = $res.','.$set;
  4820. }
  4821. }
  4822. $result = $tmp;
  4823. }
  4824. $this->db->trans_begin();
  4825. foreach ($result as $v)
  4826. {
  4827. $post = array();$title = "";$num="";
  4828. $data = explode(',',$v);
  4829. for($i=0;$i<count($list); $i++)
  4830. {
  4831. $post[$list[$i]] = $data[$i];
  4832. $typeclass = $this->typeclass->read($data[$i]);
  4833. $title = $title.$typeclass['title']." ";
  4834. if($data[$i] != 0)
  4835. {
  4836. $num .=$data[$i];//所有数据ID拼接
  4837. }
  4838. }
  4839. foreach ($ps as $kp=>$vp)
  4840. {
  4841. $post[$kp] = $vp;
  4842. }
  4843. $post['number'] = $num;
  4844. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4845. if($info_list)
  4846. {
  4847. $j++;
  4848. }
  4849. else
  4850. {
  4851. $skunum = $this->whlabel->find_count();
  4852. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4853. $post['title'] = rtrim($title,' ');
  4854. $this->whlabel->insert($post);
  4855. }
  4856. }
  4857. if ($this->db->trans_status() === FALSE)
  4858. {
  4859. $this->db->trans_commit();
  4860. return NULL;
  4861. }
  4862. else
  4863. {
  4864. $this->db->trans_commit();
  4865. return $j;
  4866. }
  4867. }
  4868. public function _kj($arg_array)
  4869. {
  4870. if(isset($_POST['sku']))
  4871. {
  4872. $time = time();
  4873. $sku = $this->input->post('sku',true);
  4874. $warehouse = $this->input->post('warehouse',true);
  4875. $num = $this->input->post('num',true);
  4876. $text = $this->input->post('text',true);
  4877. $purchase = $this->input->post('purchase',true);
  4878. $cktype = $this->input->post('cktype',true);
  4879. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4880. if($cktype != 1 && $text == '')
  4881. {
  4882. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4883. }
  4884. if($num > count($order))
  4885. {
  4886. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4887. }
  4888. else
  4889. {
  4890. for($i=0;$i<$num;$i++)
  4891. {
  4892. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4893. }
  4894. }
  4895. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4896. }
  4897. $uid = $this->whlabel->read($arg_array[0]);
  4898. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4899. $this->data['data'] = $uid ;
  4900. $this->_Template('whlabel_kj',$this->data);
  4901. }
  4902. public function _summary($arg_array)
  4903. {
  4904. $prc = array();
  4905. $purchase = $this->purchase->find_all();
  4906. foreach($purchase as $k=>$v)
  4907. {
  4908. $prc[$v['id']] = $v['title'];
  4909. }
  4910. if(isset($_GET['excel']))
  4911. {
  4912. $ktime = $this->input->get('ktime',true);
  4913. $jtime = $this->input->get('jtime',true);
  4914. $ktime = strtotime($ktime);
  4915. $jtime = strtotime($jtime);
  4916. $where = "1=1";
  4917. if($ktime && $jtime)
  4918. {
  4919. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4920. }
  4921. //数据排序
  4922. $order_str = "time desc";
  4923. if(empty($page))
  4924. {
  4925. $start = 0;
  4926. $perpage = 1;
  4927. }
  4928. else
  4929. {
  4930. $start = ($page - 1)*$perpage;
  4931. }
  4932. //取得信息列表
  4933. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  4934. foreach ($info_list as $key=>$value)
  4935. {
  4936. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4937. $warehouse = $this->warehouse->read($value['warehouse']);
  4938. $info_list[$key]['warehouse'] = $warehouse['title'];
  4939. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  4940. $details = array();
  4941. $cpid = array();
  4942. foreach ($x as $k=>$v)
  4943. {
  4944. if($v['details'] != '')
  4945. {
  4946. $details[$v['details']] = $v['details'];
  4947. }
  4948. if($v['cpid'] != 0)
  4949. {
  4950. $cpid[$v['cpid']] = $v['cpid'];
  4951. }
  4952. }
  4953. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  4954. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4955. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  4956. $info_list[$key]['s'] = $s;
  4957. $info_list[$key]['x'] = count($x);
  4958. }
  4959. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  4960. $titlename = "<table border=1>
  4961. <tr align='center'>
  4962. <td>仓库</td>
  4963. <td>供应商</td>
  4964. <td>出库位置</td>
  4965. <td>出库编码</td>
  4966. <td>SKU</td>
  4967. <td>产品名</td>
  4968. <td>总剩余库存</td>
  4969. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  4970. </tr>
  4971. </table>";
  4972. $filename = $title.".xls";
  4973. $tail = "";
  4974. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4975. }
  4976. }
  4977. //usps发货清单
  4978. public function _manifest()
  4979. {
  4980. if(isset($_POST['manifest']))
  4981. {
  4982. $wltext = $this->input->post('wltext',true);
  4983. $time = time()-16*3600;
  4984. $ptime = strtotime(date('Y-m-d',$time));
  4985. $waybill = array();
  4986. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  4987. foreach ($fullorder as $v)
  4988. {
  4989. $waybill[$v['waybill']] = $v['waybill'];
  4990. }
  4991. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  4992. foreach ($fullordersmt as $v)
  4993. {
  4994. $waybill[$v['waybill']] = $v['waybill'];
  4995. }
  4996. $wltext = explode(';',$wltext);
  4997. foreach ($wltext as $v)
  4998. {
  4999. if(isset($waybill[$v]))
  5000. {
  5001. unset($waybill[$v]);
  5002. }
  5003. }
  5004. $data = $this->usps->get_manifest($waybill);
  5005. if(isset($data['Description']))
  5006. {
  5007. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  5008. }
  5009. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  5010. {
  5011. $bctime = date('Ymd',time());
  5012. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5013. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5014. }
  5015. else
  5016. {
  5017. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5018. }
  5019. }
  5020. }
  5021. public function _pdf($pdf,$title,$bctime)
  5022. {
  5023. $pdf_path = './data/pdf/'.$bctime.'/';
  5024. $file_base64 = $pdf;
  5025. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5026. $file_base64 = base64_decode($file_base64);
  5027. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5028. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5029. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5030. }
  5031. /**
  5032. *
  5033. *
  5034. *
  5035. 进销存占单异常索引
  5036. *
  5037. *
  5038. *
  5039. **/
  5040. public function _abnormal()
  5041. {
  5042. $post = $this->input->post(NULL, TRUE);
  5043. if(isset($post['page']))
  5044. {
  5045. $page = $this->input->post('page',true);
  5046. $perpage = $this->input->post('perpage',true);
  5047. $sku = $this->input->post('sku',true);
  5048. $where = "1=1";
  5049. //数据排序
  5050. $order_str = "id desc";
  5051. if(empty($page))
  5052. {
  5053. $start = 0;
  5054. $perpage = 1;
  5055. }
  5056. else
  5057. {
  5058. $start = ($page - 1)*$perpage;
  5059. }
  5060. //取得信息列表
  5061. $info_list = $this->whlabel->find_all($where,'*');
  5062. $rows = array();$list = array();
  5063. foreach ($info_list as $key=>$value)
  5064. {
  5065. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5066. }
  5067. foreach ($rows as $value)
  5068. {
  5069. $warehouse = $this->warehouse->read($value['warehouse']);
  5070. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5071. $number = $value['number'];$ftime = time()-15*24*3600;
  5072. if($value['shop'] != '')
  5073. {
  5074. $shop = $value['shop'];
  5075. $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');
  5076. $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');
  5077. $order = array_merge($orderdlz,$ordersmt);
  5078. $od = 0;$a = '';$orid = '';
  5079. foreach ($order as $v)
  5080. {
  5081. $or = explode('|',ltrim($v['whlabel'],'|'));
  5082. for($i=0;$i<count($or);$i++)
  5083. {
  5084. $orod = explode('-',$or[$i]);
  5085. if($orod[0] == $number)
  5086. {
  5087. $od += $orod[1];
  5088. }
  5089. }
  5090. $orid .= $v['number'].'-';
  5091. }
  5092. }
  5093. else
  5094. {
  5095. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5096. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5097. $order = array_merge($orderdlz,$ordersmt);
  5098. $od = 0;$a = '';$orid = '';$qt = array();
  5099. foreach ($order as $v)
  5100. {
  5101. $or = explode('|',ltrim($v['whlabel'],'|'));
  5102. for($i=0;$i<count($or);$i++)
  5103. {
  5104. $orod = explode('-',$or[$i]);
  5105. if($orod[0] == $number)
  5106. {
  5107. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5108. if($czzs > 0)
  5109. {
  5110. if(isset($qt[$v['shop']]))
  5111. {
  5112. if($qt[$v['shop']] < $orod[1])
  5113. {
  5114. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5115. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5116. }
  5117. else
  5118. {
  5119. $qt[$v['shop']] -= $orod[1];
  5120. }
  5121. }
  5122. else
  5123. {
  5124. $qt[$v['shop']] = $czzs;
  5125. }
  5126. }
  5127. else
  5128. {
  5129. $od += $orod[1];
  5130. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5131. }
  5132. }
  5133. }
  5134. }
  5135. }
  5136. $z = $od.'('.$orid.')';//查看订单号
  5137. //$z = $od;
  5138. if($od > $c)
  5139. {
  5140. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5141. }
  5142. }
  5143. $listdata = array_slice($list,$start,$perpage);
  5144. $total = count($list);
  5145. $pagenum = ceil($total/$perpage);
  5146. $over = $total-($start+$perpage);
  5147. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5148. echo json_encode($rows);exit;
  5149. }
  5150. $this->_Template('whlabel_abnormal',$this->data);
  5151. }
  5152. /**
  5153. *
  5154. *
  5155. *
  5156. 进销存占单异常索引
  5157. *
  5158. *
  5159. *
  5160. **/
  5161. public function _error()
  5162. {
  5163. $post = $this->input->post(NULL, TRUE);
  5164. if(isset($post['page']))
  5165. {
  5166. $page = $this->input->post('page',true);
  5167. $perpage = $this->input->post('perpage',true);
  5168. $sku = $this->input->post('sku',true);
  5169. $warehouse = $this->input->post('warehouse',true);
  5170. $ktime = $this->input->post('ktime',true);
  5171. $jtime = $this->input->post('jtime',true);
  5172. $ktime = strtotime($ktime);
  5173. $jtime = strtotime($jtime);
  5174. $where = "sku != 'Preset'";
  5175. $gj = '';
  5176. if($sku)
  5177. {
  5178. $where .= " and sku like '%$sku%'";
  5179. }
  5180. else
  5181. {
  5182. if($ktime && $jtime)
  5183. {
  5184. $gj = " and time > '$ktime' and time < '$jtime'";
  5185. }
  5186. }
  5187. if($warehouse)
  5188. {
  5189. $where .= " and warehouse = '$warehouse'";
  5190. }
  5191. //数据排序
  5192. $order_str = "id desc";
  5193. if(empty($page))
  5194. {
  5195. $start = 0;
  5196. $perpage = 1;
  5197. }
  5198. else
  5199. {
  5200. $start = ($page - 1)*$perpage;
  5201. }
  5202. //取得信息列表
  5203. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5204. $rows = array();$list = array();
  5205. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5206. // foreach ($info_list as $value)
  5207. // {
  5208. // $warehouse = $this->warehouse->read($value['warehouse']);
  5209. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5210. // $number = $value['number'];$ftime = time()-15*24*3600;
  5211. // if($c < 1)
  5212. // {
  5213. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5214. // }
  5215. // }
  5216. $warehouse_list = $this->warehouse->find_all();
  5217. $warehouse_list = array_column($warehouse_list,null,'id');
  5218. foreach ($info_list as $value)
  5219. {
  5220. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5221. 'title'=>"",
  5222. ];
  5223. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5224. $number = $value['number'];$ftime = time()-15*24*3600;
  5225. if($c < 1)
  5226. {
  5227. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5228. }
  5229. }
  5230. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5231. // $query = $this->db->query($sql);
  5232. // $info_list = $query->result_array();
  5233. // $sql_two = "select title,id from crowd_warehouse";
  5234. // $query_two = $this->db->query($sql_two);
  5235. // $warehouse_list = $query_two->result_array();
  5236. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5237. // foreach ($info_list as $value)
  5238. // {
  5239. // if(isset($warehouse_arr[$value['warehouse']])){
  5240. // $warehouse = $warehouse_arr[$value['warehouse']];
  5241. // }else{
  5242. // $warehouse = [
  5243. // 'id'=>0,
  5244. // 'title'=>"异常",
  5245. // ];
  5246. // }
  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. $listdata = array_slice($list,$start,$perpage);
  5255. $total = count($list);
  5256. $pagenum = ceil($total/$perpage);
  5257. $over = $total-($start+$perpage);
  5258. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5259. echo json_encode($rows);exit;
  5260. }
  5261. if(isset($post['s']))
  5262. {
  5263. $id_arr = $this->input->post('s');
  5264. $id_arr = explode(',',trim($id_arr,','));
  5265. if(!$id_arr)
  5266. {
  5267. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5268. }
  5269. //循环删除记录
  5270. foreach ($id_arr as $v)
  5271. {
  5272. $dd = $this->whlabel->read($v);
  5273. if(!isset($dd['id']))
  5274. {
  5275. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5276. }
  5277. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5278. if(isset($zt[0]))
  5279. {
  5280. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5281. }
  5282. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5283. foreach ($deldd as $vv)
  5284. {
  5285. $this->whlabel->remove($vv['id']);
  5286. }
  5287. }
  5288. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5289. }
  5290. $this->_Template('whlabel_error',$this->data);
  5291. }
  5292. public function _errorexcel()
  5293. {
  5294. $post = $this->input->post(NULL, TRUE);
  5295. if(isset($_GET['page']))
  5296. {
  5297. $page = $this->input->get('page',true);
  5298. $perpage = $this->input->get('perpage',true);
  5299. $sku = $this->input->get('sku',true);
  5300. $warehouse = $this->input->get('warehouse',true);
  5301. $ktime = $this->input->get('ktime',true);
  5302. $jtime = $this->input->get('jtime',true);
  5303. $ktime = strtotime($ktime);
  5304. $jtime = strtotime($jtime);
  5305. $where = "sku != 'Preset'";
  5306. $gj = '';
  5307. if($sku)
  5308. {
  5309. $where .= " and sku like '%$sku%'";
  5310. }
  5311. else
  5312. {
  5313. if($ktime && $jtime)
  5314. {
  5315. $gj = " and time > '$ktime' and time < '$jtime'";
  5316. }
  5317. }
  5318. if($warehouse)
  5319. {
  5320. $where .= " and warehouse = '$warehouse'";
  5321. }
  5322. //数据排序
  5323. $order_str = "id desc";
  5324. if(empty($page))
  5325. {
  5326. $start = 0;
  5327. $perpage = 1;
  5328. }
  5329. else
  5330. {
  5331. $start = ($page - 1)*$perpage;
  5332. }
  5333. //取得信息列表
  5334. $rows = array();$list = array();
  5335. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5336. foreach ($info_list as $value)
  5337. {
  5338. $warehouse = $this->warehouse->read($value['warehouse']);
  5339. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5340. $number = $value['number'];$ftime = time()-15*24*3600;
  5341. if($c < 1)
  5342. {
  5343. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5344. }
  5345. }
  5346. $title = "0库存汇总";
  5347. $titlename = "<table border=1>
  5348. <tr align='center'>
  5349. <td>仓库</td>
  5350. <td>SKU</td>
  5351. <td>产品</td>
  5352. <td>当前库存</td>
  5353. </tr>
  5354. </table>";
  5355. $filename = $title.".xls";
  5356. $tail = "";
  5357. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5358. }
  5359. }
  5360. /**
  5361. *
  5362. *
  5363. * 占单
  5364. *
  5365. *
  5366. **/
  5367. public function _kcyz()
  5368. {
  5369. $post = $this->input->post(NULL, TRUE);
  5370. if(isset($post['warehouse']))
  5371. {
  5372. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5373. $warehouse = $this->input->post('warehouse',true);
  5374. $whlabel = $this->input->post('whlabel',true);
  5375. $id = $this->input->post('id',true);
  5376. $shop = $this->input->post('shop',true);
  5377. $number = $this->input->post('number',true);
  5378. if(!$whlabel || $whlabel == '|')
  5379. {
  5380. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5381. }
  5382. $pp = explode('|',trim($whlabel,'|'));
  5383. $x = 0;$save = array();
  5384. foreach ($pp as $va)
  5385. {
  5386. $num = explode('-',$va);
  5387. if($number)
  5388. {
  5389. $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 = '')");//通用
  5390. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5391. }
  5392. else
  5393. {
  5394. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5395. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5396. }
  5397. $x++;
  5398. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5399. {
  5400. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5401. }
  5402. }
  5403. if(isset($save[0]))
  5404. {
  5405. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5406. }
  5407. else
  5408. {
  5409. echo json_encode(array('success'=>true));exit;
  5410. }
  5411. }
  5412. }
  5413. public function _db()
  5414. {
  5415. $post = $this->input->post(NULL, TRUE);
  5416. if(isset($post['page']))
  5417. {
  5418. $page = $this->input->post('page',true);
  5419. $perpage = $this->input->post('perpage',true);
  5420. $sku = $this->input->post('sku',true);
  5421. $number = $this->input->post('number',true);
  5422. $warehouse = $this->input->post('warehouse',true);
  5423. $purchase = $this->input->post('purchase',true);
  5424. $orderinfo = $this->input->post('orderinfo',true);
  5425. $waybill = $this->input->post('waybill',true);
  5426. $category = $this->input->post('category',true);
  5427. $size = $this->input->post('size',true);
  5428. $grade = $this->input->post('grade',true);
  5429. $color = $this->input->post('color',true);
  5430. $lowe = $this->input->post('lowe',true);
  5431. $state = $this->input->post('state',true);
  5432. $label = $this->input->post('label',true);
  5433. $timetk = $this->input->post('timetkk',true);
  5434. $timetj = $this->input->post('timetjj',true);
  5435. $timetk = strtotime($timetk);
  5436. $timetj = strtotime($timetj);
  5437. $where = "dbtime > 0";
  5438. if($timetk && $timetj)
  5439. {
  5440. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5441. }
  5442. if($sku)
  5443. {
  5444. $where .= " and sku = '$sku'";
  5445. }
  5446. if($warehouse)
  5447. {
  5448. $where .= " and warehouse = '$warehouse'";
  5449. if($warehouse == 12)
  5450. {
  5451. $w = 'specialstock';
  5452. }
  5453. else
  5454. {
  5455. $w = 'whlabel';
  5456. }
  5457. }
  5458. if($purchase)
  5459. {
  5460. $where .= " and purchase = '$purchase'";
  5461. }
  5462. if($category)
  5463. {
  5464. $where .= " and features like '%-$category-%'";
  5465. }
  5466. if($size)
  5467. {
  5468. $where .= " and features like '%-$size-%'";
  5469. }
  5470. if($grade)
  5471. {
  5472. $where .= " and features like '%-$grade-%'";
  5473. }
  5474. if($color)
  5475. {
  5476. $where .= " and features like '%-$color-%'";
  5477. }
  5478. if($lowe)
  5479. {
  5480. $where .= " and features like '%-$lowe-%'";
  5481. }
  5482. if($state != '')
  5483. {
  5484. $where .= " and state = '$state'";
  5485. }
  5486. //数据排序
  5487. $order_str = "dbtime desc";
  5488. if(empty($page))
  5489. {
  5490. $start = 0;
  5491. $perpage = 1;
  5492. }
  5493. else
  5494. {
  5495. $start = ($page - 1)*$perpage;
  5496. }
  5497. //取得信息列表
  5498. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5499. foreach ($info_list as $key=>$value)
  5500. {
  5501. $warehouse = $this->$w->read($value['warehouse']);
  5502. $info_list[$key]['warehouse'] = $warehouse['title'];
  5503. $purchase = $this->purchase->read($value['purchase']);
  5504. $info_list[$key]['purchase'] = $purchase['title'];
  5505. if($value['enter'] != 0)
  5506. {
  5507. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5508. }
  5509. else
  5510. {
  5511. $info_list[$key]['enter'] = "";
  5512. }
  5513. if($value['dbtime'] != 0)
  5514. {
  5515. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5516. }
  5517. else
  5518. {
  5519. $info_list[$key]['dbtime'] = "";
  5520. }
  5521. if($value['state'] == 0)
  5522. {
  5523. $info_list[$key]['state'] = "在库";
  5524. }
  5525. else if($value['state'] == 1)
  5526. {
  5527. $info_list[$key]['state'] = "出库";
  5528. }
  5529. else if($value['state'] == 2)
  5530. {
  5531. $info_list[$key]['state'] = "退库";
  5532. }
  5533. else if($value['state'] == 3)
  5534. {
  5535. $info_list[$key]['state'] = "调拨中";
  5536. }
  5537. else if($value['state'] == 4)
  5538. {
  5539. $info_list[$key]['state'] = "再加工";
  5540. }
  5541. else if($value['state'] == 5)
  5542. {
  5543. $info_list[$key]['state'] = "维修中";
  5544. }
  5545. else if($value['state'] == 6)
  5546. {
  5547. $info_list[$key]['state'] = "盘亏";
  5548. }
  5549. else if($value['state'] == 7)
  5550. {
  5551. $info_list[$key]['state'] = "更换标签";
  5552. }
  5553. else if($value['state'] == 8)
  5554. {
  5555. $info_list[$key]['state'] = "其它";
  5556. }
  5557. else if($value['state'] == 9)
  5558. {
  5559. $info_list[$key]['state'] = "预设";
  5560. }
  5561. }
  5562. $total = $this->whlabel->find_count($where);
  5563. $pagenum = ceil($total/$perpage);
  5564. $over = $total-($start+$perpage);
  5565. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5566. echo json_encode($rows);exit;
  5567. }
  5568. if(isset($post['outsku']))
  5569. {
  5570. $time = time();
  5571. $cz = $this->input->post('cz',true);
  5572. $label = $this->input->post('outsku',true);
  5573. $sl = $this->input->post('sl',true);
  5574. $num = $this->input->post('num',true);
  5575. //$warehouse = $this->input->post('warehouse',true);
  5576. if(!$sl)
  5577. {
  5578. $sl = 1;
  5579. }
  5580. if(!$warehouse)
  5581. {
  5582. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5583. }
  5584. $dblabel = $this->whlabellabel->get_label($label);
  5585. if($dblabel)
  5586. {
  5587. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5588. if(count($data) < 1)
  5589. {
  5590. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5591. }
  5592. if(count($data) < $num)
  5593. {
  5594. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5595. }
  5596. for($i=0;$i<$sl;$i++)
  5597. {
  5598. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5599. }
  5600. echo json_encode(array('success'=>true));exit;
  5601. }
  5602. else
  5603. {
  5604. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5605. }
  5606. }
  5607. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5608. $this->_Template('whlabel_db',$this->data);
  5609. }
  5610. public function _dbrk()
  5611. {
  5612. $post = $this->input->post(NULL, TRUE);
  5613. if(isset($post['page']))
  5614. {
  5615. $page = $this->input->post('page',true);
  5616. $perpage = $this->input->post('perpage',true);
  5617. $sku = $this->input->post('sku',true);
  5618. $number = $this->input->post('number',true);
  5619. $warehouse = $this->input->post('warehouse',true);
  5620. $purchase = $this->input->post('purchase',true);
  5621. $orderinfo = $this->input->post('orderinfo',true);
  5622. $waybill = $this->input->post('waybill',true);
  5623. $category = $this->input->post('category',true);
  5624. $size = $this->input->post('size',true);
  5625. $grade = $this->input->post('grade',true);
  5626. $color = $this->input->post('color',true);
  5627. $lowe = $this->input->post('lowe',true);
  5628. $state = $this->input->post('state',true);
  5629. $label = $this->input->post('label',true);
  5630. $ctime = $this->input->post('ctime',true);
  5631. $timetk = $this->input->post('timetkk',true);
  5632. $timetj = $this->input->post('timetjj',true);
  5633. $timetk = strtotime($timetk);
  5634. $timetj = strtotime($timetj);
  5635. $where = "dbtime > 0";
  5636. if($timetk && $timetj)
  5637. {
  5638. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5639. }
  5640. if($sku)
  5641. {
  5642. $where .= " and sku = '$sku'";
  5643. }
  5644. if($warehouse)
  5645. {
  5646. $where .= " and warehouse = '$warehouse'";
  5647. }
  5648. if($purchase)
  5649. {
  5650. $where .= " and purchase = '$purchase'";
  5651. }
  5652. if($category)
  5653. {
  5654. $where .= " and features like '%-$category-%'";
  5655. }
  5656. if($size)
  5657. {
  5658. $where .= " and features like '%-$size-%'";
  5659. }
  5660. if($grade)
  5661. {
  5662. $where .= " and features like '%-$grade-%'";
  5663. }
  5664. if($color)
  5665. {
  5666. $where .= " and features like '%-$color-%'";
  5667. }
  5668. if($lowe)
  5669. {
  5670. $where .= " and features like '%-$lowe-%'";
  5671. }
  5672. if($state != '')
  5673. {
  5674. $where .= " and state = '$state'";
  5675. }
  5676. //数据排序
  5677. $order_str = "dbtime desc";
  5678. if(empty($page))
  5679. {
  5680. $start = 0;
  5681. $perpage = 1;
  5682. }
  5683. else
  5684. {
  5685. $start = ($page - 1)*$perpage;
  5686. }
  5687. //取得信息列表
  5688. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5689. foreach ($info_list as $key=>$value)
  5690. {
  5691. $warehouse = $this->warehouse->read($value['warehouse']);
  5692. $info_list[$key]['warehouse'] = $warehouse['title'];
  5693. $purchase = $this->purchase->read($value['purchase']);
  5694. $info_list[$key]['purchase'] = $purchase['title'];
  5695. if($value['enter'] != 0)
  5696. {
  5697. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5698. }
  5699. else
  5700. {
  5701. $info_list[$key]['enter'] = "";
  5702. }
  5703. if($value['dbtime'] != 0)
  5704. {
  5705. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5706. }
  5707. else
  5708. {
  5709. $info_list[$key]['dbtime'] = "";
  5710. }
  5711. if($value['state'] == 0)
  5712. {
  5713. $info_list[$key]['state'] = "在库";
  5714. }
  5715. else if($value['state'] == 1)
  5716. {
  5717. $info_list[$key]['state'] = "出库";
  5718. }
  5719. else if($value['state'] == 2)
  5720. {
  5721. $info_list[$key]['state'] = "退库";
  5722. }
  5723. else if($value['state'] == 3)
  5724. {
  5725. $info_list[$key]['state'] = "调拨中";
  5726. }
  5727. else if($value['state'] == 4)
  5728. {
  5729. $info_list[$key]['state'] = "再加工";
  5730. }
  5731. else if($value['state'] == 5)
  5732. {
  5733. $info_list[$key]['state'] = "维修中";
  5734. }
  5735. else if($value['state'] == 6)
  5736. {
  5737. $info_list[$key]['state'] = "盘亏";
  5738. }
  5739. else if($value['state'] == 7)
  5740. {
  5741. $info_list[$key]['state'] = "更换标签";
  5742. }
  5743. else if($value['state'] == 8)
  5744. {
  5745. $info_list[$key]['state'] = "其它";
  5746. }
  5747. else if($value['state'] == 9)
  5748. {
  5749. $info_list[$key]['state'] = "预设";
  5750. }
  5751. }
  5752. $total = $this->whlabel->find_count($where);
  5753. $pagenum = ceil($total/$perpage);
  5754. $over = $total-($start+$perpage);
  5755. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5756. echo json_encode($rows);exit;
  5757. }
  5758. if(isset($post['rsku']))
  5759. {
  5760. $cz = $this->input->post('cz',true);
  5761. $label = $this->input->post('rsku',true);
  5762. $sl = $this->input->post('sl',true);
  5763. $warehouse = $this->input->post('warehouse',true);
  5764. if(!$sl)
  5765. {
  5766. $sl = 1;
  5767. }
  5768. if(!$warehouse)
  5769. {
  5770. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5771. }
  5772. $dblabel = $this->whlabellabel->get_label($label);
  5773. if($dblabel)
  5774. {
  5775. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5776. if(count($data) < 1)
  5777. {
  5778. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5779. }
  5780. if($sl > count($data))
  5781. {
  5782. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5783. }
  5784. $time = time();
  5785. for($i=0;$i<$sl;$i++)
  5786. {
  5787. $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']);
  5788. }
  5789. echo json_encode(array('success'=>true));exit;
  5790. }
  5791. else
  5792. {
  5793. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5794. }
  5795. }
  5796. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5797. $this->_Template('whlabel_dbrk',$this->data);
  5798. }
  5799. public function _whlabelczdc()
  5800. {
  5801. if(isset($_GET['excel']))
  5802. {
  5803. //数据排序
  5804. $order_str = "id desc";
  5805. if(empty($page))
  5806. {
  5807. $start = 0;
  5808. $perpage = 1;
  5809. }
  5810. else
  5811. {
  5812. $start = ($page - 1)*$perpage;
  5813. }
  5814. $state = $this->input->get('state',true);
  5815. $sku = $this->input->get('sku',true);
  5816. $ctime = $this->input->get('ctime',true);
  5817. $category = $this->input->get('category',true);
  5818. $size = $this->input->get('size',true);
  5819. $grade = $this->input->get('grade',true);
  5820. $color = $this->input->get('color',true);
  5821. $lowe = $this->input->get('lowe',true);
  5822. $timetk = $this->input->get('timetkk',true);
  5823. $timetj = $this->input->get('timetjj',true);
  5824. $timetk = strtotime($timetk);
  5825. $timetj = strtotime($timetj);
  5826. $where = "dbtime > 0";
  5827. if($timetk && $timetj)
  5828. {
  5829. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5830. }
  5831. if($category)
  5832. {
  5833. $where .= " and features like '%-$category-%'";
  5834. }
  5835. if($size)
  5836. {
  5837. $where .= " and features like '%-$size-%'";
  5838. }
  5839. if($grade)
  5840. {
  5841. $where .= " and features like '%-$grade-%'";
  5842. }
  5843. if($color)
  5844. {
  5845. $where .= " and features like '%-$color-%'";
  5846. }
  5847. if($lowe)
  5848. {
  5849. $where .= " and features like '%-$lowe-%'";
  5850. }
  5851. //取得信息列表
  5852. $info_list = $this->whlabel->find_all($where,'*');
  5853. $rows = array();$list = array();
  5854. foreach ($info_list as $key=>$value)
  5855. {
  5856. $rows[$value['sku']] = $value;//所有数据sku
  5857. }
  5858. foreach ($rows as $value)
  5859. {
  5860. $warehouse = $this->warehouse->read($value['warehouse']);
  5861. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5862. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5863. if($value['orderinfo'] == 0)
  5864. {
  5865. $info_list[$key]['orderinfo'] = "";
  5866. }
  5867. if($value['waybill'] == 0)
  5868. {
  5869. $info_list[$key]['waybill'] = "";
  5870. }
  5871. if($value['state'] == 0)
  5872. {
  5873. $value['state'] = "在库";
  5874. }
  5875. else if($value['state'] == 3)
  5876. {
  5877. $value['state'] = "调拨中";
  5878. }
  5879. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5880. }
  5881. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5882. $titlename = "<table border=1>
  5883. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5884. <tr align='center'>
  5885. <td>SKU</td>
  5886. <td>产品</td>
  5887. <td>调拨数量</td>
  5888. <td>入库数量</td>
  5889. </tr>
  5890. </table>";
  5891. $filename = $title.".xls";
  5892. $tail = "";
  5893. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5894. }
  5895. }
  5896. public function _print($arg_array)
  5897. {
  5898. if(isset($_SESSION['api']))
  5899. {
  5900. $user = $this->user->get_api($_SESSION['api']);
  5901. $usp = $user;
  5902. $fgshop = "";$sid = "";$wid="";$wtype="";
  5903. $usersp = explode('|',trim($user['shop'],'|'));
  5904. $userwh = explode('|',trim($user['warehouse'],'|'));
  5905. foreach ($usersp as $value)
  5906. {
  5907. $fgshop .= " shop = ".$value." or";
  5908. $sid .= " id = ".$value." or";
  5909. }
  5910. foreach ($userwh as $value)
  5911. {
  5912. $wid .= " id = ".$value." or";
  5913. $wtype .= " type = ".$value." or";
  5914. }
  5915. }
  5916. $post = $this->input->post(NULL, TRUE);
  5917. if(isset($post['tmsku']))
  5918. {
  5919. $tmsku = $this->input->post('tmsku',true);
  5920. if(is_numeric($tmsku))
  5921. {
  5922. $yyh = $this->whlabellabel->get_label($tmsku);
  5923. }
  5924. else
  5925. {
  5926. $yyh = $this->whlabellabel->get_sku($tmsku);
  5927. }
  5928. if($yyh)
  5929. {
  5930. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5931. }
  5932. else
  5933. {
  5934. echo json_encode(array('success'=>false));exit;
  5935. }
  5936. }
  5937. $classid = $this->classid->sku();
  5938. $pm = $classid;
  5939. $scsku = $classid;
  5940. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5941. if(isset($post['warehouse']))
  5942. {
  5943. if($post['warehouse'])
  5944. {
  5945. $list = array();$num = "";$title = "";$features = "";
  5946. $order = 0;
  5947. $post['shop'] = '';
  5948. $brand = $this->input->post('brand',true);
  5949. if($brand != '0,')
  5950. {
  5951. $b = $this->brand->read(rtrim($brand,','));
  5952. if($b)
  5953. {
  5954. $post['shop'] = str_replace('|',',',$b['shop']);
  5955. }
  5956. }
  5957. $post['details'] = $this->input->post('details',true);//打印数量
  5958. $xbqnum = $this->input->post('xbqnum',true);
  5959. $post['purchase'] = $this->input->post('purchase',true);
  5960. $post['warehouse'] = $this->input->post('warehouse',true);
  5961. $post['purchase'] = $this->input->post('purchase',true);
  5962. $post['retreatwarehouse'] = $post['warehouse'];
  5963. $post['cpbz'] = $this->input->post('cpbz',true);
  5964. $post['state'] = 9;
  5965. $category = $this->input->post('category',true);
  5966. $list['category'] = $category;
  5967. $list['hairtype'] = $this->input->post('hairtype',true);
  5968. $list['grade'] = $this->input->post('grade',true);
  5969. $size = $this->input->post('size',true);
  5970. $list['size'] = rtrim($size,',');
  5971. $list['hairnumber'] = $this->input->post('hairnumber',true);
  5972. $list['extension'] = $this->input->post('extension',true);
  5973. if($category == 1297)
  5974. {
  5975. $list['sywignumber'] = $this->input->post('sywignumber',true);
  5976. }
  5977. if($category == 1702)
  5978. {
  5979. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  5980. $list['syother'] = $this->input->post('syother',true);
  5981. }
  5982. if($category == 133)
  5983. {
  5984. $list['fittype'] = $this->input->post('fittype',true);
  5985. $list['acother'] = $this->input->post('acother',true);
  5986. }
  5987. $list['color'] = $this->input->post('color',true);
  5988. $list['lowe'] = $this->input->post('lowe',true);
  5989. if($category == 127)
  5990. {
  5991. $list['type'] = $this->input->post('type',true);
  5992. $list['headroad'] = $this->input->post('headroad',true);
  5993. $list['density'] = $this->input->post('density',true);
  5994. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  5995. {
  5996. $list['lacesize'] = $this->input->post('lacesize',true);
  5997. }
  5998. $list['lacecolor'] = $this->input->post('lacecolor',true);
  5999. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6000. }
  6001. if($category == 128)
  6002. {
  6003. $list['lacetype'] = $this->input->post('lacetype',true);
  6004. $list['haircap'] = $this->input->post('haircap',true);
  6005. $list['density'] = $this->input->post('density',true);
  6006. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6007. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6008. $list['wigother'] = $this->input->post('wigother',true);
  6009. $list['wigother2'] = $this->input->post('wigother2',true);
  6010. }
  6011. if($category == 129)
  6012. {
  6013. $list['wide'] = $this->input->post('wide',true);
  6014. }
  6015. if($category == 131)
  6016. {
  6017. $list['gifttype'] = $this->input->post('gifttype',true);
  6018. $list['giftother'] = $this->input->post('giftother',true);
  6019. }
  6020. if($category == 134)
  6021. {
  6022. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6023. }
  6024. if($category == 1297)
  6025. {
  6026. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6027. $list['sywigother'] = $this->input->post('sywigother',true);
  6028. }
  6029. if($category == 130 || $category == 133 || $category == 1702)
  6030. {
  6031. $list['items'] = $this->input->post('items',true);
  6032. $list['weight'] = $this->input->post('weight',true);
  6033. }
  6034. if($category == 1702)
  6035. {
  6036. $list['syhairther'] = $this->input->post('syhairther',true);
  6037. }
  6038. foreach($list as $k=>$v)
  6039. {
  6040. if($v != 0)
  6041. {
  6042. $num .=$v;
  6043. $features .=$v.'-';
  6044. $post[$k] = $v;
  6045. $typeclass = $this->typeclass->read($v);
  6046. if(isset($pm[$typeclass['classid']]))
  6047. {
  6048. if(stripos($typeclass['zh'],'|') !== false)
  6049. {
  6050. $exzh = explode('|',$typeclass['zh']);
  6051. $pm[$typeclass['classid']] = $exzh[0];
  6052. }
  6053. else
  6054. {
  6055. $pm[$typeclass['classid']] = $typeclass['zh'];
  6056. }
  6057. }
  6058. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6059. if($k != 'size')
  6060. {
  6061. $title .= $typeclass['title']." ";
  6062. }
  6063. }
  6064. }
  6065. $typeclass = $this->typeclass->read($list['size']);
  6066. $title .= $typeclass['title'];
  6067. $time = time();
  6068. $post['title'] = rtrim($title,' ');
  6069. $post['number'] = $num;
  6070. $post['features'] = '-'.$features;
  6071. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6072. $featurespp = explode('-',trim($featurespp,'-'));
  6073. if(isset($featurespp[5]))
  6074. {
  6075. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6076. }
  6077. else
  6078. {
  6079. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6080. }
  6081. $post['enter'] = $time;
  6082. $post['time'] = $time;//操作时间
  6083. $scsku = implode("-",$scsku);
  6084. $zh = implode(" ",$pm);
  6085. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6086. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6087. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6088. $post['sku'] = $bqsku;
  6089. $label = time().rand(0,9);
  6090. $post['label'] = $label;
  6091. $cpid = $this->whlabellabel->find_count();
  6092. $post['cpid'] = $cpid+1;
  6093. $cpid = $post['cpid'];
  6094. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6095. //if($whlabelbarcode)
  6096. //{
  6097. //$post['label'] = $whlabelbarcode['label'];
  6098. //if(!$this->whlabellabel->insert($post))
  6099. //{
  6100. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6101. //}
  6102. //}
  6103. //else
  6104. //{
  6105. $this->db->trans_begin();
  6106. $this->whlabellabel->insert($post);
  6107. //$this->whlabelbarcode->insert($post);
  6108. if ($this->db->trans_status() === TRUE)
  6109. {
  6110. $this->db->trans_commit();
  6111. }
  6112. else
  6113. {
  6114. $this->db->trans_rollback();
  6115. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6116. }
  6117. //}
  6118. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6119. $purchase = $this->purchase->read($post['purchase']);
  6120. 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;//特殊仓目前不需要仓库选项
  6121. }
  6122. }
  6123. if(isset($_SESSION['api']))
  6124. {
  6125. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6126. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6127. $this->data['wlshop'] = $wlshop;
  6128. $this->data['warehouse'] = $warehouse;
  6129. }
  6130. $whlabelwz = $this->whlabelwz->find_all();
  6131. $this->data['whlabelwz'] = $whlabelwz;
  6132. $this->_Template('whlabel_print',$this->data);
  6133. }
  6134. public function _usaprint($arg_array)
  6135. {
  6136. if(isset($_SESSION['api']))
  6137. {
  6138. $user = $this->user->get_api($_SESSION['api']);
  6139. $usp = $user;
  6140. $fgshop = "";$sid = "";$wid="";$wtype="";
  6141. $usersp = explode('|',trim($user['shop'],'|'));
  6142. $userwh = explode('|',trim($user['warehouse'],'|'));
  6143. foreach ($usersp as $value)
  6144. {
  6145. $fgshop .= " shop = ".$value." or";
  6146. $sid .= " id = ".$value." or";
  6147. }
  6148. foreach ($userwh as $value)
  6149. {
  6150. $wid .= " id = ".$value." or";
  6151. $wtype .= " type = ".$value." or";
  6152. }
  6153. }
  6154. $post = $this->input->post(NULL, TRUE);
  6155. if(isset($post['tmsku']))
  6156. {
  6157. $tmsku = $this->input->post('tmsku',true);
  6158. if(is_numeric($tmsku))
  6159. {
  6160. $yyh = $this->whlabellabel->get_label($tmsku);
  6161. }
  6162. else
  6163. {
  6164. $yyh = $this->whlabellabel->get_sku($tmsku);
  6165. }
  6166. if($yyh)
  6167. {
  6168. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6169. }
  6170. else
  6171. {
  6172. echo json_encode(array('success'=>false));exit;
  6173. }
  6174. }
  6175. $classid = $this->classid->sku();
  6176. $pm = $classid;
  6177. $scsku = $classid;
  6178. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6179. if(isset($post['warehouse']))
  6180. {
  6181. if($post['warehouse'])
  6182. {
  6183. $list = array();$num = "";$title = "";$features = "";
  6184. $order = 0;
  6185. $post['shop'] = '';
  6186. $brand = $this->input->post('brand',true);
  6187. if($brand != '0,')
  6188. {
  6189. $b = $this->brand->read(rtrim($brand,','));
  6190. if($b)
  6191. {
  6192. $post['shop'] = str_replace('|',',',$b['shop']);
  6193. }
  6194. }
  6195. $post['details'] = $this->input->post('details',true);//打印数量
  6196. $xbqnum = $this->input->post('xbqnum',true);
  6197. $post['purchase'] = $this->input->post('purchase',true);
  6198. $post['warehouse'] = $this->input->post('warehouse',true);
  6199. $post['purchase'] = $this->input->post('purchase',true);
  6200. $post['retreatwarehouse'] = $post['warehouse'];
  6201. $post['cpbz'] = $this->input->post('cpbz',true);
  6202. $post['state'] = 9;
  6203. $category = $this->input->post('category',true);
  6204. $list['category'] = $category;
  6205. $list['hairtype'] = $this->input->post('hairtype',true);
  6206. $list['grade'] = $this->input->post('grade',true);
  6207. $size = $this->input->post('size',true);
  6208. $list['size'] = rtrim($size,',');
  6209. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6210. $list['extension'] = $this->input->post('extension',true);
  6211. if($category == 1297)
  6212. {
  6213. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6214. }
  6215. if($category == 1702)
  6216. {
  6217. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6218. $list['syother'] = $this->input->post('syother',true);
  6219. }
  6220. if($category == 133)
  6221. {
  6222. $list['fittype'] = $this->input->post('fittype',true);
  6223. $list['acother'] = $this->input->post('acother',true);
  6224. }
  6225. $list['color'] = $this->input->post('color',true);
  6226. $list['lowe'] = $this->input->post('lowe',true);
  6227. if($category == 127)
  6228. {
  6229. $list['type'] = $this->input->post('type',true);
  6230. $list['headroad'] = $this->input->post('headroad',true);
  6231. $list['density'] = $this->input->post('density',true);
  6232. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6233. {
  6234. $list['lacesize'] = $this->input->post('lacesize',true);
  6235. }
  6236. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6237. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6238. }
  6239. if($category == 128)
  6240. {
  6241. $list['lacetype'] = $this->input->post('lacetype',true);
  6242. $list['haircap'] = $this->input->post('haircap',true);
  6243. $list['density'] = $this->input->post('density',true);
  6244. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6245. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6246. $list['wigother'] = $this->input->post('wigother',true);
  6247. $list['wigother2'] = $this->input->post('wigother2',true);
  6248. }
  6249. if($category == 129)
  6250. {
  6251. $list['wide'] = $this->input->post('wide',true);
  6252. }
  6253. if($category == 131)
  6254. {
  6255. $list['gifttype'] = $this->input->post('gifttype',true);
  6256. $list['giftother'] = $this->input->post('giftother',true);
  6257. }
  6258. if($category == 134)
  6259. {
  6260. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6261. }
  6262. if($category == 1297)
  6263. {
  6264. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6265. $list['sywigother'] = $this->input->post('sywigother',true);
  6266. }
  6267. if($category == 130 || $category == 133 || $category == 1702)
  6268. {
  6269. $list['items'] = $this->input->post('items',true);
  6270. $list['weight'] = $this->input->post('weight',true);
  6271. }
  6272. if($category == 1702)
  6273. {
  6274. $list['syhairther'] = $this->input->post('syhairther',true);
  6275. }
  6276. foreach($list as $k=>$v)
  6277. {
  6278. if($v != 0)
  6279. {
  6280. $num .=$v;
  6281. $features .=$v.'-';
  6282. $post[$k] = $v;
  6283. $typeclass = $this->typeclass->read($v);
  6284. if(isset($pm[$typeclass['classid']]))
  6285. {
  6286. if(stripos($typeclass['zh'],'|') !== false)
  6287. {
  6288. $exzh = explode('|',$typeclass['zh']);
  6289. $pm[$typeclass['classid']] = $exzh[0];
  6290. }
  6291. else
  6292. {
  6293. $pm[$typeclass['classid']] = $typeclass['zh'];
  6294. }
  6295. }
  6296. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6297. if($k != 'size')
  6298. {
  6299. $title .= $typeclass['title']." ";
  6300. }
  6301. }
  6302. }
  6303. $typeclass = $this->typeclass->read($list['size']);
  6304. $title .= $typeclass['title'];
  6305. $time = time();
  6306. $post['title'] = rtrim($title,' ');
  6307. $post['number'] = $num;
  6308. $post['features'] = '-'.$features;
  6309. $fp = $this->whlabel->get_features($post['features']);
  6310. if(!$fp)
  6311. {
  6312. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6313. }
  6314. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6315. $featurespp = explode('-',trim($featurespp,'-'));
  6316. if(isset($featurespp[5]))
  6317. {
  6318. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6319. }
  6320. else
  6321. {
  6322. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6323. }
  6324. $post['enter'] = $time;
  6325. $post['time'] = $time;//操作时间
  6326. $scsku = implode("-",$scsku);
  6327. $zh = implode(" ",$pm);
  6328. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6329. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6330. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6331. $post['sku'] = $fp['sku'];
  6332. $post['label'] = $fp['sku'];
  6333. $cpid = $this->whlabellabel->find_count();
  6334. $post['cpid'] = $cpid+1;
  6335. $cpid = $post['cpid'];
  6336. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6337. //if($whlabelbarcode)
  6338. //{
  6339. //$post['label'] = $whlabelbarcode['label'];
  6340. //if(!$this->whlabellabel->insert($post))
  6341. //{
  6342. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6343. //}
  6344. //}
  6345. //else
  6346. //{
  6347. $this->db->trans_begin();
  6348. $this->whlabellabel->insert($post);
  6349. //$this->whlabelbarcode->insert($post);
  6350. if ($this->db->trans_status() === TRUE)
  6351. {
  6352. $this->db->trans_commit();
  6353. }
  6354. else
  6355. {
  6356. $this->db->trans_rollback();
  6357. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6358. }
  6359. //}
  6360. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6361. $purchase = $this->purchase->read($post['purchase']);
  6362. 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;//特殊仓目前不需要仓库选项
  6363. }
  6364. }
  6365. if(isset($_SESSION['api']))
  6366. {
  6367. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6368. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6369. $this->data['wlshop'] = $wlshop;
  6370. $this->data['warehouse'] = $warehouse;
  6371. }
  6372. $whlabelwz = $this->whlabelwz->find_all();
  6373. $this->data['whlabelwz'] = $whlabelwz;
  6374. $this->_Template('whlabel_usaprint',$this->data);
  6375. }
  6376. public function _printrk($arg_array)
  6377. {
  6378. $prc = array();
  6379. $purchase = $this->purchase->find_all();
  6380. foreach($purchase as $k=>$v)
  6381. {
  6382. $prc[$v['id']] = $v['title'];
  6383. }
  6384. $post = $this->input->post(NULL, TRUE);
  6385. if(isset($post['page']))
  6386. {
  6387. $page = $this->input->post('page',true);
  6388. $perpage = $this->input->post('perpage',true);
  6389. $sku = $this->input->post('sku',true);
  6390. $bs = $this->input->post('bs',true);
  6391. $number = $this->input->post('number',true);
  6392. $warehouse = $this->input->post('warehouse',true);
  6393. $purchase = $this->input->post('purchase',true);
  6394. $orderinfo = $this->input->post('orderinfo',true);
  6395. $waybill = $this->input->post('waybill',true);
  6396. $category = $this->input->post('category',true);
  6397. $size = $this->input->post('size',true);
  6398. $grade = $this->input->post('grade',true);
  6399. $color = $this->input->post('color',true);
  6400. $lowe = $this->input->post('lowe',true);
  6401. $state = $this->input->post('state',true);
  6402. $label = $this->input->post('label',true);
  6403. $timetk = $this->input->post('ktime',true);
  6404. $timetj = $this->input->post('jtime',true);
  6405. $timetk = strtotime($timetk);
  6406. $timetj = strtotime($timetj);
  6407. $where = "1=1 ";
  6408. if($timetk && $timetj)
  6409. {
  6410. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6411. }
  6412. if($sku)
  6413. {
  6414. $where .= " and sku = '$sku'";
  6415. }
  6416. if($bs != '')
  6417. {
  6418. $where .= " and bs = '$bs'";
  6419. }
  6420. if($number)
  6421. {
  6422. $where .= " and number = '$number'";
  6423. }
  6424. if($warehouse)
  6425. {
  6426. $where .= " and warehouse = '$warehouse'";
  6427. }
  6428. if($purchase)
  6429. {
  6430. $where .= " and purchase = '$purchase'";
  6431. }
  6432. if($orderinfo)
  6433. {
  6434. $where .= " and orderinfo = '$orderinfo'";
  6435. }
  6436. if($waybill)
  6437. {
  6438. $where .= " and waybill = '$waybill'";
  6439. }
  6440. if($category)
  6441. {
  6442. $where .= " and features like '%-$category-%'";
  6443. }
  6444. if($size)
  6445. {
  6446. $where .= " and features like '%-$size-%'";
  6447. }
  6448. if($grade)
  6449. {
  6450. $where .= " and features like '%-$grade-%'";
  6451. }
  6452. if($color)
  6453. {
  6454. $where .= " and features like '%-$color-%'";
  6455. }
  6456. if($lowe)
  6457. {
  6458. $where .= " and features like '%-$lowe-%'";
  6459. }
  6460. if($label)
  6461. {
  6462. $where .= " and label = '$label'";
  6463. }
  6464. if($state || $state == 0)
  6465. {
  6466. $where .= " and state = '$state'";
  6467. }
  6468. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6469. //数据排序
  6470. $order_str = "enter desc";
  6471. if(empty($page))
  6472. {
  6473. $start = 0;
  6474. $perpage = 1;
  6475. }
  6476. else
  6477. {
  6478. $start = ($page - 1)*$perpage;
  6479. }
  6480. //取得信息列表
  6481. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6482. foreach ($info_list as $key=>$value)
  6483. {
  6484. $warehouse = $this->warehouse->read($value['warehouse']);
  6485. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6486. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6487. if($value['state'] == 0)
  6488. {
  6489. $info_list[$key]['state'] = "在库";
  6490. }
  6491. else if($value['state'] == 1)
  6492. {
  6493. $info_list[$key]['state'] = "出库";
  6494. }
  6495. else if($value['state'] == 2)
  6496. {
  6497. $info_list[$key]['state'] = "退库";
  6498. }
  6499. else if($value['state'] == 3)
  6500. {
  6501. $info_list[$key]['state'] = "调拨中";
  6502. }
  6503. else if($value['state'] == 4)
  6504. {
  6505. $info_list[$key]['state'] = "再加工";
  6506. }
  6507. else if($value['state'] == 5)
  6508. {
  6509. $info_list[$key]['state'] = "维修中";
  6510. }
  6511. else if($value['state'] == 6)
  6512. {
  6513. $info_list[$key]['state'] = "盘亏";
  6514. }
  6515. else if($value['state'] == 7)
  6516. {
  6517. $info_list[$key]['state'] = "更换标签";
  6518. }
  6519. else if($value['state'] == 8)
  6520. {
  6521. $info_list[$key]['state'] = "其它";
  6522. }
  6523. else if($value['state'] == 9)
  6524. {
  6525. $info_list[$key]['state'] = "预设";
  6526. }
  6527. else if($value['state'] == 10)
  6528. {
  6529. $info_list[$key]['state'] = "美店零售";
  6530. }
  6531. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6532. }
  6533. $total = $this->$ck->find_count($where);
  6534. $pagenum = ceil($total/$perpage);
  6535. $over = $total-($start+$perpage);
  6536. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6537. echo json_encode($rows);exit;
  6538. }
  6539. if(isset($post['tmsku']))
  6540. {
  6541. $time = time();
  6542. $tmsku = $this->input->post('tmsku',true);
  6543. //$post['shop'] = $this->input->post('shop',true);
  6544. $num = $this->input->post('num',true);
  6545. $rktype = $this->input->post('rktype',true);
  6546. if($num > 200)
  6547. {
  6548. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6549. }
  6550. if(!$rktype)
  6551. {
  6552. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6553. }
  6554. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6555. /**
  6556. $wz = array();
  6557. foreach ($rk as $key=>$value)
  6558. {
  6559. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6560. }
  6561. if(count($wz) > 1)
  6562. {
  6563. $wz = array_values($wz);
  6564. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6565. }
  6566. **/
  6567. if(isset($rk[0]['purchase']))
  6568. {
  6569. $rk = $rk[0];
  6570. $j = 0;
  6571. $post['purchase'] = $rk['purchase'];
  6572. $post['warehouse'] = $rk['warehouse'];
  6573. $post['retreatwarehouse'] = $rk['warehouse'];
  6574. $post['sku'] = $rk['sku'];
  6575. $post['number'] = $rk['number'];
  6576. $post['features'] = $rk['features'];
  6577. $post['title'] = $rk['title'];
  6578. $post['enter'] = $time;
  6579. $post['time'] = $time;
  6580. $post['bs'] = 1;
  6581. $post['shop'] = $rk['shop'];
  6582. $post['details'] = $rk['details'];
  6583. $post['cpid'] = $rk['cpid'];
  6584. $post['cpbz'] = $rk['cpbz'];
  6585. //$post['rktype'] = $rktype;
  6586. $warehouse = $this->warehouse->read($rk['warehouse']);
  6587. if($warehouse['bdck'] == '')
  6588. {
  6589. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6590. }
  6591. else
  6592. {
  6593. $bdck = $warehouse['bdck'];
  6594. }
  6595. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6596. if(isset($pdwz['details']))
  6597. {
  6598. if($pdwz['details'] != $post['details'])
  6599. {
  6600. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6601. }
  6602. }
  6603. $post['featurespp'] = $rk['featurespp'];
  6604. if($post['warehouse'] == '5')
  6605. {
  6606. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6607. if($yza)
  6608. {
  6609. if($post['features'] != $yza[0]['features'])
  6610. {
  6611. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6612. }
  6613. }
  6614. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6615. if($yzb)
  6616. {
  6617. if($post['sku'] != $yzb[0]['sku'])
  6618. {
  6619. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6620. }
  6621. }
  6622. }
  6623. for($i=0;$i<$num;$i++)
  6624. {
  6625. $post['label'] = time().rand(100,999).$i;
  6626. if($this->$bdck->insert($post))
  6627. {
  6628. $j++;
  6629. }
  6630. }
  6631. /**
  6632. if($post['warehouse'] != 12)
  6633. {
  6634. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6635. }
  6636. **/
  6637. if($j == $num)
  6638. {
  6639. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6640. }
  6641. else
  6642. {
  6643. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6644. }
  6645. }
  6646. else
  6647. {
  6648. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6649. }
  6650. }
  6651. $this->_Template('whlabel_printrk',$this->data);
  6652. }
  6653. public function _printxzrk($arg_array)
  6654. {
  6655. $post = $this->input->post(NULL, TRUE);
  6656. if(isset($post['wzid']))
  6657. {
  6658. $time = time();
  6659. $id = $this->input->post('wzid',true);
  6660. //$post['shop'] = $this->input->post('shop',true);
  6661. $num = 1;
  6662. $rk = $this->whlabellabel->read($id);
  6663. if(isset($rk['purchase']))
  6664. {
  6665. $x = 0;
  6666. $post['purchase'] = $rk['purchase'];
  6667. $post['warehouse'] = $rk['warehouse'];
  6668. $post['retreatwarehouse'] = $rk['warehouse'];
  6669. $post['sku'] = $rk['sku'];
  6670. $post['number'] = $rk['number'];
  6671. $post['features'] = $rk['features'];
  6672. $post['title'] = $rk['title'];
  6673. $post['enter'] = $time;
  6674. $post['time'] = $time;
  6675. $post['bs'] = 1;
  6676. $post['shop'] = $rk['shop'];
  6677. $post['details'] = $rk['details'];
  6678. $post['cpid'] = $rk['cpid'];
  6679. $post['cpbz'] = $rk['cpbz'];
  6680. $warehouse = $this->warehouse->read($rk['warehouse']);
  6681. if($warehouse['bdck'] == '')
  6682. {
  6683. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6684. }
  6685. else
  6686. {
  6687. $bdck = $warehouse['bdck'];
  6688. }
  6689. $post['featurespp'] = $rk['featurespp'];
  6690. $this->db->trans_begin();
  6691. for($i=0;$i<$num;$i++)
  6692. {
  6693. $post['label'] = time().rand(100,999).$i;
  6694. $this->$bdck->insert($post);
  6695. }
  6696. /**
  6697. if($post['warehouse'] != 12)
  6698. {
  6699. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6700. }
  6701. **/
  6702. if ($this->db->trans_status() === TRUE)
  6703. {
  6704. $this->db->trans_commit();
  6705. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6706. }
  6707. else
  6708. {
  6709. $this->db->trans_rollback();
  6710. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6711. }
  6712. }
  6713. else
  6714. {
  6715. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6716. }
  6717. }
  6718. }
  6719. public function _printck($arg_array)
  6720. {
  6721. $prc = array();
  6722. $purchase = $this->purchase->find_all();
  6723. foreach($purchase as $k=>$v)
  6724. {
  6725. $prc[$v['id']] = $v['title'];
  6726. }
  6727. $post = $this->input->post(NULL, TRUE);
  6728. if(isset($post['page']))
  6729. {
  6730. $page = $this->input->post('page',true);
  6731. $perpage = $this->input->post('perpage',true);
  6732. $sku = $this->input->post('sku',true);
  6733. $bs = $this->input->post('bs',true);
  6734. $number = $this->input->post('number',true);
  6735. $warehouse = $this->input->post('warehouse',true);
  6736. $purchase = $this->input->post('purchase',true);
  6737. $orderinfo = $this->input->post('orderinfo',true);
  6738. $waybill = $this->input->post('waybill',true);
  6739. $category = $this->input->post('category',true);
  6740. $size = $this->input->post('size',true);
  6741. $grade = $this->input->post('grade',true);
  6742. $color = $this->input->post('color',true);
  6743. $lowe = $this->input->post('lowe',true);
  6744. $state = $this->input->post('state',true);
  6745. $label = $this->input->post('label',true);
  6746. $timetk = $this->input->post('ktime',true);
  6747. $timetj = $this->input->post('jtime',true);
  6748. $timetk = strtotime($timetk);
  6749. $timetj = strtotime($timetj);
  6750. $where = "state=1 ";
  6751. if($timetk && $timetj)
  6752. {
  6753. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6754. }
  6755. if($sku)
  6756. {
  6757. $where .= " and sku = '$sku'";
  6758. }
  6759. if($bs != '')
  6760. {
  6761. $where .= " and bs = '$bs'";
  6762. }
  6763. if($number)
  6764. {
  6765. $where .= " and number = '$number'";
  6766. }
  6767. if($warehouse)
  6768. {
  6769. $where .= " and warehouse = '$warehouse'";
  6770. }
  6771. if($purchase)
  6772. {
  6773. $where .= " and purchase = '$purchase'";
  6774. }
  6775. if($orderinfo)
  6776. {
  6777. $where .= " and orderinfo = '$orderinfo'";
  6778. }
  6779. if($waybill)
  6780. {
  6781. $where .= " and waybill = '$waybill'";
  6782. }
  6783. if($category)
  6784. {
  6785. $where .= " and features like '%-$category-%'";
  6786. }
  6787. if($size)
  6788. {
  6789. $where .= " and features like '%-$size-%'";
  6790. }
  6791. if($grade)
  6792. {
  6793. $where .= " and features like '%-$grade-%'";
  6794. }
  6795. if($color)
  6796. {
  6797. $where .= " and features like '%-$color-%'";
  6798. }
  6799. if($lowe)
  6800. {
  6801. $where .= " and features like '%-$lowe-%'";
  6802. }
  6803. if($label)
  6804. {
  6805. $where .= " and label = '$label'";
  6806. }
  6807. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6808. //数据排序
  6809. $order_str = "outk desc";
  6810. if(empty($page))
  6811. {
  6812. $start = 0;
  6813. $perpage = 1;
  6814. }
  6815. else
  6816. {
  6817. $start = ($page - 1)*$perpage;
  6818. }
  6819. //取得信息列表
  6820. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6821. foreach ($info_list as $key=>$value)
  6822. {
  6823. $warehouse = $this->warehouse->read($value['warehouse']);
  6824. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6825. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6826. if($value['state'] == 0)
  6827. {
  6828. $info_list[$key]['state'] = "在库";
  6829. }
  6830. else if($value['state'] == 1)
  6831. {
  6832. $info_list[$key]['state'] = "出库";
  6833. }
  6834. else if($value['state'] == 2)
  6835. {
  6836. $info_list[$key]['state'] = "退库";
  6837. }
  6838. else if($value['state'] == 3)
  6839. {
  6840. $info_list[$key]['state'] = "调拨中";
  6841. }
  6842. else if($value['state'] == 4)
  6843. {
  6844. $info_list[$key]['state'] = "再加工";
  6845. }
  6846. else if($value['state'] == 5)
  6847. {
  6848. $info_list[$key]['state'] = "维修中";
  6849. }
  6850. else if($value['state'] == 6)
  6851. {
  6852. $info_list[$key]['state'] = "盘亏";
  6853. }
  6854. else if($value['state'] == 7)
  6855. {
  6856. $info_list[$key]['state'] = "更换标签";
  6857. }
  6858. else if($value['state'] == 8)
  6859. {
  6860. $info_list[$key]['state'] = "其它";
  6861. }
  6862. else if($value['state'] == 9)
  6863. {
  6864. $info_list[$key]['state'] = "预设";
  6865. }
  6866. else if($value['state'] == 10)
  6867. {
  6868. $info_list[$key]['state'] = "美店零售";
  6869. }
  6870. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6871. }
  6872. $total = $this->$ck->find_count($where);
  6873. $pagenum = ceil($total/$perpage);
  6874. $over = $total-($start+$perpage);
  6875. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6876. echo json_encode($rows);exit;
  6877. }
  6878. if(isset($post['tmsku']))
  6879. {
  6880. $time = time();
  6881. $tmsku = $this->input->post('tmsku',true);
  6882. //$post['shop'] = $this->input->post('shop',true);
  6883. $num = $this->input->post('num',true);
  6884. $cktype = $this->input->post('cktype',true);
  6885. $label = $this->whlabellabel->get_label($tmsku);
  6886. if(!$cktype)
  6887. {
  6888. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6889. }
  6890. if(!isset($label['warehouse']))
  6891. {
  6892. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6893. }
  6894. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6895. if(stripos($label['features'],'-126-') !== false)
  6896. {
  6897. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6898. }
  6899. else
  6900. {
  6901. $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 = ''");
  6902. }
  6903. $j = 0;
  6904. if(count($ck) >= $num)
  6905. {
  6906. for($i=0;$i<$num;$i++)
  6907. {
  6908. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6909. {
  6910. $j++;
  6911. }
  6912. }
  6913. if($j == $num)
  6914. {
  6915. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6916. }
  6917. else
  6918. {
  6919. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6920. }
  6921. }
  6922. else
  6923. {
  6924. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6925. }
  6926. }
  6927. $this->_Template('whlabel_printck',$this->data);
  6928. }
  6929. public function _printexcel()
  6930. {
  6931. $dir = '/data/excel/'.date('Ymd',time()).'/';
  6932. $config['upload_path'] = '.'.$dir ;
  6933. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  6934. $config['allowed_types'] = 'xls|xlsx|csv';
  6935. $config['max_size'] = 10240;
  6936. $this->load->library('upload', $config);
  6937. $this->upload->initialize($config);
  6938. if ($this->upload->do_upload('userfile'))
  6939. {
  6940. $full_path = $dir.$this->upload->data('file_name');
  6941. $fileName = '.' . $full_path;
  6942. if (!file_exists($fileName))
  6943. {
  6944. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  6945. }
  6946. else
  6947. {
  6948. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6949. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  6950. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  6951. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  6952. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  6953. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  6954. ++$column;//如果列数大于26行
  6955. $list = array();
  6956. for ($i = 2; $i <= $row; $i++) // 行数循环
  6957. {
  6958. $data = array();
  6959. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6960. {
  6961. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6962. }
  6963. $list[] = $data;
  6964. }
  6965. }
  6966. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  6967. $cmf_arr = array_column($list, '1');
  6968. array_multisort($cmf_arr, SORT_ASC, $list);
  6969. foreach ($list as $key=>$value)
  6970. {
  6971. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  6972. if($typeclass)
  6973. {
  6974. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  6975. }
  6976. else
  6977. {
  6978. $ed[] = array($value['1'].'-系统未找到此订单信息');
  6979. $i++;
  6980. continue;
  6981. }
  6982. }
  6983. if($i > 0)
  6984. {
  6985. $yc = $i.'条异常';
  6986. }
  6987. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  6988. }
  6989. }
  6990. public function _uck()
  6991. {
  6992. if(isset($_GET['excel']))
  6993. {
  6994. $tc = array();
  6995. $typeclass = $this->typeclass->find_all();
  6996. foreach ($typeclass as $v)
  6997. {
  6998. $tc[$v['id']] = $v['zh'];
  6999. }
  7000. $data = array();$t = array();$rq = '';
  7001. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  7002. $ts = $ts/(24*3600);
  7003. for($i=0;$i<$ts;$i++)
  7004. {
  7005. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  7006. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  7007. }
  7008. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  7009. foreach ($info_list as $k=>$v)
  7010. {
  7011. $features = explode('-',trim($v['features'],'-'));
  7012. if(!isset($features[3]) || !isset($features[4]))
  7013. {
  7014. continue;
  7015. }
  7016. $data[$k][0] = $tc[$features[0]];//类型
  7017. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7018. $data[$k][2] = $tc[$features[4]];//曲度
  7019. $data[$k][3] = '';
  7020. if(isset($data[$k][1]))
  7021. {
  7022. $data[$k][3] .= $data[$k][1];
  7023. }
  7024. if(isset($data[$k][2]))
  7025. {
  7026. $data[$k][3] .= $data[$k][2];
  7027. }
  7028. if(isset($features[5]))
  7029. {
  7030. $data[$k][3] .= $tc[$features[5]];
  7031. }
  7032. if(isset($features[2]))
  7033. {
  7034. $data[$k][3] .= $tc[$features[2]];
  7035. }
  7036. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7037. $data[$k][4] = $v['sku'];
  7038. $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())).'))');//月初库存
  7039. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7040. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7041. $ztrq = '';$ztsl = '';
  7042. if(count($zt) > 0)
  7043. {
  7044. foreach ($zt as $vv)
  7045. {
  7046. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7047. $ztsl .= $vv['num'].'<br>';
  7048. }
  7049. }
  7050. $data[$k][] = trim($ztsl,'<br>');
  7051. $data[$k][] = trim($ztrq,'<br>');
  7052. $byck = 0;
  7053. foreach ($t as $vv)
  7054. {
  7055. $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));
  7056. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7057. $byck += $sl;
  7058. }
  7059. $data[$k][] = ($byck > 0)?$byck:'';
  7060. }
  7061. $title = "详情 ".date("Y-m-d",time());
  7062. $titlename = "<table border=1>
  7063. <tr align='center'>
  7064. <td>类别</td>
  7065. <td>颜色</td>
  7066. <td>曲度</td>
  7067. <td>名称</td>
  7068. <td>SKU</td>
  7069. <td>月初库存</td>
  7070. <td>剩余库存</td>
  7071. <td>在途数量</td>
  7072. <td>预达日期</td>".
  7073. $rq
  7074. ."<td>本月出库</td></tr>
  7075. </table>";
  7076. $filename = $title.".xls";
  7077. $tail = "";
  7078. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7079. }
  7080. }
  7081. public function _whlabelexcelzh()
  7082. {
  7083. if(isset($_GET['excel']))
  7084. {
  7085. $where = "sku != 'Preset'";
  7086. //数据排序
  7087. $order_str = "id desc";
  7088. if(empty($page))
  7089. {
  7090. $start = 0;
  7091. $perpage = 1;
  7092. }
  7093. else
  7094. {
  7095. $start = ($page - 1)*$perpage;
  7096. }
  7097. $category = $this->input->get('category',true);
  7098. $warehouse = $this->input->get('warehouse',true);
  7099. $excelid = $this->input->get('sid',true);
  7100. if($category)
  7101. {
  7102. $where .= " and features like '%-$category-%'";
  7103. }
  7104. if($warehouse)
  7105. {
  7106. $where .= " and warehouse = '$warehouse'";
  7107. }
  7108. $xzid = '';
  7109. if($excelid)
  7110. {
  7111. $excelid = explode(',',trim($excelid,','));
  7112. foreach ($excelid as $key=>$value)
  7113. {
  7114. $xzid .= " id = ".$value." or";
  7115. }
  7116. $xzid = " and (".rtrim($xzid,'or').")";;
  7117. }
  7118. //取得信息列表
  7119. /**
  7120. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7121. $rows = array();$list = array();
  7122. foreach ($info_list as $key=>$value)
  7123. {
  7124. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7125. }
  7126. **/
  7127. $list = array();
  7128. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7129. foreach ($rows as $key=>$value)
  7130. {
  7131. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7132. $zh = '';
  7133. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7134. foreach ($zt as $v)
  7135. {
  7136. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7137. }
  7138. $zt = array_sum(array_column($zt,'num'));
  7139. $number = $value['number'];
  7140. $ftime = time()-15*24*3600;
  7141. $warehouse = $this->warehouse->read($value['warehouse']);
  7142. $rows[$key]['warehouse'] = $warehouse['title'];
  7143. $rows[$key]['number'] = $c;
  7144. $rows[$key]['features'] = $zh;
  7145. $rows[$key]['hb'] = $c+$zt;
  7146. }
  7147. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7148. $titlename = "<table border=1>
  7149. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7150. <tr align='center'>
  7151. <td>仓库</td>
  7152. <td>SKU</td>
  7153. <td>产品</td>
  7154. <td>库存数量</td>
  7155. <td>在途数量及预达日期</td>
  7156. <td>在途+库存数量</td>
  7157. </tr>
  7158. </table>";
  7159. $filename = $title.".xls";
  7160. $tail = "";
  7161. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7162. }
  7163. if(isset($_GET['excel']))
  7164. {
  7165. $warehouse = $this->input->get('warehouse',true);
  7166. $sku = $this->input->get('sku',true);
  7167. $cz = $this->input->get('cz',true);
  7168. $text = $this->input->post('text',true);
  7169. $xztime = $this->input->get('xztime',true);
  7170. $timetk = $this->input->get('timetk',true);
  7171. $timetj = $this->input->get('timetj',true);
  7172. $timetk = strtotime($timetk);
  7173. $timetj = strtotime($timetj);
  7174. $where = "time = '0' ";
  7175. if($warehouse)
  7176. {
  7177. $where .= " and warehouse = '$warehouse'";
  7178. }
  7179. if($sku)
  7180. {
  7181. $where .= " and sku = '$sku'";
  7182. }
  7183. if($text)
  7184. {
  7185. $where .= " and text like '%$text%'";
  7186. }
  7187. if($cz != '')
  7188. {
  7189. $where .= " and cz = '$cz'";
  7190. }
  7191. if($timetk && $timetj)
  7192. {
  7193. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7194. }
  7195. //数据排序
  7196. $order_str = $xztime." desc";
  7197. //取得信息列表
  7198. $zh = array();
  7199. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7200. foreach ($info_list as $v)
  7201. {
  7202. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7203. $warehouse = $this->warehouse->read($v['warehouse']);
  7204. $v['warehouse'] = $warehouse['title'];
  7205. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7206. $v['stime'] = date('Y-m-d',$v['stime']);
  7207. if(isset($zh[$v['features']]))
  7208. {
  7209. $zh[$v['features']]['num'] += $v['num'];
  7210. }
  7211. else
  7212. {
  7213. $zh[$v['features']] = $v;
  7214. }
  7215. $zh[$v['features']]['features'] = $c;
  7216. }
  7217. $title = "在途数据".date('Y-m-d',time());
  7218. $titlename = "<table border=1>
  7219. <tr align='center'>
  7220. <td>仓库</td>
  7221. <td>SKU</td>
  7222. <td>名称</td>
  7223. <td>在途数量</td>
  7224. <td>库存数量</td>
  7225. <td>添加在途日期</td>
  7226. <td>预达日期</td>
  7227. <td>备注</td>
  7228. </tr>
  7229. </table>";
  7230. $filename = $title.".xls";
  7231. $tail = "";
  7232. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7233. }
  7234. }
  7235. public function _fc()
  7236. {
  7237. $vip = 0;
  7238. if(isset($_SESSION['api']))
  7239. {
  7240. $user = $this->user->get_api($_SESSION['api']);
  7241. if($user['vip'] == 1)
  7242. {
  7243. $vip = 1;
  7244. }
  7245. }
  7246. else
  7247. {
  7248. header('Location: /');exit;
  7249. }
  7250. $post = $this->input->post(NULL, TRUE);
  7251. if(isset($post['page']))
  7252. {
  7253. $page = $this->input->post('page',true);
  7254. $perpage = $this->input->post('perpage',true);
  7255. $category = $this->input->post('category',true);
  7256. $size = $this->input->post('size',true);
  7257. $grade = $this->input->post('grade',true);
  7258. $color = $this->input->post('color',true);
  7259. $lowe = $this->input->post('lowe',true);
  7260. $sku = $this->input->post('sku');
  7261. $title = $this->input->post('title');
  7262. $warehouse = $this->input->post('warehouse',true);
  7263. $usa = $this->input->post('usa',true);
  7264. $purchase = $this->input->post('purchase',true);
  7265. $lacetype = $this->input->post('lacetype',true);
  7266. $haircap = $this->input->post('haircap',true);
  7267. $density = $this->input->post('density',true);
  7268. $details = $this->input->post('details',true);
  7269. $state = $this->input->post('state',true);
  7270. $ktime = $this->input->post('ktime',true);
  7271. $jtime = $this->input->post('jtime',true);
  7272. $ktime = strtotime($ktime);
  7273. $jtime = strtotime($jtime);
  7274. $where = "state = '11'";$gj = "";$ck = "";
  7275. if($lacetype)
  7276. {
  7277. $where .= " and features like '%-$lacetype-%'";
  7278. }
  7279. if($category)
  7280. {
  7281. $where .= " and features like '%-$category-%'";
  7282. }
  7283. if($size)
  7284. {
  7285. $where .= " and features like '%-$size-%'";
  7286. }
  7287. if($grade)
  7288. {
  7289. $where .= " and features like '%-$grade-%'";
  7290. }
  7291. if($color)
  7292. {
  7293. $where .= " and features like '%-$color-%'";
  7294. }
  7295. if($lowe)
  7296. {
  7297. $where .= " and features like '%-$lowe-%'";
  7298. }
  7299. if($haircap)
  7300. {
  7301. $where .= " and features like '%-$haircap-%'";
  7302. }
  7303. if($density)
  7304. {
  7305. $where .= " and features like '%-$density-%'";
  7306. }
  7307. if($usa)
  7308. {
  7309. if(!$warehouse)
  7310. {
  7311. $where .= " and (warehouse = '5' or warehouse = '8')";
  7312. }
  7313. }
  7314. if($warehouse)
  7315. {
  7316. $where .= " and warehouse = '$warehouse'";
  7317. }
  7318. if($details)
  7319. {
  7320. $where .= " and details = '$details'";
  7321. }
  7322. if($purchase)
  7323. {
  7324. $where .= " and purchase = '$purchase'";
  7325. }
  7326. if($state)
  7327. {
  7328. $where .= " and state = '$state'";
  7329. }
  7330. if($ktime && $jtime)
  7331. {
  7332. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7333. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7334. }
  7335. //数据排序
  7336. $order_str = "id desc";
  7337. if(empty($page))
  7338. {
  7339. $start = 0;
  7340. $perpage = 1;
  7341. }
  7342. else
  7343. {
  7344. $start = ($page - 1)*$perpage;
  7345. }
  7346. if($sku)
  7347. {
  7348. $sku = trim($sku,' ');
  7349. $sku = trim($sku,' ');
  7350. $where .= " and sku like '%$sku%'";
  7351. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7352. }
  7353. else if($title)
  7354. {
  7355. $title = trim($title,' ');
  7356. $title = trim($title,' ');
  7357. $where .= " and title like '%$title%'";
  7358. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7359. }
  7360. else
  7361. {
  7362. //$where .= " and time > '$ktime' and time < '$jtime'";
  7363. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7364. }
  7365. //取得信息列表
  7366. $rows = array();$list = array();
  7367. foreach ($info_list as $key=>$value)
  7368. {
  7369. $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'].'"');
  7370. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7371. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7372. $warehouse = $this->warehouse->read($value['warehouse']);
  7373. $info_list[$key]['warehouse'] = $warehouse['title'];
  7374. $info_list[$key]['number'] = $g;
  7375. $info_list[$key]['features'] = $x;
  7376. $info_list[$key]['x'] = $s;
  7377. }
  7378. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7379. $pagenum = ceil($total/$perpage);
  7380. $over = $total-($start+$perpage);
  7381. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7382. echo json_encode($rows);exit;
  7383. }
  7384. $this->data['vip'] = $vip;
  7385. $this->_Template('whlabel_fc',$this->data);
  7386. }
  7387. public function _fcmb()
  7388. {
  7389. $where = "sku != 'Preset'";
  7390. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7391. foreach ($rows as $k=>$v)
  7392. {
  7393. $warehouse = $this->warehouse->read($v['warehouse']);
  7394. $rows[$k]['warehouse'] = $warehouse['title'];
  7395. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7396. $rows[$k]['t'] = '';
  7397. $rows[$k]['n'] = '';
  7398. }
  7399. $title = "封货产品数据导入模板";
  7400. $titlename = "<table border=1>
  7401. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7402. <tr align='center'>
  7403. <td>仓库</td>
  7404. <td>SKU</td>
  7405. <td>产品</td>
  7406. <td>封存产品总数量</td>
  7407. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7408. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7409. </tr>
  7410. </table>";
  7411. $filename = $title.".xls";
  7412. $tail = "";
  7413. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7414. }
  7415. public function _fcexcel()
  7416. {
  7417. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7418. $config['upload_path'] = '.'.$dir ;
  7419. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7420. $config['allowed_types'] = 'xls|xlsx|csv';
  7421. $config['max_size'] = 10240;
  7422. $this->load->library('upload', $config);
  7423. $this->upload->initialize($config);
  7424. if ($this->upload->do_upload('userfile'))
  7425. {
  7426. $full_path = $dir.$this->upload->data('file_name');
  7427. $fileName = '.' . $full_path;
  7428. if (!file_exists($fileName))
  7429. {
  7430. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7431. }
  7432. else
  7433. {
  7434. libxml_use_internal_errors(true);
  7435. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7436. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7437. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7438. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7439. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7440. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7441. ++$column;//如果列数大于26行
  7442. $list = array();
  7443. for ($i = 2; $i <= $row; $i++) // 行数循环
  7444. {
  7445. $data = array();
  7446. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7447. {
  7448. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7449. }
  7450. $list[] = $data;
  7451. }
  7452. }
  7453. $i = 0;$j = 0;$ed = array();
  7454. foreach ($list as $key=>$value)
  7455. {
  7456. $time = time();
  7457. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7458. {
  7459. continue;
  7460. }
  7461. $warehouse = $this->warehouse->get_title($value['0']);
  7462. $sku = $value['1'];
  7463. $type = $value['4'];//调整方式0扣减1删除
  7464. $num = $value['5'];//调整数量
  7465. //$text = $value['4'];//扣减说明
  7466. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7467. if(!$d)//如果没有这个SKU
  7468. {
  7469. $ed[] = array($sku.'-库存中不存在此SKU');
  7470. $j++;
  7471. continue;
  7472. }
  7473. if(!isset($warehouse['id']))
  7474. {
  7475. $ed[] = array($sku.'-仓库名错误!');
  7476. $j++;
  7477. continue;
  7478. }
  7479. if($type == 1 || $type == 2)//扣减库存
  7480. {
  7481. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7482. if(count($data) < abs($num))
  7483. {
  7484. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7485. $j++;
  7486. continue;
  7487. }
  7488. if($type == 1)//转入库存
  7489. {
  7490. for($i=0;$i<abs($num);$i++)
  7491. {
  7492. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7493. }
  7494. }
  7495. else if($type == 2)//删除
  7496. {
  7497. for($i=0;$i<abs($num);$i++)
  7498. {
  7499. $this->whlabel->remove($data[$i]['id']);
  7500. }
  7501. }
  7502. }
  7503. else if($type == 0)//增加库存
  7504. {
  7505. $post['sku'] = $d['sku'];
  7506. $post['shop'] = '';
  7507. $post['warehouse'] = $warehouse['id'];
  7508. $post['purchase'] = $d['purchase'];
  7509. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7510. $post['state'] = 11;
  7511. $post['title'] = $d['title'];
  7512. $post['number'] = $d['number'];
  7513. $post['features'] = $d['features'];
  7514. $post['enter'] = $time;
  7515. $post['time'] = $time;//操作时间
  7516. for($i=0;$i<$num;$i++)
  7517. {
  7518. $post['label'] = time().rand(100,999).$i;
  7519. $this->whlabel->insert($post);
  7520. }
  7521. }
  7522. sleep(1);//防止入库时间一样,需要延迟1秒
  7523. }
  7524. if($j > 0)
  7525. {
  7526. $tt = date('Ymd',time());
  7527. $title = '库存导入错误信息-'.$tt;
  7528. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7529. $tail = "\n";
  7530. $filename = $title.".xls";
  7531. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7532. $dir = '/data/excel/'.$time.'/';
  7533. $file_name = 'error_'.$time.rand(1000,9999);
  7534. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7535. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7536. fwrite($myfile,$ecl);
  7537. fclose($myfile);
  7538. $error = $dir.$file_name.'.xls';
  7539. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7540. }
  7541. else
  7542. {
  7543. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7544. }
  7545. }
  7546. }
  7547. public function _fcjxc($arg_array)
  7548. {
  7549. if(isset($_GET['excel']))
  7550. {
  7551. $category = $this->input->get('category',true);
  7552. $size = $this->input->get('size',true);
  7553. $grade = $this->input->get('grade',true);
  7554. $color = $this->input->get('color',true);
  7555. $lowe = $this->input->get('lowe',true);
  7556. $sku = $this->input->get('sku');
  7557. $title = $this->input->get('title');
  7558. $warehouse = $arg_array[0];
  7559. $usa = $this->input->get('usa',true);
  7560. $purchase = $this->input->get('purchase',true);
  7561. $lacetype = $this->input->get('lacetype',true);
  7562. $haircap = $this->input->get('haircap',true);
  7563. $density = $this->input->get('density',true);
  7564. $title = $this->input->get('title',true);
  7565. $state = $this->input->get('state',true);
  7566. $ktime = $this->input->get('ktime',true);
  7567. $jtime = $this->input->get('jtime',true);
  7568. $where = "state=11";$gj = "";$ck = "";
  7569. if($lacetype)
  7570. {
  7571. $where .= " and features like '%-$lacetype-%'";
  7572. }
  7573. if($category)
  7574. {
  7575. $where .= " and features like '%-$category-%'";
  7576. }
  7577. if($size)
  7578. {
  7579. $where .= " and features like '%-$size-%'";
  7580. }
  7581. if($grade)
  7582. {
  7583. $where .= " and features like '%-$grade-%'";
  7584. }
  7585. if($color)
  7586. {
  7587. $where .= " and features like '%-$color-%'";
  7588. }
  7589. if($lowe)
  7590. {
  7591. $where .= " and features like '%-$lowe-%'";
  7592. }
  7593. if($haircap)
  7594. {
  7595. $where .= " and features like '%-$haircap-%'";
  7596. }
  7597. if($density)
  7598. {
  7599. $where .= " and features like '%-$density-%'";
  7600. }
  7601. if($usa)
  7602. {
  7603. if(!$warehouse)
  7604. {
  7605. $where .= " and (warehouse = '5' or warehouse = '8')";
  7606. }
  7607. }
  7608. if($warehouse)
  7609. {
  7610. $where .= " and warehouse = '$warehouse'";
  7611. }
  7612. if($purchase)
  7613. {
  7614. $where .= " and purchase = '$purchase'";
  7615. }
  7616. if($state)
  7617. {
  7618. $where .= " and state = '$state'";
  7619. }
  7620. $order_str = "id desc";
  7621. if($sku)
  7622. {
  7623. $sku = trim($sku,' ');
  7624. $sku = trim($sku,' ');
  7625. $where .= " and sku like '%$sku%'";
  7626. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7627. }
  7628. else if($title)
  7629. {
  7630. $title = trim($title,' ');
  7631. $title = trim($title,' ');
  7632. $where .= " and title like '%$title%'";
  7633. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7634. }
  7635. else
  7636. {
  7637. //$where .= " and time > '$ktime' and time < '$jtime'";
  7638. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7639. }
  7640. //取得信息列表
  7641. $rows = array();$list = array();
  7642. foreach ($info_list as $key=>$value)
  7643. {
  7644. $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'].'"');
  7645. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7646. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7647. $rows[$key] = $value;
  7648. $warehouse = $this->warehouse->read($value['warehouse']);
  7649. $rows[$key]['warehouse'] = $warehouse['title'];
  7650. $rows[$key]['features'] = $g;
  7651. $rows[$key]['a'] = $x;
  7652. $rows[$key]['b'] = $s;
  7653. }
  7654. $title = "总统计表";
  7655. $titlename = "<table border=1>
  7656. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7657. <tr align='center'>
  7658. <td>仓库</td>
  7659. <td>SKU</td>
  7660. <td>产品名称</td>
  7661. <td>录入总量</td>
  7662. <td>取出总量</td>
  7663. <td>剩余总量</td>
  7664. </tr>
  7665. </table>";
  7666. $filename = $title.".xls";
  7667. $tail = "";
  7668. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7669. }
  7670. $vip = 0;
  7671. if(isset($_SESSION['api']))
  7672. {
  7673. $user = $this->user->get_api($_SESSION['api']);
  7674. if($user['vip'] == 1)
  7675. {
  7676. $vip = 1;
  7677. }
  7678. }
  7679. else
  7680. {
  7681. header('Location: /');exit;
  7682. }
  7683. $post = $this->input->post(NULL, TRUE);
  7684. if(isset($post['page']))
  7685. {
  7686. $page = $this->input->post('page',true);
  7687. $perpage = $this->input->post('perpage',true);
  7688. $category = $this->input->post('category',true);
  7689. $size = $this->input->post('size',true);
  7690. $grade = $this->input->post('grade',true);
  7691. $color = $this->input->post('color',true);
  7692. $lowe = $this->input->post('lowe',true);
  7693. $sku = $this->input->post('sku');
  7694. $title = $this->input->post('title');
  7695. $warehouse = $arg_array[0];
  7696. $usa = $this->input->post('usa',true);
  7697. $purchase = $this->input->post('purchase',true);
  7698. $lacetype = $this->input->post('lacetype',true);
  7699. $haircap = $this->input->post('haircap',true);
  7700. $density = $this->input->post('density',true);
  7701. $title = $this->input->post('title',true);
  7702. $state = $this->input->post('state',true);
  7703. $ktime = $this->input->post('ktime',true);
  7704. $jtime = $this->input->post('jtime',true);
  7705. $ktime = strtotime($ktime);
  7706. $jtime = strtotime($jtime);
  7707. $where = "state=11";$gj = "";$ck = "";
  7708. if($lacetype)
  7709. {
  7710. $where .= " and features like '%-$lacetype-%'";
  7711. }
  7712. if($category)
  7713. {
  7714. $where .= " and features like '%-$category-%'";
  7715. }
  7716. if($size)
  7717. {
  7718. $where .= " and features like '%-$size-%'";
  7719. }
  7720. if($grade)
  7721. {
  7722. $where .= " and features like '%-$grade-%'";
  7723. }
  7724. if($color)
  7725. {
  7726. $where .= " and features like '%-$color-%'";
  7727. }
  7728. if($lowe)
  7729. {
  7730. $where .= " and features like '%-$lowe-%'";
  7731. }
  7732. if($haircap)
  7733. {
  7734. $where .= " and features like '%-$haircap-%'";
  7735. }
  7736. if($density)
  7737. {
  7738. $where .= " and features like '%-$density-%'";
  7739. }
  7740. if($usa)
  7741. {
  7742. if(!$warehouse)
  7743. {
  7744. $where .= " and (warehouse = '5' or warehouse = '8')";
  7745. }
  7746. }
  7747. if($warehouse)
  7748. {
  7749. $where .= " and warehouse = '$warehouse'";
  7750. }
  7751. if($purchase)
  7752. {
  7753. $where .= " and purchase = '$purchase'";
  7754. }
  7755. if($state)
  7756. {
  7757. $where .= " and state = '$state'";
  7758. }
  7759. if($ktime && $jtime)
  7760. {
  7761. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7762. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7763. }
  7764. //数据排序
  7765. $order_str = "id desc";$xs=0;
  7766. $rows = array();$list = array();
  7767. if(empty($page))
  7768. {
  7769. $start = 0;
  7770. $perpage = 1;
  7771. }
  7772. else
  7773. {
  7774. $start = ($page - 1)*$perpage;
  7775. }
  7776. if($sku || $title)
  7777. {
  7778. if($title)
  7779. {
  7780. $title = trim($title,' ');
  7781. $title = trim($title,' ');
  7782. $where .= " and title like '%$title%'";
  7783. }
  7784. else
  7785. {
  7786. $sku = trim($sku,' ');
  7787. $sku = trim($sku,' ');
  7788. $where .= " and sku like '%$sku%'";
  7789. }
  7790. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7791. foreach ($info_list as $key=>$value)
  7792. {
  7793. $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'].'"');
  7794. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7795. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7796. $rows[$key] = $value;
  7797. $warehouse = $this->warehouse->read($value['warehouse']);
  7798. $rows[$key]['warehouse'] = $warehouse['title'];
  7799. $rows[$key]['features'] = $g;
  7800. $rows[$key]['a'] = $x;
  7801. $rows[$key]['b'] = $s;
  7802. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7803. $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天销量
  7804. $yj = $c/($xl/30);
  7805. if($yj < 7)
  7806. {
  7807. $rows[$key]['y'] = round($yj).'天销量';
  7808. }
  7809. else
  7810. {
  7811. $rows[$key]['y'] = '正常';
  7812. }
  7813. }
  7814. }
  7815. else
  7816. {
  7817. //$where .= " and time > '$ktime' and time < '$jtime'";
  7818. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7819. foreach ($info_list as $key=>$value)
  7820. {
  7821. $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'].'"');
  7822. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7823. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7824. $zs[$key] = $value;
  7825. $warehouse = $this->warehouse->read($value['warehouse']);
  7826. $zs[$key]['warehouse'] = $warehouse['title'];
  7827. $zs[$key]['features'] = $g;
  7828. $zs[$key]['a'] = $x;
  7829. $zs[$key]['b'] = $s;
  7830. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7831. $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天销量
  7832. $yj = $c/($xl/30);
  7833. if($yj < 7)
  7834. {
  7835. $zs[$key]['y'] = round($yj).'天销量';
  7836. $rows[$key] = $zs[$key];
  7837. }
  7838. }
  7839. }
  7840. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7841. $pagenum = ceil($total/$perpage);
  7842. $over = $total-($start+$perpage);
  7843. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7844. echo json_encode($rows);exit;
  7845. }
  7846. $this->data['arg_array'] = $arg_array[0];
  7847. $this->_Template('whlabel_fcjxc',$this->data);
  7848. }
  7849. public function _0kcdel()
  7850. {
  7851. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7852. $config['upload_path'] = '.'.$dir ;
  7853. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7854. $config['allowed_types'] = 'xls|xlsx|csv';
  7855. $config['max_size'] = 10240;
  7856. $this->load->library('upload', $config);
  7857. $this->upload->initialize($config);
  7858. if ($this->upload->do_upload('userfile'))
  7859. {
  7860. $full_path = $dir.$this->upload->data('file_name');
  7861. $fileName = '.' . $full_path;
  7862. if (!file_exists($fileName))
  7863. {
  7864. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7865. }
  7866. else
  7867. {
  7868. require_once "./data/excel/PHPExcel/IOFactory.php";
  7869. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7870. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7871. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7872. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7873. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7874. ++$column;//如果列数大于26行
  7875. $list = array();
  7876. for ($i = 2; $i <= $row; $i++) // 行数循环
  7877. {
  7878. $data = array();
  7879. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7880. {
  7881. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7882. }
  7883. $list[] = $data;
  7884. }
  7885. }
  7886. $i = 0;$j = 0;$ed = array();
  7887. foreach ($list as $key=>$value)
  7888. {
  7889. $time = time();
  7890. if($value['0'] == "" || $value['1'] == "")
  7891. {
  7892. continue;
  7893. }
  7894. $warehouse = $this->warehouse->get_title($value['0']);
  7895. $sku = $value['1'];
  7896. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7897. if(!$d)//如果没有这个SKU
  7898. {
  7899. $ed[] = array($sku.'-库存中不存在此SKU');
  7900. $j++;
  7901. continue;
  7902. }
  7903. if(!isset($warehouse['id']))
  7904. {
  7905. $ed[] = array($sku.'-仓库名错误!');
  7906. $j++;
  7907. continue;
  7908. }
  7909. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7910. if($z < 1)
  7911. {
  7912. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7913. foreach ($z as $v)
  7914. {
  7915. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7916. if(count($zt) > 0)
  7917. {
  7918. $ed[] = array($sku.'-有在途库存无法删除!');
  7919. $j++;
  7920. continue;
  7921. }
  7922. $this->whlabel->remove($v['id']);
  7923. }
  7924. }
  7925. else
  7926. {
  7927. $ed[] = array($sku.'-非0库存!');
  7928. $j++;
  7929. continue;
  7930. }
  7931. }
  7932. if($j > 0)
  7933. {
  7934. $tt = date('Ymd',time());
  7935. $title = '删除0库存错误信息-'.$tt;
  7936. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7937. $tail = "\n";
  7938. $filename = $title.".xls";
  7939. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7940. $dir = '/data/excel/'.$time.'/';
  7941. $file_name = 'error_'.$time.rand(1000,9999);
  7942. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7943. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7944. fwrite($myfile,$ecl);
  7945. fclose($myfile);
  7946. $error = $dir.$file_name.'.xls';
  7947. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7948. }
  7949. else
  7950. {
  7951. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7952. }
  7953. }
  7954. }
  7955. public function _gbhtype()
  7956. {
  7957. $post = $this->input->post(NULL, TRUE);
  7958. if(isset($post['s']))
  7959. {
  7960. $n = $this->input->post('n');
  7961. $d = $this->input->post('s');
  7962. if(!$d)
  7963. {
  7964. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  7965. }
  7966. $d = explode(',',trim($d,','));
  7967. $t = $this->whlabel_type->read($n);
  7968. //循环删除记录
  7969. foreach ($d as $v)
  7970. {
  7971. $u = $this->whlabel->read($v);
  7972. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  7973. foreach ($data as $val)
  7974. {
  7975. $this->whlabel->save(array('type'=>$n),$val['id']);
  7976. }
  7977. }
  7978. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  7979. }
  7980. }
  7981. //出库、退库导出
  7982. public function _dccrtype()
  7983. {
  7984. $classid = $this->classid->sku();
  7985. $pm = $classid;
  7986. $typeclass = array();
  7987. $tc = $this->typeclass->find_all();
  7988. foreach ($tc as $v)
  7989. {
  7990. $typeclass[$v['id']] = $v;
  7991. }
  7992. $prc = array();
  7993. $purchase = $this->purchase->find_all();
  7994. foreach($purchase as $k=>$v)
  7995. {
  7996. $prc[$v['id']] = $v['title'];
  7997. }
  7998. if(isset($_GET['sid']))
  7999. {
  8000. $wh = array();
  8001. $w = $this->warehouse->find_all('1=1','id,title');
  8002. foreach ($w as $v)
  8003. {
  8004. $wh[$v['id']] = $v['title'];
  8005. }
  8006. $type = $this->input->get('excel',true);
  8007. $category = $this->input->get('category',true);
  8008. $size = $this->input->get('size',true);
  8009. $grade = $this->input->get('grade',true);
  8010. $color = $this->input->get('color',true);
  8011. $lowe = $this->input->get('lowe',true);
  8012. $sku = $this->input->get('sku',true);
  8013. $warehouse = $this->input->get('warehouse',true);
  8014. $lacetype = $this->input->get('lacetype',true);
  8015. $lacecolor = $this->input->get('lacecolor',true);
  8016. $density = $this->input->get('density',true);
  8017. $haircap = $this->input->get('haircap',true);
  8018. $purchase = $this->input->get('purchase',true);
  8019. $title = $this->input->get('title',true);
  8020. $state = $this->input->get('state',true);
  8021. $sid = $this->input->get('sid',true);
  8022. $ktime = $this->input->get('ktime',true);
  8023. $jtime = $this->input->get('jtime',true);
  8024. $ktime = strtotime($ktime);
  8025. $jtime = strtotime($jtime);
  8026. $where = "1=1";$gj = "";$ck = "";
  8027. if($category)
  8028. {
  8029. $where .= " and features like '%-$category-%'";
  8030. }
  8031. if($size)
  8032. {
  8033. $where .= " and features like '%-$size-%'";
  8034. }
  8035. if($grade)
  8036. {
  8037. $where .= " and features like '%-$grade-%'";
  8038. }
  8039. if($color)
  8040. {
  8041. $where .= " and features like '%-$color-%'";
  8042. }
  8043. if($lowe)
  8044. {
  8045. $where .= " and features like '%-$lowe-%'";
  8046. }
  8047. if($warehouse)
  8048. {
  8049. $where .= " and warehouse = '$warehouse'";
  8050. }
  8051. if($purchase)
  8052. {
  8053. $where .= " and purchase = '$purchase'";
  8054. }
  8055. if($state)
  8056. {
  8057. $where .= " and state = '$state'";
  8058. }
  8059. if($lacetype)
  8060. {
  8061. $where .= " and features like '%-$lacetype-%'";
  8062. }
  8063. if($lacecolor)
  8064. {
  8065. $where .= " and features like '%-$lacecolor-%'";
  8066. }
  8067. if($density)
  8068. {
  8069. $where .= " and features like '%-$density-%'";
  8070. }
  8071. if($haircap)
  8072. {
  8073. $where .= " and features like '%-$haircap-%'";
  8074. }
  8075. if($title)
  8076. {
  8077. $title = trim($title,' ');
  8078. $title = trim($title,' ');
  8079. $where .= " and title like '%$title%'";
  8080. }
  8081. if($sku)
  8082. {
  8083. $sku = trim($sku,' ');
  8084. $sku = trim($sku,' ');
  8085. $where .= " and sku like '%$sku%'";
  8086. }
  8087. if($ktime && $jtime)
  8088. {
  8089. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8090. }
  8091. $sidwhere = '';
  8092. if($sid)
  8093. {
  8094. $sd = "";
  8095. $s = explode(',',trim($sid,','));
  8096. foreach ($s as $value)
  8097. {
  8098. $sd .= " id = ".$value." or";
  8099. }
  8100. $sidwhere = " and (".rtrim($sd,'or').")";
  8101. }
  8102. //数据排序
  8103. $order_str = "time desc";
  8104. if(empty($page))
  8105. {
  8106. $start = 0;
  8107. $perpage = 1;
  8108. }
  8109. else
  8110. {
  8111. $start = ($page - 1)*$perpage;
  8112. }
  8113. $wh = array();
  8114. $w = $this->warehouse->find_all('1=1','id,title');
  8115. foreach ($w as $v)
  8116. {
  8117. $wh[$v['id']] = $v['title'];
  8118. }
  8119. $wt = array();
  8120. $whlabel_type = $this->whlabel_type->find_all();
  8121. foreach ($whlabel_type as $v)
  8122. {
  8123. $wt[$v['id']] = $v['title'];
  8124. }
  8125. $classid = $this->classid->sku();
  8126. $list = array();
  8127. $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');
  8128. foreach ($rows_r as $key=>$value)
  8129. {
  8130. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8131. $pm = $classid;
  8132. $jm = $classid;
  8133. $rows_r[$key]['enter'] = '入库';
  8134. $rows_r[$key]['time'] = $value['enter'];
  8135. if($value['rktype'] == 1)
  8136. {
  8137. $rows_r[$key]['rktype'] = '采购入库';
  8138. }
  8139. else if($value['rktype'] == 2)
  8140. {
  8141. $rows_r[$key]['rktype'] = '盘盈调整';
  8142. }
  8143. else if($value['rktype'] == 3)
  8144. {
  8145. $rows_r[$key]['rktype'] = '其他调整入库';
  8146. }
  8147. else if($value['rktype'] == 4)
  8148. {
  8149. $rows_r[$key]['rktype'] = '其他调整入库';
  8150. }
  8151. else if($value['rktype'] == 5)
  8152. {
  8153. $rows_r[$key]['rktype'] = '退库入库';
  8154. }
  8155. else if($value['rktype'] == 6)
  8156. {
  8157. $rows_r[$key]['rktype'] = '退货可用入库';
  8158. }
  8159. else if($value['rktype'] == 7)
  8160. {
  8161. $rows_r[$key]['rktype'] = '形态转换入库';
  8162. }
  8163. else
  8164. {
  8165. $rows_r[$key]['rktype'] = '';
  8166. }
  8167. $features = explode('-',trim($value['features'],'-'));
  8168. foreach($features as $v)
  8169. {
  8170. if(isset($typeclass[$v]))
  8171. {
  8172. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8173. $pm[$typeclass[$v]['classid']] = $zh[0];
  8174. }
  8175. if(isset($typeclass[$v]))
  8176. {
  8177. if(isset($jm[$typeclass[$v]['classid']]))
  8178. {
  8179. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8180. }
  8181. }
  8182. }
  8183. $zh = implode(" ",$pm);
  8184. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8185. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8186. $rows_r[$key]['zh'] = $zh;
  8187. $jm = array_filter($jm);
  8188. $rows_r[$key]['features'] = implode("-",$jm);
  8189. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8190. }
  8191. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8192. foreach ($rows_c as $key=>$value)
  8193. {
  8194. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8195. $pm = $classid;
  8196. $jm = $classid;
  8197. $rows_c[$key]['time'] = $value['outk'];
  8198. $rows_c[$key]['outk'] = '出库';
  8199. if($value['cktype'] == 1)
  8200. {
  8201. $rows_c[$key]['cktype'] = '销售出库';
  8202. }
  8203. else if($value['cktype'] == 2)
  8204. {
  8205. $rows_c[$key]['cktype'] = '销售美国出库';
  8206. }
  8207. else if($value['cktype'] == 3)
  8208. {
  8209. $rows_c[$key]['cktype'] = '盘亏调整';
  8210. }
  8211. else if($value['cktype'] == 4)
  8212. {
  8213. $rows_c[$key]['cktype'] = '其他调整出库';
  8214. }
  8215. else if($value['cktype'] == 5)
  8216. {
  8217. $rows_c[$key]['cktype'] = '形态转换出库';
  8218. }
  8219. else
  8220. {
  8221. $rows_c[$key]['cktype'] = '';
  8222. }
  8223. $features = explode('-',trim($value['features'],'-'));
  8224. foreach($features as $v)
  8225. {
  8226. if(isset($typeclass[$v]))
  8227. {
  8228. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8229. $pm[$typeclass[$v]['classid']] = $zh[0];
  8230. }
  8231. if(isset($typeclass[$v]))
  8232. {
  8233. if(isset($jm[$typeclass[$v]['classid']]))
  8234. {
  8235. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8236. }
  8237. }
  8238. }
  8239. $zh = implode(" ",$pm);
  8240. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8241. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8242. $rows_c[$key]['zh'] = $zh;
  8243. $jm = array_filter($jm);
  8244. $rows_c[$key]['features'] = implode("-",$jm);
  8245. $rows_c[$key]['number'] = 1;
  8246. }
  8247. $merged = $rows_r;
  8248. foreach ($rows_c as $key => $value)
  8249. {
  8250. if (isset($merged[$key]))
  8251. {
  8252. $merged[] = $value;
  8253. }
  8254. else
  8255. {
  8256. $merged[$key] = $value;
  8257. }
  8258. }
  8259. usort($merged, function($a, $b)
  8260. {
  8261. return $a['time'] - $b['time'];
  8262. });
  8263. foreach ($merged as $key=>$value)
  8264. {
  8265. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8266. }
  8267. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8268. $titlename = "<table border=1>
  8269. <tr align='center'>
  8270. <td>仓库</td>
  8271. <td>SKU</td>
  8272. <td>商品名称</td>
  8273. <td>仓库品名</td>
  8274. <td>料号</td>
  8275. <td>时间</td>
  8276. <td>操作</td>
  8277. <td>类型</td>
  8278. <td>数量</td>
  8279. <td>备注</td>
  8280. </tr>
  8281. </table>";
  8282. $filename = $title.".xlsx";
  8283. $tail = "";
  8284. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8285. }
  8286. }
  8287. }