Whlabel.php 259 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else {
  190. $this->_index();
  191. }
  192. }
  193. //管理
  194. public function _index()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if (isset($post['page'])) {
  198. $page = $this->input->post('page', true);
  199. $perpage = $this->input->post('perpage', true);
  200. $sku = $this->input->post('sku', true);
  201. $number = $this->input->post('number', true);
  202. $warehouse = $this->input->post('warehouse', true);
  203. $purchase = $this->input->post('purchase', true);
  204. $orderinfo = $this->input->post('orderinfo', true);
  205. $waybill = $this->input->post('waybill', true);
  206. $category = $this->input->post('category', true);
  207. $size = $this->input->post('size', true);
  208. $grade = $this->input->post('grade', true);
  209. $color = $this->input->post('color', true);
  210. $lowe = $this->input->post('lowe', true);
  211. $state = $this->input->post('state', true);
  212. $label = $this->input->post('label', true);
  213. $timetk = $this->input->post('timetkk', true);
  214. $timetj = $this->input->post('timetjj', true);
  215. $timetk = strtotime($timetk);
  216. $timetj = strtotime($timetj);
  217. $where = "1=1 ";
  218. if ($timetk && $timetj) {
  219. $where .= " and time > '$timetk' and time < '$timetj'";
  220. }
  221. if ($sku) {
  222. $where .= " and sku = '$sku'";
  223. }
  224. if ($number) {
  225. $where .= " and number = '$number'";
  226. }
  227. if ($warehouse) {
  228. $where .= " and warehouse = '$warehouse'";
  229. }
  230. if ($purchase) {
  231. $where .= " and purchase = '$purchase'";
  232. }
  233. if ($orderinfo) {
  234. $where .= " and orderinfo = '$orderinfo'";
  235. }
  236. if ($waybill) {
  237. $where .= " and waybill = '$waybill'";
  238. }
  239. if ($category) {
  240. $where .= " and features like '%-$category-%'";
  241. }
  242. if ($size) {
  243. $where .= " and features like '%-$size-%'";
  244. }
  245. if ($grade) {
  246. $where .= " and features like '%-$grade-%'";
  247. }
  248. if ($color) {
  249. $where .= " and features like '%-$color-%'";
  250. }
  251. if ($lowe) {
  252. $where .= " and features like '%-$lowe-%'";
  253. }
  254. if ($label) {
  255. $where .= " and label = '$label'";
  256. }
  257. if ($state != '') {
  258. $where .= " and state = '$state'";
  259. }
  260. //数据排序
  261. $order_str = "time desc";
  262. if (empty($page)) {
  263. $start = 0;
  264. $perpage = 1;
  265. } else {
  266. $start = ($page - 1) * $perpage;
  267. }
  268. //取得信息列表
  269. $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);
  270. foreach ($info_list as $key => $value) {
  271. $warehouse = $this->warehouse->read($value['warehouse']);
  272. $info_list[$key]['warehouse'] = $warehouse['title'];
  273. $purchase = $this->purchase->read($value['purchase']);
  274. $info_list[$key]['purchase'] = $purchase['title'];
  275. if ($value['enter'] != 0) {
  276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  277. } else {
  278. $info_list[$key]['enter'] = "";
  279. }
  280. if ($value['outk'] != 0) {
  281. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  282. } else {
  283. $info_list[$key]['outk'] = "";
  284. }
  285. if ($value['printing'] != 0) {
  286. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  287. } else {
  288. $info_list[$key]['printing'] = "";
  289. }
  290. if ($value['orderinfo'] == 0) {
  291. $info_list[$key]['orderinfo'] = "";
  292. }
  293. if ($value['waybill'] == 0) {
  294. $info_list[$key]['waybill'] = "";
  295. }
  296. if ($value['state'] == 0) {
  297. $info_list[$key]['state'] = "在库";
  298. } else if ($value['state'] == 1) {
  299. $info_list[$key]['state'] = "出库";
  300. } else if ($value['state'] == 2) {
  301. $info_list[$key]['state'] = "退库";
  302. } else if ($value['state'] == 3) {
  303. $info_list[$key]['state'] = "调拨中";
  304. } else if ($value['state'] == 4) {
  305. $info_list[$key]['state'] = "再加工";
  306. } else if ($value['state'] == 5) {
  307. $info_list[$key]['state'] = "维修中";
  308. } else if ($value['state'] == 6) {
  309. $info_list[$key]['state'] = "盘亏";
  310. } else if ($value['state'] == 7) {
  311. $info_list[$key]['state'] = "更换标签";
  312. } else if ($value['state'] == 8) {
  313. $info_list[$key]['state'] = "其它";
  314. } else if ($value['state'] == 9) {
  315. $info_list[$key]['state'] = "预设";
  316. } else if ($value['state'] == 10) {
  317. $info_list[$key]['state'] = "美店零售";
  318. }
  319. if ($value['text'] == "") {
  320. $info_list[$key]['text'] = "";
  321. }
  322. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  323. }
  324. $total = $this->whlabel->find_count($where);
  325. $pagenum = ceil($total / $perpage);
  326. $over = $total - ($start + $perpage);
  327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  328. echo json_encode($rows);
  329. exit;
  330. }
  331. if (isset($post['outsku'])) {
  332. $cz = $this->input->post('cz', true);
  333. if ($cz == '1') {
  334. $sku = $this->input->post('outsku', true);
  335. if ($sku) {
  336. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  337. if (count($data) < 1) {
  338. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  339. exit;
  340. }
  341. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  342. echo json_encode(array('success' => true));
  343. exit;
  344. }
  345. } else {
  346. $sku = $this->input->post('outsku', true);
  347. if ($sku) {
  348. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  349. if (count($data) < 1) {
  350. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  351. exit;
  352. }
  353. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  354. echo json_encode(array('success' => true));
  355. exit;
  356. }
  357. }
  358. }
  359. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  360. $this->_Template('whlabel', $this->data);
  361. }
  362. //在库标签
  363. public function _existence()
  364. {
  365. $post = $this->input->post(NULL, TRUE);
  366. if (isset($post['s'])) {
  367. $id_arr = $this->input->post('s');
  368. $id_arr = explode(',', $id_arr);
  369. if (!$id_arr) {
  370. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  371. exit;
  372. }
  373. //循环删除记录
  374. foreach ($id_arr as $v) {
  375. $sid = $this->whlabel->read($v);
  376. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  377. if ($count > 0) {
  378. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  379. exit;
  380. }
  381. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  382. if (count($zt) > 0) {
  383. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  384. exit;
  385. }
  386. $this->whlabel->remove($v);
  387. }
  388. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  389. exit;
  390. }
  391. if (isset($post['page'])) {
  392. $page = $this->input->post('page', true);
  393. $perpage = $this->input->post('perpage', true);
  394. $warehouse = $this->input->post('warehouse', true);
  395. $label = $this->input->post('label', true);
  396. $where = "1=1 and state = 0";
  397. if ($warehouse) {
  398. $where .= " and warehouse = '$warehouse'";
  399. }
  400. if ($label) {
  401. $where .= " and label = '$label'";
  402. }
  403. //数据排序
  404. $order_str = "time asc";
  405. if (empty($page)) {
  406. $start = 0;
  407. $perpage = 1;
  408. } else {
  409. $start = ($page - 1) * $perpage;
  410. }
  411. //取得信息列表
  412. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  413. foreach ($info_list as $key => $value) {
  414. if ($value['enter'] != 0) {
  415. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  416. } else {
  417. $info_list[$key]['enter'] = "";
  418. }
  419. if ($value['printing'] != 0) {
  420. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  421. } else {
  422. $info_list[$key]['printing'] = "";
  423. }
  424. }
  425. $total = $this->whlabel->find_count($where);
  426. $pagenum = ceil($total / $perpage);
  427. $over = $total - ($start + $perpage);
  428. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  429. echo json_encode($rows);
  430. exit;
  431. }
  432. $this->_Template('whlabel_existence', $this->data);
  433. }
  434. //进销存浏览
  435. public function _typedy($arg_array)
  436. {
  437. $prc = array();
  438. $purchase = $this->purchase->find_all();
  439. foreach ($purchase as $k => $v) {
  440. $prc[$v['id']] = $v['title'];
  441. }
  442. $post = $this->input->post(NULL, TRUE);
  443. if (isset($post['page'])) {
  444. $page = $this->input->post('page', true);
  445. $perpage = $this->input->post('perpage', true);
  446. $category = $this->input->post('category', true);
  447. $size = $this->input->post('size', true);
  448. $grade = $this->input->post('grade', true);
  449. $color = $this->input->post('color', true);
  450. $lowe = $this->input->post('lowe', true);
  451. $sku = $this->input->post('sku');
  452. $title = $this->input->post('title');
  453. $warehouse = $this->input->post('warehouse', true);
  454. $usa = $this->input->post('usa', true);
  455. $purchase = $this->input->post('purchase', true);
  456. $lacetype = $this->input->post('lacetype', true);
  457. $haircap = $this->input->post('haircap', true);
  458. $density = $this->input->post('density', true);
  459. $details = $this->input->post('details', true);
  460. $state = $this->input->post('state', true);
  461. $lacecolor = $this->input->post('lacecolor', true);
  462. $hairnumber = $this->input->post('hairnumber', true);
  463. $cklx = $this->input->post('cklx', true);
  464. $ktime = $this->input->post('ktime', true);
  465. $jtime = $this->input->post('jtime', true);
  466. $sm = $this->input->post('sm', true);
  467. $cpbz = $this->input->post('cpbz', true);
  468. $type = $this->input->post('type', true);
  469. $ktime = strtotime($ktime);
  470. $jtime = strtotime($jtime);
  471. $where = "1=1";
  472. $gj = "";
  473. $ck = "";
  474. if ($usa) {
  475. if (!$warehouse) {
  476. $where .= " and (warehouse = '5' or warehouse = '8')";
  477. }
  478. }
  479. if ($warehouse) {
  480. $where .= " and warehouse = '$warehouse'";
  481. }
  482. if ($details) {
  483. $where .= " and details = '$details'";
  484. }
  485. if ($purchase) {
  486. $where .= " and purchase = '$purchase'";
  487. }
  488. if ($state) {
  489. $where .= " and state = '$state'";
  490. }
  491. if ($lacetype) {
  492. $where .= " and features like '%-$lacetype-%'";
  493. }
  494. if ($category) {
  495. $where .= " and features like '%-$category-%'";
  496. }
  497. if ($size) {
  498. $where .= " and features like '%-$size-%'";
  499. }
  500. if ($grade) {
  501. $where .= " and features like '%-$grade-%'";
  502. }
  503. if ($color) {
  504. $where .= " and features like '%-$color-%'";
  505. }
  506. if ($lowe) {
  507. $where .= " and features like '%-$lowe-%'";
  508. }
  509. if ($haircap) {
  510. $where .= " and features like '%-$haircap-%'";
  511. }
  512. if ($density) {
  513. $where .= " and features like '%-$density-%'";
  514. }
  515. if ($lacecolor) {
  516. $where .= " and features like '%-$lacecolor-%'";
  517. }
  518. if($sm){
  519. $where .= " and sm like '%".$sm."%'";
  520. }
  521. if($cpbz){
  522. $where .= " and cpbz like '%".$cpbz."%'";
  523. }
  524. if($type){
  525. $where .= " and type = ".$type."";
  526. }
  527. if (!empty($hairnumber)) {
  528. $where .= " and features like '%-128-%' ";
  529. if ($hairnumber < 0) {
  530. $class_list = $this->typeclass->find_all('classid = 43');
  531. foreach ($class_list as $v) {
  532. $where .= " and features not like '%-" . $v['id'] . "-%'";
  533. }
  534. } else {
  535. $where .= " and features like '%-$hairnumber-%'";
  536. }
  537. }
  538. $where_add = '';
  539. if ($cklx) {
  540. $shop = $this->shop->read($cklx);
  541. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  542. }
  543. if ($ktime && $jtime) {
  544. $gj = " and enter > '$ktime' and enter < '$jtime'";
  545. $ck = " and outk > '$ktime' and outk < '$jtime'";
  546. }
  547. //数据排序
  548. $order_str = "id desc";
  549. if (empty($page)) {
  550. $start = 0;
  551. $perpage = 1;
  552. } else {
  553. $start = ($page - 1) * $perpage;
  554. }
  555. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  556. if ($sku) {
  557. $sku = trim($sku, ' ');
  558. $sku = trim($sku, ' ');
  559. $where .= " and sku like '%$sku%'";
  560. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  561. } else if ($title) {
  562. $title = trim($title, ' ');
  563. $title = trim($title, ' ');
  564. $where .= " and title like '%$title%'";
  565. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  566. } else {
  567. //$where .= " and time > '$ktime' and time < '$jtime'";
  568. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  569. }
  570. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  571. foreach ($info_list as $k => $v) {
  572. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  573. unset($info_list[$k]['pm']);
  574. unset($info_list[$k]['jm']);
  575. unset($info_list[$k]['bm']);
  576. }
  577. //取得信息列表
  578. $rows = array();
  579. $list = array();
  580. foreach ($info_list as $key => $value) {
  581. $warehouse = $this->warehouse->read($value['warehouse']);
  582. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  583. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  584. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  585. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  586. $info_list[$key]['label'] = $value['sm'];
  587. $number = $value['number'];
  588. $ftime = time() - 15 * 24 * 3600;
  589. $info_list[$key]['warehouse'] = $warehouse['title'];
  590. $info_list[$key]['features'] = count($c);
  591. $z = count($z); //查看订单号
  592. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  593. $ztdata = '';
  594. if (count($zt) > 0) {
  595. foreach ($zt as $vv) {
  596. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  597. }
  598. }
  599. $info_list[$key]['number'] = $ztdata;
  600. $info_list[$key]['sm'] = $z;
  601. $details = array();
  602. $cpid = array();
  603. foreach ($c as $k => $v) {
  604. $details[$v['details']] = $v['details'];
  605. if ($v['cpid'] != 0) {
  606. $cpid[$v['cpid']] = $v['cpid'];
  607. }
  608. }
  609. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  610. if ($value['shop'] != '') {
  611. $shop = explode(',', trim($value['shop'], ','));
  612. $shop = $this->shop->read($shop[0]);
  613. $info_list[$key]['shop'] = $shop['shopname'];
  614. }
  615. }
  616. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  617. $pagenum = ceil($total / $perpage);
  618. $over = $total - ($start + $perpage);
  619. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  620. echo json_encode($rows);
  621. exit;
  622. }
  623. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  624. $this->_Template('whlabel_typedy', $this->data);
  625. }
  626. //进销存浏览
  627. public function _typedy_ck($arg_array)
  628. {
  629. $prc = array();
  630. $purchase = $this->purchase->find_all();
  631. foreach ($purchase as $k => $v) {
  632. $prc[$v['id']] = $v['title'];
  633. }
  634. $post = $this->input->post(NULL, TRUE);
  635. if (isset($post['page'])) {
  636. $page = $this->input->post('page', true);
  637. $perpage = $this->input->post('perpage', true);
  638. $category = $this->input->post('category', true);
  639. $size = $this->input->post('size', true);
  640. $grade = $this->input->post('grade', true);
  641. $color = $this->input->post('color', true);
  642. $lowe = $this->input->post('lowe', true);
  643. $sku = $this->input->post('sku');
  644. $title = $this->input->post('title');
  645. $warehouse = $this->input->post('warehouse', true);
  646. $usa = $this->input->post('usa', true);
  647. $purchase = $this->input->post('purchase', true);
  648. $lacetype = $this->input->post('lacetype', true);
  649. $haircap = $this->input->post('haircap', true);
  650. $density = $this->input->post('density', true);
  651. $details = $this->input->post('details', true);
  652. $state = $this->input->post('state', true);
  653. $lacecolor = $this->input->post('lacecolor', true);
  654. $cklx = $this->input->post('cklx', true);
  655. $ktime = $this->input->post('ktime', true);
  656. $jtime = $this->input->post('jtime', true);
  657. $ktime = strtotime($ktime);
  658. $jtime = strtotime($jtime);
  659. $where = "1=1";
  660. $gj = "";
  661. $ck = "";
  662. if ($lacetype) {
  663. $where .= " and features like '%-$lacetype-%'";
  664. }
  665. if ($category) {
  666. $where .= " and features like '%-$category-%'";
  667. }
  668. if ($size) {
  669. $where .= " and features like '%-$size-%'";
  670. }
  671. if ($grade) {
  672. $where .= " and features like '%-$grade-%'";
  673. }
  674. if ($color) {
  675. $where .= " and features like '%-$color-%'";
  676. }
  677. if ($lowe) {
  678. $where .= " and features like '%-$lowe-%'";
  679. }
  680. if ($haircap) {
  681. $where .= " and features like '%-$haircap-%'";
  682. }
  683. if ($density) {
  684. $where .= " and features like '%-$density-%'";
  685. }
  686. if ($lacecolor) {
  687. $where .= " and features like '%-$lacecolor-%'";
  688. }
  689. if ($usa) {
  690. if (!$warehouse) {
  691. $where .= " and (warehouse = '5' or warehouse = '8')";
  692. }
  693. }
  694. if ($warehouse) {
  695. $where .= " and warehouse = '$warehouse'";
  696. }
  697. if ($details) {
  698. $where .= " and details = '$details'";
  699. }
  700. if ($purchase) {
  701. $where .= " and purchase = '$purchase'";
  702. }
  703. if ($state) {
  704. $where .= " and state = '$state'";
  705. }
  706. $where_add = '';
  707. if ($cklx) {
  708. $shop = $this->shop->read($cklx);
  709. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  710. }
  711. if ($ktime && $jtime) {
  712. $gj = " and enter > '$ktime' and enter < '$jtime'";
  713. $ck = " and outk > '$ktime' and outk < '$jtime'";
  714. }
  715. //数据排序
  716. $order_str = "id desc";
  717. if (empty($page)) {
  718. $start = 0;
  719. $perpage = 1;
  720. } else {
  721. $start = ($page - 1) * $perpage;
  722. }
  723. if ($sku) {
  724. $sku = trim($sku, ' ');
  725. $sku = trim($sku, ' ');
  726. $where .= " and sku like '%$sku%'";
  727. $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);
  728. } else if ($title) {
  729. $title = trim($title, ' ');
  730. $title = trim($title, ' ');
  731. $where .= " and title like '%$title%'";
  732. $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);
  733. } else {
  734. //$where .= " and time > '$ktime' and time < '$jtime'";
  735. $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);
  736. }
  737. //取得信息列表
  738. $rows = array();
  739. $list = array();
  740. foreach ($info_list as $key => $value) {
  741. $warehouse = $this->warehouse->read($value['warehouse']);
  742. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  743. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  744. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  745. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  746. $ftime = time() - 15 * 24 * 3600;
  747. $info_list[$key]['warehouse'] = $warehouse['title'];
  748. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  749. //$z = count($z);//查看订单号
  750. //$info_list[$key]['zd'] = $z;
  751. $details = array();
  752. $cpid = array();
  753. foreach ($c as $k => $v) {
  754. $details[$v['details']] = $v['details'];
  755. if ($v['cpid'] != 0) {
  756. $cpid[$v['cpid']] = $v['cpid'];
  757. }
  758. }
  759. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  760. if ($value['shop'] != '') {
  761. $shop = explode(',', trim($value['shop'], ','));
  762. $shop = $this->shop->read($shop[0]);
  763. $info_list[$key]['shop'] = $shop['shopname'];
  764. }
  765. }
  766. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  767. $pagenum = ceil($total / $perpage);
  768. $over = $total - ($start + $perpage);
  769. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  770. echo json_encode($rows);
  771. exit;
  772. }
  773. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  774. $this->_Template('whlabel_typedy_ck', $this->data);
  775. }
  776. public function _typeck($arg_array)
  777. {
  778. $prc = array();
  779. $purchase = $this->purchase->find_all();
  780. foreach ($purchase as $k => $v) {
  781. $prc[$v['id']] = $v['title'];
  782. }
  783. $post = $this->input->post(NULL, TRUE);
  784. if (isset($post['page'])) {
  785. $page = $this->input->post('page', true);
  786. $perpage = $this->input->post('perpage', true);
  787. $category = $this->input->post('category', true);
  788. $size = $this->input->post('size', true);
  789. $grade = $this->input->post('grade', true);
  790. $color = $this->input->post('color', true);
  791. $lacecolor = $this->input->post('lacecolor', true);
  792. $lowe = $this->input->post('lowe', true);
  793. $sku = $this->input->post('sku');
  794. $title = $this->input->post('title');
  795. $warehouse = 13;
  796. $usa = $this->input->post('usa', true);
  797. $purchase = $this->input->post('purchase', true);
  798. $lacetype = $this->input->post('lacetype', true);
  799. $haircap = $this->input->post('haircap', true);
  800. $density = $this->input->post('density', true);
  801. $details = $this->input->post('details', true);
  802. $state = $this->input->post('state', true);
  803. $ktime = $this->input->post('ktime', true);
  804. $jtime = $this->input->post('jtime', true);
  805. $ktime = strtotime($ktime);
  806. $jtime = strtotime($jtime);
  807. $where = "1=1";
  808. $gj = "";
  809. $ck = "";
  810. if ($lacetype) {
  811. $where .= " and features like '%-$lacetype-%'";
  812. }
  813. if ($category) {
  814. $where .= " and features like '%-$category-%'";
  815. }
  816. if ($size) {
  817. $where .= " and features like '%-$size-%'";
  818. }
  819. if ($grade) {
  820. $where .= " and features like '%-$grade-%'";
  821. }
  822. if ($color) {
  823. $where .= " and features like '%-$color-%'";
  824. }
  825. if ($lacecolor) {
  826. $where .= " and features like '%-$lacecolor-%'";
  827. }
  828. if ($lowe) {
  829. $where .= " and features like '%-$lowe-%'";
  830. }
  831. if ($haircap) {
  832. $where .= " and features like '%-$haircap-%'";
  833. }
  834. if ($density) {
  835. $where .= " and features like '%-$density-%'";
  836. }
  837. if ($warehouse) {
  838. $where .= " and warehouse = '$warehouse'";
  839. }
  840. if ($details) {
  841. $where .= " and details = '$details'";
  842. }
  843. if ($purchase) {
  844. $where .= " and purchase = '$purchase'";
  845. }
  846. if ($state) {
  847. $where .= " and state = '$state'";
  848. }
  849. if ($ktime && $jtime) {
  850. $gj = " and enter > '$ktime' and enter < '$jtime'";
  851. $ck = " and outk > '$ktime' and outk < '$jtime'";
  852. }
  853. //数据排序
  854. $order_str = "id desc";
  855. if (empty($page)) {
  856. $start = 0;
  857. $perpage = 1;
  858. } else {
  859. $start = ($page - 1) * $perpage;
  860. }
  861. if ($sku) {
  862. $sku = trim($sku, ' ');
  863. $sku = trim($sku, ' ');
  864. $where .= " and sku like '%$sku%'";
  865. } else if ($title) {
  866. $title = trim($title, ' ');
  867. $title = trim($title, ' ');
  868. $where .= " and title like '%$title%'";
  869. }
  870. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  871. //取得信息列表
  872. $t = array();
  873. $typeclass = $this->typeclass->find_all();
  874. foreach ($typeclass as $v) {
  875. $t[$v['id']] = $v;
  876. }
  877. $rows = array();
  878. $list = array();
  879. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  880. foreach ($info_list as $key => $value) {
  881. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  882. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  883. $warehouse = $this->warehouse->read($value['warehouse']);
  884. $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');
  885. $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'] . '"');
  886. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  887. $number = $value['number'];
  888. $ftime = time() - 15 * 24 * 3600;
  889. $z = count($z); //查看订单号
  890. $info_list[$key]['warehouse'] = $warehouse['title'];
  891. $info_list[$key]['features'] = count($c);
  892. $info_list[$key]['number'] = $z;
  893. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  894. $details = array();
  895. $cpid = array();
  896. foreach ($c as $k => $v) {
  897. $details[$v['details']] = $v['details'];
  898. if ($v['cpid'] != 0) {
  899. $cpid[$v['cpid']] = $v['cpid'];
  900. }
  901. }
  902. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  903. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  904. unset($info_list[$key]['pm']);
  905. unset($info_list[$key]['jm']);
  906. unset($info_list[$key]['bm']);
  907. }
  908. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  909. $pagenum = ceil($total / $perpage);
  910. $over = $total - ($start + $perpage);
  911. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  912. echo json_encode($rows);
  913. exit;
  914. }
  915. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  916. $this->_Template('whlabel_typeck', $this->data);
  917. }
  918. //进销存导出
  919. public function _whlabeckdc()
  920. {
  921. $prc = array();
  922. $purchase = $this->purchase->find_all();
  923. foreach ($purchase as $k => $v) {
  924. $prc[$v['id']] = $v['title'];
  925. }
  926. if (isset($_GET['excel'])) {
  927. $where = "sku != 'Preset'";
  928. //数据排序
  929. $order_str = "id desc";
  930. if (empty($page)) {
  931. $start = 0;
  932. $perpage = 1;
  933. } else {
  934. $start = ($page - 1) * $perpage;
  935. }
  936. $category = $this->input->get('category', true);
  937. $color = $this->input->get('color', true);
  938. $lowe = $this->input->get('lowe', true);
  939. $lacetype = $this->input->get('lacetype', true);
  940. $size = $this->input->get('size', true);
  941. $density = $this->input->get('density', true);
  942. $haircap = $this->input->get('haircap', true);
  943. $sku = $this->input->get('sku', true);
  944. $details = $this->input->get('details', true);
  945. $warehouse = 13;
  946. $excelid = $this->input->get('sid', true);
  947. if ($category) {
  948. $where .= " and features like '%-$category-%'";
  949. }
  950. if ($color) {
  951. $where .= " and features like '%-$color-%'";
  952. }
  953. if ($lowe) {
  954. $where .= " and features like '%-$lowe-%'";
  955. }
  956. if ($lacetype) {
  957. $where .= " and features like '%-$lacetype-%'";
  958. }
  959. if ($size) {
  960. $where .= " and features like '%-$size-%'";
  961. }
  962. if ($density) {
  963. $where .= " and features like '%-$density-%'";
  964. }
  965. if ($haircap) {
  966. $where .= " and features like '%-$haircap-%'";
  967. }
  968. if ($warehouse) {
  969. $where .= " and warehouse = '$warehouse'";
  970. }
  971. if ($sku) {
  972. $where .= " and sku like '%$sku%'";
  973. }
  974. if ($details) {
  975. $where .= " and details = '$details'";
  976. }
  977. $xzid = '';
  978. if ($excelid) {
  979. $excelid = explode(',', trim($excelid, ','));
  980. foreach ($excelid as $key => $value) {
  981. $xzid .= " id = " . $value . " or";
  982. }
  983. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  984. }
  985. //取得信息列表
  986. /**
  987. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  988. $rows = array();$list = array();
  989. foreach ($info_list as $key=>$value)
  990. {
  991. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  992. }
  993. **/
  994. $wh = array();
  995. $w = $this->warehouse->find_all('1=1', 'id,title');
  996. foreach ($w as $v) {
  997. $wh[$v['id']] = $v['title'];
  998. }
  999. $tc = array();
  1000. $tcdata = array();
  1001. $list = array();
  1002. $classid = $this->classid->sku();
  1003. $tcall = $this->typeclass->find_all();
  1004. $typeclass = array();
  1005. foreach ($tcall as $v)
  1006. {
  1007. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1008. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1009. }
  1010. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1011. foreach ($rows as $key => $value) {
  1012. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1013. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1014. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1015. $rows[$key]['cpbz'] = $u9_info['bm'];
  1016. $rows[$key]['cs'] = $u9_info['jm'];
  1017. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1018. $details = array();
  1019. $cpid = array();
  1020. $cpbz = array();
  1021. $c = 0;
  1022. $g = 0;
  1023. $x = 0;
  1024. $t = 0;
  1025. $s = 0;
  1026. $q = 0;
  1027. foreach ($sd as $k => $v) {
  1028. if ($v['state'] == 0) {
  1029. $c++;
  1030. }
  1031. if ($v['state'] != 9) {
  1032. $g++;
  1033. }
  1034. if ($v['state'] == 1) {
  1035. $x++;
  1036. }
  1037. if ($v['state'] == 2) {
  1038. $t++;
  1039. }
  1040. if ($v['state'] == 8) {
  1041. $s++;
  1042. }
  1043. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1044. $q++;
  1045. }
  1046. $details[$v['details']] = $v['details'];
  1047. if ($v['cpid'] != 0) {
  1048. $cpid[$v['cpid']] = $v['cpid'];
  1049. }
  1050. if ($v['cpbz'] != '') {
  1051. $cpbz[$v['cpbz']] = $v['cpbz'];
  1052. }
  1053. }
  1054. $rows[$key]['details'] = implode("、", $details);
  1055. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1056. $number = $value['number'];
  1057. $ftime = time() - 15 * 24 * 3600;
  1058. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1059. $rows[$key]['number'] = $g;
  1060. $rows[$key]['features'] = $c;
  1061. $rows[$key]['x'] = $x;
  1062. $rows[$key]['t'] = $t;
  1063. $rows[$key]['s'] = $s;
  1064. $rows[$key]['q'] = $q;
  1065. $rows[$key]['wzsl'] = count($details);
  1066. }
  1067. $title = "进销存统计表" . date('Y-m-d', time());
  1068. $titlename = "<table border=1>
  1069. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1070. <tr align='center'>
  1071. <td>仓库</td>
  1072. <td>供应商</td>
  1073. <td>位置</td>
  1074. <td>库存编码</td>
  1075. <td>SKU</td>
  1076. <td>用友编码</td>
  1077. <td>用友料号</td>
  1078. <td>产品英文名</td>
  1079. <td>产品中文名</td>
  1080. <td>入库总量</td>
  1081. <td>库存数量</td>
  1082. <td>销售数量</td>
  1083. <td>退货数量</td>
  1084. <td>删除数量</td>
  1085. <td>其它操作</td>
  1086. <td>位置数量</td>
  1087. </tr>
  1088. </table>";
  1089. $filename = $title . ".xls";
  1090. $tail = "";
  1091. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1092. }
  1093. }
  1094. public function _type()
  1095. {
  1096. $vip = 0;
  1097. if (isset($_SESSION['api'])) {
  1098. $user = $this->user->get_api($_SESSION['api']);
  1099. $fgshop = "";
  1100. $sid = "";
  1101. $usersp = explode('|', trim($user['shop'], '|'));
  1102. foreach ($usersp as $value) {
  1103. $fgshop .= " shop = " . $value . " or";
  1104. $sid .= " id = " . $value . " or";
  1105. }
  1106. if ($user['vip'] == 1) {
  1107. $vip = 1;
  1108. }
  1109. } else {
  1110. header('Location: /');
  1111. exit;
  1112. }
  1113. $prc = array();
  1114. $purchase = $this->purchase->find_all();
  1115. foreach ($purchase as $k => $v) {
  1116. $prc[$v['id']] = $v['title'];
  1117. }
  1118. $company = array();
  1119. $ct = $this->company->find_all();
  1120. foreach ($ct as $k => $v) {
  1121. $company[$v['id']] = $v['title'];
  1122. }
  1123. $sp = array();
  1124. $s = $this->shop->find_all('1=1', 'id,shopname');
  1125. foreach ($s as $v) {
  1126. $sp[$v['id']] = $v['shopname'];
  1127. }
  1128. $wh = array();
  1129. $w = $this->warehouse->find_all('1=1', 'id,title');
  1130. foreach ($w as $v) {
  1131. $wh[$v['id']] = $v['title'];
  1132. }
  1133. $post = $this->input->post(NULL, TRUE);
  1134. if (isset($post['page'])) {
  1135. $page = $this->input->post('page', true);
  1136. $perpage = $this->input->post('perpage', true);
  1137. $category = $this->input->post('category', true);
  1138. $size = $this->input->post('size', true);
  1139. $grade = $this->input->post('grade', true);
  1140. $color = $this->input->post('color', true);
  1141. $lowe = $this->input->post('lowe', true);
  1142. $sku = $this->input->post('sku');
  1143. $title = $this->input->post('title');
  1144. $warehouse = $this->input->post('warehouse', true);
  1145. $usa = $this->input->post('usa', true);
  1146. $purchase = $this->input->post('purchase', true);
  1147. $lacetype = $this->input->post('lacetype', true);
  1148. $haircap = $this->input->post('haircap', true);
  1149. $density = $this->input->post('density', true);
  1150. $details = $this->input->post('details', true);
  1151. $state = $this->input->post('state', true);
  1152. $shop = $this->input->post('shop', true);
  1153. $lacecolor = $this->input->post('lacecolor', true);
  1154. $hairnumber = $this->input->post('hairnumber', true);
  1155. $type = $this->input->post('type', true);
  1156. $ktime = $this->input->post('ktime', true);
  1157. $jtime = $this->input->post('jtime', true);
  1158. $ktime = strtotime($ktime);
  1159. $jtime = strtotime($jtime);
  1160. $cpbz = $this->input->post('cpbz', true);
  1161. $sm = $this->input->post('sm', true);
  1162. $where = "1=1";
  1163. $gj = "";
  1164. $ck = "";
  1165. if ($usa) {
  1166. if (!$warehouse) {
  1167. $where .= " and (warehouse = '5' or warehouse = '8')";
  1168. }
  1169. }
  1170. if ($warehouse) {
  1171. $where .= " and warehouse = '$warehouse'";
  1172. }
  1173. if ($details) {
  1174. $where .= " and details = '$details'";
  1175. }
  1176. if ($purchase) {
  1177. $where .= " and purchase = '$purchase'";
  1178. }
  1179. if ($state) {
  1180. $where .= " and state = '$state'";
  1181. }
  1182. if ($shop) {
  1183. $where .= " and shop like '%$shop%'";
  1184. }
  1185. if ($type) {
  1186. $where .= " and type = '$type'";
  1187. }
  1188. if ($ktime && $jtime) {
  1189. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1190. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1191. }
  1192. if ($cpbz) {
  1193. $where .= " and cpbz like '%$cpbz%' ";
  1194. }
  1195. if ($sm) {
  1196. $where .= " and sm like '%$sm%' ";
  1197. }
  1198. if ($lacecolor) {
  1199. $where .= " and features like '%-$lacecolor-%'";
  1200. }
  1201. if ($lacetype) {
  1202. $where .= " and features like '%-$lacetype-%'";
  1203. }
  1204. if ($category) {
  1205. $where .= " and features like '%-$category-%'";
  1206. }
  1207. if ($size) {
  1208. $where .= " and features like '%-$size-%'";
  1209. }
  1210. if ($grade) {
  1211. $where .= " and features like '%-$grade-%'";
  1212. }
  1213. if ($color) {
  1214. $where .= " and features like '%-$color-%'";
  1215. }
  1216. if ($lowe) {
  1217. $where .= " and features like '%-$lowe-%'";
  1218. }
  1219. if ($haircap) {
  1220. $where .= " and features like '%-$haircap-%'";
  1221. }
  1222. if ($density) {
  1223. $where .= " and features like '%-$density-%'";
  1224. }
  1225. if (!empty($hairnumber)) {
  1226. $where .= " and features like '%-128-%' ";
  1227. if ($hairnumber < 0) {
  1228. $class_list = $this->typeclass->find_all('classid = 43');
  1229. foreach ($class_list as $v) {
  1230. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1231. }
  1232. } else {
  1233. $where .= " and features like '%-$hairnumber-%'";
  1234. }
  1235. }
  1236. //数据排序
  1237. $order_str = "id desc";
  1238. if (empty($page)) {
  1239. $start = 0;
  1240. $perpage = 1;
  1241. } else {
  1242. $start = ($page - 1) * $perpage;
  1243. }
  1244. $fjnr = '';
  1245. if ($sku) {
  1246. $sku = trim($sku, ' ');
  1247. $sku = trim($sku, ' ');
  1248. $fjnr .= " and sku like '%$sku%'";
  1249. }
  1250. if ($title) {
  1251. $title = trim($title, ' ');
  1252. $title = trim($title, ' ');
  1253. $fjnr .= " and title like '%$title%'";
  1254. }
  1255. $wt = array();
  1256. $whlabel_type = $this->whlabel_type->find_all();
  1257. foreach ($whlabel_type as $v) {
  1258. $wt[$v['id']] = $v['title'];
  1259. }
  1260. $this->logic_ding->sendToDing("进销存浏览请求的数据类型参考".$where.$fjnr);
  1261. //$where .= " and time > '$ktime' and time < '$jtime'";
  1262. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1263. //取得信息列表
  1264. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1265. $rows = array();
  1266. $list = array();
  1267. foreach ($info_list as $key => $value) {
  1268. if (isset($wt[$value['type']])) {
  1269. $info_list[$key]['type'] = $wt[$value['type']];
  1270. } else {
  1271. $info_list[$key]['type'] = '未设置';
  1272. }
  1273. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1274. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1275. $ztdata = '';
  1276. if (count($zt) > 0) {
  1277. foreach ($zt as $vv) {
  1278. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1279. }
  1280. }
  1281. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1282. $cdata = array_filter($qbdata, function ($item) {
  1283. return $item['state'] < 1;
  1284. });
  1285. $c = array_sum(array_column($cdata, 'jnum'));
  1286. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1287. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1288. });
  1289. $g = array_sum(array_column($gdata, 'jnum'));
  1290. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1291. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1292. });
  1293. $x = array_sum(array_column($xdata, 'jnum'));
  1294. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1295. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1296. });
  1297. $t = array_sum(array_column($tdata, 'jnum'));
  1298. $zdata = array_filter($qbdata, function ($item) {
  1299. return $item['zd'] != "" && $item['state'] < 1;
  1300. });
  1301. $z = array_sum(array_column($zdata, 'jnum'));
  1302. $zdata = array_filter($qbdata, function ($item) {
  1303. return $item['zd'] != "" && $item['state'] < 1;
  1304. });
  1305. $z = array_sum(array_column($zdata, 'jnum'));
  1306. //$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');
  1307. //$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'].'"');
  1308. //$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'].'"');
  1309. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1310. //$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'].'"');
  1311. $details = array();
  1312. $cpid = array();
  1313. $od = array();
  1314. $odid = '';
  1315. $companytitle = '';
  1316. $shop_list = [];
  1317. foreach ($qbdata as $v) {
  1318. if ($v['zd'] != "" && $v['state'] < 1) {
  1319. if (!isset($od[$v['zd']])) {
  1320. $od[$v['zd']] = 1; //所有数据sku
  1321. } else {
  1322. $od[$v['zd']] = $od[$v['zd']] + 1;
  1323. }
  1324. }
  1325. if ($v['state'] < 1) {
  1326. $details[$v['details']] = $v['details'];
  1327. if ($v['cpid'] != 0) {
  1328. $cpid[$v['cpid']] = $v['cpid'];
  1329. }
  1330. }
  1331. if($v['state'] == 0){
  1332. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1333. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1334. }
  1335. if ($v['shop'] != '') {
  1336. $shop = explode(',', trim($v['shop'], ','));
  1337. foreach ($shop as $vv) {
  1338. if (!in_array($vv, $shop_list)) {
  1339. $shop_list[] = $vv;
  1340. }
  1341. }
  1342. }
  1343. }
  1344. }
  1345. foreach ($od as $k => $vv) {
  1346. $odid .= $k . '数量' . $vv;
  1347. }
  1348. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1349. $info_list[$key]['label'] = $value['sm'];
  1350. $number = $value['number'];
  1351. $ftime = time() - 15 * 24 * 3600;
  1352. $z = $z . '(' . $odid . ')'; //查看订单号
  1353. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1354. $info_list[$key]['features'] = $c;
  1355. $info_list[$key]['number'] = $ztdata;
  1356. $info_list[$key]['sm'] = $g;
  1357. $info_list[$key]['x'] = $x;
  1358. $info_list[$key]['t'] = $t;
  1359. $info_list[$key]['z'] = $z;
  1360. /**
  1361. foreach ($cdata as $k=>$v)
  1362. {
  1363. $details[$v['details']] = $v['details'];
  1364. if($v['cpid'] != 0)
  1365. {
  1366. $cpid[$v['cpid']] = $v['cpid'];
  1367. }
  1368. }
  1369. **/
  1370. $info_list[$key]['shop'] = '';
  1371. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1372. // if ($value['shop'] != '') {
  1373. // $shop = explode(',', trim($value['shop'], ','));
  1374. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1375. // }
  1376. $shop_list = array_unique($shop_list);
  1377. $shop_str = '';
  1378. foreach ($shop_list as $v) {
  1379. if(isset($sp[$v])){
  1380. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1381. }
  1382. }
  1383. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1384. /**
  1385. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1386. if(isset($companytitle[0]))
  1387. {
  1388. foreach ($companytitle as $k=>$v)
  1389. {
  1390. if($v['companytitle'] != '')
  1391. {
  1392. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1393. }
  1394. }
  1395. }
  1396. **/
  1397. }
  1398. $final_all_list = [];
  1399. foreach ($info_list as $k => $v) {
  1400. $final_all_list[] = [
  1401. 'id' => $v['id'],
  1402. "warehouse" => $v["warehouse"],
  1403. "purchase" => $v["purchase"],
  1404. "sku" => $v["sku"],
  1405. "title" => $v["title"] . "<br/>" . $v["pm"],
  1406. "details" => $v["details"],
  1407. "shop" => $v["shop"],
  1408. "cpbz" => $v["cpbz"],
  1409. 'label' => $v['label'],
  1410. "type" => $v["type"],
  1411. "features" => $v["features"],
  1412. "number" => $v["number"],
  1413. "sm" => $v["sm"],
  1414. "x" => $v["x"],
  1415. "t" => $v["t"],
  1416. "z" => $v["z"]
  1417. ];
  1418. }
  1419. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1420. $pagenum = ceil($total / $perpage);
  1421. $over = $total - ($start + $perpage);
  1422. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1423. echo json_encode($rows);
  1424. exit;
  1425. }
  1426. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1427. $this->data['shop'] = $wlshop;
  1428. $this->data['vip'] = $vip;
  1429. $this->_Template('whlabel_type', $this->data);
  1430. }
  1431. //美仓进销存浏览
  1432. public function _usatype()
  1433. {
  1434. if (isset($_SESSION['api'])) {
  1435. $user = $this->user->get_api($_SESSION['api']);
  1436. $usp = $user;
  1437. $fgshop = "";
  1438. $sid = "";
  1439. $wid = "";
  1440. $wtype = "";
  1441. $userwh = explode('|', trim($user['warehouse'], '|'));
  1442. foreach ($userwh as $value) {
  1443. $wid .= " id = " . $value . " or";
  1444. $wtype .= " type = " . $value . " or";
  1445. }
  1446. }
  1447. $prc = array();
  1448. $purchase = $this->purchase->find_all();
  1449. foreach ($purchase as $k => $v) {
  1450. $prc[$v['id']] = $v['title'];
  1451. }
  1452. $post = $this->input->post(NULL, TRUE);
  1453. if (isset($post['page'])) {
  1454. $page = $this->input->post('page', true);
  1455. $perpage = $this->input->post('perpage', true);
  1456. $category = $this->input->post('category', true);
  1457. $size = $this->input->post('size', true);
  1458. $grade = $this->input->post('grade', true);
  1459. $color = $this->input->post('color', true);
  1460. $lowe = $this->input->post('lowe', true);
  1461. $sku = $this->input->post('sku');
  1462. $title = $this->input->post('title');
  1463. $warehouse = $this->input->post('warehouse', true);
  1464. $usa = $this->input->post('usa', true);
  1465. $purchase = $this->input->post('purchase', true);
  1466. $lacetype = $this->input->post('lacetype', true);
  1467. $haircap = $this->input->post('haircap', true);
  1468. $density = $this->input->post('density', true);
  1469. $details = $this->input->post('details', true);
  1470. $state = $this->input->post('state', true);
  1471. $lacecolor = $this->input->post('lacecolor', true);
  1472. $cklx = $this->input->post('cklx', true);
  1473. $ktime = $this->input->post('ktime', true);
  1474. $jtime = $this->input->post('jtime', true);
  1475. $ktime = strtotime($ktime);
  1476. $jtime = strtotime($jtime);
  1477. $where = "1=1";
  1478. $gj = "";
  1479. $ck = "";
  1480. if ($lacetype) {
  1481. $where .= " and features like '%-$lacetype-%'";
  1482. }
  1483. if ($category) {
  1484. $where .= " and features like '%-$category-%'";
  1485. }
  1486. if ($size) {
  1487. $where .= " and features like '%-$size-%'";
  1488. }
  1489. if ($grade) {
  1490. $where .= " and features like '%-$grade-%'";
  1491. }
  1492. if ($color) {
  1493. $where .= " and features like '%-$color-%'";
  1494. }
  1495. if ($lowe) {
  1496. $where .= " and features like '%-$lowe-%'";
  1497. }
  1498. if ($haircap) {
  1499. $where .= " and features like '%-$haircap-%'";
  1500. }
  1501. if ($density) {
  1502. $where .= " and features like '%-$density-%'";
  1503. }
  1504. if ($lacecolor) {
  1505. $where .= " and features like '%-$lacecolor-%'";
  1506. }
  1507. if ($usa) {
  1508. if (!$warehouse) {
  1509. $where .= " and (warehouse = '5' or warehouse = '8')";
  1510. }
  1511. }
  1512. if ($warehouse) {
  1513. $where .= " and warehouse = '$warehouse'";
  1514. }
  1515. if ($details) {
  1516. $where .= " and details = '$details'";
  1517. }
  1518. if ($purchase) {
  1519. $where .= " and purchase = '$purchase'";
  1520. }
  1521. if ($state) {
  1522. $where .= " and state = '$state'";
  1523. }
  1524. $where_add = '';
  1525. if ($cklx) {
  1526. $shop = $this->shop->read($cklx);
  1527. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1528. }
  1529. if ($ktime && $jtime) {
  1530. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1531. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1532. }
  1533. //数据排序
  1534. $order_str = "id desc";
  1535. if (empty($page)) {
  1536. $start = 0;
  1537. $perpage = 1;
  1538. } else {
  1539. $start = ($page - 1) * $perpage;
  1540. }
  1541. if ($sku) {
  1542. $sku = trim($sku, ' ');
  1543. $sku = trim($sku, ' ');
  1544. $where .= " and sku like '%$sku%'";
  1545. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1546. } else if ($title) {
  1547. $title = trim($title, ' ');
  1548. $title = trim($title, ' ');
  1549. $where .= " and title like '%$title%'";
  1550. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1551. } else {
  1552. //$where .= " and time > '$ktime' and time < '$jtime'";
  1553. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1554. }
  1555. //取得信息列表
  1556. $rows = array();
  1557. $list = array();
  1558. foreach ($info_list as $key => $value) {
  1559. $warehouse = $this->warehouse->read($value['warehouse']);
  1560. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1561. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1562. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1563. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1564. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1565. $od = array();
  1566. $odid = '';
  1567. foreach ($z as $v) {
  1568. if (!isset($od[$v['zd']])) {
  1569. $od[$v['zd']] = 1; //所有数据sku
  1570. } else {
  1571. $od[$v['zd']] = $od[$v['zd']] + 1;
  1572. }
  1573. }
  1574. foreach ($od as $k => $vv) {
  1575. $odid .= $k . '数量' . $vv . ' ';
  1576. }
  1577. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1578. $info_list[$key]['features'] = $c;
  1579. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1580. $ztdata = '';
  1581. if (count($zt) > 0) {
  1582. foreach ($zt as $vv) {
  1583. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1584. }
  1585. }
  1586. $info_list[$key]['warehouse'] = $ztdata;
  1587. $info_list[$key]['g'] = $g;
  1588. $info_list[$key]['x'] = $x;
  1589. $info_list[$key]['t'] = $t;
  1590. $info_list[$key]['z'] = $z;
  1591. }
  1592. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1593. $pagenum = ceil($total / $perpage);
  1594. $over = $total - ($start + $perpage);
  1595. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1596. echo json_encode($rows);
  1597. exit;
  1598. }
  1599. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1600. $this->data['warehouse'] = $warehouse;
  1601. $this->_Template('whlabel_typeusa', $this->data);
  1602. }
  1603. //美仓进销存浏览
  1604. public function _usatypeapp()
  1605. {
  1606. $post = $this->input->post(NULL, TRUE);
  1607. if (isset($post['page'])) {
  1608. $page = $this->input->post('page', true);
  1609. $perpage = $this->input->post('perpage', true);
  1610. $sku = $this->input->post('sku', true);
  1611. $warehouse = 5;
  1612. $title = $this->input->post('title', true);
  1613. $state = $this->input->post('state', true);
  1614. $ktime = $this->input->post('ktime', true);
  1615. $jtime = $this->input->post('jtime', true);
  1616. $ktime = strtotime($ktime);
  1617. $jtime = strtotime($jtime);
  1618. $where = "1=1";
  1619. $gj = "";
  1620. $ck = "";
  1621. if ($title) {
  1622. $st = explode(' ', trim($title, ' '));
  1623. foreach ($st as $v) {
  1624. $where .= " and title like '%$v%'";
  1625. }
  1626. }
  1627. if ($warehouse) {
  1628. $where .= " and warehouse = '$warehouse'";
  1629. }
  1630. if ($state) {
  1631. $where .= " and state = '$state'";
  1632. }
  1633. if ($sku) {
  1634. $where .= " and sku like '%$sku%'";
  1635. }
  1636. if ($ktime && $jtime) {
  1637. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1638. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1639. }
  1640. //数据排序
  1641. $order_str = "id desc";
  1642. if (empty($page)) {
  1643. $start = 0;
  1644. $perpage = 1;
  1645. } else {
  1646. $start = ($page - 1) * $perpage;
  1647. }
  1648. //取得信息列表
  1649. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1650. $rows = array();
  1651. $list = array();
  1652. foreach ($info_list as $key => $value) {
  1653. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1654. }
  1655. $rowsdq = array_slice($rows, $start, $perpage);
  1656. foreach ($rowsdq as $value) {
  1657. $warehouse = $this->warehouse->read($value['warehouse']);
  1658. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1659. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1660. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1661. $od = array();
  1662. $odid = '';
  1663. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1664. }
  1665. $total = count($rows);
  1666. $pagenum = ceil($total / $perpage);
  1667. $over = $total - ($start + $perpage);
  1668. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1669. echo json_encode($rows);
  1670. exit;
  1671. }
  1672. $this->_Template('phone/p_usatypeapp', $this->data);
  1673. }
  1674. //入库操作
  1675. public function _enteradd()
  1676. {
  1677. $dt = 0;
  1678. if (isset($_SESSION['api'])) {
  1679. $user = $this->user->get_api($_SESSION['api']);
  1680. $usp = $user;
  1681. $fgshop = "";
  1682. $sid = "";
  1683. $user = explode('|', trim($user['shop'], '|'));
  1684. foreach ($user as $value) {
  1685. $fgshop .= " shop = " . $value . " or";
  1686. $sid .= " id = " . $value . " or";
  1687. }
  1688. }
  1689. $tc = $this->typeclass->find_all();
  1690. $typeclass = array();
  1691. foreach ($tc as $v) {
  1692. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1693. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1694. }
  1695. $post = $this->input->post(NULL, TRUE);
  1696. if (isset($post['sku'])) {
  1697. $list = array();
  1698. $num = "";
  1699. $title = "";
  1700. $features = "";
  1701. $order = $this->input->post('order', true);
  1702. $shop = $this->input->post('shop', true);
  1703. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1704. $sku = $this->input->post('sku', true);
  1705. $post['sm'] = $this->input->post('sm', true);
  1706. $post['warehouse'] = $this->input->post('warehouse', true);
  1707. $post['purchase'] = $this->input->post('purchase', true);
  1708. $post['retreatwarehouse'] = $post['warehouse'];
  1709. $post['state'] = $this->input->post('state', true);
  1710. $post['rktype'] = $this->input->post('rktype', true);
  1711. $post['text'] = $this->input->post('text', true);
  1712. $category = $this->input->post('category', true);
  1713. $list['category'] = $category;
  1714. $list['hairtype'] = $this->input->post('hairtype', true);
  1715. $list['grade'] = $this->input->post('grade', true);
  1716. $size = $this->input->post('size', true);
  1717. $xzsku = $this->input->post('xzsku', true);
  1718. $list['size'] = rtrim($size, ',');
  1719. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1720. $list['extension'] = $this->input->post('extension', true);
  1721. if ($category == 1297) {
  1722. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1723. }
  1724. if ($category == 1702) {
  1725. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1726. $list['syother'] = $this->input->post('syother', true);
  1727. }
  1728. if ($category == 133) {
  1729. $list['fittype'] = $this->input->post('fittype', true);
  1730. $list['acother'] = $this->input->post('acother', true);
  1731. }
  1732. $list['color'] = $this->input->post('color', true);
  1733. $list['lowe'] = $this->input->post('lowe', true);
  1734. if (!$post['purchase']) {
  1735. $post['purchase'] = 1;
  1736. }
  1737. if ($category == 127) {
  1738. $list['type'] = $this->input->post('type', true);
  1739. $list['headroad'] = $this->input->post('headroad', true);
  1740. $list['density'] = $this->input->post('density', true);
  1741. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1742. $list['lacesize'] = $this->input->post('lacesize', true);
  1743. }
  1744. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1745. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1746. }
  1747. if ($category == 128) {
  1748. $list['lacetype'] = $this->input->post('lacetype', true);
  1749. $list['haircap'] = $this->input->post('haircap', true);
  1750. $list['density'] = $this->input->post('density', true);
  1751. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1752. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1753. $list['wigother'] = $this->input->post('wigother', true);
  1754. $list['wigother1'] = $this->input->post('wigother1', true);
  1755. $list['wigother2'] = $this->input->post('wigother2', true);
  1756. }
  1757. if ($category == 129) {
  1758. $list['wide'] = $this->input->post('wide', true);
  1759. }
  1760. if ($category == 131) {
  1761. $list['gifttype'] = $this->input->post('gifttype', true);
  1762. $list['giftother'] = $this->input->post('giftother', true);
  1763. }
  1764. if ($category == 134) {
  1765. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1766. }
  1767. if ($category == 1297) {
  1768. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1769. $list['sywigother'] = $this->input->post('sywigother', true);
  1770. }
  1771. if ($category == 130 || $category == 133 || $category == 1702) {
  1772. $list['items'] = $this->input->post('items', true);
  1773. $list['weight'] = $this->input->post('weight', true);
  1774. }
  1775. if ($category == 1702) {
  1776. $list['syhairther'] = $this->input->post('syhairther', true);
  1777. }
  1778. $classid = $this->classid->sku();
  1779. $scsku = $classid;
  1780. $pm = $classid;
  1781. foreach ($list as $k => $v) {
  1782. if ($v != 0) {
  1783. $num .= $v;
  1784. $features .= $v . '-';
  1785. $post[$k] = $v;
  1786. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1787. if ($k != 'size') {
  1788. $title .= $typeclass[$v]['title'] . " ";
  1789. }
  1790. if (isset($pm[$typeclass[$v]['classid']])) {
  1791. if ($typeclass[$v]['title'] == '9A') {
  1792. $pm[$typeclass[$v]['classid']] = '9A';
  1793. } else if ($typeclass[$v]['title'] == '10A') {
  1794. $pm[$typeclass[$v]['classid']] = '10A';
  1795. } else {
  1796. $clzh = $typeclass[$v]['zh'];
  1797. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1798. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1799. $clzh = $clzh[0];
  1800. }
  1801. $pm[$typeclass[$v]['classid']] = $clzh;
  1802. }
  1803. }
  1804. }
  1805. }
  1806. $zh = implode(" ", $pm);
  1807. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1808. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1809. if ($list['size']) {
  1810. $typeclass = $this->typeclass->read($list['size']);
  1811. $title .= $typeclass['title'];
  1812. }
  1813. $time = time();
  1814. if ($xzsku) {
  1815. $scsku = implode("-", $scsku);
  1816. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1817. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1818. $post['sku'] = trim($scsku, ' ');
  1819. } else {
  1820. $post['sku'] = $sku;
  1821. }
  1822. //$post['sku'] = trim($sku,' ');
  1823. $post['title'] = rtrim($title, ' ');
  1824. $post['number'] = $num;
  1825. $post['features'] = '-' . $features;
  1826. $post['enter'] = $time;
  1827. $post['time'] = $time; //操作时间
  1828. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1829. if ($yza) {
  1830. if ($post['features'] != $yza[0]['features']) {
  1831. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1832. exit;
  1833. }
  1834. }
  1835. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1836. if ($yzb) {
  1837. if ($post['sku'] != $yzb[0]['sku']) {
  1838. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1839. exit;
  1840. }
  1841. }
  1842. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1843. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1844. exit;
  1845. }
  1846. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1847. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1848. exit;
  1849. }
  1850. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1851. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1852. exit;
  1853. }
  1854. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1855. if (isset($yz[0]['type'])) {
  1856. $post['type'] = $yz[0]['type'];
  1857. }
  1858. if ($post['state'] == 9) //如果选择预设库存
  1859. {
  1860. $this->whlabel->insert($post);
  1861. } else {
  1862. /**
  1863. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1864. if($ljg == 1)
  1865. {
  1866. for($i=0;$i<$order;$i++)
  1867. {
  1868. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1869. $this->whlabel->insert($post);
  1870. }
  1871. }
  1872. **/
  1873. //if($post['warehouse'] == '5')
  1874. //{
  1875. //}
  1876. $yydata = $post;
  1877. $yydata['zh'] = $zh;
  1878. /**
  1879. $wl = $this->apiyy->get_cjlp($yydata);
  1880. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1881. {
  1882. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1883. }
  1884. if($wl['Data'][0]['m_isSucess'] != 1)
  1885. {
  1886. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1887. }
  1888. **/
  1889. for ($i = 0; $i < $order; $i++) {
  1890. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1891. $this->whlabel->insert($post);
  1892. }
  1893. }
  1894. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1895. exit;
  1896. }
  1897. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1898. $this->data['wlshop'] = $wlshop;
  1899. $this->_Template('whlabel_enteradd', $this->data);
  1900. }
  1901. //修改产品
  1902. public function _enteredit($arg_array)
  1903. {
  1904. $dt = 0;
  1905. if (isset($_SESSION['api'])) {
  1906. $user = $this->user->get_api($_SESSION['api']);
  1907. $usp = $user;
  1908. $fgshop = "";
  1909. $sid = "";
  1910. $user = explode('|', trim($user['shop'], '|'));
  1911. foreach ($user as $value) {
  1912. $fgshop .= " shop = " . $value . " or";
  1913. $sid .= " id = " . $value . " or";
  1914. }
  1915. }
  1916. $post = $this->input->post(NULL, TRUE);
  1917. if (isset($post['sku'])) {
  1918. $list = array();
  1919. $num = "";
  1920. $title = "";
  1921. $features = "";
  1922. $id = $this->input->post('id', true);
  1923. $order = $this->input->post('order', true);
  1924. $shop = $this->input->post('shop', true);
  1925. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1926. $post['sku'] = $this->input->post('sku', true);
  1927. $post['sm'] = $this->input->post('sm', true);
  1928. $post['warehouse'] = $this->input->post('warehouse', true);
  1929. $post['purchase'] = $this->input->post('purchase', true);
  1930. $post['retreatwarehouse'] = $post['warehouse'];
  1931. $category = $this->input->post('category', true);
  1932. $list['category'] = $category;
  1933. $list['hairtype'] = $this->input->post('hairtype', true);
  1934. $list['grade'] = $this->input->post('grade', true);
  1935. $size = $this->input->post('size', true);
  1936. $list['size'] = rtrim($size, ',');
  1937. $post['rktype'] = $this->input->post('rktype', true);
  1938. $post['text'] = $this->input->post('text', true);
  1939. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1940. $list['extension'] = $this->input->post('extension', true);
  1941. if ($category == 1297) {
  1942. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1943. }
  1944. if ($category == 1702) {
  1945. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1946. $list['syother'] = $this->input->post('syother', true);
  1947. }
  1948. if ($category == 133) {
  1949. $list['fittype'] = $this->input->post('fittype', true);
  1950. $list['acother'] = $this->input->post('acother', true);
  1951. }
  1952. $list['color'] = $this->input->post('color', true);
  1953. $list['lowe'] = $this->input->post('lowe', true);
  1954. if (!$post['purchase']) {
  1955. $post['purchase'] = 1;
  1956. }
  1957. if ($category == 127) {
  1958. $list['type'] = $this->input->post('type', true);
  1959. $list['headroad'] = $this->input->post('headroad', true);
  1960. $list['density'] = $this->input->post('density', true);
  1961. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1962. $list['lacesize'] = $this->input->post('lacesize', true);
  1963. }
  1964. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1965. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1966. }
  1967. if ($category == 128) {
  1968. $list['lacetype'] = $this->input->post('lacetype', true);
  1969. $list['haircap'] = $this->input->post('haircap', true);
  1970. $list['density'] = $this->input->post('density', true);
  1971. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1972. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1973. $list['wigother'] = $this->input->post('wigother', true);
  1974. $list['wigother1'] = $this->input->post('wigother1', true);
  1975. $list['wigother2'] = $this->input->post('wigother2', true);
  1976. }
  1977. if ($category == 129) {
  1978. $list['wide'] = $this->input->post('wide', true);
  1979. }
  1980. if ($category == 131) {
  1981. $list['gifttype'] = $this->input->post('gifttype', true);
  1982. $list['giftother'] = $this->input->post('giftother', true);
  1983. }
  1984. if ($category == 134) {
  1985. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1986. }
  1987. if ($category == 1297) {
  1988. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1989. $list['sywigother'] = $this->input->post('sywigother', true);
  1990. }
  1991. if ($category == 130 || $category == 133 || $category == 1702) {
  1992. $list['items'] = $this->input->post('items', true);
  1993. $list['weight'] = $this->input->post('weight', true);
  1994. }
  1995. if ($category == 1702) {
  1996. $list['syhairther'] = $this->input->post('syhairther', true);
  1997. }
  1998. foreach ($list as $k => $v) {
  1999. if ($v != 0) {
  2000. $num .= $v;
  2001. $features .= $v . '-';
  2002. $typeclass = $this->typeclass->read($v);
  2003. if ($k != 'size') {
  2004. $title .= $typeclass['title'] . " ";
  2005. }
  2006. }
  2007. }
  2008. $typeclass = $this->typeclass->read($list['size']);
  2009. $title .= $typeclass['title'];
  2010. $time = time();
  2011. $post['title'] = rtrim($title, ' ');
  2012. $post['number'] = $num;
  2013. $post['features'] = '-' . $features;
  2014. $post['time'] = $time; //操作时间
  2015. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2016. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2017. exit;
  2018. }
  2019. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2020. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2021. exit;
  2022. }
  2023. $uid = $this->whlabel->read($id);
  2024. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2025. if ($datanum > 0) {
  2026. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2027. exit;
  2028. }
  2029. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2030. {
  2031. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2032. if ($yza) {
  2033. if ($post['features'] != $yza[0]['features']) {
  2034. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2035. exit;
  2036. }
  2037. }
  2038. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2039. if ($yzb) {
  2040. if ($post['sku'] != $yzb[0]['sku']) {
  2041. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2042. exit;
  2043. }
  2044. }
  2045. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2046. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2047. exit;
  2048. }
  2049. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2050. foreach ($data as $v) {
  2051. $post['id'] = $v['id'];
  2052. $this->whlabel->save($post, $v['id']);
  2053. }
  2054. } else {
  2055. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2056. if ($data > 0) {
  2057. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2058. exit;
  2059. } else {
  2060. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2061. foreach ($data as $v) {
  2062. $post['id'] = $v['id'];
  2063. $this->whlabel->save($post, $v['id']);
  2064. }
  2065. }
  2066. }
  2067. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2068. exit;
  2069. }
  2070. $uid = $this->whlabel->read($arg_array[0]);
  2071. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2072. $this->data['enter'] = $uid;
  2073. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2074. $this->data['wlshop'] = $wlshop;
  2075. $this->_Template('whlabel_enteredit', $this->data);
  2076. }
  2077. //入库浏览
  2078. public function _enter()
  2079. {
  2080. $post = $this->input->post(NULL, TRUE);
  2081. if (isset($post['s'])) {
  2082. $id_arr = $this->input->post('s');
  2083. $id_arr = explode(',', $id_arr);
  2084. if (!$id_arr) {
  2085. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2086. exit;
  2087. }
  2088. //循环删除记录
  2089. foreach ($id_arr as $v) {
  2090. $sid = $this->whlabel->read($v);
  2091. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2092. if ($count > 0) {
  2093. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2094. exit;
  2095. }
  2096. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2097. foreach ($info_list as $va) {
  2098. $this->whlabel->remove($va['id']);
  2099. }
  2100. }
  2101. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2102. exit;
  2103. }
  2104. $sp = array();
  2105. $s = $this->shop->find_all('1=1', 'id,shopname');
  2106. foreach ($s as $v) {
  2107. $sp[$v['id']] = $v['shopname'];
  2108. }
  2109. $wh = array();
  2110. $w = $this->warehouse->find_all('1=1', 'id,title');
  2111. foreach ($w as $v) {
  2112. $wh[$v['id']] = $v['title'];
  2113. }
  2114. if (isset($post['page'])) {
  2115. $page = $this->input->post('page', true);
  2116. $perpage = $this->input->post('perpage', true);
  2117. $category = $this->input->post('category', true);
  2118. $size = $this->input->post('size', true);
  2119. $grade = $this->input->post('grade', true);
  2120. $color = $this->input->post('color', true);
  2121. $lowe = $this->input->post('lowe', true);
  2122. $sku = $this->input->post('sku', true);
  2123. $warehouse = $this->input->post('warehouse', true);
  2124. $purchase = $this->input->post('purchase', true);
  2125. $ktime = $this->input->post('ktime', true);
  2126. $jtime = $this->input->post('jtime', true);
  2127. $ktime = strtotime($ktime);
  2128. $jtime = strtotime($jtime);
  2129. $where = "1=1";
  2130. $gj = "";
  2131. $ck = "";
  2132. if ($category) {
  2133. $where .= " and features like '%-$category-%'";
  2134. }
  2135. if ($size) {
  2136. $where .= " and features like '%-$size-%'";
  2137. }
  2138. if ($grade) {
  2139. $where .= " and features like '%-$grade-%'";
  2140. }
  2141. if ($color) {
  2142. $where .= " and features like '%-$color-%'";
  2143. }
  2144. if ($lowe) {
  2145. $where .= " and features like '%-$lowe-%'";
  2146. }
  2147. if ($warehouse) {
  2148. $where .= " and warehouse = '$warehouse'";
  2149. }
  2150. if ($purchase) {
  2151. $where .= " and purchase = '$purchase'";
  2152. }
  2153. if ($sku) {
  2154. $where .= " and sku like '%$sku%'";
  2155. }
  2156. if ($ktime && $jtime) {
  2157. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2158. }
  2159. //数据排序
  2160. $order_str = "enter desc";
  2161. if (empty($page)) {
  2162. $start = 0;
  2163. $perpage = 1;
  2164. } else {
  2165. $start = ($page - 1) * $perpage;
  2166. }
  2167. //取得信息列表
  2168. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2169. foreach ($info_list as $k => $v) {
  2170. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2171. if ($v['shop'] == '') {
  2172. $s = '通用';
  2173. } else {
  2174. $info_list[$k]['shop'] = '';
  2175. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2176. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2177. }
  2178. }
  2179. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2180. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2181. $info_list[$k]['g'] = $g;
  2182. }
  2183. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2184. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2185. $pagenum = ceil($total / $perpage);
  2186. $over = $total - ($start + $perpage);
  2187. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2188. echo json_encode($rows);
  2189. exit;
  2190. }
  2191. $this->_Template('whlabel_enter', $this->data);
  2192. }
  2193. //出库浏览
  2194. public function _out()
  2195. {
  2196. $post = $this->input->post(NULL, TRUE);
  2197. if (isset($post['page'])) {
  2198. $page = $this->input->post('page', true);
  2199. $perpage = $this->input->post('perpage', true);
  2200. $category = $this->input->post('category', true);
  2201. $size = $this->input->post('size', true);
  2202. $grade = $this->input->post('grade', true);
  2203. $color = $this->input->post('color', true);
  2204. $lowe = $this->input->post('lowe', true);
  2205. $sku = $this->input->post('sku', true);
  2206. $warehouse = $this->input->post('warehouse', true);
  2207. $purchase = $this->input->post('purchase', true);
  2208. $state = $this->input->post('state', true);
  2209. $ktime = $this->input->post('ktime', true);
  2210. $jtime = $this->input->post('jtime', true);
  2211. $ktime = strtotime($ktime);
  2212. $jtime = strtotime($jtime);
  2213. $where = "state=3";
  2214. $gj = "";
  2215. $ck = "";
  2216. if ($category) {
  2217. $where .= " and features like '%-$category-%'";
  2218. }
  2219. if ($size) {
  2220. $where .= " and features like '%-$size-%'";
  2221. }
  2222. if ($grade) {
  2223. $where .= " and features like '%-$grade-%'";
  2224. }
  2225. if ($color) {
  2226. $where .= " and features like '%-$color-%'";
  2227. }
  2228. if ($lowe) {
  2229. $where .= " and features like '%-$lowe-%'";
  2230. }
  2231. if ($state) {
  2232. $where .= " and state = '$state'";
  2233. }
  2234. if ($warehouse) {
  2235. $where .= " and warehouse = '$warehouse'";
  2236. }
  2237. if ($purchase) {
  2238. $where .= " and purchase = '$purchase'";
  2239. }
  2240. if ($sku) {
  2241. $where .= " and sku = '$sku'";
  2242. }
  2243. if ($ktime && $jtime) {
  2244. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2245. }
  2246. //数据排序
  2247. $order_str = "id desc";
  2248. if (empty($page)) {
  2249. $start = 0;
  2250. $perpage = 1;
  2251. } else {
  2252. $start = ($page - 1) * $perpage;
  2253. }
  2254. //取得信息列表
  2255. $info_list = $this->whlabel->find_all($where, 'sku');
  2256. $rows = array();
  2257. $list = array();
  2258. foreach ($info_list as $key => $value) {
  2259. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2260. }
  2261. $rows = array_unique($rows); //删除重复记录
  2262. foreach ($rows as $key => $value) {
  2263. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2264. $ck = $this->warehouse->read($data['warehouse']);
  2265. $warehouse = $ck['title'];
  2266. $gy = $this->purchase->read($data['purchase']);
  2267. $purchase = $gy['purchase'];
  2268. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2269. $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);
  2270. }
  2271. $total = count($list);
  2272. $pagenum = ceil($total / $perpage);
  2273. $over = $total - ($start + $perpage);
  2274. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2275. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2276. echo json_encode($rows);
  2277. exit;
  2278. }
  2279. $this->_Template('whlabel_out', $this->data);
  2280. }
  2281. //出库标签浏览
  2282. public function _label()
  2283. {
  2284. $post = $this->input->post(NULL, TRUE);
  2285. if (isset($post['page'])) {
  2286. $page = $this->input->post('page', true);
  2287. $perpage = $this->input->post('perpage', true);
  2288. $sku = $this->input->post('sku', true);
  2289. $warehouse = $this->input->post('warehouse', true);
  2290. $purchase = $this->input->post('purchase', true);
  2291. $orderinfo = $this->input->post('orderinfo', true);
  2292. $waybill = $this->input->post('waybill', true);
  2293. $category = $this->input->post('category', true);
  2294. $size = $this->input->post('size', true);
  2295. $grade = $this->input->post('grade', true);
  2296. $color = $this->input->post('color', true);
  2297. $lowe = $this->input->post('lowe', true);
  2298. $where = "state=1";
  2299. if ($sku) {
  2300. $where .= " and sku = '$sku'";
  2301. }
  2302. if ($warehouse) {
  2303. $where .= " and warehouse = '$warehouse'";
  2304. }
  2305. if ($purchase) {
  2306. $where .= " and purchase = '$purchase'";
  2307. }
  2308. if ($orderinfo) {
  2309. $where .= " and orderinfo = '$orderinfo'";
  2310. }
  2311. if ($waybill) {
  2312. $where .= " and waybill = '$waybill'";
  2313. }
  2314. if ($category) {
  2315. $where .= " and features like '%-$category-%'";
  2316. }
  2317. if ($size) {
  2318. $where .= " and features like '%-$size-%'";
  2319. }
  2320. if ($grade) {
  2321. $where .= " and features like '%-$grade-%'";
  2322. }
  2323. if ($color) {
  2324. $where .= " and features like '%-$color-%'";
  2325. }
  2326. if ($lowe) {
  2327. $where .= " and features like '%-$lowe-%'";
  2328. }
  2329. //数据排序
  2330. $order_str = "outk desc";
  2331. if (empty($page)) {
  2332. $start = 0;
  2333. $perpage = 1;
  2334. } else {
  2335. $start = ($page - 1) * $perpage;
  2336. }
  2337. //取得信息列表
  2338. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2339. foreach ($info_list as $key => $value) {
  2340. $warehouse = $this->warehouse->read($value['warehouse']);
  2341. $info_list[$key]['warehouse'] = $warehouse['title'];
  2342. $purchase = $this->purchase->read($value['purchase']);
  2343. $info_list[$key]['purchase'] = $purchase['title'];
  2344. if ($value['outk'] != 0) {
  2345. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2346. } else {
  2347. $info_list[$key]['outk'] = "";
  2348. }
  2349. if ($value['orderinfo'] == 0) {
  2350. $info_list[$key]['orderinfo'] = "";
  2351. }
  2352. if ($value['waybill'] == 0) {
  2353. $info_list[$key]['waybill'] = "";
  2354. }
  2355. }
  2356. $total = $this->whlabel->find_count($where);
  2357. $pagenum = ceil($total / $perpage);
  2358. $over = $total - ($start + $perpage);
  2359. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2360. echo json_encode($rows);
  2361. exit;
  2362. }
  2363. $this->_Template('whlabel_label', $this->data);
  2364. }
  2365. //独立站出库订单
  2366. public function _outorder()
  2367. {
  2368. if (isset($_SESSION['api'])) {
  2369. $user = $this->user->get_api($_SESSION['api']);
  2370. $usp = $user;
  2371. $fgshop = "";
  2372. $sid = "";
  2373. $user = explode('|', trim($user['shop'], '|'));
  2374. foreach ($user as $value) {
  2375. $fgshop .= " shop = " . $value . " or";
  2376. $sid .= " id = " . $value . " or";
  2377. }
  2378. } else {
  2379. echo "请重新登录";
  2380. }
  2381. $post = $this->input->post(NULL, TRUE);
  2382. if (isset($post['page'])) {
  2383. $page = $this->input->post('page', true);
  2384. $perpage = $this->input->post('perpage', true);
  2385. $warehouse = $this->input->post('warehouse', true);
  2386. $xztime = $this->input->post('xztime', true);
  2387. $timetk = $this->input->post('timetkk', true);
  2388. $timetj = $this->input->post('timetjj', true);
  2389. $shop = $this->input->post('shop', true);
  2390. $source = $this->input->post('source', true);
  2391. $orderinfo = $this->input->post('orderinfo', true);
  2392. $number = $this->input->post('number', true);
  2393. $sfxh = $this->input->post('sfxh', true);
  2394. $express = $this->input->post('express', true);
  2395. $waybill = $this->input->post('waybill', true);
  2396. $library = $this->input->post('library', true);
  2397. $country = $this->input->post('country', true);
  2398. $so = $this->input->post('so', true);
  2399. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2400. $print = $this->input->post('print', true);
  2401. $state = $this->input->post('state', true);
  2402. $orderurl = $this->input->post('orderurl', true);
  2403. $timetk = strtotime($timetk);
  2404. $timetj = strtotime($timetj);
  2405. /**
  2406. $sj = $this->input->post('sj',true);
  2407. if($sj)
  2408. {
  2409. $sj = $this->input->post('sj',true);
  2410. }
  2411. else
  2412. {
  2413. $sj = "fullorder";
  2414. }
  2415. **/
  2416. $sj = "fullorder";
  2417. $where = "1=1";
  2418. if ($warehouse) {
  2419. $where .= " and type = '$warehouse'";
  2420. }
  2421. if ($timetk && $timetj) {
  2422. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2423. }
  2424. if ($orderinfo) {
  2425. $where .= " and orderinfo = '$orderinfo'";
  2426. }
  2427. if ($number) {
  2428. $where .= " and number = '$number'";
  2429. }
  2430. if ($express) {
  2431. $where .= " and express = '$express'";
  2432. }
  2433. if ($waybill) {
  2434. $where .= " and waybill = '$waybill'";
  2435. }
  2436. if ($library) {
  2437. $where .= " and library = '$library'";
  2438. }
  2439. if ($print) {
  2440. $where .= " and print = '$print'";
  2441. }
  2442. if ($libraryconfirm) {
  2443. $where .= " and libraryconfirm = '$libraryconfirm'";
  2444. }
  2445. if ($state) {
  2446. $where .= " and state = '$state'";
  2447. }
  2448. if ($shop) {
  2449. $where .= " and shop = '$shop'";
  2450. }
  2451. if ($country) {
  2452. $where .= " and country = '$country'";
  2453. }
  2454. if ($sfxh != '') {
  2455. $where .= " and sfxh = '$sfxh'";
  2456. }
  2457. if ($so) {
  2458. $where .= " and shipremarks like '%$so%'";
  2459. }
  2460. if ($source) {
  2461. if ($source == '2d') {
  2462. $where .= " and source >= '2'";
  2463. } else {
  2464. $where .= " and source = '$source'";
  2465. }
  2466. }
  2467. if (isset($_SESSION['api'])) {
  2468. foreach ($user as $value) {
  2469. $fgshop .= " shop = " . $value . " or";
  2470. }
  2471. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2472. }
  2473. if ($orderurl) {
  2474. $url = $this->orderurl->read($orderurl);
  2475. $where .= " and link like '%" . $url['url'] . "%'";
  2476. }
  2477. //数据排序
  2478. $order_str = "librarytime desc";
  2479. if (empty($page)) {
  2480. $start = 0;
  2481. $perpage = 1;
  2482. } else {
  2483. $start = ($page - 1) * $perpage;
  2484. }
  2485. //取得信息列表
  2486. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2487. //格式化数据
  2488. foreach ($info_list as $key => $value) {
  2489. $shop = $this->shop->read($value['shop']);
  2490. $info_list[$key]['shop'] = $shop['shopname'];
  2491. $express = $this->express->read($value['express']);
  2492. $info_list[$key]['express'] = $express['servicename'];
  2493. $warehouse = $this->warehouse->read($value['type']);
  2494. $info_list[$key]['type'] = $warehouse['title'];
  2495. if ($value['librarytime'] == '0') {
  2496. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2497. } else {
  2498. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2499. }
  2500. }
  2501. $total = $this->$sj->find_count($where);
  2502. $pagenum = ceil($total / $perpage);
  2503. $over = $total - ($start + $perpage);
  2504. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2505. echo json_encode($rows);
  2506. exit;
  2507. }
  2508. $this->data['express'] = $this->express->find_all();
  2509. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2510. $this->data['wlshop'] = $wlshop;
  2511. $user = $this->user->get_api($_SESSION['api']);
  2512. $powerid = $this->power->read($user['power']);
  2513. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2514. $pid = '';
  2515. foreach ($powertext as $v) {
  2516. $pid .= " id = " . $v . " or";
  2517. }
  2518. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2519. $this->data['fullorderexcel'] = $fullorderexcel;
  2520. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2521. $this->data['orderurl'] = $orderurl;
  2522. $this->_Template('whlabel_outorder', $this->data);
  2523. }
  2524. //tt出库
  2525. public function _toutorder()
  2526. {
  2527. if (isset($_SESSION['api'])) {
  2528. $user = $this->user->get_api($_SESSION['api']);
  2529. $usp = $user;
  2530. $fgshop = "";
  2531. $sid = "";
  2532. $user = explode('|', trim($user['shop'], '|'));
  2533. foreach ($user as $value) {
  2534. $fgshop .= " shop = " . $value . " or";
  2535. $sid .= " id = " . $value . " or";
  2536. }
  2537. } else {
  2538. echo "请重新登录";
  2539. }
  2540. $post = $this->input->post(NULL, TRUE);
  2541. if (isset($post['page'])) {
  2542. $page = $this->input->post('page', true);
  2543. $perpage = $this->input->post('perpage', true);
  2544. $warehouse = $this->input->post('warehouse', true);
  2545. $xztime = $this->input->post('xztime', true);
  2546. $timetk = $this->input->post('timetkk', true);
  2547. $timetj = $this->input->post('timetjj', true);
  2548. $shop = $this->input->post('shop', true);
  2549. $source = $this->input->post('source', true);
  2550. $orderinfo = $this->input->post('orderinfo', true);
  2551. $number = $this->input->post('number', true);
  2552. $sfxh = $this->input->post('sfxh', true);
  2553. $express = $this->input->post('express', true);
  2554. $waybill = $this->input->post('waybill', true);
  2555. $library = $this->input->post('library', true);
  2556. $country = $this->input->post('country', true);
  2557. $so = $this->input->post('so', true);
  2558. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2559. $print = $this->input->post('print', true);
  2560. $state = $this->input->post('state', true);
  2561. $orderurl = $this->input->post('orderurl', true);
  2562. $timetk = strtotime($timetk);
  2563. $timetj = strtotime($timetj);
  2564. /**
  2565. $sj = $this->input->post('sj',true);
  2566. if($sj)
  2567. {
  2568. $sj = $this->input->post('sj',true);
  2569. }
  2570. else
  2571. {
  2572. $sj = "fullorder";
  2573. }
  2574. **/
  2575. $sj = "fullordertt";
  2576. $where = "1=1";
  2577. if ($warehouse) {
  2578. $where .= " and type = '$warehouse'";
  2579. }
  2580. if ($timetk && $timetj) {
  2581. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2582. }
  2583. if ($orderinfo) {
  2584. $where .= " and orderinfo = '$orderinfo'";
  2585. }
  2586. if ($number) {
  2587. $where .= " and number = '$number'";
  2588. }
  2589. if ($express) {
  2590. $where .= " and express = '$express'";
  2591. }
  2592. if ($waybill) {
  2593. $where .= " and waybill = '$waybill'";
  2594. }
  2595. if ($library) {
  2596. $where .= " and library = '$library'";
  2597. }
  2598. if ($print) {
  2599. $where .= " and print = '$print'";
  2600. }
  2601. if ($libraryconfirm) {
  2602. $where .= " and libraryconfirm = '$libraryconfirm'";
  2603. }
  2604. if ($state) {
  2605. $where .= " and state = '$state'";
  2606. }
  2607. if ($shop) {
  2608. $where .= " and shop = '$shop'";
  2609. }
  2610. if ($country) {
  2611. $where .= " and country = '$country'";
  2612. }
  2613. if ($sfxh != '') {
  2614. $where .= " and sfxh = '$sfxh'";
  2615. }
  2616. if ($so) {
  2617. $where .= " and shipremarks like '%$so%'";
  2618. }
  2619. if ($source) {
  2620. if ($source == '2d') {
  2621. $where .= " and source >= '2'";
  2622. } else {
  2623. $where .= " and source = '$source'";
  2624. }
  2625. }
  2626. if (isset($_SESSION['api'])) {
  2627. foreach ($user as $value) {
  2628. $fgshop .= " shop = " . $value . " or";
  2629. }
  2630. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2631. }
  2632. if ($orderurl) {
  2633. $url = $this->orderurl->read($orderurl);
  2634. $where .= " and link like '%" . $url['url'] . "%'";
  2635. }
  2636. //数据排序
  2637. $order_str = "librarytime desc";
  2638. if (empty($page)) {
  2639. $start = 0;
  2640. $perpage = 1;
  2641. } else {
  2642. $start = ($page - 1) * $perpage;
  2643. }
  2644. //取得信息列表
  2645. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2646. //格式化数据
  2647. foreach ($info_list as $key => $value) {
  2648. $shop = $this->shop->read($value['shop']);
  2649. $info_list[$key]['shop'] = $shop['shopname'];
  2650. $express = $this->express->read($value['express']);
  2651. $info_list[$key]['express'] = $express['servicename'];
  2652. $warehouse = $this->warehouse->read($value['type']);
  2653. $info_list[$key]['type'] = $warehouse['title'];
  2654. if ($value['librarytime'] == '0') {
  2655. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2656. } else {
  2657. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2658. }
  2659. }
  2660. $total = $this->$sj->find_count($where);
  2661. $pagenum = ceil($total / $perpage);
  2662. $over = $total - ($start + $perpage);
  2663. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2664. echo json_encode($rows);
  2665. exit;
  2666. }
  2667. $this->data['express'] = $this->express->find_all();
  2668. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2669. $this->data['wlshop'] = $wlshop;
  2670. $user = $this->user->get_api($_SESSION['api']);
  2671. $powerid = $this->power->read($user['power']);
  2672. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2673. $pid = '';
  2674. foreach ($powertext as $v) {
  2675. $pid .= " id = " . $v . " or";
  2676. }
  2677. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2678. $this->data['fullorderexcel'] = $fullorderexcel;
  2679. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2680. $this->data['orderurl'] = $orderurl;
  2681. $this->_Template('whlabel_toutorder', $this->data);
  2682. }
  2683. //tt出库
  2684. public function _aoutorder()
  2685. {
  2686. if (isset($_SESSION['api'])) {
  2687. $user = $this->user->get_api($_SESSION['api']);
  2688. $usp = $user;
  2689. $fgshop = "";
  2690. $sid = "";
  2691. $user = explode('|', trim($user['shop'], '|'));
  2692. foreach ($user as $value) {
  2693. $fgshop .= " shop = " . $value . " or";
  2694. $sid .= " id = " . $value . " or";
  2695. }
  2696. } else {
  2697. echo "请重新登录";
  2698. }
  2699. $post = $this->input->post(NULL, TRUE);
  2700. if (isset($post['page'])) {
  2701. $page = $this->input->post('page', true);
  2702. $perpage = $this->input->post('perpage', true);
  2703. $warehouse = $this->input->post('warehouse', true);
  2704. $xztime = $this->input->post('xztime', true);
  2705. $timetk = $this->input->post('timetkk', true);
  2706. $timetj = $this->input->post('timetjj', true);
  2707. $shop = $this->input->post('shop', true);
  2708. $source = $this->input->post('source', true);
  2709. $orderinfo = $this->input->post('orderinfo', true);
  2710. $number = $this->input->post('number', true);
  2711. $sfxh = $this->input->post('sfxh', true);
  2712. $express = $this->input->post('express', true);
  2713. $waybill = $this->input->post('waybill', true);
  2714. $library = $this->input->post('library', true);
  2715. $country = $this->input->post('country', true);
  2716. $so = $this->input->post('so', true);
  2717. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2718. $print = $this->input->post('print', true);
  2719. $state = $this->input->post('state', true);
  2720. $orderurl = $this->input->post('orderurl', true);
  2721. $timetk = strtotime($timetk);
  2722. $timetj = strtotime($timetj);
  2723. /**
  2724. $sj = $this->input->post('sj',true);
  2725. if($sj)
  2726. {
  2727. $sj = $this->input->post('sj',true);
  2728. }
  2729. else
  2730. {
  2731. $sj = "fullorder";
  2732. }
  2733. **/
  2734. $sj = "fullorderamz";
  2735. $where = "1=1";
  2736. if ($warehouse) {
  2737. $where .= " and type = '$warehouse'";
  2738. }
  2739. if ($timetk && $timetj) {
  2740. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2741. }
  2742. if ($orderinfo) {
  2743. $where .= " and orderinfo = '$orderinfo'";
  2744. }
  2745. if ($number) {
  2746. $where .= " and number = '$number'";
  2747. }
  2748. if ($express) {
  2749. $where .= " and express = '$express'";
  2750. }
  2751. if ($waybill) {
  2752. $where .= " and waybill = '$waybill'";
  2753. }
  2754. if ($library) {
  2755. $where .= " and library = '$library'";
  2756. }
  2757. if ($print) {
  2758. $where .= " and print = '$print'";
  2759. }
  2760. if ($libraryconfirm) {
  2761. $where .= " and libraryconfirm = '$libraryconfirm'";
  2762. }
  2763. if ($state) {
  2764. $where .= " and state = '$state'";
  2765. }
  2766. if ($shop) {
  2767. $where .= " and shop = '$shop'";
  2768. }
  2769. if ($country) {
  2770. $where .= " and country = '$country'";
  2771. }
  2772. if ($sfxh != '') {
  2773. $where .= " and sfxh = '$sfxh'";
  2774. }
  2775. if ($so) {
  2776. $where .= " and shipremarks like '%$so%'";
  2777. }
  2778. if ($source) {
  2779. if ($source == '2d') {
  2780. $where .= " and source >= '2'";
  2781. } else {
  2782. $where .= " and source = '$source'";
  2783. }
  2784. }
  2785. if (isset($_SESSION['api'])) {
  2786. foreach ($user as $value) {
  2787. $fgshop .= " shop = " . $value . " or";
  2788. }
  2789. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2790. }
  2791. if ($orderurl) {
  2792. $url = $this->orderurl->read($orderurl);
  2793. $where .= " and link like '%" . $url['url'] . "%'";
  2794. }
  2795. //数据排序
  2796. $order_str = "librarytime desc";
  2797. if (empty($page)) {
  2798. $start = 0;
  2799. $perpage = 1;
  2800. } else {
  2801. $start = ($page - 1) * $perpage;
  2802. }
  2803. //取得信息列表
  2804. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2805. //格式化数据
  2806. foreach ($info_list as $key => $value) {
  2807. $shop = $this->shop->read($value['shop']);
  2808. $info_list[$key]['shop'] = $shop['shopname'];
  2809. $express = $this->express->read($value['express']);
  2810. $info_list[$key]['express'] = $express['servicename'];
  2811. $warehouse = $this->warehouse->read($value['type']);
  2812. $info_list[$key]['type'] = $warehouse['title'];
  2813. if ($value['librarytime'] == '0') {
  2814. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2815. } else {
  2816. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2817. }
  2818. }
  2819. $total = $this->$sj->find_count($where);
  2820. $pagenum = ceil($total / $perpage);
  2821. $over = $total - ($start + $perpage);
  2822. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2823. echo json_encode($rows);
  2824. exit;
  2825. }
  2826. $this->data['express'] = $this->express->find_all();
  2827. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2828. $this->data['wlshop'] = $wlshop;
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $powerid = $this->power->read($user['power']);
  2831. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2832. $pid = '';
  2833. foreach ($powertext as $v) {
  2834. $pid .= " id = " . $v . " or";
  2835. }
  2836. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2837. $this->data['fullorderexcel'] = $fullorderexcel;
  2838. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2839. $this->data['orderurl'] = $orderurl;
  2840. $this->_Template('whlabel_aoutorder', $this->data);
  2841. }
  2842. //速卖通出库订单
  2843. public function _soutorder()
  2844. {
  2845. if (isset($_SESSION['api'])) {
  2846. $user = $this->user->get_api($_SESSION['api']);
  2847. $usp = $user;
  2848. $fgshop = "";
  2849. $sid = "";
  2850. $user = explode('|', trim($user['shop'], '|'));
  2851. foreach ($user as $value) {
  2852. $sid .= " id = " . $value . " or";
  2853. }
  2854. }
  2855. $post = $this->input->post(NULL, TRUE);
  2856. if (isset($post['page'])) {
  2857. $page = $this->input->post('page', true);
  2858. $perpage = $this->input->post('perpage', true);
  2859. $warehouse = $this->input->post('warehouse', true);
  2860. $xztime = $this->input->post('xztime', true);
  2861. $timetk = $this->input->post('timetkk', true);
  2862. $timetj = $this->input->post('timetjj', true);
  2863. $shop = $this->input->post('shop', true);
  2864. $source = $this->input->post('source', true);
  2865. $orderinfo = $this->input->post('orderinfo', true);
  2866. $number = $this->input->post('number', true);
  2867. $express = $this->input->post('express', true);
  2868. $waybill = $this->input->post('waybill', true);
  2869. $library = $this->input->post('library', true);
  2870. $country = $this->input->post('country', true);
  2871. $sfxh = $this->input->post('sfxh', true);
  2872. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2873. $print = $this->input->post('print', true);
  2874. $state = $this->input->post('state', true);
  2875. $so = $this->input->post('so', true);
  2876. $timetk = strtotime($timetk);
  2877. $timetj = strtotime($timetj);
  2878. /**
  2879. $sj = $this->input->post('sj',true);
  2880. if($sj)
  2881. {
  2882. $sj = $this->input->post('sj',true);
  2883. }
  2884. else
  2885. {
  2886. $sj = "fullorder";
  2887. }
  2888. **/
  2889. $sj = "fullordersmt";
  2890. $where = "1=1";
  2891. if ($warehouse) {
  2892. $where .= " and type = '$warehouse'";
  2893. }
  2894. if ($timetk && $timetj) {
  2895. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2896. }
  2897. if ($orderinfo) {
  2898. $where .= " and orderinfo = '$orderinfo'";
  2899. }
  2900. if ($number) {
  2901. $where .= " and number = '$number'";
  2902. }
  2903. if ($express) {
  2904. $where .= " and express = '$express'";
  2905. }
  2906. if ($waybill) {
  2907. $where .= " and waybill = '$waybill'";
  2908. }
  2909. if ($library) {
  2910. $where .= " and library = '$library'";
  2911. }
  2912. if ($print) {
  2913. $where .= " and print = '$print'";
  2914. }
  2915. if ($libraryconfirm) {
  2916. $where .= " and libraryconfirm = '$libraryconfirm'";
  2917. }
  2918. if ($state) {
  2919. $where .= " and state = '$state'";
  2920. }
  2921. if ($shop) {
  2922. $where .= " and shop = '$shop'";
  2923. }
  2924. if ($sfxh != '') {
  2925. $where .= " and sfxh = '$sfxh'";
  2926. }
  2927. if ($so) {
  2928. $where .= " and shipremarks like '%$so%'";
  2929. }
  2930. if ($source) {
  2931. $where .= " and source = '$source'";
  2932. }
  2933. if ($country) {
  2934. $where .= " and country = '$country'";
  2935. } else {
  2936. if (isset($_SESSION['api'])) {
  2937. foreach ($user as $value) {
  2938. $fgshop .= " shop = " . $value . " or";
  2939. }
  2940. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2941. }
  2942. }
  2943. //数据排序
  2944. $order_str = "librarytime desc";
  2945. if (empty($page)) {
  2946. $start = 0;
  2947. $perpage = 1;
  2948. } else {
  2949. $start = ($page - 1) * $perpage;
  2950. }
  2951. //取得信息列表
  2952. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2953. //格式化数据
  2954. foreach ($info_list as $key => $value) {
  2955. $shop = $this->shop->read($value['shop']);
  2956. $info_list[$key]['shop'] = $shop['shopname'];
  2957. $express = $this->express->read($value['express']);
  2958. $info_list[$key]['express'] = $express['servicename'];
  2959. $warehouse = $this->warehouse->read($value['type']);
  2960. $info_list[$key]['type'] = $warehouse['title'];
  2961. if ($value['librarytime'] == '0') {
  2962. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2963. } else {
  2964. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2965. }
  2966. }
  2967. $total = $this->$sj->find_count($where);
  2968. $pagenum = ceil($total / $perpage);
  2969. $over = $total - ($start + $perpage);
  2970. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2971. echo json_encode($rows);
  2972. exit;
  2973. }
  2974. $this->data['express'] = $this->express->find_all();
  2975. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2976. $this->data['wlshop'] = $wlshop;
  2977. $user = $this->user->get_api($_SESSION['api']);
  2978. $powerid = $this->power->read($user['power']);
  2979. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2980. $pid = '';
  2981. foreach ($powertext as $v) {
  2982. $pid .= " id = " . $v . " or";
  2983. }
  2984. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2985. $this->data['fullorderexcel'] = $fullorderexcel;
  2986. $this->_Template('whlabel_soutorder', $this->data);
  2987. }
  2988. //订单退库
  2989. public function _retreat()
  2990. {
  2991. $post = $this->input->post(NULL, TRUE);
  2992. if (isset($post['page'])) {
  2993. $page = $this->input->post('page', true);
  2994. $perpage = $this->input->post('perpage', true);
  2995. $warehouse = $this->input->post('warehouse', true);
  2996. $timetk = $this->input->post('timetk', true);
  2997. $timetj = $this->input->post('timetj', true);
  2998. $shop = $this->input->post('shop', true);
  2999. $source = $this->input->post('source', true);
  3000. $state = $this->input->post('state', true);
  3001. $review = $this->input->post('review', true);
  3002. $state = $this->input->post('state', true);
  3003. $express = $this->input->post('express', true);
  3004. $orderinfo = $this->input->post('orderinfo', true);
  3005. $user = $this->input->post('user', true);
  3006. $name = $this->input->post('name', true);
  3007. $waybill = $this->input->post('waybill', true);
  3008. $timetk = strtotime($timetk);
  3009. $timetj = strtotime($timetj);
  3010. $where = "(state=206 or state=210) and mergeid = 0";
  3011. if ($warehouse) {
  3012. $where .= " and state = '$warehouse'";
  3013. }
  3014. if ($timetk && $timetj) {
  3015. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3016. }
  3017. if ($shop) {
  3018. $where .= " and shop = '$shop'";
  3019. }
  3020. if ($source) {
  3021. $where .= " and source = '$source'";
  3022. }
  3023. if ($state) {
  3024. $where .= " and state = '$state'";
  3025. }
  3026. if ($review) {
  3027. $where .= " and review = '$review'";
  3028. }
  3029. if ($state) {
  3030. $where .= " and state = '$state'";
  3031. }
  3032. if ($express) {
  3033. $where .= " and express = '$express'";
  3034. }
  3035. if ($orderinfo) {
  3036. $where .= " and orderinfo = '$orderinfo'";
  3037. }
  3038. if ($user) {
  3039. $where .= " and user = '$user'";
  3040. }
  3041. if ($name) {
  3042. $where .= " and name = '$name'";
  3043. }
  3044. if ($waybill) {
  3045. $where .= " and waybill = '$waybill'";
  3046. }
  3047. //数据排序
  3048. $order_str = "id desc";
  3049. if (empty($page)) {
  3050. $start = 0;
  3051. $perpage = 1;
  3052. } else {
  3053. $start = ($page - 1) * $perpage;
  3054. }
  3055. //取得信息列表
  3056. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3057. //格式化数据
  3058. foreach ($info_list as $key => $value) {
  3059. $shop = $this->shop->read($value['shop']);
  3060. $info_list[$key]['shop'] = $shop['shopname'];
  3061. $warehouse = $this->warehouse->read($value['warehouse']);
  3062. $info_list[$key]['warehouse'] = $warehouse['title'];
  3063. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3064. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3065. if ($value['waybill'] == 0) {
  3066. $info_list[$key]['waybill'] = "";
  3067. }
  3068. $express = $this->express->read($value['express']);
  3069. $info_list[$key]['express'] = $express['title'];
  3070. $typeclass = $this->typeclass->read($value['state']);
  3071. $info_list[$key]['state'] = $typeclass['title'];
  3072. }
  3073. $total = $this->fullorder->find_count($where);
  3074. $pagenum = ceil($total / $perpage);
  3075. $over = $total - ($start + $perpage);
  3076. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3077. echo json_encode($rows);
  3078. exit;
  3079. }
  3080. $this->data['express'] = $this->express->find_all();
  3081. $this->_Template('whlabel_retreat', $this->data);
  3082. }
  3083. //退库标签浏览
  3084. public function _retreatlk()
  3085. {
  3086. $post = $this->input->post(NULL, TRUE);
  3087. if (isset($post['page'])) {
  3088. $page = $this->input->post('page', true);
  3089. $perpage = $this->input->post('perpage', true);
  3090. $timetk = $this->input->post('timetk', true);
  3091. $timetj = $this->input->post('timetj', true);
  3092. $sku = $this->input->post('sku', true);
  3093. $warehouse = $this->input->post('warehouse', true);
  3094. $purchase = $this->input->post('purchase', true);
  3095. $orderinfo = $this->input->post('orderinfo', true);
  3096. $waybill = $this->input->post('waybill', true);
  3097. $category = $this->input->post('category', true);
  3098. $size = $this->input->post('size', true);
  3099. $grade = $this->input->post('grade', true);
  3100. $color = $this->input->post('color', true);
  3101. $lowe = $this->input->post('lowe', true);
  3102. $state = $this->input->post('state', true);
  3103. $timetk = strtotime($timetk);
  3104. $timetj = strtotime($timetj);
  3105. $where = "state=2";
  3106. if ($timetk && $timetj) {
  3107. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3108. }
  3109. if ($sku) {
  3110. $where .= " and sku = '$sku'";
  3111. }
  3112. if ($warehouse) {
  3113. $where .= " and warehouse = '$warehouse'";
  3114. }
  3115. if ($purchase) {
  3116. $where .= " and purchase = '$purchase'";
  3117. }
  3118. if ($orderinfo) {
  3119. $where .= " and orderinfo = '$orderinfo'";
  3120. }
  3121. if ($waybill) {
  3122. $where .= " and waybill = '$waybill'";
  3123. }
  3124. if ($category) {
  3125. $where .= " and features like '%-$category-%'";
  3126. }
  3127. if ($size) {
  3128. $where .= " and features like '%-$size-%'";
  3129. }
  3130. if ($grade) {
  3131. $where .= " and features like '%-$grade-%'";
  3132. }
  3133. if ($color) {
  3134. $where .= " and features like '%-$color-%'";
  3135. }
  3136. if ($lowe) {
  3137. $where .= " and features like '%-$lowe-%'";
  3138. }
  3139. //数据排序
  3140. $order_str = "time desc";
  3141. if (empty($page)) {
  3142. $start = 0;
  3143. $perpage = 1;
  3144. } else {
  3145. $start = ($page - 1) * $perpage;
  3146. }
  3147. //取得信息列表
  3148. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3149. foreach ($info_list as $key => $value) {
  3150. $warehouse = $this->warehouse->read($value['warehouse']);
  3151. $info_list[$key]['warehouse'] = $warehouse['title'];
  3152. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3153. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3154. $purchase = $this->purchase->read($value['purchase']);
  3155. $info_list[$key]['purchase'] = $purchase['title'];
  3156. if ($value['outk'] != 0) {
  3157. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3158. } else {
  3159. $info_list[$key]['outk'] = "";
  3160. }
  3161. if ($value['retreat'] != 0) {
  3162. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3163. } else {
  3164. $info_list[$key]['retreat'] = "";
  3165. }
  3166. if ($value['orderinfo'] == 0) {
  3167. $info_list[$key]['orderinfo'] = "";
  3168. }
  3169. if ($value['waybill'] == 0) {
  3170. $info_list[$key]['waybill'] = "";
  3171. }
  3172. }
  3173. $total = $this->whlabel->find_count($where);
  3174. $pagenum = ceil($total / $perpage);
  3175. $over = $total - ($start + $perpage);
  3176. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3177. echo json_encode($rows);
  3178. exit;
  3179. }
  3180. $this->_Template('whlabel_retreatlk', $this->data);
  3181. }
  3182. //更换标签及浏览
  3183. public function _change()
  3184. {
  3185. $post = $this->input->post(NULL, TRUE);
  3186. if (isset($post['page'])) {
  3187. $page = $this->input->post('page', true);
  3188. $perpage = $this->input->post('perpage', true);
  3189. $timetk = $this->input->post('timetk', true);
  3190. $timetj = $this->input->post('timetj', true);
  3191. $label = $this->input->post('label', true);
  3192. $oldlabel = $this->input->post('oldlabel', true);
  3193. $timetk = strtotime($timetk);
  3194. $timetj = strtotime($timetj);
  3195. $where = "state=10 ";
  3196. if ($timetk && $timetj) {
  3197. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3198. }
  3199. if ($label) {
  3200. $where .= " and label = '$label'";
  3201. }
  3202. if ($oldlabel) {
  3203. $where .= " and oldlabel = '$oldlabel'";
  3204. }
  3205. //数据排序
  3206. $order_str = "time asc";
  3207. if (empty($page)) {
  3208. $start = 0;
  3209. $perpage = 1;
  3210. } else {
  3211. $start = ($page - 1) * $perpage;
  3212. }
  3213. //取得信息列表
  3214. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3215. foreach ($info_list as $key => $value) {
  3216. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3217. }
  3218. $total = $this->whlabel->find_count($where);
  3219. $pagenum = ceil($total / $perpage);
  3220. $over = $total - ($start + $perpage);
  3221. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3222. echo json_encode($rows);
  3223. exit;
  3224. }
  3225. $this->_Template('whlabel_change', $this->data);
  3226. }
  3227. //产品标签
  3228. public function _cpbqdc()
  3229. {
  3230. if (isset($_GET['excel'])) {
  3231. $where = "1=1";
  3232. //数据排序
  3233. $order_str = "id desc";
  3234. if (empty($page)) {
  3235. $start = 0;
  3236. $perpage = 1;
  3237. } else {
  3238. $start = ($page - 1) * $perpage;
  3239. }
  3240. $warehouse = $this->input->get('warehouse', true);
  3241. $state = $this->input->get('state', true);
  3242. $timetk = $this->input->get('timetkk', true);
  3243. $timetj = $this->input->get('timetjj', true);
  3244. $timetk = strtotime($timetk);
  3245. $timetj = strtotime($timetj);
  3246. if ($warehouse) {
  3247. $where .= " and warehouse = '$warehouse'";
  3248. }
  3249. if ($state || $state == 0) {
  3250. $where .= " and state = '$state'";
  3251. }
  3252. if ($timetk && $timetj) {
  3253. $where .= " and time > '$timetk' and time < '$timetj'";
  3254. }
  3255. //取得信息列表
  3256. $info_list = $this->whlabel->find_all($where, '*');
  3257. $rows = array();
  3258. $list = array();
  3259. foreach ($info_list as $key => $value) {
  3260. $rows[$value['time']] = $value; //所有数据sku
  3261. }
  3262. foreach ($rows as $value) {
  3263. $warehouse = $this->warehouse->read($value['warehouse']);
  3264. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3265. $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);
  3266. }
  3267. $title = "产品标签统计表";
  3268. $titlename = "<table border=1>
  3269. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3270. <tr align='center'>
  3271. <td>仓库</td>
  3272. <td>SKU</td>
  3273. <td>产品</td>
  3274. <td>入库时间</td>
  3275. <td>操作时间</td>
  3276. <td>备注</td>
  3277. <td>数量</td>
  3278. </tr>
  3279. </table>";
  3280. $filename = $title . ".xls";
  3281. $tail = "";
  3282. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3283. }
  3284. }
  3285. //进销存导出
  3286. public function _exceljxc()
  3287. {
  3288. $classid = $this->classid->sku();
  3289. $pm = $classid;
  3290. $typeclass = array();
  3291. $tc = $this->typeclass->find_all();
  3292. foreach ($tc as $v) {
  3293. $typeclass[$v['id']] = $v;
  3294. }
  3295. $prc = array();
  3296. $purchase = $this->purchase->find_all();
  3297. foreach ($purchase as $k => $v) {
  3298. $prc[$v['id']] = $v['title'];
  3299. }
  3300. if (isset($_GET['excel'])) {
  3301. $where = "sku != 'Preset'";
  3302. //数据排序
  3303. $order_str = "id desc";
  3304. if (empty($page)) {
  3305. $start = 0;
  3306. $perpage = 1;
  3307. } else {
  3308. $start = ($page - 1) * $perpage;
  3309. }
  3310. $category = $this->input->get('category', true);
  3311. $warehouse = $this->input->get('warehouse', true);
  3312. $excelid = $this->input->get('sid', true);
  3313. if ($category) {
  3314. $where .= " and features like '%-$category-%'";
  3315. }
  3316. if ($warehouse) {
  3317. $where .= " and warehouse = '$warehouse'";
  3318. }
  3319. $xzid = '';
  3320. if ($excelid) {
  3321. $excelid = explode(',', trim($excelid, ','));
  3322. foreach ($excelid as $key => $value) {
  3323. $xzid .= " id = " . $value . " or";
  3324. }
  3325. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3326. }
  3327. //取得信息列表
  3328. /**
  3329. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3330. $rows = array();$list = array();
  3331. foreach ($info_list as $key=>$value)
  3332. {
  3333. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3334. }
  3335. **/
  3336. $wt = array();
  3337. $whlabel_type = $this->whlabel_type->find_all();
  3338. foreach ($whlabel_type as $v) {
  3339. $wt[$v['id']] = $v['title'];
  3340. }
  3341. $wh = array();
  3342. $w = $this->warehouse->find_all('1=1', 'id,title');
  3343. foreach ($w as $v) {
  3344. $wh[$v['id']] = $v['title'];
  3345. }
  3346. $list = array();
  3347. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3348. foreach ($rows as $key => $value) {
  3349. if (isset($wt[$value['type']])) {
  3350. $rows[$key]['type'] = $wt[$value['type']];
  3351. } else {
  3352. $rows[$key]['type'] = '未设置';
  3353. }
  3354. $bm = '03';
  3355. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3356. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3357. $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');
  3358. $details = array();
  3359. $cpid = array();
  3360. $cpbz = array();
  3361. $c = 0;
  3362. $g = 0;
  3363. $x = 0;
  3364. $t = 0;
  3365. $s = 0;
  3366. $q = 0;
  3367. foreach ($sd as $k => $v) {
  3368. if ($v['state'] == 0) {
  3369. $c++;
  3370. if ($v['cpid'] != 0) {
  3371. $cpid[$v['cpid']] = $v['cpid'];
  3372. }
  3373. if ($v['cpbz'] != '') {
  3374. $cpbz[$v['cpbz']] = $v['cpbz'];
  3375. }
  3376. }
  3377. if ($v['state'] != 9) {
  3378. $g++;
  3379. }
  3380. if ($v['state'] == 1) {
  3381. $x++;
  3382. }
  3383. if ($v['state'] == 2) {
  3384. $t++;
  3385. }
  3386. if ($v['state'] == 8) {
  3387. $s++;
  3388. }
  3389. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3390. $q++;
  3391. }
  3392. $details[$v['details']] = $v['details'];
  3393. }
  3394. $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'] . '"');
  3395. $rows[$key]['details'] = implode("、", $details);
  3396. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3397. $number = $value['number'];
  3398. $ftime = time() - 15 * 24 * 3600;
  3399. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3400. $rows[$key]['number'] = $g;
  3401. $rows[$key]['c'] = $c;
  3402. $rows[$key]['x'] = $x;
  3403. $rows[$key]['t'] = $t;
  3404. $rows[$key]['s'] = $s;
  3405. $rows[$key]['q'] = $q;
  3406. $rows[$key]['z'] = $z;
  3407. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3408. $features = explode('-', trim($features, '-'));
  3409. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3410. // $pm = $classid;
  3411. // $jm = $classid;
  3412. // foreach($features as $k=>$v)
  3413. // {
  3414. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3415. // {
  3416. // if($typeclass[$v]['bm'] != '')
  3417. // {
  3418. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3419. // }
  3420. // }
  3421. // if($v != 0)
  3422. // {
  3423. // if(!isset($typeclass[$v]))
  3424. // {
  3425. // continue;
  3426. // }
  3427. // if(isset($pm[$typeclass[$v]['classid']]))
  3428. // {
  3429. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3430. // {
  3431. // $tz = explode('|',$typeclass[$v]['zh']);
  3432. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3433. // }
  3434. // else
  3435. // {
  3436. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3437. // }
  3438. // }
  3439. // if(isset($jm[$typeclass[$v]['classid']]))
  3440. // {
  3441. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3442. // }
  3443. // }
  3444. // }
  3445. // $jm = array_filter($jm);
  3446. // $rows[$key]['bs'] = implode("-",$jm);
  3447. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3448. // $zh = implode(" ",$pm);
  3449. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3450. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3451. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3452. // $rows[$key]['features'] = $zh;
  3453. }
  3454. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3455. $final_list = [];
  3456. foreach ($list as $k => $v) {
  3457. if (empty($v['sku'])) {
  3458. continue;
  3459. }
  3460. $final_list[] = [
  3461. "warehouse" => $v["warehouse"],
  3462. "purchase" => $v["purchase"],
  3463. "details" => $v["details"],
  3464. "cpid" => $v["cpid"],
  3465. "dbcontent" => $v["dbcontent"],
  3466. "sku" => $v["sku"],
  3467. "cs" => $v["bm"],
  3468. "bs" => $v["jm"],
  3469. "title" => $v["title"],
  3470. "features" => $v["pm"],
  3471. "cpbz" => $v["cpbz"],
  3472. "sm" => $v["sm"],
  3473. "type" => $v["type"],
  3474. "number" => $v["number"],
  3475. "c" => $v["c"],
  3476. "x" => $v["x"],
  3477. "t" => $v["t"],
  3478. "s" => $v["s"],
  3479. "q" => $v["q"],
  3480. "z" => $v["z"],
  3481. "weight" => $v['weight'],
  3482. ];
  3483. }
  3484. $title = "总进销存统计表";
  3485. $titlename = "<table border=1>
  3486. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3487. <tr align='center'>
  3488. <td>仓库</td>
  3489. <td>供应商</td>
  3490. <td>位置</td>
  3491. <td>库存编码</td>
  3492. <td>类目</td>
  3493. <td>SKU</td>
  3494. <td>用友编码</td>
  3495. <td>用友料号</td>
  3496. <td>商品名称</td>
  3497. <td>商品中文</td>
  3498. <td>产品备注</td>
  3499. <td>说明</td>
  3500. <td>类型</td>
  3501. <td>入库总量</td>
  3502. <td>库存数量</td>
  3503. <td>销售数量</td>
  3504. <td>退货数量</td>
  3505. <td>删除数量</td>
  3506. <td>其它操作</td>
  3507. <td>占单数量</td>
  3508. <td>重量(g)</td>
  3509. </tr>
  3510. </table>";
  3511. $filename = $title . ".xls";
  3512. $tail = "";
  3513. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3514. }
  3515. }
  3516. //入库导出
  3517. public function _excelr()
  3518. {
  3519. if (isset($_GET['excel'])) {
  3520. $category = $this->input->get('category', true);
  3521. $size = $this->input->get('size', true);
  3522. $grade = $this->input->get('grade', true);
  3523. $color = $this->input->get('color', true);
  3524. $lowe = $this->input->get('lowe', true);
  3525. $sku = $this->input->get('sku', true);
  3526. $warehouse = $this->input->get('warehouse', true);
  3527. $purchase = $this->input->get('purchase', true);
  3528. $ktime = $this->input->get('ktime', true);
  3529. $jtime = $this->input->get('jtime', true);
  3530. $ktime = strtotime($ktime);
  3531. $jtime = strtotime($jtime);
  3532. $where = "1=1";
  3533. $gj = "";
  3534. $ck = "";
  3535. if ($category) {
  3536. $where .= " and features like '%-$category-%'";
  3537. }
  3538. if ($size) {
  3539. $where .= " and features like '%-$size-%'";
  3540. }
  3541. if ($grade) {
  3542. $where .= " and features like '%-$grade-%'";
  3543. }
  3544. if ($color) {
  3545. $where .= " and features like '%-$color-%'";
  3546. }
  3547. if ($lowe) {
  3548. $where .= " and features like '%-$lowe-%'";
  3549. }
  3550. if ($warehouse) {
  3551. $where .= " and warehouse = '$warehouse'";
  3552. }
  3553. if ($purchase) {
  3554. $where .= " and purchase = '$purchase'";
  3555. }
  3556. if ($sku) {
  3557. $where .= " and sku = '$sku'";
  3558. }
  3559. if ($ktime && $jtime) {
  3560. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3561. }
  3562. //数据排序
  3563. $order_str = "id desc";
  3564. if (empty($page)) {
  3565. $start = 0;
  3566. $perpage = 1;
  3567. } else {
  3568. $start = ($page - 1) * $perpage;
  3569. }
  3570. $list = array();
  3571. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3572. foreach ($rows as $value) {
  3573. $ck = $this->warehouse->read($value['warehouse']);
  3574. $warehouse = $ck['title'];
  3575. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3576. $retreatwarehouse = $tkck['title'];
  3577. $gy = $this->purchase->read($value['purchase']);
  3578. $purchase = $gy['title'];
  3579. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3580. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3581. }
  3582. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3583. $titlename = "<table border=1>
  3584. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3585. <tr align='center'>
  3586. <td>仓库</td>
  3587. <td>SKU</td>
  3588. <td>产品</td>
  3589. <td>时间</td>
  3590. <td>数量</td>
  3591. </tr>
  3592. </table>";
  3593. $filename = $title . ".xls";
  3594. $tail = "";
  3595. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3596. }
  3597. }
  3598. //出库、退库导出
  3599. public function _excelct()
  3600. {
  3601. $classid = $this->classid->sku();
  3602. $pm = $classid;
  3603. $typeclass = array();
  3604. $tc = $this->typeclass->find_all();
  3605. foreach ($tc as $v) {
  3606. $typeclass[$v['id']] = $v;
  3607. }
  3608. $prc = array();
  3609. $purchase = $this->purchase->find_all();
  3610. foreach ($purchase as $k => $v) {
  3611. $prc[$v['id']] = $v['title'];
  3612. }
  3613. if (isset($_GET['excel'])) {
  3614. $wh = array();
  3615. $w = $this->warehouse->find_all('1=1', 'id,title');
  3616. foreach ($w as $v) {
  3617. $wh[$v['id']] = $v['title'];
  3618. }
  3619. $type = $this->input->get('excel', true);
  3620. $category = $this->input->get('category', true);
  3621. $size = $this->input->get('size', true);
  3622. $grade = $this->input->get('grade', true);
  3623. $color = $this->input->get('color', true);
  3624. $lowe = $this->input->get('lowe', true);
  3625. $sku = $this->input->get('sku', true);
  3626. $warehouse = $this->input->get('warehouse', true);
  3627. $lacetype = $this->input->get('lacetype', true);
  3628. $lacecolor = $this->input->get('lacecolor', true);
  3629. $density = $this->input->get('density', true);
  3630. $haircap = $this->input->get('haircap', true);
  3631. $purchase = $this->input->get('purchase', true);
  3632. $title = $this->input->get('title', true);
  3633. $state = $this->input->get('state', true);
  3634. $sid = $this->input->get('sid', true);
  3635. $ktime = $this->input->get('ktime', true);
  3636. $jtime = $this->input->get('jtime', true);
  3637. $ktime = strtotime($ktime);
  3638. $jtime = strtotime($jtime);
  3639. $where = "1=1";
  3640. $gj = "";
  3641. $ck = "";
  3642. if ($category) {
  3643. $where .= " and features like '%-$category-%'";
  3644. }
  3645. if ($size) {
  3646. $where .= " and features like '%-$size-%'";
  3647. }
  3648. if ($grade) {
  3649. $where .= " and features like '%-$grade-%'";
  3650. }
  3651. if ($color) {
  3652. $where .= " and features like '%-$color-%'";
  3653. }
  3654. if ($lowe) {
  3655. $where .= " and features like '%-$lowe-%'";
  3656. }
  3657. if ($warehouse) {
  3658. $where .= " and warehouse = '$warehouse'";
  3659. }
  3660. if ($purchase) {
  3661. $where .= " and purchase = '$purchase'";
  3662. }
  3663. if ($state) {
  3664. $where .= " and state = '$state'";
  3665. }
  3666. if ($lacetype) {
  3667. $where .= " and features like '%-$lacetype-%'";
  3668. }
  3669. if ($lacecolor) {
  3670. $where .= " and features like '%-$lacecolor-%'";
  3671. }
  3672. if ($density) {
  3673. $where .= " and features like '%-$density-%'";
  3674. }
  3675. if ($haircap) {
  3676. $where .= " and features like '%-$haircap-%'";
  3677. }
  3678. if ($title) {
  3679. $title = trim($title, ' ');
  3680. $title = trim($title, ' ');
  3681. $where .= " and title like '%$title%'";
  3682. }
  3683. if ($sku) {
  3684. $sku = trim($sku, ' ');
  3685. $sku = trim($sku, ' ');
  3686. $where .= " and sku like '%$sku%'";
  3687. }
  3688. if ($ktime && $jtime) {
  3689. if ($type == 1) {
  3690. $tl = '出库';
  3691. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3692. } else if ($type == 2) {
  3693. $tl = '退库';
  3694. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3695. } else if ($type == 3) {
  3696. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3697. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3698. } else if ($type == 4) {
  3699. $tl = '出库+零售';
  3700. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3701. } else if ($type == 5) {
  3702. $tl = '零售';
  3703. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3704. }
  3705. }
  3706. $sidwhere = '';
  3707. if ($sid) {
  3708. $sd = "";
  3709. $s = explode(',', trim($sid, ','));
  3710. foreach ($s as $value) {
  3711. $sd .= " id = " . $value . " or";
  3712. }
  3713. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3714. }
  3715. //数据排序
  3716. $order_str = "time desc";
  3717. if (empty($page)) {
  3718. $start = 0;
  3719. $perpage = 1;
  3720. } else {
  3721. $start = ($page - 1) * $perpage;
  3722. }
  3723. //取得信息列表
  3724. if ($type != 3 && $type != 5) {
  3725. if ($type == 1 || $type == 4) {
  3726. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3727. foreach ($info_list as $key => $value) {
  3728. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3729. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3730. $warehouse = $this->warehouse->read($value['warehouse']);
  3731. $info_list[$key]['warehouse'] = $warehouse['title'];
  3732. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3733. $features = explode('-', trim($features, '-'));
  3734. $pm = $classid;
  3735. foreach ($features as $k => $v) {
  3736. if ($v != 0) {
  3737. if (!isset($typeclass[$v])) {
  3738. continue;
  3739. }
  3740. if (isset($pm[$typeclass[$v]['classid']])) {
  3741. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3742. $tz = explode('|', $typeclass[$v]['zh']);
  3743. $pm[$typeclass[$v]['classid']] = $tz[0];
  3744. } else {
  3745. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3746. }
  3747. }
  3748. }
  3749. }
  3750. $zh = implode(" ", $pm);
  3751. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3752. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3753. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3754. $info_list[$key]['features'] = $zh;
  3755. }
  3756. $final_list = [];
  3757. foreach($info_list as $k=>$v){
  3758. $number = "";
  3759. if(!empty($v['orderinfo'])){
  3760. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3761. if(!empty($tmp_info['number'])){
  3762. $number = $tmp_info['number'];
  3763. }
  3764. }
  3765. $final_list[] = [
  3766. 'warehouse'=>$v['warehouse'],
  3767. 'purchase'=>$v['purchase'],
  3768. 'sku'=>$v['sku'],
  3769. 'title'=>$v['title'],
  3770. 'features'=>$v['features'],
  3771. 'label'=>$v['label'],
  3772. 'orderinfo'=>$v['orderinfo'],
  3773. 'number'=>$number,
  3774. 'waybill'=>$v['waybill'],
  3775. 'outk'=>$v['outk'],
  3776. ];
  3777. }
  3778. } else {
  3779. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3780. foreach ($info_list as $key => $value) {
  3781. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3782. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3783. $warehouse = $this->warehouse->read($value['warehouse']);
  3784. $info_list[$key]['warehouse'] = $warehouse['title'];
  3785. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3786. $features = explode('-', trim($features, '-'));
  3787. $pm = $classid;
  3788. foreach ($features as $k => $v) {
  3789. if ($v != 0) {
  3790. if (!isset($typeclass[$v])) {
  3791. continue;
  3792. }
  3793. if (isset($pm[$typeclass[$v]['classid']])) {
  3794. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3795. $tz = explode('|', $typeclass[$v]['zh']);
  3796. $pm[$typeclass[$v]['classid']] = $tz[0];
  3797. } else {
  3798. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3799. }
  3800. }
  3801. }
  3802. }
  3803. $zh = implode(" ", $pm);
  3804. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3805. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3806. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3807. $info_list[$key]['features'] = $zh;
  3808. }
  3809. $final_list = [];
  3810. foreach($info_list as $k=>$v){
  3811. $number = "";
  3812. if(!empty($v['orderinfo'])){
  3813. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3814. if(!empty($tmp_info['number'])){
  3815. $number = $tmp_info['number'];
  3816. }
  3817. }
  3818. $final_list[] = [
  3819. 'warehouse'=>$v['warehouse'],
  3820. 'purchase'=>$v['purchase'],
  3821. 'sku'=>$v['sku'],
  3822. 'title'=>$v['title'],
  3823. 'features'=>$v['features'],
  3824. 'label'=>$v['label'],
  3825. 'orderinfo'=>$v['orderinfo'],
  3826. 'number'=>$number,
  3827. 'waybill'=>$v['waybill'],
  3828. 'retreat'=>$v['retreat'],
  3829. ];
  3830. }
  3831. }
  3832. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3833. $titlename = "<table border=1>
  3834. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3835. <tr align='center'>
  3836. <td>仓库</td>
  3837. <td>供应商</td>
  3838. <td>SKU</td>
  3839. <td>商品名称</td>
  3840. <td>商品中文</td>
  3841. <td>标签</td>
  3842. <td>订单号</td>
  3843. <td>订单编码</td>
  3844. <td>运单号</td>
  3845. <td>" . $tl . "时间(中国时间)</td>
  3846. </tr>
  3847. </table>";
  3848. $filename = $title . ".xls";
  3849. $tail = "";
  3850. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3851. } else if ($type == 5) {
  3852. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3853. foreach ($info_list as $key => $value) {
  3854. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3855. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3856. $warehouse = $this->warehouse->read($value['warehouse']);
  3857. $info_list[$key]['warehouse'] = $warehouse['title'];
  3858. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3859. $features = explode('-', trim($features, '-'));
  3860. $pm = $classid;
  3861. foreach ($features as $k => $v) {
  3862. if ($v != 0) {
  3863. if (!isset($typeclass[$v])) {
  3864. continue;
  3865. }
  3866. if (isset($pm[$typeclass[$v]['classid']])) {
  3867. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3868. $tz = explode('|', $typeclass[$v]['zh']);
  3869. $pm[$typeclass[$v]['classid']] = $tz[0];
  3870. } else {
  3871. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3872. }
  3873. }
  3874. }
  3875. }
  3876. $zh = implode(" ", $pm);
  3877. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3878. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3879. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3880. $info_list[$key]['features'] = $zh;
  3881. }
  3882. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3883. $titlename = "<table border=1>
  3884. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3885. <tr align='center'>
  3886. <td>仓库</td>
  3887. <td>供应商</td>
  3888. <td>SKU</td>
  3889. <td>商品名称</td>
  3890. <td>商品中文</td>
  3891. <td>标签</td>
  3892. <td>" . $tl . "时间(中国时间)</td>
  3893. </tr>
  3894. </table>";
  3895. $filename = $title . ".xls";
  3896. $tail = "";
  3897. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3898. } else {
  3899. /**
  3900. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3901. $rows = array();$list = array();
  3902. foreach ($info_list as $key=>$value)
  3903. {
  3904. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3905. }
  3906. **/
  3907. $wh = array();
  3908. $w = $this->warehouse->find_all('1=1', 'id,title');
  3909. foreach ($w as $v) {
  3910. $wh[$v['id']] = $v['title'];
  3911. }
  3912. $wt = array();
  3913. $whlabel_type = $this->whlabel_type->find_all();
  3914. foreach ($whlabel_type as $v) {
  3915. $wt[$v['id']] = $v['title'];
  3916. }
  3917. $classid = $this->classid->sku();
  3918. $list = array();
  3919. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3920. foreach ($rows as $key => $value) {
  3921. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3922. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3923. $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');
  3924. $details = array();
  3925. $cpid = array();
  3926. $cpbz = array();
  3927. $c = 0;
  3928. $g = 0;
  3929. $x = 0;
  3930. $t = 0;
  3931. $s = 0;
  3932. $q = 0;
  3933. foreach ($sd as $k => $v) {
  3934. if ($v['state'] == 0) {
  3935. $c++;
  3936. }
  3937. if ($v['state'] != 9) {
  3938. $g++;
  3939. }
  3940. if ($v['outk'] > 1) {
  3941. $x++;
  3942. }
  3943. if ($v['retreat'] > 0) {
  3944. $t++;
  3945. }
  3946. if ($v['state'] == 8) {
  3947. $s++;
  3948. }
  3949. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3950. $q++;
  3951. }
  3952. $details[$v['details']] = $v['details'];
  3953. if ($v['cpid'] != 0) {
  3954. $cpid[$v['cpid']] = $v['cpid'];
  3955. }
  3956. if ($v['cpbz'] != '') {
  3957. $cpbz[$v['cpbz']] = $v['cpbz'];
  3958. }
  3959. }
  3960. if (isset($wt[$value['type']])) {
  3961. $rows[$key]['type'] = $wt[$value['type']];
  3962. } else {
  3963. $rows[$key]['type'] = '未设置';
  3964. }
  3965. $rows[$key]['details'] = implode("、", $details);
  3966. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3967. $ftime = time() - 15 * 24 * 3600;
  3968. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3969. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3970. $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);
  3971. $rows[$key]['c'] = $c;
  3972. $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);
  3973. $rows[$key]['t'] = $t;
  3974. $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'] . '"');
  3975. $rows[$key]['z'] = $z;
  3976. // $jm = $classid;
  3977. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3978. $features = explode('-', trim($features, '-'));
  3979. // $pm = $classid;
  3980. // foreach ($features as $k => $v) {
  3981. // if ($v != 0) {
  3982. // if (!isset($typeclass[$v])) {
  3983. // continue;
  3984. // }
  3985. // if (isset($pm[$typeclass[$v]['classid']])) {
  3986. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3987. // $tz = explode('|', $typeclass[$v]['zh']);
  3988. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3989. // } else {
  3990. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3991. // }
  3992. // if (isset($jm[$typeclass[$v]['classid']])) {
  3993. // if ($typeclass[$v]['jm']) {
  3994. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3995. // }
  3996. // }
  3997. // }
  3998. // }
  3999. // }
  4000. // $zh = implode(" ", $pm);
  4001. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4002. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4003. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4004. // $rows[$key]['features'] = $zh;
  4005. // $jm = array_filter($jm); //去除空值
  4006. // $jm = implode("-", $jm);
  4007. // $rows[$key]['jm'] = $jm;
  4008. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4009. }
  4010. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4011. // echo "<pre>";
  4012. // print_r($tmp_list);
  4013. // die;
  4014. $final_list =[];
  4015. foreach($tmp_list as $k=>$v){
  4016. $final_list[] = [
  4017. "warehouse"=>$v['warehouse'],
  4018. "purchase"=>$v['purchase'],
  4019. "details"=>$v['details'],
  4020. "cpid"=>$v['cpid'],
  4021. "sku"=>$v['sku'],
  4022. "title"=>$v['title'],
  4023. "features"=>$v['pm'],
  4024. "cpbz"=>$v['cpbz'],
  4025. "sm"=>$v['sm'],
  4026. "type"=>$v['type'],
  4027. "g"=>$v["g"],
  4028. "c"=>$v["c"],
  4029. "x"=>$v["x"],
  4030. "t"=>$v["t"],
  4031. "z"=>$v["z"],
  4032. "jm"=>$v["jm"],
  4033. "weight"=>$v["weight"],
  4034. "asd"=>$v["asd"],
  4035. ];
  4036. }
  4037. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4038. $titlename = "<table border=1>
  4039. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4040. <tr align='center'>
  4041. <td>仓库</td>
  4042. <td>供应商</td>
  4043. <td>位置</td>
  4044. <td>库存编码</td>
  4045. <td>SKU</td>
  4046. <td>商品名称</td>
  4047. <td>商品中文</td>
  4048. <td>产品备注</td>
  4049. <td>说明</td>
  4050. <td>类型</td>
  4051. <td>入库总量</td>
  4052. <td>库存数量</td>
  4053. <td>销售数量</td>
  4054. <td>退货数量</td>
  4055. <td>占单数量</td>
  4056. <td>料号</td>
  4057. <td>重量</td>
  4058. <td>类目</td>
  4059. </tr>
  4060. </table>";
  4061. $filename = $title . ".xls";
  4062. $tail = "";
  4063. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4064. }
  4065. }
  4066. }
  4067. //出库+入库数据整合
  4068. public function _excelcr()
  4069. {
  4070. if (isset($_GET['excel'])) {
  4071. $type = $this->input->get('excel', true);
  4072. $category = $this->input->get('category', true);
  4073. $size = $this->input->get('size', true);
  4074. $grade = $this->input->get('grade', true);
  4075. $color = $this->input->get('color', true);
  4076. $lowe = $this->input->get('lowe', true);
  4077. $sku = $this->input->get('sku', true);
  4078. $warehouse = $this->input->get('warehouse', true);
  4079. $purchase = $this->input->get('purchase', true);
  4080. $state = $this->input->get('state', true);
  4081. $sid = $this->input->get('sid', true);
  4082. $ktime = $this->input->get('ktime', true);
  4083. $jtime = $this->input->get('jtime', true);
  4084. $ktime = strtotime($ktime);
  4085. $jtime = strtotime($jtime);
  4086. $where = "1=1";
  4087. $gj = "";
  4088. $ck = "";
  4089. if ($category) {
  4090. $where .= " and features like '%-$category-%'";
  4091. }
  4092. if ($size) {
  4093. $where .= " and features like '%-$size-%'";
  4094. }
  4095. if ($grade) {
  4096. $where .= " and features like '%-$grade-%'";
  4097. }
  4098. if ($color) {
  4099. $where .= " and features like '%-$color-%'";
  4100. }
  4101. if ($lowe) {
  4102. $where .= " and features like '%-$lowe-%'";
  4103. }
  4104. if ($warehouse) {
  4105. $where .= " and warehouse = '$warehouse'";
  4106. }
  4107. if ($purchase) {
  4108. $where .= " and purchase = '$purchase'";
  4109. }
  4110. if ($state) {
  4111. $where .= " and state = '$state'";
  4112. }
  4113. if ($sku) {
  4114. $where .= " and sku like '%$sku%'";
  4115. }
  4116. if ($ktime && $jtime) {
  4117. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4118. }
  4119. $sidwhere = '';
  4120. if ($sid) {
  4121. $sd = "";
  4122. $s = explode(',', trim($sid, ','));
  4123. foreach ($s as $value) {
  4124. $sd .= " id = " . $value . " or";
  4125. }
  4126. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4127. }
  4128. //取得信息列表
  4129. $timeread = $ktime;
  4130. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4131. $timelist = array();
  4132. for ($i = 0; $i < $timenum; $i++) {
  4133. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4134. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4135. }
  4136. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4137. //echo "<pre>";
  4138. //print_r($info_list);
  4139. //exit();
  4140. $rows = array();
  4141. $list = array();
  4142. foreach ($info_list as $key => $value) {
  4143. $thistime = $timelist;
  4144. if (isset($rows[strtolower($value['sku'])])) {
  4145. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4146. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4147. }
  4148. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4149. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4150. }
  4151. } else {
  4152. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4153. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4154. }
  4155. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4156. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4157. }
  4158. $rows[strtolower($value['sku'])] = $thistime;
  4159. }
  4160. }
  4161. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4162. <head>
  4163. <!--[if gte mso 9]><xml>
  4164. <x:ExcelWorkbook>
  4165. <x:ExcelWorksheets>
  4166. <x:ExcelWorksheet>
  4167. <x:Name>EXCEL</x:Name>
  4168. <x:WorksheetOptions>
  4169. <x:Print>
  4170. <x:ValidPrinterInfo />
  4171. </x:Print>
  4172. </x:WorksheetOptions>
  4173. </x:ExcelWorksheet>
  4174. </x:ExcelWorksheets>
  4175. </x:ExcelWorkbook>
  4176. </xml>
  4177. <![endif]-->
  4178. </head><body>";
  4179. $str .= "<table border=1><tr><td>SKU</td>";
  4180. foreach ($timelist as $k => $v) {
  4181. $str .= "<td>" . $k . "出库</td>";
  4182. $str .= "<td>" . $k . "入库</td>";
  4183. }
  4184. $str .= "</tr></table>";
  4185. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4186. foreach ($rows as $key => $val) {
  4187. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4188. foreach ($val as $k => $v) {
  4189. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4190. if ($val[$k]['r'] > 0) {
  4191. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4192. } else {
  4193. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4194. }
  4195. }
  4196. $str .= "</tr>";
  4197. }
  4198. $str .= "</table>";
  4199. $str .= "</body></html>";
  4200. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4201. header("Content-type: application/octet-stream");
  4202. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4203. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4204. header("Pragma: no-cache");
  4205. header("Expires: 0");
  4206. exit($str);
  4207. }
  4208. }
  4209. //数量调整模板导出
  4210. public function _presetout()
  4211. {
  4212. if (isset($_GET['excel'])) {
  4213. $where = "sku != 'Preset' and purchase != 0";
  4214. //数据排序
  4215. $order_str = "id desc";
  4216. if (empty($page)) {
  4217. $start = 0;
  4218. $perpage = 1;
  4219. } else {
  4220. $start = ($page - 1) * $perpage;
  4221. }
  4222. //取得信息列表
  4223. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4224. $rows = array();
  4225. $list = array();
  4226. foreach ($info_list as $value) {
  4227. $warehouse = $this->warehouse->read($value['warehouse']);
  4228. $number = $value['number'];
  4229. $ftime = time() - 15 * 24 * 3600;
  4230. $purchase = $this->purchase->read($value['purchase']);
  4231. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4232. }
  4233. $title = "库存模板";
  4234. $titlename = "<table border=1>
  4235. <tr align='center'>
  4236. <td>仓库</td>
  4237. <td>供应商编码</td>
  4238. <td>SKU</td>
  4239. <td>增减数量(正数或负数)</td>
  4240. <td>增减备注</td>
  4241. <td>扣减方式:0减少库存1删除库存</td>
  4242. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4243. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4244. </tr>
  4245. </table>";
  4246. $filename = $title . ".xls";
  4247. $tail = "";
  4248. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4249. }
  4250. }
  4251. //数量调整模板导入
  4252. public function _presetedit()
  4253. {
  4254. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4255. $config['upload_path'] = '.' . $dir;
  4256. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4257. $config['allowed_types'] = 'xls|xlsx|csv';
  4258. $config['max_size'] = 10240;
  4259. $this->load->library('upload', $config);
  4260. $this->upload->initialize($config);
  4261. if ($this->upload->do_upload('userfile')) {
  4262. $full_path = $dir . $this->upload->data('file_name');
  4263. $fileName = '.' . $full_path;
  4264. if (!file_exists($fileName)) {
  4265. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4266. exit;
  4267. } else {
  4268. require_once "./data/excel/PHPExcel/IOFactory.php";
  4269. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4270. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4271. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4272. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4273. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4274. ++$column; //如果列数大于26行
  4275. $list = array();
  4276. for ($i = 2; $i <= $row; $i++) // 行数循环
  4277. {
  4278. $data = array();
  4279. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4280. {
  4281. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4282. }
  4283. $list[] = $data;
  4284. }
  4285. }
  4286. $i = 0;
  4287. $j = 0;
  4288. $ed = array();
  4289. foreach ($list as $key => $value) {
  4290. $time = time();
  4291. if ($value['0'] == "") {
  4292. continue;
  4293. }
  4294. $warehouse = $this->warehouse->get_title($value['0']);
  4295. $purchase = $this->purchase->get_bm($value['1']);
  4296. $sku = $value['2'];
  4297. $num = $value['3']; //调整数量
  4298. $text = $value['4']; //扣减说明
  4299. $type = $value['5']; //调整方式0扣减1删除
  4300. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4301. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4302. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4303. if (!$purchase) //如果没有这个SKU
  4304. {
  4305. $ed[] = array($purchase . '-不存在此供应商编码');
  4306. $j++;
  4307. continue;
  4308. }
  4309. if (!$d) //如果没有这个SKU
  4310. {
  4311. $ed[] = array($sku . '-库存中不存在此SKU');
  4312. $j++;
  4313. continue;
  4314. }
  4315. if (!isset($warehouse['id'])) {
  4316. $ed[] = array($sku . '-仓库名错误!');
  4317. $j++;
  4318. continue;
  4319. }
  4320. if ($type != '0' && $type != '1') {
  4321. $ed[] = array($sku . '-扣减方式填写错误!');
  4322. $j++;
  4323. continue;
  4324. }
  4325. if ($num < 0) //扣减库存
  4326. {
  4327. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4328. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4329. $j++;
  4330. continue;
  4331. }
  4332. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4333. if (count($data) < abs($num)) {
  4334. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4335. $j++;
  4336. continue;
  4337. }
  4338. if ($type == 0) //如果扣减方式为 扣减库存
  4339. {
  4340. for ($i = 0; $i < abs($num); $i++) {
  4341. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4342. }
  4343. } else if ($type == 1) {
  4344. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4345. if (count($zt) > 0) {
  4346. $ed[] = array($sku . '-有在途库存无法删除!');
  4347. $j++;
  4348. continue;
  4349. }
  4350. for ($i = 0; $i < abs($num); $i++) {
  4351. $this->whlabel->remove($data[$i]['id']);
  4352. }
  4353. }
  4354. } else if ($num > 0) //增加库存
  4355. {
  4356. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4357. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4358. $j++;
  4359. continue;
  4360. }
  4361. $post['sku'] = $d['sku'];
  4362. $post['shop'] = $d['shop'];
  4363. $post['warehouse'] = $warehouse['id'];
  4364. $post['purchase'] = $purchase['id'];
  4365. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4366. $post['state'] = 0;
  4367. $post['title'] = $d['title'];
  4368. $post['number'] = $d['number'];
  4369. $post['features'] = $d['features'];
  4370. $post['enter'] = $time;
  4371. $post['time'] = $time; //操作时间
  4372. $post['rktype'] = $rktype;
  4373. for ($i = 0; $i < $num; $i++) {
  4374. $post['label'] = time() . rand(100, 999) . $i;
  4375. $this->whlabel->insert($post);
  4376. }
  4377. }
  4378. sleep(1); //防止入库时间一样,需要延迟1秒
  4379. }
  4380. if ($j > 0) {
  4381. $tt = date('Ymd', time());
  4382. $title = '库存导入错误信息-' . $tt;
  4383. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4384. $tail = "\n";
  4385. $filename = $title . ".xls";
  4386. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4387. $dir = '/data/excel/' . $time . '/';
  4388. $file_name = 'error_' . $time . rand(1000, 9999);
  4389. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4390. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4391. fwrite($myfile, $ecl);
  4392. fclose($myfile);
  4393. $error = $dir . $file_name . '.xls';
  4394. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4395. exit;
  4396. } else {
  4397. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4398. exit;
  4399. }
  4400. }
  4401. }
  4402. //笛卡儿积
  4403. function cp($ps, $sets, $list)
  4404. {
  4405. $result = array();
  4406. $j = 0;
  4407. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4408. if ($i == 0) {
  4409. $result = $sets[$i];
  4410. }
  4411. $tmp = array();
  4412. foreach ($result as $res) {
  4413. foreach ($sets[$i + 1] as $set) {
  4414. $tmp[] = $res . ',' . $set;
  4415. }
  4416. }
  4417. $result = $tmp;
  4418. }
  4419. $this->db->trans_begin();
  4420. foreach ($result as $v) {
  4421. $post = array();
  4422. $title = "";
  4423. $num = "";
  4424. $data = explode(',', $v);
  4425. for ($i = 0; $i < count($list); $i++) {
  4426. $post[$list[$i]] = $data[$i];
  4427. $typeclass = $this->typeclass->read($data[$i]);
  4428. $title = $title . $typeclass['title'] . " ";
  4429. if ($data[$i] != 0) {
  4430. $num .= $data[$i]; //所有数据ID拼接
  4431. }
  4432. }
  4433. foreach ($ps as $kp => $vp) {
  4434. $post[$kp] = $vp;
  4435. }
  4436. $post['number'] = $num;
  4437. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4438. if ($info_list) {
  4439. $j++;
  4440. } else {
  4441. $skunum = $this->whlabel->find_count();
  4442. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4443. $post['title'] = rtrim($title, ' ');
  4444. $this->whlabel->insert($post);
  4445. }
  4446. }
  4447. if ($this->db->trans_status() === FALSE) {
  4448. $this->db->trans_commit();
  4449. return NULL;
  4450. } else {
  4451. $this->db->trans_commit();
  4452. return $j;
  4453. }
  4454. }
  4455. public function _kj($arg_array)
  4456. {
  4457. if (isset($_POST['sku'])) {
  4458. $time = time();
  4459. $sku = $this->input->post('sku', true);
  4460. $warehouse = $this->input->post('warehouse', true);
  4461. $num = $this->input->post('num', true);
  4462. $text = $this->input->post('text', true);
  4463. $purchase = $this->input->post('purchase', true);
  4464. $cktype = $this->input->post('cktype', true);
  4465. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4466. if ($cktype != 1 && $text == '') {
  4467. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4468. exit;
  4469. }
  4470. if ($num > count($order)) {
  4471. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4472. exit;
  4473. } else {
  4474. for ($i = 0; $i < $num; $i++) {
  4475. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4476. }
  4477. }
  4478. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4479. exit;
  4480. }
  4481. $uid = $this->whlabel->read($arg_array[0]);
  4482. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4483. $this->data['data'] = $uid;
  4484. $this->_Template('whlabel_kj', $this->data);
  4485. }
  4486. public function _summary($arg_array)
  4487. {
  4488. $prc = array();
  4489. $purchase = $this->purchase->find_all();
  4490. foreach ($purchase as $k => $v) {
  4491. $prc[$v['id']] = $v['title'];
  4492. }
  4493. if (isset($_GET['excel'])) {
  4494. $ktime = $this->input->get('ktime', true);
  4495. $jtime = $this->input->get('jtime', true);
  4496. $ktime = strtotime($ktime);
  4497. $jtime = strtotime($jtime);
  4498. $where = "1=1";
  4499. if ($ktime && $jtime) {
  4500. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4501. }
  4502. //数据排序
  4503. $order_str = "time desc";
  4504. if (empty($page)) {
  4505. $start = 0;
  4506. $perpage = 1;
  4507. } else {
  4508. $start = ($page - 1) * $perpage;
  4509. }
  4510. //取得信息列表
  4511. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4512. foreach ($info_list as $key => $value) {
  4513. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4514. $warehouse = $this->warehouse->read($value['warehouse']);
  4515. $info_list[$key]['warehouse'] = $warehouse['title'];
  4516. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4517. $details = array();
  4518. $cpid = array();
  4519. foreach ($x as $k => $v) {
  4520. if ($v['details'] != '') {
  4521. $details[$v['details']] = $v['details'];
  4522. }
  4523. if ($v['cpid'] != 0) {
  4524. $cpid[$v['cpid']] = $v['cpid'];
  4525. }
  4526. }
  4527. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4528. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4529. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4530. $info_list[$key]['s'] = $s;
  4531. $info_list[$key]['x'] = count($x);
  4532. }
  4533. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4534. $titlename = "<table border=1>
  4535. <tr align='center'>
  4536. <td>仓库</td>
  4537. <td>供应商</td>
  4538. <td>出库位置</td>
  4539. <td>出库编码</td>
  4540. <td>SKU</td>
  4541. <td>产品名</td>
  4542. <td>总剩余库存</td>
  4543. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4544. </tr>
  4545. </table>";
  4546. $filename = $title . ".xls";
  4547. $tail = "";
  4548. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4549. }
  4550. }
  4551. //usps发货清单
  4552. public function _manifest()
  4553. {
  4554. if (isset($_POST['manifest'])) {
  4555. $wltext = $this->input->post('wltext', true);
  4556. $time = time() - 16 * 3600;
  4557. $ptime = strtotime(date('Y-m-d', $time));
  4558. $waybill = array();
  4559. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4560. foreach ($fullorder as $v) {
  4561. $waybill[$v['waybill']] = $v['waybill'];
  4562. }
  4563. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4564. foreach ($fullordersmt as $v) {
  4565. $waybill[$v['waybill']] = $v['waybill'];
  4566. }
  4567. $wltext = explode(';', $wltext);
  4568. foreach ($wltext as $v) {
  4569. if (isset($waybill[$v])) {
  4570. unset($waybill[$v]);
  4571. }
  4572. }
  4573. $data = $this->usps->get_manifest($waybill);
  4574. if (isset($data['Description'])) {
  4575. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4576. exit;
  4577. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4578. $bctime = date('Ymd', time());
  4579. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4580. echo json_encode(array('msg' => $pdf, 'success' => true));
  4581. exit;
  4582. } else {
  4583. echo json_encode(array('msg' => $data, 'success' => false));
  4584. exit;
  4585. }
  4586. }
  4587. }
  4588. public function _pdf($pdf, $title, $bctime)
  4589. {
  4590. $pdf_path = './data/pdf/' . $bctime . '/';
  4591. $file_base64 = $pdf;
  4592. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4593. $file_base64 = base64_decode($file_base64);
  4594. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4595. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4596. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4597. }
  4598. /**
  4599. *
  4600. *
  4601. *
  4602. 进销存占单异常索引
  4603. *
  4604. *
  4605. *
  4606. **/
  4607. public function _abnormal()
  4608. {
  4609. $post = $this->input->post(NULL, TRUE);
  4610. if (isset($post['page'])) {
  4611. $page = $this->input->post('page', true);
  4612. $perpage = $this->input->post('perpage', true);
  4613. $sku = $this->input->post('sku', true);
  4614. $where = "1=1";
  4615. //数据排序
  4616. $order_str = "id desc";
  4617. if (empty($page)) {
  4618. $start = 0;
  4619. $perpage = 1;
  4620. } else {
  4621. $start = ($page - 1) * $perpage;
  4622. }
  4623. //取得信息列表
  4624. $info_list = $this->whlabel->find_all($where, '*');
  4625. $rows = array();
  4626. $list = array();
  4627. foreach ($info_list as $key => $value) {
  4628. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4629. }
  4630. foreach ($rows as $value) {
  4631. $warehouse = $this->warehouse->read($value['warehouse']);
  4632. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4633. $number = $value['number'];
  4634. $ftime = time() - 15 * 24 * 3600;
  4635. if ($value['shop'] != '') {
  4636. $shop = $value['shop'];
  4637. $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');
  4638. $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');
  4639. $order = array_merge($orderdlz, $ordersmt);
  4640. $od = 0;
  4641. $a = '';
  4642. $orid = '';
  4643. foreach ($order as $v) {
  4644. $or = explode('|', ltrim($v['whlabel'], '|'));
  4645. for ($i = 0; $i < count($or); $i++) {
  4646. $orod = explode('-', $or[$i]);
  4647. if ($orod[0] == $number) {
  4648. $od += $orod[1];
  4649. }
  4650. }
  4651. $orid .= $v['number'] . '-';
  4652. }
  4653. } else {
  4654. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4655. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4656. $order = array_merge($orderdlz, $ordersmt);
  4657. $od = 0;
  4658. $a = '';
  4659. $orid = '';
  4660. $qt = array();
  4661. foreach ($order as $v) {
  4662. $or = explode('|', ltrim($v['whlabel'], '|'));
  4663. for ($i = 0; $i < count($or); $i++) {
  4664. $orod = explode('-', $or[$i]);
  4665. if ($orod[0] == $number) {
  4666. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4667. if ($czzs > 0) {
  4668. if (isset($qt[$v['shop']])) {
  4669. if ($qt[$v['shop']] < $orod[1]) {
  4670. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4671. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4672. } else {
  4673. $qt[$v['shop']] -= $orod[1];
  4674. }
  4675. } else {
  4676. $qt[$v['shop']] = $czzs;
  4677. }
  4678. } else {
  4679. $od += $orod[1];
  4680. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4681. }
  4682. }
  4683. }
  4684. }
  4685. }
  4686. $z = $od . '(' . $orid . ')'; //查看订单号
  4687. //$z = $od;
  4688. if ($od > $c) {
  4689. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4690. }
  4691. }
  4692. $listdata = array_slice($list, $start, $perpage);
  4693. $total = count($list);
  4694. $pagenum = ceil($total / $perpage);
  4695. $over = $total - ($start + $perpage);
  4696. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4697. echo json_encode($rows);
  4698. exit;
  4699. }
  4700. $this->_Template('whlabel_abnormal', $this->data);
  4701. }
  4702. /**
  4703. *
  4704. *
  4705. *
  4706. 进销存占单异常索引
  4707. *
  4708. *
  4709. *
  4710. **/
  4711. public function _error()
  4712. {
  4713. $post = $this->input->post(NULL, TRUE);
  4714. if (isset($post['page'])) {
  4715. $page = $this->input->post('page', true);
  4716. $perpage = $this->input->post('perpage', true);
  4717. $sku = $this->input->post('sku', true);
  4718. $warehouse = $this->input->post('warehouse', true);
  4719. $ktime = $this->input->post('ktime', true);
  4720. $jtime = $this->input->post('jtime', true);
  4721. $ktime = strtotime($ktime);
  4722. $jtime = strtotime($jtime);
  4723. $where = "sku != 'Preset'";
  4724. $gj = '';
  4725. if ($sku) {
  4726. $where .= " and sku like '%$sku%'";
  4727. } else {
  4728. if ($ktime && $jtime) {
  4729. $gj = " and time > '$ktime' and time < '$jtime'";
  4730. }
  4731. }
  4732. if ($warehouse) {
  4733. $where .= " and warehouse = '$warehouse'";
  4734. }
  4735. //数据排序
  4736. $order_str = "id desc";
  4737. if (empty($page)) {
  4738. $start = 0;
  4739. $perpage = 1;
  4740. } else {
  4741. $start = ($page - 1) * $perpage;
  4742. }
  4743. //取得信息列表
  4744. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4745. $rows = array();
  4746. $list = array();
  4747. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4748. // foreach ($info_list as $value)
  4749. // {
  4750. // $warehouse = $this->warehouse->read($value['warehouse']);
  4751. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4752. // $number = $value['number'];$ftime = time()-15*24*3600;
  4753. // if($c < 1)
  4754. // {
  4755. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4756. // }
  4757. // }
  4758. $warehouse_list = $this->warehouse->find_all();
  4759. $warehouse_list = array_column($warehouse_list, null, 'id');
  4760. foreach ($info_list as $value) {
  4761. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4762. 'title' => "",
  4763. ];
  4764. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4765. $number = $value['number'];
  4766. $ftime = time() - 15 * 24 * 3600;
  4767. if ($c < 1) {
  4768. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4769. }
  4770. }
  4771. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4772. // $query = $this->db->query($sql);
  4773. // $info_list = $query->result_array();
  4774. // $sql_two = "select title,id from crowd_warehouse";
  4775. // $query_two = $this->db->query($sql_two);
  4776. // $warehouse_list = $query_two->result_array();
  4777. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4778. // foreach ($info_list as $value)
  4779. // {
  4780. // if(isset($warehouse_arr[$value['warehouse']])){
  4781. // $warehouse = $warehouse_arr[$value['warehouse']];
  4782. // }else{
  4783. // $warehouse = [
  4784. // 'id'=>0,
  4785. // 'title'=>"异常",
  4786. // ];
  4787. // }
  4788. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4789. // $number = $value['number'];$ftime = time()-15*24*3600;
  4790. // if($c < 1)
  4791. // {
  4792. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4793. // }
  4794. // }
  4795. $listdata = array_slice($list, $start, $perpage);
  4796. $total = count($list);
  4797. $pagenum = ceil($total / $perpage);
  4798. $over = $total - ($start + $perpage);
  4799. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4800. echo json_encode($rows);
  4801. exit;
  4802. }
  4803. if (isset($post['s'])) {
  4804. $id_arr = $this->input->post('s');
  4805. $id_arr = explode(',', trim($id_arr, ','));
  4806. if (!$id_arr) {
  4807. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4808. exit;
  4809. }
  4810. //循环删除记录
  4811. foreach ($id_arr as $v) {
  4812. $dd = $this->whlabel->read($v);
  4813. if (!isset($dd['id'])) {
  4814. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4815. exit;
  4816. }
  4817. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4818. if (isset($zt[0])) {
  4819. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4820. exit;
  4821. }
  4822. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4823. foreach ($deldd as $vv) {
  4824. $this->whlabel->remove($vv['id']);
  4825. }
  4826. }
  4827. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4828. exit;
  4829. }
  4830. $this->_Template('whlabel_error', $this->data);
  4831. }
  4832. public function _errorexcel()
  4833. {
  4834. $post = $this->input->post(NULL, TRUE);
  4835. if (isset($_GET['page'])) {
  4836. $page = $this->input->get('page', true);
  4837. $perpage = $this->input->get('perpage', true);
  4838. $sku = $this->input->get('sku', true);
  4839. $warehouse = $this->input->get('warehouse', true);
  4840. $ktime = $this->input->get('ktime', true);
  4841. $jtime = $this->input->get('jtime', true);
  4842. $ktime = strtotime($ktime);
  4843. $jtime = strtotime($jtime);
  4844. $where = "sku != 'Preset'";
  4845. $gj = '';
  4846. if ($sku) {
  4847. $where .= " and sku like '%$sku%'";
  4848. } else {
  4849. if ($ktime && $jtime) {
  4850. $gj = " and time > '$ktime' and time < '$jtime'";
  4851. }
  4852. }
  4853. if ($warehouse) {
  4854. $where .= " and warehouse = '$warehouse'";
  4855. }
  4856. //数据排序
  4857. $order_str = "id desc";
  4858. if (empty($page)) {
  4859. $start = 0;
  4860. $perpage = 1;
  4861. } else {
  4862. $start = ($page - 1) * $perpage;
  4863. }
  4864. //取得信息列表
  4865. $rows = array();
  4866. $list = array();
  4867. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4868. foreach ($info_list as $value) {
  4869. $warehouse = $this->warehouse->read($value['warehouse']);
  4870. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4871. $number = $value['number'];
  4872. $ftime = time() - 15 * 24 * 3600;
  4873. if ($c < 1) {
  4874. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4875. }
  4876. }
  4877. $title = "0库存汇总";
  4878. $titlename = "<table border=1>
  4879. <tr align='center'>
  4880. <td>仓库</td>
  4881. <td>SKU</td>
  4882. <td>产品</td>
  4883. <td>当前库存</td>
  4884. </tr>
  4885. </table>";
  4886. $filename = $title . ".xls";
  4887. $tail = "";
  4888. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4889. }
  4890. }
  4891. /**
  4892. *
  4893. *
  4894. * 占单
  4895. *
  4896. *
  4897. **/
  4898. public function _kcyz()
  4899. {
  4900. $post = $this->input->post(NULL, TRUE);
  4901. if (isset($post['warehouse'])) {
  4902. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4903. exit; //不再使用
  4904. $warehouse = $this->input->post('warehouse', true);
  4905. $whlabel = $this->input->post('whlabel', true);
  4906. $id = $this->input->post('id', true);
  4907. $shop = $this->input->post('shop', true);
  4908. $number = $this->input->post('number', true);
  4909. if (!$whlabel || $whlabel == '|') {
  4910. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4911. exit;
  4912. }
  4913. $pp = explode('|', trim($whlabel, '|'));
  4914. $x = 0;
  4915. $save = array();
  4916. foreach ($pp as $va) {
  4917. $num = explode('-', $va);
  4918. if ($number) {
  4919. $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 = '')"); //通用
  4920. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4921. } else {
  4922. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4923. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4924. }
  4925. $x++;
  4926. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4927. $save[] = $x - 1;
  4928. continue; //提前先加X不然出错,所以要减1
  4929. }
  4930. }
  4931. if (isset($save[0])) {
  4932. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4933. exit;
  4934. } else {
  4935. echo json_encode(array('success' => true));
  4936. exit;
  4937. }
  4938. }
  4939. }
  4940. public function _db()
  4941. {
  4942. $post = $this->input->post(NULL, TRUE);
  4943. if (isset($post['page'])) {
  4944. $page = $this->input->post('page', true);
  4945. $perpage = $this->input->post('perpage', true);
  4946. $sku = $this->input->post('sku', true);
  4947. $number = $this->input->post('number', true);
  4948. $warehouse = $this->input->post('warehouse', true);
  4949. $purchase = $this->input->post('purchase', true);
  4950. $orderinfo = $this->input->post('orderinfo', true);
  4951. $waybill = $this->input->post('waybill', true);
  4952. $category = $this->input->post('category', true);
  4953. $size = $this->input->post('size', true);
  4954. $grade = $this->input->post('grade', true);
  4955. $color = $this->input->post('color', true);
  4956. $lowe = $this->input->post('lowe', true);
  4957. $state = $this->input->post('state', true);
  4958. $label = $this->input->post('label', true);
  4959. $timetk = $this->input->post('timetkk', true);
  4960. $timetj = $this->input->post('timetjj', true);
  4961. $timetk = strtotime($timetk);
  4962. $timetj = strtotime($timetj);
  4963. $where = "dbtime > 0";
  4964. if ($timetk && $timetj) {
  4965. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4966. }
  4967. if ($sku) {
  4968. $where .= " and sku = '$sku'";
  4969. }
  4970. if ($warehouse) {
  4971. $where .= " and warehouse = '$warehouse'";
  4972. if ($warehouse == 12) {
  4973. $w = 'specialstock';
  4974. } else {
  4975. $w = 'whlabel';
  4976. }
  4977. }
  4978. if ($purchase) {
  4979. $where .= " and purchase = '$purchase'";
  4980. }
  4981. if ($category) {
  4982. $where .= " and features like '%-$category-%'";
  4983. }
  4984. if ($size) {
  4985. $where .= " and features like '%-$size-%'";
  4986. }
  4987. if ($grade) {
  4988. $where .= " and features like '%-$grade-%'";
  4989. }
  4990. if ($color) {
  4991. $where .= " and features like '%-$color-%'";
  4992. }
  4993. if ($lowe) {
  4994. $where .= " and features like '%-$lowe-%'";
  4995. }
  4996. if ($state != '') {
  4997. $where .= " and state = '$state'";
  4998. }
  4999. //数据排序
  5000. $order_str = "dbtime desc";
  5001. if (empty($page)) {
  5002. $start = 0;
  5003. $perpage = 1;
  5004. } else {
  5005. $start = ($page - 1) * $perpage;
  5006. }
  5007. //取得信息列表
  5008. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5009. foreach ($info_list as $key => $value) {
  5010. $warehouse = $this->$w->read($value['warehouse']);
  5011. $info_list[$key]['warehouse'] = $warehouse['title'];
  5012. $purchase = $this->purchase->read($value['purchase']);
  5013. $info_list[$key]['purchase'] = $purchase['title'];
  5014. if ($value['enter'] != 0) {
  5015. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5016. } else {
  5017. $info_list[$key]['enter'] = "";
  5018. }
  5019. if ($value['dbtime'] != 0) {
  5020. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5021. } else {
  5022. $info_list[$key]['dbtime'] = "";
  5023. }
  5024. if ($value['state'] == 0) {
  5025. $info_list[$key]['state'] = "在库";
  5026. } else if ($value['state'] == 1) {
  5027. $info_list[$key]['state'] = "出库";
  5028. } else if ($value['state'] == 2) {
  5029. $info_list[$key]['state'] = "退库";
  5030. } else if ($value['state'] == 3) {
  5031. $info_list[$key]['state'] = "调拨中";
  5032. } else if ($value['state'] == 4) {
  5033. $info_list[$key]['state'] = "再加工";
  5034. } else if ($value['state'] == 5) {
  5035. $info_list[$key]['state'] = "维修中";
  5036. } else if ($value['state'] == 6) {
  5037. $info_list[$key]['state'] = "盘亏";
  5038. } else if ($value['state'] == 7) {
  5039. $info_list[$key]['state'] = "更换标签";
  5040. } else if ($value['state'] == 8) {
  5041. $info_list[$key]['state'] = "其它";
  5042. } else if ($value['state'] == 9) {
  5043. $info_list[$key]['state'] = "预设";
  5044. }
  5045. }
  5046. $total = $this->whlabel->find_count($where);
  5047. $pagenum = ceil($total / $perpage);
  5048. $over = $total - ($start + $perpage);
  5049. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5050. echo json_encode($rows);
  5051. exit;
  5052. }
  5053. if (isset($post['outsku'])) {
  5054. $time = time();
  5055. $cz = $this->input->post('cz', true);
  5056. $label = $this->input->post('outsku', true);
  5057. $sl = $this->input->post('sl', true);
  5058. $num = $this->input->post('num', true);
  5059. //$warehouse = $this->input->post('warehouse',true);
  5060. if (!$sl) {
  5061. $sl = 1;
  5062. }
  5063. if (!$warehouse) {
  5064. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5065. exit;
  5066. }
  5067. $dblabel = $this->whlabellabel->get_label($label);
  5068. if ($dblabel) {
  5069. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5070. if (count($data) < 1) {
  5071. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5072. exit;
  5073. }
  5074. if (count($data) < $num) {
  5075. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5076. exit;
  5077. }
  5078. for ($i = 0; $i < $sl; $i++) {
  5079. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5080. }
  5081. echo json_encode(array('success' => true));
  5082. exit;
  5083. } else {
  5084. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5085. exit;
  5086. }
  5087. }
  5088. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5089. $this->_Template('whlabel_db', $this->data);
  5090. }
  5091. public function _dbrk()
  5092. {
  5093. $post = $this->input->post(NULL, TRUE);
  5094. if (isset($post['page'])) {
  5095. $page = $this->input->post('page', true);
  5096. $perpage = $this->input->post('perpage', true);
  5097. $sku = $this->input->post('sku', true);
  5098. $number = $this->input->post('number', true);
  5099. $warehouse = $this->input->post('warehouse', true);
  5100. $purchase = $this->input->post('purchase', true);
  5101. $orderinfo = $this->input->post('orderinfo', true);
  5102. $waybill = $this->input->post('waybill', true);
  5103. $category = $this->input->post('category', true);
  5104. $size = $this->input->post('size', true);
  5105. $grade = $this->input->post('grade', true);
  5106. $color = $this->input->post('color', true);
  5107. $lowe = $this->input->post('lowe', true);
  5108. $state = $this->input->post('state', true);
  5109. $label = $this->input->post('label', true);
  5110. $ctime = $this->input->post('ctime', true);
  5111. $timetk = $this->input->post('timetkk', true);
  5112. $timetj = $this->input->post('timetjj', true);
  5113. $timetk = strtotime($timetk);
  5114. $timetj = strtotime($timetj);
  5115. $where = "dbtime > 0";
  5116. if ($timetk && $timetj) {
  5117. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5118. }
  5119. if ($sku) {
  5120. $where .= " and sku = '$sku'";
  5121. }
  5122. if ($warehouse) {
  5123. $where .= " and warehouse = '$warehouse'";
  5124. }
  5125. if ($purchase) {
  5126. $where .= " and purchase = '$purchase'";
  5127. }
  5128. if ($category) {
  5129. $where .= " and features like '%-$category-%'";
  5130. }
  5131. if ($size) {
  5132. $where .= " and features like '%-$size-%'";
  5133. }
  5134. if ($grade) {
  5135. $where .= " and features like '%-$grade-%'";
  5136. }
  5137. if ($color) {
  5138. $where .= " and features like '%-$color-%'";
  5139. }
  5140. if ($lowe) {
  5141. $where .= " and features like '%-$lowe-%'";
  5142. }
  5143. if ($state != '') {
  5144. $where .= " and state = '$state'";
  5145. }
  5146. //数据排序
  5147. $order_str = "dbtime desc";
  5148. if (empty($page)) {
  5149. $start = 0;
  5150. $perpage = 1;
  5151. } else {
  5152. $start = ($page - 1) * $perpage;
  5153. }
  5154. //取得信息列表
  5155. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5156. foreach ($info_list as $key => $value) {
  5157. $warehouse = $this->warehouse->read($value['warehouse']);
  5158. $info_list[$key]['warehouse'] = $warehouse['title'];
  5159. $purchase = $this->purchase->read($value['purchase']);
  5160. $info_list[$key]['purchase'] = $purchase['title'];
  5161. if ($value['enter'] != 0) {
  5162. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5163. } else {
  5164. $info_list[$key]['enter'] = "";
  5165. }
  5166. if ($value['dbtime'] != 0) {
  5167. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5168. } else {
  5169. $info_list[$key]['dbtime'] = "";
  5170. }
  5171. if ($value['state'] == 0) {
  5172. $info_list[$key]['state'] = "在库";
  5173. } else if ($value['state'] == 1) {
  5174. $info_list[$key]['state'] = "出库";
  5175. } else if ($value['state'] == 2) {
  5176. $info_list[$key]['state'] = "退库";
  5177. } else if ($value['state'] == 3) {
  5178. $info_list[$key]['state'] = "调拨中";
  5179. } else if ($value['state'] == 4) {
  5180. $info_list[$key]['state'] = "再加工";
  5181. } else if ($value['state'] == 5) {
  5182. $info_list[$key]['state'] = "维修中";
  5183. } else if ($value['state'] == 6) {
  5184. $info_list[$key]['state'] = "盘亏";
  5185. } else if ($value['state'] == 7) {
  5186. $info_list[$key]['state'] = "更换标签";
  5187. } else if ($value['state'] == 8) {
  5188. $info_list[$key]['state'] = "其它";
  5189. } else if ($value['state'] == 9) {
  5190. $info_list[$key]['state'] = "预设";
  5191. }
  5192. }
  5193. $total = $this->whlabel->find_count($where);
  5194. $pagenum = ceil($total / $perpage);
  5195. $over = $total - ($start + $perpage);
  5196. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5197. echo json_encode($rows);
  5198. exit;
  5199. }
  5200. if (isset($post['rsku'])) {
  5201. $cz = $this->input->post('cz', true);
  5202. $label = $this->input->post('rsku', true);
  5203. $sl = $this->input->post('sl', true);
  5204. $warehouse = $this->input->post('warehouse', true);
  5205. if (!$sl) {
  5206. $sl = 1;
  5207. }
  5208. if (!$warehouse) {
  5209. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5210. exit;
  5211. }
  5212. $dblabel = $this->whlabellabel->get_label($label);
  5213. if ($dblabel) {
  5214. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5215. if (count($data) < 1) {
  5216. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5217. exit;
  5218. }
  5219. if ($sl > count($data)) {
  5220. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5221. exit;
  5222. }
  5223. $time = time();
  5224. for ($i = 0; $i < $sl; $i++) {
  5225. $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']);
  5226. }
  5227. echo json_encode(array('success' => true));
  5228. exit;
  5229. } else {
  5230. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5231. exit;
  5232. }
  5233. }
  5234. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5235. $this->_Template('whlabel_dbrk', $this->data);
  5236. }
  5237. public function _whlabelczdc()
  5238. {
  5239. if (isset($_GET['excel'])) {
  5240. //数据排序
  5241. $order_str = "id desc";
  5242. if (empty($page)) {
  5243. $start = 0;
  5244. $perpage = 1;
  5245. } else {
  5246. $start = ($page - 1) * $perpage;
  5247. }
  5248. $state = $this->input->get('state', true);
  5249. $sku = $this->input->get('sku', true);
  5250. $ctime = $this->input->get('ctime', true);
  5251. $category = $this->input->get('category', true);
  5252. $size = $this->input->get('size', true);
  5253. $grade = $this->input->get('grade', true);
  5254. $color = $this->input->get('color', true);
  5255. $lowe = $this->input->get('lowe', true);
  5256. $timetk = $this->input->get('timetkk', true);
  5257. $timetj = $this->input->get('timetjj', true);
  5258. $timetk = strtotime($timetk);
  5259. $timetj = strtotime($timetj);
  5260. $where = "dbtime > 0";
  5261. if ($timetk && $timetj) {
  5262. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5263. }
  5264. if ($category) {
  5265. $where .= " and features like '%-$category-%'";
  5266. }
  5267. if ($size) {
  5268. $where .= " and features like '%-$size-%'";
  5269. }
  5270. if ($grade) {
  5271. $where .= " and features like '%-$grade-%'";
  5272. }
  5273. if ($color) {
  5274. $where .= " and features like '%-$color-%'";
  5275. }
  5276. if ($lowe) {
  5277. $where .= " and features like '%-$lowe-%'";
  5278. }
  5279. //取得信息列表
  5280. $info_list = $this->whlabel->find_all($where, '*');
  5281. $rows = array();
  5282. $list = array();
  5283. foreach ($info_list as $key => $value) {
  5284. $rows[$value['sku']] = $value; //所有数据sku
  5285. }
  5286. foreach ($rows as $value) {
  5287. $warehouse = $this->warehouse->read($value['warehouse']);
  5288. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5289. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5290. if ($value['orderinfo'] == 0) {
  5291. $info_list[$key]['orderinfo'] = "";
  5292. }
  5293. if ($value['waybill'] == 0) {
  5294. $info_list[$key]['waybill'] = "";
  5295. }
  5296. if ($value['state'] == 0) {
  5297. $value['state'] = "在库";
  5298. } else if ($value['state'] == 3) {
  5299. $value['state'] = "调拨中";
  5300. }
  5301. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5302. }
  5303. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5304. $titlename = "<table border=1>
  5305. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5306. <tr align='center'>
  5307. <td>SKU</td>
  5308. <td>产品</td>
  5309. <td>调拨数量</td>
  5310. <td>入库数量</td>
  5311. </tr>
  5312. </table>";
  5313. $filename = $title . ".xls";
  5314. $tail = "";
  5315. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5316. }
  5317. }
  5318. public function _print($arg_array)
  5319. {
  5320. if (isset($_SESSION['api'])) {
  5321. $user = $this->user->get_api($_SESSION['api']);
  5322. $usp = $user;
  5323. $fgshop = "";
  5324. $sid = "";
  5325. $wid = "";
  5326. $wtype = "";
  5327. $usersp = explode('|', trim($user['shop'], '|'));
  5328. $userwh = explode('|', trim($user['warehouse'], '|'));
  5329. foreach ($usersp as $value) {
  5330. $fgshop .= " shop = " . $value . " or";
  5331. $sid .= " id = " . $value . " or";
  5332. }
  5333. foreach ($userwh as $value) {
  5334. $wid .= " id = " . $value . " or";
  5335. $wtype .= " type = " . $value . " or";
  5336. }
  5337. }
  5338. $post = $this->input->post(NULL, TRUE);
  5339. if (isset($post['tmsku'])) {
  5340. $tmsku = $this->input->post('tmsku', true);
  5341. if (is_numeric($tmsku)) {
  5342. $yyh = $this->whlabellabel->get_label($tmsku);
  5343. } else {
  5344. $yyh = $this->whlabellabel->get_sku($tmsku);
  5345. }
  5346. if ($yyh) {
  5347. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5348. exit;
  5349. } else {
  5350. echo json_encode(array('success' => false));
  5351. exit;
  5352. }
  5353. }
  5354. $classid = $this->classid->sku();
  5355. $pm = $classid;
  5356. $scsku = $classid;
  5357. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5358. if (isset($post['warehouse'])) {
  5359. if ($post['warehouse']) {
  5360. $list = array();
  5361. $num = "";
  5362. $title = "";
  5363. $features = "";
  5364. $order = 0;
  5365. $post['shop'] = '';
  5366. $brand = $this->input->post('brand', true);
  5367. if ($brand != '0,') {
  5368. $b = $this->brand->read(rtrim($brand, ','));
  5369. if ($b) {
  5370. $post['shop'] = str_replace('|', ',', $b['shop']);
  5371. }
  5372. }
  5373. $post['details'] = $this->input->post('details', true); //打印数量
  5374. $xbqnum = $this->input->post('xbqnum', true);
  5375. $post['purchase'] = $this->input->post('purchase', true);
  5376. $post['warehouse'] = $this->input->post('warehouse', true);
  5377. $post['purchase'] = $this->input->post('purchase', true);
  5378. $post['retreatwarehouse'] = $post['warehouse'];
  5379. $post['cpbz'] = $this->input->post('cpbz', true);
  5380. $post['state'] = 9;
  5381. $category = $this->input->post('category', true);
  5382. $list['category'] = $category;
  5383. $list['hairtype'] = $this->input->post('hairtype', true);
  5384. $list['grade'] = $this->input->post('grade', true);
  5385. $size = $this->input->post('size', true);
  5386. $list['size'] = rtrim($size, ',');
  5387. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5388. $list['extension'] = $this->input->post('extension', true);
  5389. if ($category == 1297) {
  5390. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5391. }
  5392. if ($category == 1702) {
  5393. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5394. $list['syother'] = $this->input->post('syother', true);
  5395. }
  5396. if ($category == 133) {
  5397. $list['fittype'] = $this->input->post('fittype', true);
  5398. $list['acother'] = $this->input->post('acother', true);
  5399. }
  5400. $list['color'] = $this->input->post('color', true);
  5401. $list['lowe'] = $this->input->post('lowe', true);
  5402. if ($category == 127) {
  5403. $list['type'] = $this->input->post('type', true);
  5404. $list['headroad'] = $this->input->post('headroad', true);
  5405. $list['density'] = $this->input->post('density', true);
  5406. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5407. $list['lacesize'] = $this->input->post('lacesize', true);
  5408. }
  5409. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5410. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5411. }
  5412. if ($category == 128) {
  5413. $list['lacetype'] = $this->input->post('lacetype', true);
  5414. $list['haircap'] = $this->input->post('haircap', true);
  5415. $list['density'] = $this->input->post('density', true);
  5416. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5417. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5418. $list['wigother'] = $this->input->post('wigother', true);
  5419. $list['wigother1'] = $this->input->post('wigother1', true);
  5420. $list['wigother2'] = $this->input->post('wigother2', true);
  5421. }
  5422. if ($category == 129) {
  5423. $list['wide'] = $this->input->post('wide', true);
  5424. }
  5425. if ($category == 131) {
  5426. $list['gifttype'] = $this->input->post('gifttype', true);
  5427. $list['giftother'] = $this->input->post('giftother', true);
  5428. }
  5429. if ($category == 134) {
  5430. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5431. }
  5432. if ($category == 1297) {
  5433. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5434. $list['sywigother'] = $this->input->post('sywigother', true);
  5435. }
  5436. if ($category == 130 || $category == 133 || $category == 1702) {
  5437. $list['items'] = $this->input->post('items', true);
  5438. $list['weight'] = $this->input->post('weight', true);
  5439. }
  5440. if ($category == 1702) {
  5441. $list['syhairther'] = $this->input->post('syhairther', true);
  5442. }
  5443. foreach ($list as $k => $v) {
  5444. if ($v != 0) {
  5445. $num .= $v;
  5446. $features .= $v . '-';
  5447. $post[$k] = $v;
  5448. $typeclass = $this->typeclass->read($v);
  5449. if (isset($pm[$typeclass['classid']])) {
  5450. if (stripos($typeclass['zh'], '|') !== false) {
  5451. $exzh = explode('|', $typeclass['zh']);
  5452. $pm[$typeclass['classid']] = $exzh[0];
  5453. } else {
  5454. $pm[$typeclass['classid']] = $typeclass['zh'];
  5455. }
  5456. }
  5457. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5458. if ($k != 'size') {
  5459. $title .= $typeclass['title'] . " ";
  5460. }
  5461. }
  5462. }
  5463. $typeclass = $this->typeclass->read($list['size']);
  5464. $title .= $typeclass['title'];
  5465. $time = time();
  5466. $post['title'] = rtrim($title, ' ');
  5467. $post['number'] = $num;
  5468. $post['features'] = '-' . $features;
  5469. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5470. $featurespp = explode('-', trim($featurespp, '-'));
  5471. if (isset($featurespp[5])) {
  5472. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5473. } else {
  5474. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5475. }
  5476. $post['enter'] = $time;
  5477. $post['time'] = $time; //操作时间
  5478. $scsku = implode("-", $scsku);
  5479. $zh = implode(" ", $pm);
  5480. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5481. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5482. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5483. $post['sku'] = $bqsku;
  5484. $label = time() . rand(0, 9);
  5485. $post['label'] = $label;
  5486. $cpid = $this->whlabellabel->find_count();
  5487. $post['cpid'] = $cpid + 1;
  5488. $cpid = $post['cpid'];
  5489. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5490. //if($whlabelbarcode)
  5491. //{
  5492. //$post['label'] = $whlabelbarcode['label'];
  5493. //if(!$this->whlabellabel->insert($post))
  5494. //{
  5495. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5496. //}
  5497. //}
  5498. //else
  5499. //{
  5500. $this->db->trans_begin();
  5501. $this->whlabellabel->insert($post);
  5502. //$this->whlabelbarcode->insert($post);
  5503. if ($this->db->trans_status() === TRUE) {
  5504. $this->db->trans_commit();
  5505. } else {
  5506. $this->db->trans_rollback();
  5507. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5508. exit;
  5509. }
  5510. //}
  5511. $warehouse_name = "";
  5512. $warehouse = $post['warehouse'];
  5513. if($warehouse == 12){
  5514. $warehouse_name = "特殊库存库";
  5515. }
  5516. // if($warehouse == 13){
  5517. // $warehouse_name = "许昌仓";
  5518. // }
  5519. // if($warehouse == 5){
  5520. // $warehouse_name = "美国店";
  5521. // }
  5522. // if($warehouse == 16){
  5523. // $warehouse_name = "定制头套仓";
  5524. // }
  5525. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5526. if(!empty($warehouse_name)){
  5527. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5528. }
  5529. $purchase = $this->purchase->read($post['purchase']);
  5530. 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));
  5531. exit; //特殊仓目前不需要仓库选项
  5532. }
  5533. }
  5534. if (isset($_SESSION['api'])) {
  5535. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5536. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5537. $this->data['wlshop'] = $wlshop;
  5538. $this->data['warehouse'] = $warehouse;
  5539. }
  5540. $whlabelwz = $this->whlabelwz->find_all();
  5541. $this->data['whlabelwz'] = $whlabelwz;
  5542. $this->_Template('whlabel_print', $this->data);
  5543. }
  5544. public function _usaprint($arg_array)
  5545. {
  5546. if (isset($_SESSION['api'])) {
  5547. $user = $this->user->get_api($_SESSION['api']);
  5548. $usp = $user;
  5549. $fgshop = "";
  5550. $sid = "";
  5551. $wid = "";
  5552. $wtype = "";
  5553. $usersp = explode('|', trim($user['shop'], '|'));
  5554. $userwh = explode('|', trim($user['warehouse'], '|'));
  5555. foreach ($usersp as $value) {
  5556. $fgshop .= " shop = " . $value . " or";
  5557. $sid .= " id = " . $value . " or";
  5558. }
  5559. foreach ($userwh as $value) {
  5560. $wid .= " id = " . $value . " or";
  5561. $wtype .= " type = " . $value . " or";
  5562. }
  5563. }
  5564. $post = $this->input->post(NULL, TRUE);
  5565. if (isset($post['tmsku'])) {
  5566. $tmsku = $this->input->post('tmsku', true);
  5567. if (is_numeric($tmsku)) {
  5568. $yyh = $this->whlabellabel->get_label($tmsku);
  5569. } else {
  5570. $yyh = $this->whlabellabel->get_sku($tmsku);
  5571. }
  5572. if ($yyh) {
  5573. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5574. exit;
  5575. } else {
  5576. echo json_encode(array('success' => false));
  5577. exit;
  5578. }
  5579. }
  5580. $classid = $this->classid->sku();
  5581. $pm = $classid;
  5582. $scsku = $classid;
  5583. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5584. if (isset($post['warehouse'])) {
  5585. if ($post['warehouse']) {
  5586. $list = array();
  5587. $num = "";
  5588. $title = "";
  5589. $features = "";
  5590. $order = 0;
  5591. $post['shop'] = '';
  5592. $brand = $this->input->post('brand', true);
  5593. if ($brand != '0,') {
  5594. $b = $this->brand->read(rtrim($brand, ','));
  5595. if ($b) {
  5596. $post['shop'] = str_replace('|', ',', $b['shop']);
  5597. }
  5598. }
  5599. $post['details'] = $this->input->post('details', true); //打印数量
  5600. $xbqnum = $this->input->post('xbqnum', true);
  5601. $post['purchase'] = $this->input->post('purchase', true);
  5602. $post['warehouse'] = $this->input->post('warehouse', true);
  5603. $post['purchase'] = $this->input->post('purchase', true);
  5604. $post['retreatwarehouse'] = $post['warehouse'];
  5605. $post['cpbz'] = $this->input->post('cpbz', true);
  5606. $post['state'] = 9;
  5607. $category = $this->input->post('category', true);
  5608. $list['category'] = $category;
  5609. $list['hairtype'] = $this->input->post('hairtype', true);
  5610. $list['grade'] = $this->input->post('grade', true);
  5611. $size = $this->input->post('size', true);
  5612. $list['size'] = rtrim($size, ',');
  5613. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5614. $list['extension'] = $this->input->post('extension', true);
  5615. if ($category == 1297) {
  5616. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5617. }
  5618. if ($category == 1702) {
  5619. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5620. $list['syother'] = $this->input->post('syother', true);
  5621. }
  5622. if ($category == 133) {
  5623. $list['fittype'] = $this->input->post('fittype', true);
  5624. $list['acother'] = $this->input->post('acother', true);
  5625. }
  5626. $list['color'] = $this->input->post('color', true);
  5627. $list['lowe'] = $this->input->post('lowe', true);
  5628. if ($category == 127) {
  5629. $list['type'] = $this->input->post('type', true);
  5630. $list['headroad'] = $this->input->post('headroad', true);
  5631. $list['density'] = $this->input->post('density', true);
  5632. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5633. $list['lacesize'] = $this->input->post('lacesize', true);
  5634. }
  5635. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5636. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5637. }
  5638. if ($category == 128) {
  5639. $list['lacetype'] = $this->input->post('lacetype', true);
  5640. $list['haircap'] = $this->input->post('haircap', true);
  5641. $list['density'] = $this->input->post('density', true);
  5642. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5643. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5644. $list['wigother'] = $this->input->post('wigother', true);
  5645. $list['wigother1'] = $this->input->post('wigother1', true);
  5646. $list['wigother2'] = $this->input->post('wigother2', true);
  5647. }
  5648. if ($category == 129) {
  5649. $list['wide'] = $this->input->post('wide', true);
  5650. }
  5651. if ($category == 131) {
  5652. $list['gifttype'] = $this->input->post('gifttype', true);
  5653. $list['giftother'] = $this->input->post('giftother', true);
  5654. }
  5655. if ($category == 134) {
  5656. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5657. }
  5658. if ($category == 1297) {
  5659. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5660. $list['sywigother'] = $this->input->post('sywigother', true);
  5661. }
  5662. if ($category == 130 || $category == 133 || $category == 1702) {
  5663. $list['items'] = $this->input->post('items', true);
  5664. $list['weight'] = $this->input->post('weight', true);
  5665. }
  5666. if ($category == 1702) {
  5667. $list['syhairther'] = $this->input->post('syhairther', true);
  5668. }
  5669. foreach ($list as $k => $v) {
  5670. if ($v != 0) {
  5671. $num .= $v;
  5672. $features .= $v . '-';
  5673. $post[$k] = $v;
  5674. $typeclass = $this->typeclass->read($v);
  5675. if (isset($pm[$typeclass['classid']])) {
  5676. if (stripos($typeclass['zh'], '|') !== false) {
  5677. $exzh = explode('|', $typeclass['zh']);
  5678. $pm[$typeclass['classid']] = $exzh[0];
  5679. } else {
  5680. $pm[$typeclass['classid']] = $typeclass['zh'];
  5681. }
  5682. }
  5683. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5684. if ($k != 'size') {
  5685. $title .= $typeclass['title'] . " ";
  5686. }
  5687. }
  5688. }
  5689. $typeclass = $this->typeclass->read($list['size']);
  5690. $title .= $typeclass['title'];
  5691. $time = time();
  5692. $post['title'] = rtrim($title, ' ');
  5693. $post['number'] = $num;
  5694. $post['features'] = '-' . $features;
  5695. $fp = $this->whlabel->get_features($post['features']);
  5696. if (!$fp) {
  5697. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5698. exit;
  5699. }
  5700. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5701. $featurespp = explode('-', trim($featurespp, '-'));
  5702. if (isset($featurespp[5])) {
  5703. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5704. } else {
  5705. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5706. }
  5707. $post['enter'] = $time;
  5708. $post['time'] = $time; //操作时间
  5709. $scsku = implode("-", $scsku);
  5710. $zh = implode(" ", $pm);
  5711. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5712. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5713. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5714. $post['sku'] = $fp['sku'];
  5715. $post['label'] = $fp['sku'];
  5716. $cpid = $this->whlabellabel->find_count();
  5717. $post['cpid'] = $cpid + 1;
  5718. $cpid = $post['cpid'];
  5719. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5720. //if($whlabelbarcode)
  5721. //{
  5722. //$post['label'] = $whlabelbarcode['label'];
  5723. //if(!$this->whlabellabel->insert($post))
  5724. //{
  5725. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5726. //}
  5727. //}
  5728. //else
  5729. //{
  5730. $this->db->trans_begin();
  5731. $this->whlabellabel->insert($post);
  5732. //$this->whlabelbarcode->insert($post);
  5733. if ($this->db->trans_status() === TRUE) {
  5734. $this->db->trans_commit();
  5735. } else {
  5736. $this->db->trans_rollback();
  5737. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5738. exit;
  5739. }
  5740. //}
  5741. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5742. $purchase = $this->purchase->read($post['purchase']);
  5743. 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));
  5744. exit; //特殊仓目前不需要仓库选项
  5745. }
  5746. }
  5747. if (isset($_SESSION['api'])) {
  5748. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5749. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5750. $this->data['wlshop'] = $wlshop;
  5751. $this->data['warehouse'] = $warehouse;
  5752. }
  5753. $whlabelwz = $this->whlabelwz->find_all();
  5754. $this->data['whlabelwz'] = $whlabelwz;
  5755. $this->_Template('whlabel_usaprint', $this->data);
  5756. }
  5757. public function _printrk($arg_array)
  5758. {
  5759. $prc = array();
  5760. $purchase = $this->purchase->find_all();
  5761. foreach ($purchase as $k => $v) {
  5762. $prc[$v['id']] = $v['title'];
  5763. }
  5764. $post = $this->input->post(NULL, TRUE);
  5765. if (isset($post['page'])) {
  5766. $page = $this->input->post('page', true);
  5767. $perpage = $this->input->post('perpage', true);
  5768. $sku = $this->input->post('sku', true);
  5769. $bs = $this->input->post('bs', true);
  5770. $number = $this->input->post('number', true);
  5771. $warehouse = $this->input->post('warehouse', true);
  5772. $purchase = $this->input->post('purchase', true);
  5773. $orderinfo = $this->input->post('orderinfo', true);
  5774. $waybill = $this->input->post('waybill', true);
  5775. $category = $this->input->post('category', true);
  5776. $size = $this->input->post('size', true);
  5777. $grade = $this->input->post('grade', true);
  5778. $color = $this->input->post('color', true);
  5779. $lowe = $this->input->post('lowe', true);
  5780. $state = $this->input->post('state', true);
  5781. $label = $this->input->post('label', true);
  5782. $timetk = $this->input->post('ktime', true);
  5783. $timetj = $this->input->post('jtime', true);
  5784. $timetk = strtotime($timetk);
  5785. $timetj = strtotime($timetj);
  5786. $where = "1=1 ";
  5787. if ($timetk && $timetj) {
  5788. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5789. }
  5790. if ($sku) {
  5791. $where .= " and sku = '$sku'";
  5792. }
  5793. if ($bs != '') {
  5794. $where .= " and bs = '$bs'";
  5795. }
  5796. if ($number) {
  5797. $where .= " and number = '$number'";
  5798. }
  5799. if ($warehouse) {
  5800. $where .= " and warehouse = '$warehouse'";
  5801. }
  5802. if ($purchase) {
  5803. $where .= " and purchase = '$purchase'";
  5804. }
  5805. if ($orderinfo) {
  5806. $where .= " and orderinfo = '$orderinfo'";
  5807. }
  5808. if ($waybill) {
  5809. $where .= " and waybill = '$waybill'";
  5810. }
  5811. if ($category) {
  5812. $where .= " and features like '%-$category-%'";
  5813. }
  5814. if ($size) {
  5815. $where .= " and features like '%-$size-%'";
  5816. }
  5817. if ($grade) {
  5818. $where .= " and features like '%-$grade-%'";
  5819. }
  5820. if ($color) {
  5821. $where .= " and features like '%-$color-%'";
  5822. }
  5823. if ($lowe) {
  5824. $where .= " and features like '%-$lowe-%'";
  5825. }
  5826. if ($label) {
  5827. $where .= " and label = '$label'";
  5828. }
  5829. if ($state || $state == 0) {
  5830. $where .= " and state = '$state'";
  5831. }
  5832. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5833. //数据排序
  5834. $order_str = "enter desc";
  5835. if (empty($page)) {
  5836. $start = 0;
  5837. $perpage = 1;
  5838. } else {
  5839. $start = ($page - 1) * $perpage;
  5840. }
  5841. //取得信息列表
  5842. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5843. foreach ($info_list as $key => $value) {
  5844. $warehouse = $this->warehouse->read($value['warehouse']);
  5845. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5846. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5847. if ($value['state'] == 0) {
  5848. $info_list[$key]['state'] = "在库";
  5849. } else if ($value['state'] == 1) {
  5850. $info_list[$key]['state'] = "出库";
  5851. } else if ($value['state'] == 2) {
  5852. $info_list[$key]['state'] = "退库";
  5853. } else if ($value['state'] == 3) {
  5854. $info_list[$key]['state'] = "调拨中";
  5855. } else if ($value['state'] == 4) {
  5856. $info_list[$key]['state'] = "再加工";
  5857. } else if ($value['state'] == 5) {
  5858. $info_list[$key]['state'] = "维修中";
  5859. } else if ($value['state'] == 6) {
  5860. $info_list[$key]['state'] = "盘亏";
  5861. } else if ($value['state'] == 7) {
  5862. $info_list[$key]['state'] = "更换标签";
  5863. } else if ($value['state'] == 8) {
  5864. $info_list[$key]['state'] = "其它";
  5865. } else if ($value['state'] == 9) {
  5866. $info_list[$key]['state'] = "预设";
  5867. } else if ($value['state'] == 10) {
  5868. $info_list[$key]['state'] = "美店零售";
  5869. }
  5870. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5871. }
  5872. $total = $this->$ck->find_count($where);
  5873. $pagenum = ceil($total / $perpage);
  5874. $over = $total - ($start + $perpage);
  5875. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5876. echo json_encode($rows);
  5877. exit;
  5878. }
  5879. if (isset($post['tmsku'])) {
  5880. $time = time();
  5881. $tmsku = $this->input->post('tmsku', true);
  5882. //$post['shop'] = $this->input->post('shop',true);
  5883. $num = $this->input->post('num', true);
  5884. $rktype = $this->input->post('rktype', true);
  5885. if ($num > 200) {
  5886. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5887. exit;
  5888. }
  5889. if (!$rktype) {
  5890. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5891. }
  5892. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5893. /**
  5894. $wz = array();
  5895. foreach ($rk as $key=>$value)
  5896. {
  5897. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5898. }
  5899. if(count($wz) > 1)
  5900. {
  5901. $wz = array_values($wz);
  5902. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5903. }
  5904. **/
  5905. if (isset($rk[0]['purchase'])) {
  5906. $rk = $rk[0];
  5907. $j = 0;
  5908. $post['purchase'] = $rk['purchase'];
  5909. $post['warehouse'] = $rk['warehouse'];
  5910. $post['retreatwarehouse'] = $rk['warehouse'];
  5911. $post['sku'] = $rk['sku'];
  5912. $post['number'] = $rk['number'];
  5913. $post['features'] = $rk['features'];
  5914. $post['title'] = $rk['title'];
  5915. $post['enter'] = $time;
  5916. $post['time'] = $time;
  5917. $post['bs'] = 1;
  5918. $post['shop'] = $rk['shop'];
  5919. $post['details'] = $rk['details'];
  5920. $post['cpid'] = $rk['cpid'];
  5921. $post['cpbz'] = $rk['cpbz'];
  5922. //$post['rktype'] = $rktype;
  5923. $warehouse = $this->warehouse->read($rk['warehouse']);
  5924. if ($warehouse['bdck'] == '') {
  5925. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5926. exit;
  5927. } else {
  5928. $bdck = $warehouse['bdck'];
  5929. }
  5930. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5931. if (isset($pdwz['details'])) {
  5932. if ($pdwz['details'] != $post['details']) {
  5933. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5934. exit;
  5935. }
  5936. }
  5937. $post['featurespp'] = $rk['featurespp'];
  5938. if ($post['warehouse'] == '5') {
  5939. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5940. if ($yza) {
  5941. if ($post['features'] != $yza[0]['features']) {
  5942. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5943. exit;
  5944. }
  5945. }
  5946. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5947. if ($yzb) {
  5948. if ($post['sku'] != $yzb[0]['sku']) {
  5949. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5950. exit;
  5951. }
  5952. }
  5953. }
  5954. for ($i = 0; $i < $num; $i++) {
  5955. $post['label'] = time() . rand(100, 999) . $i;
  5956. if ($this->$bdck->insert($post)) {
  5957. $j++;
  5958. }
  5959. }
  5960. /**
  5961. if($post['warehouse'] != 12)
  5962. {
  5963. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5964. }
  5965. **/
  5966. if ($j == $num) {
  5967. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5968. exit;
  5969. } else {
  5970. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5971. exit;
  5972. }
  5973. } else {
  5974. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5975. exit;
  5976. }
  5977. }
  5978. $this->_Template('whlabel_printrk', $this->data);
  5979. }
  5980. public function _printxzrk($arg_array)
  5981. {
  5982. $post = $this->input->post(NULL, TRUE);
  5983. if (isset($post['wzid'])) {
  5984. $time = time();
  5985. $id = $this->input->post('wzid', true);
  5986. //$post['shop'] = $this->input->post('shop',true);
  5987. $num = 1;
  5988. $rk = $this->whlabellabel->read($id);
  5989. if (isset($rk['purchase'])) {
  5990. $x = 0;
  5991. $post['purchase'] = $rk['purchase'];
  5992. $post['warehouse'] = $rk['warehouse'];
  5993. $post['retreatwarehouse'] = $rk['warehouse'];
  5994. $post['sku'] = $rk['sku'];
  5995. $post['number'] = $rk['number'];
  5996. $post['features'] = $rk['features'];
  5997. $post['title'] = $rk['title'];
  5998. $post['enter'] = $time;
  5999. $post['time'] = $time;
  6000. $post['bs'] = 1;
  6001. $post['shop'] = $rk['shop'];
  6002. $post['details'] = $rk['details'];
  6003. $post['cpid'] = $rk['cpid'];
  6004. $post['cpbz'] = $rk['cpbz'];
  6005. $warehouse = $this->warehouse->read($rk['warehouse']);
  6006. if ($warehouse['bdck'] == '') {
  6007. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6008. exit;
  6009. } else {
  6010. $bdck = $warehouse['bdck'];
  6011. }
  6012. $post['featurespp'] = $rk['featurespp'];
  6013. $this->db->trans_begin();
  6014. for ($i = 0; $i < $num; $i++) {
  6015. $post['label'] = time() . rand(100, 999) . $i;
  6016. $this->$bdck->insert($post);
  6017. }
  6018. /**
  6019. if($post['warehouse'] != 12)
  6020. {
  6021. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6022. }
  6023. **/
  6024. if ($this->db->trans_status() === TRUE) {
  6025. $this->db->trans_commit();
  6026. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6027. exit;
  6028. } else {
  6029. $this->db->trans_rollback();
  6030. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6031. exit;
  6032. }
  6033. } else {
  6034. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6035. exit;
  6036. }
  6037. }
  6038. }
  6039. public function _printck($arg_array)
  6040. {
  6041. $prc = array();
  6042. $purchase = $this->purchase->find_all();
  6043. foreach ($purchase as $k => $v) {
  6044. $prc[$v['id']] = $v['title'];
  6045. }
  6046. $post = $this->input->post(NULL, TRUE);
  6047. if (isset($post['page'])) {
  6048. $page = $this->input->post('page', true);
  6049. $perpage = $this->input->post('perpage', true);
  6050. $sku = $this->input->post('sku', true);
  6051. $bs = $this->input->post('bs', true);
  6052. $number = $this->input->post('number', true);
  6053. $warehouse = $this->input->post('warehouse', true);
  6054. $purchase = $this->input->post('purchase', true);
  6055. $orderinfo = $this->input->post('orderinfo', true);
  6056. $waybill = $this->input->post('waybill', true);
  6057. $category = $this->input->post('category', true);
  6058. $size = $this->input->post('size', true);
  6059. $grade = $this->input->post('grade', true);
  6060. $color = $this->input->post('color', true);
  6061. $lowe = $this->input->post('lowe', true);
  6062. $state = $this->input->post('state', true);
  6063. $label = $this->input->post('label', true);
  6064. $timetk = $this->input->post('ktime', true);
  6065. $timetj = $this->input->post('jtime', true);
  6066. $timetk = strtotime($timetk);
  6067. $timetj = strtotime($timetj);
  6068. $where = "state=1 ";
  6069. if ($timetk && $timetj) {
  6070. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6071. }
  6072. if ($sku) {
  6073. $where .= " and sku = '$sku'";
  6074. }
  6075. if ($bs != '') {
  6076. $where .= " and bs = '$bs'";
  6077. }
  6078. if ($number) {
  6079. $where .= " and number = '$number'";
  6080. }
  6081. if ($warehouse) {
  6082. $where .= " and warehouse = '$warehouse'";
  6083. }
  6084. if ($purchase) {
  6085. $where .= " and purchase = '$purchase'";
  6086. }
  6087. if ($orderinfo) {
  6088. $where .= " and orderinfo = '$orderinfo'";
  6089. }
  6090. if ($waybill) {
  6091. $where .= " and waybill = '$waybill'";
  6092. }
  6093. if ($category) {
  6094. $where .= " and features like '%-$category-%'";
  6095. }
  6096. if ($size) {
  6097. $where .= " and features like '%-$size-%'";
  6098. }
  6099. if ($grade) {
  6100. $where .= " and features like '%-$grade-%'";
  6101. }
  6102. if ($color) {
  6103. $where .= " and features like '%-$color-%'";
  6104. }
  6105. if ($lowe) {
  6106. $where .= " and features like '%-$lowe-%'";
  6107. }
  6108. if ($label) {
  6109. $where .= " and label = '$label'";
  6110. }
  6111. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6112. //数据排序
  6113. $order_str = "outk desc";
  6114. if (empty($page)) {
  6115. $start = 0;
  6116. $perpage = 1;
  6117. } else {
  6118. $start = ($page - 1) * $perpage;
  6119. }
  6120. //取得信息列表
  6121. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6122. foreach ($info_list as $key => $value) {
  6123. $warehouse = $this->warehouse->read($value['warehouse']);
  6124. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6125. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6126. if ($value['state'] == 0) {
  6127. $info_list[$key]['state'] = "在库";
  6128. } else if ($value['state'] == 1) {
  6129. $info_list[$key]['state'] = "出库";
  6130. } else if ($value['state'] == 2) {
  6131. $info_list[$key]['state'] = "退库";
  6132. } else if ($value['state'] == 3) {
  6133. $info_list[$key]['state'] = "调拨中";
  6134. } else if ($value['state'] == 4) {
  6135. $info_list[$key]['state'] = "再加工";
  6136. } else if ($value['state'] == 5) {
  6137. $info_list[$key]['state'] = "维修中";
  6138. } else if ($value['state'] == 6) {
  6139. $info_list[$key]['state'] = "盘亏";
  6140. } else if ($value['state'] == 7) {
  6141. $info_list[$key]['state'] = "更换标签";
  6142. } else if ($value['state'] == 8) {
  6143. $info_list[$key]['state'] = "其它";
  6144. } else if ($value['state'] == 9) {
  6145. $info_list[$key]['state'] = "预设";
  6146. } else if ($value['state'] == 10) {
  6147. $info_list[$key]['state'] = "美店零售";
  6148. }
  6149. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6150. }
  6151. $total = $this->$ck->find_count($where);
  6152. $pagenum = ceil($total / $perpage);
  6153. $over = $total - ($start + $perpage);
  6154. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6155. echo json_encode($rows);
  6156. exit;
  6157. }
  6158. if (isset($post['tmsku'])) {
  6159. $time = time();
  6160. $tmsku = $this->input->post('tmsku', true);
  6161. //$post['shop'] = $this->input->post('shop',true);
  6162. $num = $this->input->post('num', true);
  6163. $cktype = $this->input->post('cktype', true);
  6164. $label = $this->whlabellabel->get_label($tmsku);
  6165. if (!$cktype) {
  6166. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6167. }
  6168. if (!isset($label['warehouse'])) {
  6169. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6170. exit;
  6171. }
  6172. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6173. if (stripos($label['features'], '-126-') !== false) {
  6174. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6175. } else {
  6176. $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 = ''");
  6177. }
  6178. $j = 0;
  6179. if (count($ck) >= $num) {
  6180. for ($i = 0; $i < $num; $i++) {
  6181. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6182. {
  6183. $j++;
  6184. }
  6185. }
  6186. if ($j == $num) {
  6187. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6188. exit;
  6189. } else {
  6190. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6191. exit;
  6192. }
  6193. } else {
  6194. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6195. exit;
  6196. }
  6197. }
  6198. if(isset($_SESSION['api']))
  6199. {
  6200. $user = $this->user->get_api($_SESSION['api']);
  6201. if(in_array($user['power'],[1,27])){
  6202. $vip = 1;
  6203. }
  6204. }
  6205. else
  6206. {
  6207. $vip = 0;
  6208. header('Location: /');exit;
  6209. }
  6210. $this->data['vip'] = $vip;
  6211. $this->_Template('whlabel_printck', $this->data);
  6212. }
  6213. public function _printexcel()
  6214. {
  6215. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6216. $config['upload_path'] = '.' . $dir;
  6217. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6218. $config['allowed_types'] = 'xls|xlsx|csv';
  6219. $config['max_size'] = 10240;
  6220. $this->load->library('upload', $config);
  6221. $this->upload->initialize($config);
  6222. if ($this->upload->do_upload('userfile')) {
  6223. $full_path = $dir . $this->upload->data('file_name');
  6224. $fileName = '.' . $full_path;
  6225. if (!file_exists($fileName)) {
  6226. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6227. exit;
  6228. } else {
  6229. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6230. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6231. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6232. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6233. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6234. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6235. ++$column; //如果列数大于26行
  6236. $list = array();
  6237. for ($i = 2; $i <= $row; $i++) // 行数循环
  6238. {
  6239. $data = array();
  6240. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6241. {
  6242. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6243. }
  6244. $list[] = $data;
  6245. }
  6246. }
  6247. $ed = array();
  6248. $i = 0;
  6249. $j = 0;
  6250. $dcdata = array();
  6251. $yc = '';
  6252. $cmf_arr = array_column($list, '1');
  6253. array_multisort($cmf_arr, SORT_ASC, $list);
  6254. foreach ($list as $key => $value) {
  6255. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6256. if ($typeclass) {
  6257. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6258. } else {
  6259. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6260. $i++;
  6261. continue;
  6262. }
  6263. }
  6264. if ($i > 0) {
  6265. $yc = $i . '条异常';
  6266. }
  6267. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6268. exit;
  6269. }
  6270. }
  6271. public function _uck()
  6272. {
  6273. if (isset($_GET['excel'])) {
  6274. $tc = array();
  6275. $typeclass = $this->typeclass->find_all();
  6276. foreach ($typeclass as $v) {
  6277. $tc[$v['id']] = $v['zh'];
  6278. }
  6279. $data = array();
  6280. $t = array();
  6281. $rq = '';
  6282. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6283. $ts = $ts / (24 * 3600);
  6284. for ($i = 0; $i < $ts; $i++) {
  6285. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6286. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6287. }
  6288. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6289. foreach ($info_list as $k => $v) {
  6290. $features = explode('-', trim($v['features'], '-'));
  6291. if (!isset($features[3]) || !isset($features[4])) {
  6292. continue;
  6293. }
  6294. $data[$k][0] = $tc[$features[0]]; //类型
  6295. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6296. $data[$k][2] = $tc[$features[4]]; //曲度
  6297. $data[$k][3] = '';
  6298. if (isset($data[$k][1])) {
  6299. $data[$k][3] .= $data[$k][1];
  6300. }
  6301. if (isset($data[$k][2])) {
  6302. $data[$k][3] .= $data[$k][2];
  6303. }
  6304. if (isset($features[5])) {
  6305. $data[$k][3] .= $tc[$features[5]];
  6306. }
  6307. if (isset($features[2])) {
  6308. $data[$k][3] .= $tc[$features[2]];
  6309. }
  6310. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6311. $data[$k][4] = $v['sku'];
  6312. $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())) . '))'); //月初库存
  6313. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6314. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6315. $ztrq = '';
  6316. $ztsl = '';
  6317. if (count($zt) > 0) {
  6318. foreach ($zt as $vv) {
  6319. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6320. $ztsl .= $vv['num'] . '<br>';
  6321. }
  6322. }
  6323. $data[$k][] = trim($ztsl, '<br>');
  6324. $data[$k][] = trim($ztrq, '<br>');
  6325. $byck = 0;
  6326. foreach ($t as $vv) {
  6327. $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));
  6328. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6329. $byck += $sl;
  6330. }
  6331. $data[$k][] = ($byck > 0) ? $byck : '';
  6332. }
  6333. $title = "详情 " . date("Y-m-d", time());
  6334. $titlename = "<table border=1>
  6335. <tr align='center'>
  6336. <td>类别</td>
  6337. <td>颜色</td>
  6338. <td>曲度</td>
  6339. <td>名称</td>
  6340. <td>SKU</td>
  6341. <td>月初库存</td>
  6342. <td>剩余库存</td>
  6343. <td>在途数量</td>
  6344. <td>预达日期</td>" .
  6345. $rq
  6346. . "<td>本月出库</td></tr>
  6347. </table>";
  6348. $filename = $title . ".xls";
  6349. $tail = "";
  6350. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6351. }
  6352. }
  6353. public function _whlabelexcelzh()
  6354. {
  6355. if (isset($_GET['excel'])) {
  6356. $where = "sku != 'Preset'";
  6357. //数据排序
  6358. $order_str = "id desc";
  6359. if (empty($page)) {
  6360. $start = 0;
  6361. $perpage = 1;
  6362. } else {
  6363. $start = ($page - 1) * $perpage;
  6364. }
  6365. $category = $this->input->get('category', true);
  6366. $warehouse = $this->input->get('warehouse', true);
  6367. $excelid = $this->input->get('sid', true);
  6368. if ($category) {
  6369. $where .= " and features like '%-$category-%'";
  6370. }
  6371. if ($warehouse) {
  6372. $where .= " and warehouse = '$warehouse'";
  6373. }
  6374. $xzid = '';
  6375. if ($excelid) {
  6376. $excelid = explode(',', trim($excelid, ','));
  6377. foreach ($excelid as $key => $value) {
  6378. $xzid .= " id = " . $value . " or";
  6379. }
  6380. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6381. }
  6382. //取得信息列表
  6383. /**
  6384. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6385. $rows = array();$list = array();
  6386. foreach ($info_list as $key=>$value)
  6387. {
  6388. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6389. }
  6390. **/
  6391. $list = array();
  6392. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6393. foreach ($rows as $key => $value) {
  6394. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6395. $zh = '';
  6396. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6397. foreach ($zt as $v) {
  6398. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6399. }
  6400. $zt = array_sum(array_column($zt, 'num'));
  6401. $number = $value['number'];
  6402. $ftime = time() - 15 * 24 * 3600;
  6403. $warehouse = $this->warehouse->read($value['warehouse']);
  6404. $rows[$key]['warehouse'] = $warehouse['title'];
  6405. $rows[$key]['number'] = $c;
  6406. $rows[$key]['features'] = $zh;
  6407. $rows[$key]['hb'] = $c + $zt;
  6408. }
  6409. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6410. $titlename = "<table border=1>
  6411. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6412. <tr align='center'>
  6413. <td>仓库</td>
  6414. <td>SKU</td>
  6415. <td>产品</td>
  6416. <td>库存数量</td>
  6417. <td>在途数量及预达日期</td>
  6418. <td>在途+库存数量</td>
  6419. </tr>
  6420. </table>";
  6421. $filename = $title . ".xls";
  6422. $tail = "";
  6423. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6424. }
  6425. if (isset($_GET['excel'])) {
  6426. $warehouse = $this->input->get('warehouse', true);
  6427. $sku = $this->input->get('sku', true);
  6428. $cz = $this->input->get('cz', true);
  6429. $text = $this->input->post('text', true);
  6430. $xztime = $this->input->get('xztime', true);
  6431. $timetk = $this->input->get('timetk', true);
  6432. $timetj = $this->input->get('timetj', true);
  6433. $timetk = strtotime($timetk);
  6434. $timetj = strtotime($timetj);
  6435. $where = "time = '0' ";
  6436. if ($warehouse) {
  6437. $where .= " and warehouse = '$warehouse'";
  6438. }
  6439. if ($sku) {
  6440. $where .= " and sku = '$sku'";
  6441. }
  6442. if ($text) {
  6443. $where .= " and text like '%$text%'";
  6444. }
  6445. if ($cz != '') {
  6446. $where .= " and cz = '$cz'";
  6447. }
  6448. if ($timetk && $timetj) {
  6449. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6450. }
  6451. //数据排序
  6452. $order_str = $xztime . " desc";
  6453. //取得信息列表
  6454. $zh = array();
  6455. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6456. foreach ($info_list as $v) {
  6457. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6458. $warehouse = $this->warehouse->read($v['warehouse']);
  6459. $v['warehouse'] = $warehouse['title'];
  6460. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6461. $v['stime'] = date('Y-m-d', $v['stime']);
  6462. if (isset($zh[$v['features']])) {
  6463. $zh[$v['features']]['num'] += $v['num'];
  6464. } else {
  6465. $zh[$v['features']] = $v;
  6466. }
  6467. $zh[$v['features']]['features'] = $c;
  6468. }
  6469. $title = "在途数据" . date('Y-m-d', time());
  6470. $titlename = "<table border=1>
  6471. <tr align='center'>
  6472. <td>仓库</td>
  6473. <td>SKU</td>
  6474. <td>名称</td>
  6475. <td>在途数量</td>
  6476. <td>库存数量</td>
  6477. <td>添加在途日期</td>
  6478. <td>预达日期</td>
  6479. <td>备注</td>
  6480. </tr>
  6481. </table>";
  6482. $filename = $title . ".xls";
  6483. $tail = "";
  6484. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6485. }
  6486. }
  6487. public function _fc()
  6488. {
  6489. $vip = 0;
  6490. if (isset($_SESSION['api'])) {
  6491. $user = $this->user->get_api($_SESSION['api']);
  6492. if ($user['vip'] == 1) {
  6493. $vip = 1;
  6494. }
  6495. } else {
  6496. header('Location: /');
  6497. exit;
  6498. }
  6499. $post = $this->input->post(NULL, TRUE);
  6500. if (isset($post['page'])) {
  6501. $page = $this->input->post('page', true);
  6502. $perpage = $this->input->post('perpage', true);
  6503. $category = $this->input->post('category', true);
  6504. $size = $this->input->post('size', true);
  6505. $grade = $this->input->post('grade', true);
  6506. $color = $this->input->post('color', true);
  6507. $lowe = $this->input->post('lowe', true);
  6508. $sku = $this->input->post('sku');
  6509. $title = $this->input->post('title');
  6510. $warehouse = $this->input->post('warehouse', true);
  6511. $usa = $this->input->post('usa', true);
  6512. $purchase = $this->input->post('purchase', true);
  6513. $lacetype = $this->input->post('lacetype', true);
  6514. $haircap = $this->input->post('haircap', true);
  6515. $density = $this->input->post('density', true);
  6516. $details = $this->input->post('details', true);
  6517. $state = $this->input->post('state', true);
  6518. $ktime = $this->input->post('ktime', true);
  6519. $jtime = $this->input->post('jtime', true);
  6520. $ktime = strtotime($ktime);
  6521. $jtime = strtotime($jtime);
  6522. $where = "state = '11'";
  6523. $gj = "";
  6524. $ck = "";
  6525. if ($lacetype) {
  6526. $where .= " and features like '%-$lacetype-%'";
  6527. }
  6528. if ($category) {
  6529. $where .= " and features like '%-$category-%'";
  6530. }
  6531. if ($size) {
  6532. $where .= " and features like '%-$size-%'";
  6533. }
  6534. if ($grade) {
  6535. $where .= " and features like '%-$grade-%'";
  6536. }
  6537. if ($color) {
  6538. $where .= " and features like '%-$color-%'";
  6539. }
  6540. if ($lowe) {
  6541. $where .= " and features like '%-$lowe-%'";
  6542. }
  6543. if ($haircap) {
  6544. $where .= " and features like '%-$haircap-%'";
  6545. }
  6546. if ($density) {
  6547. $where .= " and features like '%-$density-%'";
  6548. }
  6549. if ($usa) {
  6550. if (!$warehouse) {
  6551. $where .= " and (warehouse = '5' or warehouse = '8')";
  6552. }
  6553. }
  6554. if ($warehouse) {
  6555. $where .= " and warehouse = '$warehouse'";
  6556. }
  6557. if ($details) {
  6558. $where .= " and details = '$details'";
  6559. }
  6560. if ($purchase) {
  6561. $where .= " and purchase = '$purchase'";
  6562. }
  6563. if ($state) {
  6564. $where .= " and state = '$state'";
  6565. }
  6566. if ($ktime && $jtime) {
  6567. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6568. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6569. }
  6570. //数据排序
  6571. $order_str = "id desc";
  6572. if (empty($page)) {
  6573. $start = 0;
  6574. $perpage = 1;
  6575. } else {
  6576. $start = ($page - 1) * $perpage;
  6577. }
  6578. if ($sku) {
  6579. $sku = trim($sku, ' ');
  6580. $sku = trim($sku, ' ');
  6581. $where .= " and sku like '%$sku%'";
  6582. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6583. } else if ($title) {
  6584. $title = trim($title, ' ');
  6585. $title = trim($title, ' ');
  6586. $where .= " and title like '%$title%'";
  6587. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6588. } else {
  6589. //$where .= " and time > '$ktime' and time < '$jtime'";
  6590. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6591. }
  6592. //取得信息列表
  6593. $rows = array();
  6594. $list = array();
  6595. foreach ($info_list as $key => $value) {
  6596. $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'] . '"');
  6597. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6598. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6599. $warehouse = $this->warehouse->read($value['warehouse']);
  6600. $info_list[$key]['warehouse'] = $warehouse['title'];
  6601. $info_list[$key]['number'] = $g;
  6602. $info_list[$key]['features'] = $x;
  6603. $info_list[$key]['x'] = $s;
  6604. }
  6605. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6606. $pagenum = ceil($total / $perpage);
  6607. $over = $total - ($start + $perpage);
  6608. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6609. echo json_encode($rows);
  6610. exit;
  6611. }
  6612. $this->data['vip'] = $vip;
  6613. $this->_Template('whlabel_fc', $this->data);
  6614. }
  6615. public function _fcmb()
  6616. {
  6617. $where = "sku != 'Preset'";
  6618. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6619. foreach ($rows as $k => $v) {
  6620. $warehouse = $this->warehouse->read($v['warehouse']);
  6621. $rows[$k]['warehouse'] = $warehouse['title'];
  6622. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6623. $rows[$k]['t'] = '';
  6624. $rows[$k]['n'] = '';
  6625. }
  6626. $title = "封货产品数据导入模板";
  6627. $titlename = "<table border=1>
  6628. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6629. <tr align='center'>
  6630. <td>仓库</td>
  6631. <td>SKU</td>
  6632. <td>产品</td>
  6633. <td>封存产品总数量</td>
  6634. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6635. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6636. </tr>
  6637. </table>";
  6638. $filename = $title . ".xls";
  6639. $tail = "";
  6640. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6641. }
  6642. public function _fcexcel()
  6643. {
  6644. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6645. $config['upload_path'] = '.' . $dir;
  6646. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6647. $config['allowed_types'] = 'xls|xlsx|csv';
  6648. $config['max_size'] = 10240;
  6649. $this->load->library('upload', $config);
  6650. $this->upload->initialize($config);
  6651. if ($this->upload->do_upload('userfile')) {
  6652. $full_path = $dir . $this->upload->data('file_name');
  6653. $fileName = '.' . $full_path;
  6654. if (!file_exists($fileName)) {
  6655. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6656. exit;
  6657. } else {
  6658. libxml_use_internal_errors(true);
  6659. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6660. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6661. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6662. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6663. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6664. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6665. ++$column; //如果列数大于26行
  6666. $list = array();
  6667. for ($i = 2; $i <= $row; $i++) // 行数循环
  6668. {
  6669. $data = array();
  6670. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6671. {
  6672. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6673. }
  6674. $list[] = $data;
  6675. }
  6676. }
  6677. $i = 0;
  6678. $j = 0;
  6679. $ed = array();
  6680. foreach ($list as $key => $value) {
  6681. $time = time();
  6682. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6683. continue;
  6684. }
  6685. $warehouse = $this->warehouse->get_title($value['0']);
  6686. $sku = $value['1'];
  6687. $type = $value['4']; //调整方式0扣减1删除
  6688. $num = $value['5']; //调整数量
  6689. //$text = $value['4'];//扣减说明
  6690. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6691. if (!$d) //如果没有这个SKU
  6692. {
  6693. $ed[] = array($sku . '-库存中不存在此SKU');
  6694. $j++;
  6695. continue;
  6696. }
  6697. if (!isset($warehouse['id'])) {
  6698. $ed[] = array($sku . '-仓库名错误!');
  6699. $j++;
  6700. continue;
  6701. }
  6702. if ($type == 1 || $type == 2) //扣减库存
  6703. {
  6704. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6705. if (count($data) < abs($num)) {
  6706. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6707. $j++;
  6708. continue;
  6709. }
  6710. if ($type == 1) //转入库存
  6711. {
  6712. for ($i = 0; $i < abs($num); $i++) {
  6713. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6714. }
  6715. } else if ($type == 2) //删除
  6716. {
  6717. for ($i = 0; $i < abs($num); $i++) {
  6718. $this->whlabel->remove($data[$i]['id']);
  6719. }
  6720. }
  6721. } else if ($type == 0) //增加库存
  6722. {
  6723. $post['sku'] = $d['sku'];
  6724. $post['shop'] = '';
  6725. $post['warehouse'] = $warehouse['id'];
  6726. $post['purchase'] = $d['purchase'];
  6727. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6728. $post['state'] = 11;
  6729. $post['title'] = $d['title'];
  6730. $post['number'] = $d['number'];
  6731. $post['features'] = $d['features'];
  6732. $post['enter'] = $time;
  6733. $post['time'] = $time; //操作时间
  6734. for ($i = 0; $i < $num; $i++) {
  6735. $post['label'] = time() . rand(100, 999) . $i;
  6736. $this->whlabel->insert($post);
  6737. }
  6738. }
  6739. sleep(1); //防止入库时间一样,需要延迟1秒
  6740. }
  6741. if ($j > 0) {
  6742. $tt = date('Ymd', time());
  6743. $title = '库存导入错误信息-' . $tt;
  6744. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6745. $tail = "\n";
  6746. $filename = $title . ".xls";
  6747. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6748. $dir = '/data/excel/' . $time . '/';
  6749. $file_name = 'error_' . $time . rand(1000, 9999);
  6750. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6751. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6752. fwrite($myfile, $ecl);
  6753. fclose($myfile);
  6754. $error = $dir . $file_name . '.xls';
  6755. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6756. exit;
  6757. } else {
  6758. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6759. exit;
  6760. }
  6761. }
  6762. }
  6763. public function _fcjxc($arg_array)
  6764. {
  6765. if (isset($_GET['excel'])) {
  6766. $category = $this->input->get('category', true);
  6767. $size = $this->input->get('size', true);
  6768. $grade = $this->input->get('grade', true);
  6769. $color = $this->input->get('color', true);
  6770. $lowe = $this->input->get('lowe', true);
  6771. $sku = $this->input->get('sku');
  6772. $title = $this->input->get('title');
  6773. $warehouse = $arg_array[0];
  6774. $usa = $this->input->get('usa', true);
  6775. $purchase = $this->input->get('purchase', true);
  6776. $lacetype = $this->input->get('lacetype', true);
  6777. $haircap = $this->input->get('haircap', true);
  6778. $density = $this->input->get('density', true);
  6779. $title = $this->input->get('title', true);
  6780. $state = $this->input->get('state', true);
  6781. $ktime = $this->input->get('ktime', true);
  6782. $jtime = $this->input->get('jtime', true);
  6783. $where = "state=11";
  6784. $gj = "";
  6785. $ck = "";
  6786. if ($lacetype) {
  6787. $where .= " and features like '%-$lacetype-%'";
  6788. }
  6789. if ($category) {
  6790. $where .= " and features like '%-$category-%'";
  6791. }
  6792. if ($size) {
  6793. $where .= " and features like '%-$size-%'";
  6794. }
  6795. if ($grade) {
  6796. $where .= " and features like '%-$grade-%'";
  6797. }
  6798. if ($color) {
  6799. $where .= " and features like '%-$color-%'";
  6800. }
  6801. if ($lowe) {
  6802. $where .= " and features like '%-$lowe-%'";
  6803. }
  6804. if ($haircap) {
  6805. $where .= " and features like '%-$haircap-%'";
  6806. }
  6807. if ($density) {
  6808. $where .= " and features like '%-$density-%'";
  6809. }
  6810. if ($usa) {
  6811. if (!$warehouse) {
  6812. $where .= " and (warehouse = '5' or warehouse = '8')";
  6813. }
  6814. }
  6815. if ($warehouse) {
  6816. $where .= " and warehouse = '$warehouse'";
  6817. }
  6818. if ($purchase) {
  6819. $where .= " and purchase = '$purchase'";
  6820. }
  6821. if ($state) {
  6822. $where .= " and state = '$state'";
  6823. }
  6824. $order_str = "id desc";
  6825. if ($sku) {
  6826. $sku = trim($sku, ' ');
  6827. $sku = trim($sku, ' ');
  6828. $where .= " and sku like '%$sku%'";
  6829. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6830. } else if ($title) {
  6831. $title = trim($title, ' ');
  6832. $title = trim($title, ' ');
  6833. $where .= " and title like '%$title%'";
  6834. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6835. } else {
  6836. //$where .= " and time > '$ktime' and time < '$jtime'";
  6837. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6838. }
  6839. //取得信息列表
  6840. $rows = array();
  6841. $list = array();
  6842. foreach ($info_list as $key => $value) {
  6843. $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'] . '"');
  6844. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6845. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6846. $rows[$key] = $value;
  6847. $warehouse = $this->warehouse->read($value['warehouse']);
  6848. $rows[$key]['warehouse'] = $warehouse['title'];
  6849. $rows[$key]['features'] = $g;
  6850. $rows[$key]['a'] = $x;
  6851. $rows[$key]['b'] = $s;
  6852. }
  6853. $title = "总统计表";
  6854. $titlename = "<table border=1>
  6855. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6856. <tr align='center'>
  6857. <td>仓库</td>
  6858. <td>SKU</td>
  6859. <td>产品名称</td>
  6860. <td>录入总量</td>
  6861. <td>取出总量</td>
  6862. <td>剩余总量</td>
  6863. </tr>
  6864. </table>";
  6865. $filename = $title . ".xls";
  6866. $tail = "";
  6867. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6868. }
  6869. $vip = 0;
  6870. if (isset($_SESSION['api'])) {
  6871. $user = $this->user->get_api($_SESSION['api']);
  6872. if ($user['vip'] == 1) {
  6873. $vip = 1;
  6874. }
  6875. } else {
  6876. header('Location: /');
  6877. exit;
  6878. }
  6879. $post = $this->input->post(NULL, TRUE);
  6880. if (isset($post['page'])) {
  6881. $page = $this->input->post('page', true);
  6882. $perpage = $this->input->post('perpage', true);
  6883. $category = $this->input->post('category', true);
  6884. $size = $this->input->post('size', true);
  6885. $grade = $this->input->post('grade', true);
  6886. $color = $this->input->post('color', true);
  6887. $lowe = $this->input->post('lowe', true);
  6888. $sku = $this->input->post('sku');
  6889. $title = $this->input->post('title');
  6890. $warehouse = $arg_array[0];
  6891. $usa = $this->input->post('usa', true);
  6892. $purchase = $this->input->post('purchase', true);
  6893. $lacetype = $this->input->post('lacetype', true);
  6894. $haircap = $this->input->post('haircap', true);
  6895. $density = $this->input->post('density', true);
  6896. $title = $this->input->post('title', true);
  6897. $state = $this->input->post('state', true);
  6898. $ktime = $this->input->post('ktime', true);
  6899. $jtime = $this->input->post('jtime', true);
  6900. $ktime = strtotime($ktime);
  6901. $jtime = strtotime($jtime);
  6902. $where = "state=11";
  6903. $gj = "";
  6904. $ck = "";
  6905. if ($lacetype) {
  6906. $where .= " and features like '%-$lacetype-%'";
  6907. }
  6908. if ($category) {
  6909. $where .= " and features like '%-$category-%'";
  6910. }
  6911. if ($size) {
  6912. $where .= " and features like '%-$size-%'";
  6913. }
  6914. if ($grade) {
  6915. $where .= " and features like '%-$grade-%'";
  6916. }
  6917. if ($color) {
  6918. $where .= " and features like '%-$color-%'";
  6919. }
  6920. if ($lowe) {
  6921. $where .= " and features like '%-$lowe-%'";
  6922. }
  6923. if ($haircap) {
  6924. $where .= " and features like '%-$haircap-%'";
  6925. }
  6926. if ($density) {
  6927. $where .= " and features like '%-$density-%'";
  6928. }
  6929. if ($usa) {
  6930. if (!$warehouse) {
  6931. $where .= " and (warehouse = '5' or warehouse = '8')";
  6932. }
  6933. }
  6934. if ($warehouse) {
  6935. $where .= " and warehouse = '$warehouse'";
  6936. }
  6937. if ($purchase) {
  6938. $where .= " and purchase = '$purchase'";
  6939. }
  6940. if ($state) {
  6941. $where .= " and state = '$state'";
  6942. }
  6943. if ($ktime && $jtime) {
  6944. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6945. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6946. }
  6947. //数据排序
  6948. $order_str = "id desc";
  6949. $xs = 0;
  6950. $rows = array();
  6951. $list = array();
  6952. if (empty($page)) {
  6953. $start = 0;
  6954. $perpage = 1;
  6955. } else {
  6956. $start = ($page - 1) * $perpage;
  6957. }
  6958. if ($sku || $title) {
  6959. if ($title) {
  6960. $title = trim($title, ' ');
  6961. $title = trim($title, ' ');
  6962. $where .= " and title like '%$title%'";
  6963. } else {
  6964. $sku = trim($sku, ' ');
  6965. $sku = trim($sku, ' ');
  6966. $where .= " and sku like '%$sku%'";
  6967. }
  6968. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6969. foreach ($info_list as $key => $value) {
  6970. $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'] . '"');
  6971. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6972. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6973. $rows[$key] = $value;
  6974. $warehouse = $this->warehouse->read($value['warehouse']);
  6975. $rows[$key]['warehouse'] = $warehouse['title'];
  6976. $rows[$key]['features'] = $g;
  6977. $rows[$key]['a'] = $x;
  6978. $rows[$key]['b'] = $s;
  6979. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6980. $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天销量
  6981. $yj = $c / ($xl / 30);
  6982. if ($yj < 7) {
  6983. $rows[$key]['y'] = round($yj) . '天销量';
  6984. } else {
  6985. $rows[$key]['y'] = '正常';
  6986. }
  6987. }
  6988. } else {
  6989. //$where .= " and time > '$ktime' and time < '$jtime'";
  6990. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6991. foreach ($info_list as $key => $value) {
  6992. $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'] . '"');
  6993. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6994. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6995. $zs[$key] = $value;
  6996. $warehouse = $this->warehouse->read($value['warehouse']);
  6997. $zs[$key]['warehouse'] = $warehouse['title'];
  6998. $zs[$key]['features'] = $g;
  6999. $zs[$key]['a'] = $x;
  7000. $zs[$key]['b'] = $s;
  7001. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7002. $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天销量
  7003. $yj = $c / ($xl / 30);
  7004. if ($yj < 7) {
  7005. $zs[$key]['y'] = round($yj) . '天销量';
  7006. $rows[$key] = $zs[$key];
  7007. }
  7008. }
  7009. }
  7010. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7011. $pagenum = ceil($total / $perpage);
  7012. $over = $total - ($start + $perpage);
  7013. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7014. echo json_encode($rows);
  7015. exit;
  7016. }
  7017. $this->data['arg_array'] = $arg_array[0];
  7018. $this->_Template('whlabel_fcjxc', $this->data);
  7019. }
  7020. public function _0kcdel()
  7021. {
  7022. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7023. $config['upload_path'] = '.' . $dir;
  7024. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7025. $config['allowed_types'] = 'xls|xlsx|csv';
  7026. $config['max_size'] = 10240;
  7027. $this->load->library('upload', $config);
  7028. $this->upload->initialize($config);
  7029. if ($this->upload->do_upload('userfile')) {
  7030. $full_path = $dir . $this->upload->data('file_name');
  7031. $fileName = '.' . $full_path;
  7032. if (!file_exists($fileName)) {
  7033. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7034. exit;
  7035. } else {
  7036. require_once "./data/excel/PHPExcel/IOFactory.php";
  7037. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7038. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7039. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7040. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7041. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7042. ++$column; //如果列数大于26行
  7043. $list = array();
  7044. for ($i = 2; $i <= $row; $i++) // 行数循环
  7045. {
  7046. $data = array();
  7047. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7048. {
  7049. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7050. }
  7051. $list[] = $data;
  7052. }
  7053. }
  7054. $i = 0;
  7055. $j = 0;
  7056. $ed = array();
  7057. foreach ($list as $key => $value) {
  7058. $time = time();
  7059. if ($value['0'] == "" || $value['1'] == "") {
  7060. continue;
  7061. }
  7062. $warehouse = $this->warehouse->get_title($value['0']);
  7063. $sku = $value['1'];
  7064. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7065. if (!$d) //如果没有这个SKU
  7066. {
  7067. $ed[] = array($sku . '-库存中不存在此SKU');
  7068. $j++;
  7069. continue;
  7070. }
  7071. if (!isset($warehouse['id'])) {
  7072. $ed[] = array($sku . '-仓库名错误!');
  7073. $j++;
  7074. continue;
  7075. }
  7076. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7077. if ($z < 1) {
  7078. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7079. foreach ($z as $v) {
  7080. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7081. if (count($zt) > 0) {
  7082. $ed[] = array($sku . '-有在途库存无法删除!');
  7083. $j++;
  7084. continue;
  7085. }
  7086. $this->whlabel->remove($v['id']);
  7087. }
  7088. } else {
  7089. $ed[] = array($sku . '-非0库存!');
  7090. $j++;
  7091. continue;
  7092. }
  7093. }
  7094. if ($j > 0) {
  7095. $tt = date('Ymd', time());
  7096. $title = '删除0库存错误信息-' . $tt;
  7097. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7098. $tail = "\n";
  7099. $filename = $title . ".xls";
  7100. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7101. $dir = '/data/excel/' . $time . '/';
  7102. $file_name = 'error_' . $time . rand(1000, 9999);
  7103. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7104. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7105. fwrite($myfile, $ecl);
  7106. fclose($myfile);
  7107. $error = $dir . $file_name . '.xls';
  7108. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7109. exit;
  7110. } else {
  7111. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7112. exit;
  7113. }
  7114. }
  7115. }
  7116. public function _gbhtype()
  7117. {
  7118. $post = $this->input->post(NULL, TRUE);
  7119. if (isset($post['s'])) {
  7120. $n = $this->input->post('n');
  7121. $d = $this->input->post('s');
  7122. if (!$d) {
  7123. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7124. exit;
  7125. }
  7126. $d = explode(',', trim($d, ','));
  7127. $t = $this->whlabel_type->read($n);
  7128. //循环删除记录
  7129. foreach ($d as $v) {
  7130. $u = $this->whlabel->read($v);
  7131. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7132. foreach ($data as $val) {
  7133. $this->whlabel->save(array('type' => $n), $val['id']);
  7134. }
  7135. }
  7136. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7137. }
  7138. }
  7139. //出库、退库导出
  7140. public function _dccrtype()
  7141. {
  7142. $classid = $this->classid->sku();
  7143. $pm = $classid;
  7144. $typeclass = array();
  7145. $tc = $this->typeclass->find_all();
  7146. foreach ($tc as $v) {
  7147. $typeclass[$v['id']] = $v;
  7148. }
  7149. $prc = array();
  7150. $purchase = $this->purchase->find_all();
  7151. foreach ($purchase as $k => $v) {
  7152. $prc[$v['id']] = $v['title'];
  7153. }
  7154. if (isset($_GET['sid'])) {
  7155. $wh = array();
  7156. $w = $this->warehouse->find_all('1=1', 'id,title');
  7157. foreach ($w as $v) {
  7158. $wh[$v['id']] = $v['title'];
  7159. }
  7160. $type = $this->input->get('excel', true);
  7161. $category = $this->input->get('category', true);
  7162. $size = $this->input->get('size', true);
  7163. $grade = $this->input->get('grade', true);
  7164. $color = $this->input->get('color', true);
  7165. $lowe = $this->input->get('lowe', true);
  7166. $sku = $this->input->get('sku', true);
  7167. $warehouse = $this->input->get('warehouse', true);
  7168. $lacetype = $this->input->get('lacetype', true);
  7169. $lacecolor = $this->input->get('lacecolor', true);
  7170. $density = $this->input->get('density', true);
  7171. $haircap = $this->input->get('haircap', true);
  7172. $purchase = $this->input->get('purchase', true);
  7173. $title = $this->input->get('title', true);
  7174. $state = $this->input->get('state', true);
  7175. $sid = $this->input->get('sid', true);
  7176. $ktime = $this->input->get('ktime', true);
  7177. $jtime = $this->input->get('jtime', true);
  7178. $ktime = strtotime($ktime);
  7179. $jtime = strtotime($jtime);
  7180. $where = "1=1";
  7181. $gj = "";
  7182. $ck = "";
  7183. if ($category) {
  7184. $where .= " and features like '%-$category-%'";
  7185. }
  7186. if ($size) {
  7187. $where .= " and features like '%-$size-%'";
  7188. }
  7189. if ($grade) {
  7190. $where .= " and features like '%-$grade-%'";
  7191. }
  7192. if ($color) {
  7193. $where .= " and features like '%-$color-%'";
  7194. }
  7195. if ($lowe) {
  7196. $where .= " and features like '%-$lowe-%'";
  7197. }
  7198. if ($warehouse) {
  7199. $where .= " and warehouse = '$warehouse'";
  7200. }
  7201. if ($purchase) {
  7202. $where .= " and purchase = '$purchase'";
  7203. }
  7204. if ($state) {
  7205. $where .= " and state = '$state'";
  7206. }
  7207. if ($lacetype) {
  7208. $where .= " and features like '%-$lacetype-%'";
  7209. }
  7210. if ($lacecolor) {
  7211. $where .= " and features like '%-$lacecolor-%'";
  7212. }
  7213. if ($density) {
  7214. $where .= " and features like '%-$density-%'";
  7215. }
  7216. if ($haircap) {
  7217. $where .= " and features like '%-$haircap-%'";
  7218. }
  7219. if ($title) {
  7220. $title = trim($title, ' ');
  7221. $title = trim($title, ' ');
  7222. $where .= " and title like '%$title%'";
  7223. }
  7224. if ($sku) {
  7225. $sku = trim($sku, ' ');
  7226. $sku = trim($sku, ' ');
  7227. $where .= " and sku like '%$sku%'";
  7228. }
  7229. if ($ktime && $jtime) {
  7230. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7231. }
  7232. $sidwhere = '';
  7233. if ($sid) {
  7234. $sd = "";
  7235. $s = explode(',', trim($sid, ','));
  7236. foreach ($s as $value) {
  7237. $sd .= " id = " . $value . " or";
  7238. }
  7239. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7240. }
  7241. //数据排序
  7242. $order_str = "time desc";
  7243. if (empty($page)) {
  7244. $start = 0;
  7245. $perpage = 1;
  7246. } else {
  7247. $start = ($page - 1) * $perpage;
  7248. }
  7249. $wh = array();
  7250. $w = $this->warehouse->find_all('1=1', 'id,title');
  7251. foreach ($w as $v) {
  7252. $wh[$v['id']] = $v['title'];
  7253. }
  7254. $wt = array();
  7255. $whlabel_type = $this->whlabel_type->find_all();
  7256. foreach ($whlabel_type as $v) {
  7257. $wt[$v['id']] = $v['title'];
  7258. }
  7259. $classid = $this->classid->sku();
  7260. $list = array();
  7261. $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');
  7262. foreach ($rows_r as $key => $value) {
  7263. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7264. $pm = $classid;
  7265. $jm = $classid;
  7266. $rows_r[$key]['enter'] = '入库';
  7267. $rows_r[$key]['time'] = $value['enter'];
  7268. if ($value['rktype'] == 1) {
  7269. $rows_r[$key]['rktype'] = '采购入库';
  7270. } else if ($value['rktype'] == 2) {
  7271. $rows_r[$key]['rktype'] = '盘盈调整';
  7272. } else if ($value['rktype'] == 3) {
  7273. $rows_r[$key]['rktype'] = '其他调整入库';
  7274. } else if ($value['rktype'] == 4) {
  7275. $rows_r[$key]['rktype'] = '其他调整入库';
  7276. } else if ($value['rktype'] == 5) {
  7277. $rows_r[$key]['rktype'] = '退库入库';
  7278. } else if ($value['rktype'] == 6) {
  7279. $rows_r[$key]['rktype'] = '退货可用入库';
  7280. } else if ($value['rktype'] == 7) {
  7281. $rows_r[$key]['rktype'] = '形态转换入库';
  7282. } else {
  7283. $rows_r[$key]['rktype'] = '';
  7284. }
  7285. $features = explode('-', trim($value['features'], '-'));
  7286. foreach ($features as $v) {
  7287. if (isset($typeclass[$v])) {
  7288. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7289. $pm[$typeclass[$v]['classid']] = $zh[0];
  7290. }
  7291. if (isset($typeclass[$v])) {
  7292. if (isset($jm[$typeclass[$v]['classid']])) {
  7293. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7294. }
  7295. }
  7296. }
  7297. $zh = implode(" ", $pm);
  7298. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7299. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7300. $rows_r[$key]['zh'] = $zh;
  7301. $jm = array_filter($jm);
  7302. $rows_r[$key]['features'] = implode("-", $jm);
  7303. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7304. }
  7305. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7306. foreach ($rows_c as $key => $value) {
  7307. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7308. $pm = $classid;
  7309. $jm = $classid;
  7310. $rows_c[$key]['time'] = $value['outk'];
  7311. $rows_c[$key]['outk'] = '出库';
  7312. if ($value['cktype'] == 1) {
  7313. $rows_c[$key]['cktype'] = '销售出库';
  7314. } else if ($value['cktype'] == 2) {
  7315. $rows_c[$key]['cktype'] = '销售美国出库';
  7316. } else if ($value['cktype'] == 3) {
  7317. $rows_c[$key]['cktype'] = '盘亏调整';
  7318. } else if ($value['cktype'] == 4) {
  7319. $rows_c[$key]['cktype'] = '其他调整出库';
  7320. } else if ($value['cktype'] == 5) {
  7321. $rows_c[$key]['cktype'] = '形态转换出库';
  7322. } else {
  7323. $rows_c[$key]['cktype'] = '';
  7324. }
  7325. $features = explode('-', trim($value['features'], '-'));
  7326. foreach ($features as $v) {
  7327. if (isset($typeclass[$v])) {
  7328. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7329. $pm[$typeclass[$v]['classid']] = $zh[0];
  7330. }
  7331. if (isset($typeclass[$v])) {
  7332. if (isset($jm[$typeclass[$v]['classid']])) {
  7333. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7334. }
  7335. }
  7336. }
  7337. $zh = implode(" ", $pm);
  7338. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7339. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7340. $rows_c[$key]['zh'] = $zh;
  7341. $jm = array_filter($jm);
  7342. $rows_c[$key]['features'] = implode("-", $jm);
  7343. $rows_c[$key]['number'] = 1;
  7344. }
  7345. $merged = $rows_r;
  7346. foreach ($rows_c as $key => $value) {
  7347. if (isset($merged[$key])) {
  7348. $merged[] = $value;
  7349. } else {
  7350. $merged[$key] = $value;
  7351. }
  7352. }
  7353. usort($merged, function ($a, $b) {
  7354. return $a['time'] - $b['time'];
  7355. });
  7356. foreach ($merged as $key => $value) {
  7357. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7358. }
  7359. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7360. $titlename = "<table border=1>
  7361. <tr align='center'>
  7362. <td>仓库</td>
  7363. <td>SKU</td>
  7364. <td>商品名称</td>
  7365. <td>仓库品名</td>
  7366. <td>料号</td>
  7367. <td>时间</td>
  7368. <td>操作</td>
  7369. <td>类型</td>
  7370. <td>数量</td>
  7371. <td>备注</td>
  7372. </tr>
  7373. </table>";
  7374. $filename = $title . ".xlsx";
  7375. $tail = "";
  7376. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7377. }
  7378. }
  7379. }