Whlabel.php 259 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534
  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. $this->logic_ding->sendToDing("进销存浏览请求的数据类型参考".json_encode($info_list));
  1399. $final_all_list = [];
  1400. foreach ($info_list as $k => $v) {
  1401. $final_all_list[] = [
  1402. 'id' => $v['id'],
  1403. "warehouse" => $v["warehouse"],
  1404. "purchase" => $v["purchase"],
  1405. "sku" => $v["sku"],
  1406. "title" => $v["title"] . "<br/>" . $v["pm"],
  1407. "details" => $v["details"],
  1408. "shop" => $v["shop"],
  1409. "cpbz" => $v["cpbz"],
  1410. 'label' => $v['label'],
  1411. "type" => $v["type"],
  1412. "features" => $v["features"],
  1413. "number" => $v["number"],
  1414. "sm" => $v["sm"],
  1415. "x" => $v["x"],
  1416. "t" => $v["t"],
  1417. "z" => $v["z"]
  1418. ];
  1419. }
  1420. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1421. $pagenum = ceil($total / $perpage);
  1422. $over = $total - ($start + $perpage);
  1423. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1424. echo json_encode($rows);
  1425. exit;
  1426. }
  1427. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1428. $this->data['shop'] = $wlshop;
  1429. $this->data['vip'] = $vip;
  1430. $this->_Template('whlabel_type', $this->data);
  1431. }
  1432. //美仓进销存浏览
  1433. public function _usatype()
  1434. {
  1435. if (isset($_SESSION['api'])) {
  1436. $user = $this->user->get_api($_SESSION['api']);
  1437. $usp = $user;
  1438. $fgshop = "";
  1439. $sid = "";
  1440. $wid = "";
  1441. $wtype = "";
  1442. $userwh = explode('|', trim($user['warehouse'], '|'));
  1443. foreach ($userwh as $value) {
  1444. $wid .= " id = " . $value . " or";
  1445. $wtype .= " type = " . $value . " or";
  1446. }
  1447. }
  1448. $prc = array();
  1449. $purchase = $this->purchase->find_all();
  1450. foreach ($purchase as $k => $v) {
  1451. $prc[$v['id']] = $v['title'];
  1452. }
  1453. $post = $this->input->post(NULL, TRUE);
  1454. if (isset($post['page'])) {
  1455. $page = $this->input->post('page', true);
  1456. $perpage = $this->input->post('perpage', true);
  1457. $category = $this->input->post('category', true);
  1458. $size = $this->input->post('size', true);
  1459. $grade = $this->input->post('grade', true);
  1460. $color = $this->input->post('color', true);
  1461. $lowe = $this->input->post('lowe', true);
  1462. $sku = $this->input->post('sku');
  1463. $title = $this->input->post('title');
  1464. $warehouse = $this->input->post('warehouse', true);
  1465. $usa = $this->input->post('usa', true);
  1466. $purchase = $this->input->post('purchase', true);
  1467. $lacetype = $this->input->post('lacetype', true);
  1468. $haircap = $this->input->post('haircap', true);
  1469. $density = $this->input->post('density', true);
  1470. $details = $this->input->post('details', true);
  1471. $state = $this->input->post('state', true);
  1472. $lacecolor = $this->input->post('lacecolor', true);
  1473. $cklx = $this->input->post('cklx', true);
  1474. $ktime = $this->input->post('ktime', true);
  1475. $jtime = $this->input->post('jtime', true);
  1476. $ktime = strtotime($ktime);
  1477. $jtime = strtotime($jtime);
  1478. $where = "1=1";
  1479. $gj = "";
  1480. $ck = "";
  1481. if ($lacetype) {
  1482. $where .= " and features like '%-$lacetype-%'";
  1483. }
  1484. if ($category) {
  1485. $where .= " and features like '%-$category-%'";
  1486. }
  1487. if ($size) {
  1488. $where .= " and features like '%-$size-%'";
  1489. }
  1490. if ($grade) {
  1491. $where .= " and features like '%-$grade-%'";
  1492. }
  1493. if ($color) {
  1494. $where .= " and features like '%-$color-%'";
  1495. }
  1496. if ($lowe) {
  1497. $where .= " and features like '%-$lowe-%'";
  1498. }
  1499. if ($haircap) {
  1500. $where .= " and features like '%-$haircap-%'";
  1501. }
  1502. if ($density) {
  1503. $where .= " and features like '%-$density-%'";
  1504. }
  1505. if ($lacecolor) {
  1506. $where .= " and features like '%-$lacecolor-%'";
  1507. }
  1508. if ($usa) {
  1509. if (!$warehouse) {
  1510. $where .= " and (warehouse = '5' or warehouse = '8')";
  1511. }
  1512. }
  1513. if ($warehouse) {
  1514. $where .= " and warehouse = '$warehouse'";
  1515. }
  1516. if ($details) {
  1517. $where .= " and details = '$details'";
  1518. }
  1519. if ($purchase) {
  1520. $where .= " and purchase = '$purchase'";
  1521. }
  1522. if ($state) {
  1523. $where .= " and state = '$state'";
  1524. }
  1525. $where_add = '';
  1526. if ($cklx) {
  1527. $shop = $this->shop->read($cklx);
  1528. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1529. }
  1530. if ($ktime && $jtime) {
  1531. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1532. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1533. }
  1534. //数据排序
  1535. $order_str = "id desc";
  1536. if (empty($page)) {
  1537. $start = 0;
  1538. $perpage = 1;
  1539. } else {
  1540. $start = ($page - 1) * $perpage;
  1541. }
  1542. if ($sku) {
  1543. $sku = trim($sku, ' ');
  1544. $sku = trim($sku, ' ');
  1545. $where .= " and sku like '%$sku%'";
  1546. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1547. } else if ($title) {
  1548. $title = trim($title, ' ');
  1549. $title = trim($title, ' ');
  1550. $where .= " and title like '%$title%'";
  1551. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1552. } else {
  1553. //$where .= " and time > '$ktime' and time < '$jtime'";
  1554. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1555. }
  1556. //取得信息列表
  1557. $rows = array();
  1558. $list = array();
  1559. foreach ($info_list as $key => $value) {
  1560. $warehouse = $this->warehouse->read($value['warehouse']);
  1561. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1562. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1563. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1564. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1565. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1566. $od = array();
  1567. $odid = '';
  1568. foreach ($z as $v) {
  1569. if (!isset($od[$v['zd']])) {
  1570. $od[$v['zd']] = 1; //所有数据sku
  1571. } else {
  1572. $od[$v['zd']] = $od[$v['zd']] + 1;
  1573. }
  1574. }
  1575. foreach ($od as $k => $vv) {
  1576. $odid .= $k . '数量' . $vv . ' ';
  1577. }
  1578. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1579. $info_list[$key]['features'] = $c;
  1580. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1581. $ztdata = '';
  1582. if (count($zt) > 0) {
  1583. foreach ($zt as $vv) {
  1584. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1585. }
  1586. }
  1587. $info_list[$key]['warehouse'] = $ztdata;
  1588. $info_list[$key]['g'] = $g;
  1589. $info_list[$key]['x'] = $x;
  1590. $info_list[$key]['t'] = $t;
  1591. $info_list[$key]['z'] = $z;
  1592. }
  1593. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1594. $pagenum = ceil($total / $perpage);
  1595. $over = $total - ($start + $perpage);
  1596. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1597. echo json_encode($rows);
  1598. exit;
  1599. }
  1600. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1601. $this->data['warehouse'] = $warehouse;
  1602. $this->_Template('whlabel_typeusa', $this->data);
  1603. }
  1604. //美仓进销存浏览
  1605. public function _usatypeapp()
  1606. {
  1607. $post = $this->input->post(NULL, TRUE);
  1608. if (isset($post['page'])) {
  1609. $page = $this->input->post('page', true);
  1610. $perpage = $this->input->post('perpage', true);
  1611. $sku = $this->input->post('sku', true);
  1612. $warehouse = 5;
  1613. $title = $this->input->post('title', true);
  1614. $state = $this->input->post('state', true);
  1615. $ktime = $this->input->post('ktime', true);
  1616. $jtime = $this->input->post('jtime', true);
  1617. $ktime = strtotime($ktime);
  1618. $jtime = strtotime($jtime);
  1619. $where = "1=1";
  1620. $gj = "";
  1621. $ck = "";
  1622. if ($title) {
  1623. $st = explode(' ', trim($title, ' '));
  1624. foreach ($st as $v) {
  1625. $where .= " and title like '%$v%'";
  1626. }
  1627. }
  1628. if ($warehouse) {
  1629. $where .= " and warehouse = '$warehouse'";
  1630. }
  1631. if ($state) {
  1632. $where .= " and state = '$state'";
  1633. }
  1634. if ($sku) {
  1635. $where .= " and sku like '%$sku%'";
  1636. }
  1637. if ($ktime && $jtime) {
  1638. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1639. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1640. }
  1641. //数据排序
  1642. $order_str = "id desc";
  1643. if (empty($page)) {
  1644. $start = 0;
  1645. $perpage = 1;
  1646. } else {
  1647. $start = ($page - 1) * $perpage;
  1648. }
  1649. //取得信息列表
  1650. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1651. $rows = array();
  1652. $list = array();
  1653. foreach ($info_list as $key => $value) {
  1654. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1655. }
  1656. $rowsdq = array_slice($rows, $start, $perpage);
  1657. foreach ($rowsdq as $value) {
  1658. $warehouse = $this->warehouse->read($value['warehouse']);
  1659. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1660. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1661. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1662. $od = array();
  1663. $odid = '';
  1664. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1665. }
  1666. $total = count($rows);
  1667. $pagenum = ceil($total / $perpage);
  1668. $over = $total - ($start + $perpage);
  1669. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1670. echo json_encode($rows);
  1671. exit;
  1672. }
  1673. $this->_Template('phone/p_usatypeapp', $this->data);
  1674. }
  1675. //入库操作
  1676. public function _enteradd()
  1677. {
  1678. $dt = 0;
  1679. if (isset($_SESSION['api'])) {
  1680. $user = $this->user->get_api($_SESSION['api']);
  1681. $usp = $user;
  1682. $fgshop = "";
  1683. $sid = "";
  1684. $user = explode('|', trim($user['shop'], '|'));
  1685. foreach ($user as $value) {
  1686. $fgshop .= " shop = " . $value . " or";
  1687. $sid .= " id = " . $value . " or";
  1688. }
  1689. }
  1690. $tc = $this->typeclass->find_all();
  1691. $typeclass = array();
  1692. foreach ($tc as $v) {
  1693. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1694. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1695. }
  1696. $post = $this->input->post(NULL, TRUE);
  1697. if (isset($post['sku'])) {
  1698. $list = array();
  1699. $num = "";
  1700. $title = "";
  1701. $features = "";
  1702. $order = $this->input->post('order', true);
  1703. $shop = $this->input->post('shop', true);
  1704. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1705. $sku = $this->input->post('sku', true);
  1706. $post['sm'] = $this->input->post('sm', true);
  1707. $post['warehouse'] = $this->input->post('warehouse', true);
  1708. $post['purchase'] = $this->input->post('purchase', true);
  1709. $post['retreatwarehouse'] = $post['warehouse'];
  1710. $post['state'] = $this->input->post('state', true);
  1711. $post['rktype'] = $this->input->post('rktype', true);
  1712. $post['text'] = $this->input->post('text', true);
  1713. $category = $this->input->post('category', true);
  1714. $list['category'] = $category;
  1715. $list['hairtype'] = $this->input->post('hairtype', true);
  1716. $list['grade'] = $this->input->post('grade', true);
  1717. $size = $this->input->post('size', true);
  1718. $xzsku = $this->input->post('xzsku', true);
  1719. $list['size'] = rtrim($size, ',');
  1720. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1721. $list['extension'] = $this->input->post('extension', true);
  1722. if ($category == 1297) {
  1723. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1724. }
  1725. if ($category == 1702) {
  1726. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1727. $list['syother'] = $this->input->post('syother', true);
  1728. }
  1729. if ($category == 133) {
  1730. $list['fittype'] = $this->input->post('fittype', true);
  1731. $list['acother'] = $this->input->post('acother', true);
  1732. }
  1733. $list['color'] = $this->input->post('color', true);
  1734. $list['lowe'] = $this->input->post('lowe', true);
  1735. if (!$post['purchase']) {
  1736. $post['purchase'] = 1;
  1737. }
  1738. if ($category == 127) {
  1739. $list['type'] = $this->input->post('type', true);
  1740. $list['headroad'] = $this->input->post('headroad', true);
  1741. $list['density'] = $this->input->post('density', true);
  1742. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1743. $list['lacesize'] = $this->input->post('lacesize', true);
  1744. }
  1745. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1746. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1747. }
  1748. if ($category == 128) {
  1749. $list['lacetype'] = $this->input->post('lacetype', true);
  1750. $list['haircap'] = $this->input->post('haircap', true);
  1751. $list['density'] = $this->input->post('density', true);
  1752. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1753. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1754. $list['wigother'] = $this->input->post('wigother', true);
  1755. $list['wigother1'] = $this->input->post('wigother1', true);
  1756. $list['wigother2'] = $this->input->post('wigother2', true);
  1757. }
  1758. if ($category == 129) {
  1759. $list['wide'] = $this->input->post('wide', true);
  1760. }
  1761. if ($category == 131) {
  1762. $list['gifttype'] = $this->input->post('gifttype', true);
  1763. $list['giftother'] = $this->input->post('giftother', true);
  1764. }
  1765. if ($category == 134) {
  1766. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1767. }
  1768. if ($category == 1297) {
  1769. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1770. $list['sywigother'] = $this->input->post('sywigother', true);
  1771. }
  1772. if ($category == 130 || $category == 133 || $category == 1702) {
  1773. $list['items'] = $this->input->post('items', true);
  1774. $list['weight'] = $this->input->post('weight', true);
  1775. }
  1776. if ($category == 1702) {
  1777. $list['syhairther'] = $this->input->post('syhairther', true);
  1778. }
  1779. $classid = $this->classid->sku();
  1780. $scsku = $classid;
  1781. $pm = $classid;
  1782. foreach ($list as $k => $v) {
  1783. if ($v != 0) {
  1784. $num .= $v;
  1785. $features .= $v . '-';
  1786. $post[$k] = $v;
  1787. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1788. if ($k != 'size') {
  1789. $title .= $typeclass[$v]['title'] . " ";
  1790. }
  1791. if (isset($pm[$typeclass[$v]['classid']])) {
  1792. if ($typeclass[$v]['title'] == '9A') {
  1793. $pm[$typeclass[$v]['classid']] = '9A';
  1794. } else if ($typeclass[$v]['title'] == '10A') {
  1795. $pm[$typeclass[$v]['classid']] = '10A';
  1796. } else {
  1797. $clzh = $typeclass[$v]['zh'];
  1798. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1799. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1800. $clzh = $clzh[0];
  1801. }
  1802. $pm[$typeclass[$v]['classid']] = $clzh;
  1803. }
  1804. }
  1805. }
  1806. }
  1807. $zh = implode(" ", $pm);
  1808. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1809. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1810. if ($list['size']) {
  1811. $typeclass = $this->typeclass->read($list['size']);
  1812. $title .= $typeclass['title'];
  1813. }
  1814. $time = time();
  1815. if ($xzsku) {
  1816. $scsku = implode("-", $scsku);
  1817. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1818. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1819. $post['sku'] = trim($scsku, ' ');
  1820. } else {
  1821. $post['sku'] = $sku;
  1822. }
  1823. //$post['sku'] = trim($sku,' ');
  1824. $post['title'] = rtrim($title, ' ');
  1825. $post['number'] = $num;
  1826. $post['features'] = '-' . $features;
  1827. $post['enter'] = $time;
  1828. $post['time'] = $time; //操作时间
  1829. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1830. if ($yza) {
  1831. if ($post['features'] != $yza[0]['features']) {
  1832. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1833. exit;
  1834. }
  1835. }
  1836. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1837. if ($yzb) {
  1838. if ($post['sku'] != $yzb[0]['sku']) {
  1839. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1840. exit;
  1841. }
  1842. }
  1843. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1844. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1845. exit;
  1846. }
  1847. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1848. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1849. exit;
  1850. }
  1851. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1852. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1853. exit;
  1854. }
  1855. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1856. if (isset($yz[0]['type'])) {
  1857. $post['type'] = $yz[0]['type'];
  1858. }
  1859. if ($post['state'] == 9) //如果选择预设库存
  1860. {
  1861. $this->whlabel->insert($post);
  1862. } else {
  1863. /**
  1864. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1865. if($ljg == 1)
  1866. {
  1867. for($i=0;$i<$order;$i++)
  1868. {
  1869. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1870. $this->whlabel->insert($post);
  1871. }
  1872. }
  1873. **/
  1874. //if($post['warehouse'] == '5')
  1875. //{
  1876. //}
  1877. $yydata = $post;
  1878. $yydata['zh'] = $zh;
  1879. /**
  1880. $wl = $this->apiyy->get_cjlp($yydata);
  1881. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1882. {
  1883. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1884. }
  1885. if($wl['Data'][0]['m_isSucess'] != 1)
  1886. {
  1887. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1888. }
  1889. **/
  1890. for ($i = 0; $i < $order; $i++) {
  1891. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1892. $this->whlabel->insert($post);
  1893. }
  1894. }
  1895. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1896. exit;
  1897. }
  1898. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1899. $this->data['wlshop'] = $wlshop;
  1900. $this->_Template('whlabel_enteradd', $this->data);
  1901. }
  1902. //修改产品
  1903. public function _enteredit($arg_array)
  1904. {
  1905. $dt = 0;
  1906. if (isset($_SESSION['api'])) {
  1907. $user = $this->user->get_api($_SESSION['api']);
  1908. $usp = $user;
  1909. $fgshop = "";
  1910. $sid = "";
  1911. $user = explode('|', trim($user['shop'], '|'));
  1912. foreach ($user as $value) {
  1913. $fgshop .= " shop = " . $value . " or";
  1914. $sid .= " id = " . $value . " or";
  1915. }
  1916. }
  1917. $post = $this->input->post(NULL, TRUE);
  1918. if (isset($post['sku'])) {
  1919. $list = array();
  1920. $num = "";
  1921. $title = "";
  1922. $features = "";
  1923. $id = $this->input->post('id', true);
  1924. $order = $this->input->post('order', true);
  1925. $shop = $this->input->post('shop', true);
  1926. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1927. $post['sku'] = $this->input->post('sku', true);
  1928. $post['sm'] = $this->input->post('sm', true);
  1929. $post['warehouse'] = $this->input->post('warehouse', true);
  1930. $post['purchase'] = $this->input->post('purchase', true);
  1931. $post['retreatwarehouse'] = $post['warehouse'];
  1932. $category = $this->input->post('category', true);
  1933. $list['category'] = $category;
  1934. $list['hairtype'] = $this->input->post('hairtype', true);
  1935. $list['grade'] = $this->input->post('grade', true);
  1936. $size = $this->input->post('size', true);
  1937. $list['size'] = rtrim($size, ',');
  1938. $post['rktype'] = $this->input->post('rktype', true);
  1939. $post['text'] = $this->input->post('text', true);
  1940. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1941. $list['extension'] = $this->input->post('extension', true);
  1942. if ($category == 1297) {
  1943. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1944. }
  1945. if ($category == 1702) {
  1946. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1947. $list['syother'] = $this->input->post('syother', true);
  1948. }
  1949. if ($category == 133) {
  1950. $list['fittype'] = $this->input->post('fittype', true);
  1951. $list['acother'] = $this->input->post('acother', true);
  1952. }
  1953. $list['color'] = $this->input->post('color', true);
  1954. $list['lowe'] = $this->input->post('lowe', true);
  1955. if (!$post['purchase']) {
  1956. $post['purchase'] = 1;
  1957. }
  1958. if ($category == 127) {
  1959. $list['type'] = $this->input->post('type', true);
  1960. $list['headroad'] = $this->input->post('headroad', true);
  1961. $list['density'] = $this->input->post('density', true);
  1962. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1963. $list['lacesize'] = $this->input->post('lacesize', true);
  1964. }
  1965. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1966. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1967. }
  1968. if ($category == 128) {
  1969. $list['lacetype'] = $this->input->post('lacetype', true);
  1970. $list['haircap'] = $this->input->post('haircap', true);
  1971. $list['density'] = $this->input->post('density', true);
  1972. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1973. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1974. $list['wigother'] = $this->input->post('wigother', true);
  1975. $list['wigother1'] = $this->input->post('wigother1', true);
  1976. $list['wigother2'] = $this->input->post('wigother2', true);
  1977. }
  1978. if ($category == 129) {
  1979. $list['wide'] = $this->input->post('wide', true);
  1980. }
  1981. if ($category == 131) {
  1982. $list['gifttype'] = $this->input->post('gifttype', true);
  1983. $list['giftother'] = $this->input->post('giftother', true);
  1984. }
  1985. if ($category == 134) {
  1986. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1987. }
  1988. if ($category == 1297) {
  1989. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1990. $list['sywigother'] = $this->input->post('sywigother', true);
  1991. }
  1992. if ($category == 130 || $category == 133 || $category == 1702) {
  1993. $list['items'] = $this->input->post('items', true);
  1994. $list['weight'] = $this->input->post('weight', true);
  1995. }
  1996. if ($category == 1702) {
  1997. $list['syhairther'] = $this->input->post('syhairther', true);
  1998. }
  1999. foreach ($list as $k => $v) {
  2000. if ($v != 0) {
  2001. $num .= $v;
  2002. $features .= $v . '-';
  2003. $typeclass = $this->typeclass->read($v);
  2004. if ($k != 'size') {
  2005. $title .= $typeclass['title'] . " ";
  2006. }
  2007. }
  2008. }
  2009. $typeclass = $this->typeclass->read($list['size']);
  2010. $title .= $typeclass['title'];
  2011. $time = time();
  2012. $post['title'] = rtrim($title, ' ');
  2013. $post['number'] = $num;
  2014. $post['features'] = '-' . $features;
  2015. $post['time'] = $time; //操作时间
  2016. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2017. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2018. exit;
  2019. }
  2020. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2021. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2022. exit;
  2023. }
  2024. $uid = $this->whlabel->read($id);
  2025. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2026. if ($datanum > 0) {
  2027. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2028. exit;
  2029. }
  2030. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2031. {
  2032. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2033. if ($yza) {
  2034. if ($post['features'] != $yza[0]['features']) {
  2035. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2036. exit;
  2037. }
  2038. }
  2039. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2040. if ($yzb) {
  2041. if ($post['sku'] != $yzb[0]['sku']) {
  2042. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2043. exit;
  2044. }
  2045. }
  2046. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2047. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2048. exit;
  2049. }
  2050. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2051. foreach ($data as $v) {
  2052. $post['id'] = $v['id'];
  2053. $this->whlabel->save($post, $v['id']);
  2054. }
  2055. } else {
  2056. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2057. if ($data > 0) {
  2058. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2059. exit;
  2060. } else {
  2061. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2062. foreach ($data as $v) {
  2063. $post['id'] = $v['id'];
  2064. $this->whlabel->save($post, $v['id']);
  2065. }
  2066. }
  2067. }
  2068. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2069. exit;
  2070. }
  2071. $uid = $this->whlabel->read($arg_array[0]);
  2072. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2073. $this->data['enter'] = $uid;
  2074. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2075. $this->data['wlshop'] = $wlshop;
  2076. $this->_Template('whlabel_enteredit', $this->data);
  2077. }
  2078. //入库浏览
  2079. public function _enter()
  2080. {
  2081. $post = $this->input->post(NULL, TRUE);
  2082. if (isset($post['s'])) {
  2083. $id_arr = $this->input->post('s');
  2084. $id_arr = explode(',', $id_arr);
  2085. if (!$id_arr) {
  2086. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2087. exit;
  2088. }
  2089. //循环删除记录
  2090. foreach ($id_arr as $v) {
  2091. $sid = $this->whlabel->read($v);
  2092. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2093. if ($count > 0) {
  2094. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2095. exit;
  2096. }
  2097. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2098. foreach ($info_list as $va) {
  2099. $this->whlabel->remove($va['id']);
  2100. }
  2101. }
  2102. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2103. exit;
  2104. }
  2105. $sp = array();
  2106. $s = $this->shop->find_all('1=1', 'id,shopname');
  2107. foreach ($s as $v) {
  2108. $sp[$v['id']] = $v['shopname'];
  2109. }
  2110. $wh = array();
  2111. $w = $this->warehouse->find_all('1=1', 'id,title');
  2112. foreach ($w as $v) {
  2113. $wh[$v['id']] = $v['title'];
  2114. }
  2115. if (isset($post['page'])) {
  2116. $page = $this->input->post('page', true);
  2117. $perpage = $this->input->post('perpage', true);
  2118. $category = $this->input->post('category', true);
  2119. $size = $this->input->post('size', true);
  2120. $grade = $this->input->post('grade', true);
  2121. $color = $this->input->post('color', true);
  2122. $lowe = $this->input->post('lowe', true);
  2123. $sku = $this->input->post('sku', true);
  2124. $warehouse = $this->input->post('warehouse', true);
  2125. $purchase = $this->input->post('purchase', true);
  2126. $ktime = $this->input->post('ktime', true);
  2127. $jtime = $this->input->post('jtime', true);
  2128. $ktime = strtotime($ktime);
  2129. $jtime = strtotime($jtime);
  2130. $where = "1=1";
  2131. $gj = "";
  2132. $ck = "";
  2133. if ($category) {
  2134. $where .= " and features like '%-$category-%'";
  2135. }
  2136. if ($size) {
  2137. $where .= " and features like '%-$size-%'";
  2138. }
  2139. if ($grade) {
  2140. $where .= " and features like '%-$grade-%'";
  2141. }
  2142. if ($color) {
  2143. $where .= " and features like '%-$color-%'";
  2144. }
  2145. if ($lowe) {
  2146. $where .= " and features like '%-$lowe-%'";
  2147. }
  2148. if ($warehouse) {
  2149. $where .= " and warehouse = '$warehouse'";
  2150. }
  2151. if ($purchase) {
  2152. $where .= " and purchase = '$purchase'";
  2153. }
  2154. if ($sku) {
  2155. $where .= " and sku like '%$sku%'";
  2156. }
  2157. if ($ktime && $jtime) {
  2158. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2159. }
  2160. //数据排序
  2161. $order_str = "enter desc";
  2162. if (empty($page)) {
  2163. $start = 0;
  2164. $perpage = 1;
  2165. } else {
  2166. $start = ($page - 1) * $perpage;
  2167. }
  2168. //取得信息列表
  2169. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2170. foreach ($info_list as $k => $v) {
  2171. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2172. if ($v['shop'] == '') {
  2173. $s = '通用';
  2174. } else {
  2175. $info_list[$k]['shop'] = '';
  2176. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2177. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2178. }
  2179. }
  2180. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2181. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2182. $info_list[$k]['g'] = $g;
  2183. }
  2184. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2185. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2186. $pagenum = ceil($total / $perpage);
  2187. $over = $total - ($start + $perpage);
  2188. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2189. echo json_encode($rows);
  2190. exit;
  2191. }
  2192. $this->_Template('whlabel_enter', $this->data);
  2193. }
  2194. //出库浏览
  2195. public function _out()
  2196. {
  2197. $post = $this->input->post(NULL, TRUE);
  2198. if (isset($post['page'])) {
  2199. $page = $this->input->post('page', true);
  2200. $perpage = $this->input->post('perpage', true);
  2201. $category = $this->input->post('category', true);
  2202. $size = $this->input->post('size', true);
  2203. $grade = $this->input->post('grade', true);
  2204. $color = $this->input->post('color', true);
  2205. $lowe = $this->input->post('lowe', true);
  2206. $sku = $this->input->post('sku', true);
  2207. $warehouse = $this->input->post('warehouse', true);
  2208. $purchase = $this->input->post('purchase', true);
  2209. $state = $this->input->post('state', true);
  2210. $ktime = $this->input->post('ktime', true);
  2211. $jtime = $this->input->post('jtime', true);
  2212. $ktime = strtotime($ktime);
  2213. $jtime = strtotime($jtime);
  2214. $where = "state=3";
  2215. $gj = "";
  2216. $ck = "";
  2217. if ($category) {
  2218. $where .= " and features like '%-$category-%'";
  2219. }
  2220. if ($size) {
  2221. $where .= " and features like '%-$size-%'";
  2222. }
  2223. if ($grade) {
  2224. $where .= " and features like '%-$grade-%'";
  2225. }
  2226. if ($color) {
  2227. $where .= " and features like '%-$color-%'";
  2228. }
  2229. if ($lowe) {
  2230. $where .= " and features like '%-$lowe-%'";
  2231. }
  2232. if ($state) {
  2233. $where .= " and state = '$state'";
  2234. }
  2235. if ($warehouse) {
  2236. $where .= " and warehouse = '$warehouse'";
  2237. }
  2238. if ($purchase) {
  2239. $where .= " and purchase = '$purchase'";
  2240. }
  2241. if ($sku) {
  2242. $where .= " and sku = '$sku'";
  2243. }
  2244. if ($ktime && $jtime) {
  2245. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2246. }
  2247. //数据排序
  2248. $order_str = "id desc";
  2249. if (empty($page)) {
  2250. $start = 0;
  2251. $perpage = 1;
  2252. } else {
  2253. $start = ($page - 1) * $perpage;
  2254. }
  2255. //取得信息列表
  2256. $info_list = $this->whlabel->find_all($where, 'sku');
  2257. $rows = array();
  2258. $list = array();
  2259. foreach ($info_list as $key => $value) {
  2260. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2261. }
  2262. $rows = array_unique($rows); //删除重复记录
  2263. foreach ($rows as $key => $value) {
  2264. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2265. $ck = $this->warehouse->read($data['warehouse']);
  2266. $warehouse = $ck['title'];
  2267. $gy = $this->purchase->read($data['purchase']);
  2268. $purchase = $gy['purchase'];
  2269. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2270. $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);
  2271. }
  2272. $total = count($list);
  2273. $pagenum = ceil($total / $perpage);
  2274. $over = $total - ($start + $perpage);
  2275. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2276. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2277. echo json_encode($rows);
  2278. exit;
  2279. }
  2280. $this->_Template('whlabel_out', $this->data);
  2281. }
  2282. //出库标签浏览
  2283. public function _label()
  2284. {
  2285. $post = $this->input->post(NULL, TRUE);
  2286. if (isset($post['page'])) {
  2287. $page = $this->input->post('page', true);
  2288. $perpage = $this->input->post('perpage', true);
  2289. $sku = $this->input->post('sku', true);
  2290. $warehouse = $this->input->post('warehouse', true);
  2291. $purchase = $this->input->post('purchase', true);
  2292. $orderinfo = $this->input->post('orderinfo', true);
  2293. $waybill = $this->input->post('waybill', true);
  2294. $category = $this->input->post('category', true);
  2295. $size = $this->input->post('size', true);
  2296. $grade = $this->input->post('grade', true);
  2297. $color = $this->input->post('color', true);
  2298. $lowe = $this->input->post('lowe', true);
  2299. $where = "state=1";
  2300. if ($sku) {
  2301. $where .= " and sku = '$sku'";
  2302. }
  2303. if ($warehouse) {
  2304. $where .= " and warehouse = '$warehouse'";
  2305. }
  2306. if ($purchase) {
  2307. $where .= " and purchase = '$purchase'";
  2308. }
  2309. if ($orderinfo) {
  2310. $where .= " and orderinfo = '$orderinfo'";
  2311. }
  2312. if ($waybill) {
  2313. $where .= " and waybill = '$waybill'";
  2314. }
  2315. if ($category) {
  2316. $where .= " and features like '%-$category-%'";
  2317. }
  2318. if ($size) {
  2319. $where .= " and features like '%-$size-%'";
  2320. }
  2321. if ($grade) {
  2322. $where .= " and features like '%-$grade-%'";
  2323. }
  2324. if ($color) {
  2325. $where .= " and features like '%-$color-%'";
  2326. }
  2327. if ($lowe) {
  2328. $where .= " and features like '%-$lowe-%'";
  2329. }
  2330. //数据排序
  2331. $order_str = "outk desc";
  2332. if (empty($page)) {
  2333. $start = 0;
  2334. $perpage = 1;
  2335. } else {
  2336. $start = ($page - 1) * $perpage;
  2337. }
  2338. //取得信息列表
  2339. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2340. foreach ($info_list as $key => $value) {
  2341. $warehouse = $this->warehouse->read($value['warehouse']);
  2342. $info_list[$key]['warehouse'] = $warehouse['title'];
  2343. $purchase = $this->purchase->read($value['purchase']);
  2344. $info_list[$key]['purchase'] = $purchase['title'];
  2345. if ($value['outk'] != 0) {
  2346. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2347. } else {
  2348. $info_list[$key]['outk'] = "";
  2349. }
  2350. if ($value['orderinfo'] == 0) {
  2351. $info_list[$key]['orderinfo'] = "";
  2352. }
  2353. if ($value['waybill'] == 0) {
  2354. $info_list[$key]['waybill'] = "";
  2355. }
  2356. }
  2357. $total = $this->whlabel->find_count($where);
  2358. $pagenum = ceil($total / $perpage);
  2359. $over = $total - ($start + $perpage);
  2360. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2361. echo json_encode($rows);
  2362. exit;
  2363. }
  2364. $this->_Template('whlabel_label', $this->data);
  2365. }
  2366. //独立站出库订单
  2367. public function _outorder()
  2368. {
  2369. if (isset($_SESSION['api'])) {
  2370. $user = $this->user->get_api($_SESSION['api']);
  2371. $usp = $user;
  2372. $fgshop = "";
  2373. $sid = "";
  2374. $user = explode('|', trim($user['shop'], '|'));
  2375. foreach ($user as $value) {
  2376. $fgshop .= " shop = " . $value . " or";
  2377. $sid .= " id = " . $value . " or";
  2378. }
  2379. } else {
  2380. echo "请重新登录";
  2381. }
  2382. $post = $this->input->post(NULL, TRUE);
  2383. if (isset($post['page'])) {
  2384. $page = $this->input->post('page', true);
  2385. $perpage = $this->input->post('perpage', true);
  2386. $warehouse = $this->input->post('warehouse', true);
  2387. $xztime = $this->input->post('xztime', true);
  2388. $timetk = $this->input->post('timetkk', true);
  2389. $timetj = $this->input->post('timetjj', true);
  2390. $shop = $this->input->post('shop', true);
  2391. $source = $this->input->post('source', true);
  2392. $orderinfo = $this->input->post('orderinfo', true);
  2393. $number = $this->input->post('number', true);
  2394. $sfxh = $this->input->post('sfxh', true);
  2395. $express = $this->input->post('express', true);
  2396. $waybill = $this->input->post('waybill', true);
  2397. $library = $this->input->post('library', true);
  2398. $country = $this->input->post('country', true);
  2399. $so = $this->input->post('so', true);
  2400. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2401. $print = $this->input->post('print', true);
  2402. $state = $this->input->post('state', true);
  2403. $orderurl = $this->input->post('orderurl', true);
  2404. $timetk = strtotime($timetk);
  2405. $timetj = strtotime($timetj);
  2406. /**
  2407. $sj = $this->input->post('sj',true);
  2408. if($sj)
  2409. {
  2410. $sj = $this->input->post('sj',true);
  2411. }
  2412. else
  2413. {
  2414. $sj = "fullorder";
  2415. }
  2416. **/
  2417. $sj = "fullorder";
  2418. $where = "1=1";
  2419. if ($warehouse) {
  2420. $where .= " and type = '$warehouse'";
  2421. }
  2422. if ($timetk && $timetj) {
  2423. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2424. }
  2425. if ($orderinfo) {
  2426. $where .= " and orderinfo = '$orderinfo'";
  2427. }
  2428. if ($number) {
  2429. $where .= " and number = '$number'";
  2430. }
  2431. if ($express) {
  2432. $where .= " and express = '$express'";
  2433. }
  2434. if ($waybill) {
  2435. $where .= " and waybill = '$waybill'";
  2436. }
  2437. if ($library) {
  2438. $where .= " and library = '$library'";
  2439. }
  2440. if ($print) {
  2441. $where .= " and print = '$print'";
  2442. }
  2443. if ($libraryconfirm) {
  2444. $where .= " and libraryconfirm = '$libraryconfirm'";
  2445. }
  2446. if ($state) {
  2447. $where .= " and state = '$state'";
  2448. }
  2449. if ($shop) {
  2450. $where .= " and shop = '$shop'";
  2451. }
  2452. if ($country) {
  2453. $where .= " and country = '$country'";
  2454. }
  2455. if ($sfxh != '') {
  2456. $where .= " and sfxh = '$sfxh'";
  2457. }
  2458. if ($so) {
  2459. $where .= " and shipremarks like '%$so%'";
  2460. }
  2461. if ($source) {
  2462. if ($source == '2d') {
  2463. $where .= " and source >= '2'";
  2464. } else {
  2465. $where .= " and source = '$source'";
  2466. }
  2467. }
  2468. if (isset($_SESSION['api'])) {
  2469. foreach ($user as $value) {
  2470. $fgshop .= " shop = " . $value . " or";
  2471. }
  2472. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2473. }
  2474. if ($orderurl) {
  2475. $url = $this->orderurl->read($orderurl);
  2476. $where .= " and link like '%" . $url['url'] . "%'";
  2477. }
  2478. //数据排序
  2479. $order_str = "librarytime desc";
  2480. if (empty($page)) {
  2481. $start = 0;
  2482. $perpage = 1;
  2483. } else {
  2484. $start = ($page - 1) * $perpage;
  2485. }
  2486. //取得信息列表
  2487. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2488. //格式化数据
  2489. foreach ($info_list as $key => $value) {
  2490. $shop = $this->shop->read($value['shop']);
  2491. $info_list[$key]['shop'] = $shop['shopname'];
  2492. $express = $this->express->read($value['express']);
  2493. $info_list[$key]['express'] = $express['servicename'];
  2494. $warehouse = $this->warehouse->read($value['type']);
  2495. $info_list[$key]['type'] = $warehouse['title'];
  2496. if ($value['librarytime'] == '0') {
  2497. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2498. } else {
  2499. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2500. }
  2501. }
  2502. $total = $this->$sj->find_count($where);
  2503. $pagenum = ceil($total / $perpage);
  2504. $over = $total - ($start + $perpage);
  2505. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2506. echo json_encode($rows);
  2507. exit;
  2508. }
  2509. $this->data['express'] = $this->express->find_all();
  2510. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2511. $this->data['wlshop'] = $wlshop;
  2512. $user = $this->user->get_api($_SESSION['api']);
  2513. $powerid = $this->power->read($user['power']);
  2514. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2515. $pid = '';
  2516. foreach ($powertext as $v) {
  2517. $pid .= " id = " . $v . " or";
  2518. }
  2519. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2520. $this->data['fullorderexcel'] = $fullorderexcel;
  2521. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2522. $this->data['orderurl'] = $orderurl;
  2523. $this->_Template('whlabel_outorder', $this->data);
  2524. }
  2525. //tt出库
  2526. public function _toutorder()
  2527. {
  2528. if (isset($_SESSION['api'])) {
  2529. $user = $this->user->get_api($_SESSION['api']);
  2530. $usp = $user;
  2531. $fgshop = "";
  2532. $sid = "";
  2533. $user = explode('|', trim($user['shop'], '|'));
  2534. foreach ($user as $value) {
  2535. $fgshop .= " shop = " . $value . " or";
  2536. $sid .= " id = " . $value . " or";
  2537. }
  2538. } else {
  2539. echo "请重新登录";
  2540. }
  2541. $post = $this->input->post(NULL, TRUE);
  2542. if (isset($post['page'])) {
  2543. $page = $this->input->post('page', true);
  2544. $perpage = $this->input->post('perpage', true);
  2545. $warehouse = $this->input->post('warehouse', true);
  2546. $xztime = $this->input->post('xztime', true);
  2547. $timetk = $this->input->post('timetkk', true);
  2548. $timetj = $this->input->post('timetjj', true);
  2549. $shop = $this->input->post('shop', true);
  2550. $source = $this->input->post('source', true);
  2551. $orderinfo = $this->input->post('orderinfo', true);
  2552. $number = $this->input->post('number', true);
  2553. $sfxh = $this->input->post('sfxh', true);
  2554. $express = $this->input->post('express', true);
  2555. $waybill = $this->input->post('waybill', true);
  2556. $library = $this->input->post('library', true);
  2557. $country = $this->input->post('country', true);
  2558. $so = $this->input->post('so', true);
  2559. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2560. $print = $this->input->post('print', true);
  2561. $state = $this->input->post('state', true);
  2562. $orderurl = $this->input->post('orderurl', true);
  2563. $timetk = strtotime($timetk);
  2564. $timetj = strtotime($timetj);
  2565. /**
  2566. $sj = $this->input->post('sj',true);
  2567. if($sj)
  2568. {
  2569. $sj = $this->input->post('sj',true);
  2570. }
  2571. else
  2572. {
  2573. $sj = "fullorder";
  2574. }
  2575. **/
  2576. $sj = "fullordertt";
  2577. $where = "1=1";
  2578. if ($warehouse) {
  2579. $where .= " and type = '$warehouse'";
  2580. }
  2581. if ($timetk && $timetj) {
  2582. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2583. }
  2584. if ($orderinfo) {
  2585. $where .= " and orderinfo = '$orderinfo'";
  2586. }
  2587. if ($number) {
  2588. $where .= " and number = '$number'";
  2589. }
  2590. if ($express) {
  2591. $where .= " and express = '$express'";
  2592. }
  2593. if ($waybill) {
  2594. $where .= " and waybill = '$waybill'";
  2595. }
  2596. if ($library) {
  2597. $where .= " and library = '$library'";
  2598. }
  2599. if ($print) {
  2600. $where .= " and print = '$print'";
  2601. }
  2602. if ($libraryconfirm) {
  2603. $where .= " and libraryconfirm = '$libraryconfirm'";
  2604. }
  2605. if ($state) {
  2606. $where .= " and state = '$state'";
  2607. }
  2608. if ($shop) {
  2609. $where .= " and shop = '$shop'";
  2610. }
  2611. if ($country) {
  2612. $where .= " and country = '$country'";
  2613. }
  2614. if ($sfxh != '') {
  2615. $where .= " and sfxh = '$sfxh'";
  2616. }
  2617. if ($so) {
  2618. $where .= " and shipremarks like '%$so%'";
  2619. }
  2620. if ($source) {
  2621. if ($source == '2d') {
  2622. $where .= " and source >= '2'";
  2623. } else {
  2624. $where .= " and source = '$source'";
  2625. }
  2626. }
  2627. if (isset($_SESSION['api'])) {
  2628. foreach ($user as $value) {
  2629. $fgshop .= " shop = " . $value . " or";
  2630. }
  2631. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2632. }
  2633. if ($orderurl) {
  2634. $url = $this->orderurl->read($orderurl);
  2635. $where .= " and link like '%" . $url['url'] . "%'";
  2636. }
  2637. //数据排序
  2638. $order_str = "librarytime desc";
  2639. if (empty($page)) {
  2640. $start = 0;
  2641. $perpage = 1;
  2642. } else {
  2643. $start = ($page - 1) * $perpage;
  2644. }
  2645. //取得信息列表
  2646. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2647. //格式化数据
  2648. foreach ($info_list as $key => $value) {
  2649. $shop = $this->shop->read($value['shop']);
  2650. $info_list[$key]['shop'] = $shop['shopname'];
  2651. $express = $this->express->read($value['express']);
  2652. $info_list[$key]['express'] = $express['servicename'];
  2653. $warehouse = $this->warehouse->read($value['type']);
  2654. $info_list[$key]['type'] = $warehouse['title'];
  2655. if ($value['librarytime'] == '0') {
  2656. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2657. } else {
  2658. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2659. }
  2660. }
  2661. $total = $this->$sj->find_count($where);
  2662. $pagenum = ceil($total / $perpage);
  2663. $over = $total - ($start + $perpage);
  2664. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2665. echo json_encode($rows);
  2666. exit;
  2667. }
  2668. $this->data['express'] = $this->express->find_all();
  2669. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2670. $this->data['wlshop'] = $wlshop;
  2671. $user = $this->user->get_api($_SESSION['api']);
  2672. $powerid = $this->power->read($user['power']);
  2673. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2674. $pid = '';
  2675. foreach ($powertext as $v) {
  2676. $pid .= " id = " . $v . " or";
  2677. }
  2678. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2679. $this->data['fullorderexcel'] = $fullorderexcel;
  2680. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2681. $this->data['orderurl'] = $orderurl;
  2682. $this->_Template('whlabel_toutorder', $this->data);
  2683. }
  2684. //tt出库
  2685. public function _aoutorder()
  2686. {
  2687. if (isset($_SESSION['api'])) {
  2688. $user = $this->user->get_api($_SESSION['api']);
  2689. $usp = $user;
  2690. $fgshop = "";
  2691. $sid = "";
  2692. $user = explode('|', trim($user['shop'], '|'));
  2693. foreach ($user as $value) {
  2694. $fgshop .= " shop = " . $value . " or";
  2695. $sid .= " id = " . $value . " or";
  2696. }
  2697. } else {
  2698. echo "请重新登录";
  2699. }
  2700. $post = $this->input->post(NULL, TRUE);
  2701. if (isset($post['page'])) {
  2702. $page = $this->input->post('page', true);
  2703. $perpage = $this->input->post('perpage', true);
  2704. $warehouse = $this->input->post('warehouse', true);
  2705. $xztime = $this->input->post('xztime', true);
  2706. $timetk = $this->input->post('timetkk', true);
  2707. $timetj = $this->input->post('timetjj', true);
  2708. $shop = $this->input->post('shop', true);
  2709. $source = $this->input->post('source', true);
  2710. $orderinfo = $this->input->post('orderinfo', true);
  2711. $number = $this->input->post('number', true);
  2712. $sfxh = $this->input->post('sfxh', true);
  2713. $express = $this->input->post('express', true);
  2714. $waybill = $this->input->post('waybill', true);
  2715. $library = $this->input->post('library', true);
  2716. $country = $this->input->post('country', true);
  2717. $so = $this->input->post('so', true);
  2718. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2719. $print = $this->input->post('print', true);
  2720. $state = $this->input->post('state', true);
  2721. $orderurl = $this->input->post('orderurl', true);
  2722. $timetk = strtotime($timetk);
  2723. $timetj = strtotime($timetj);
  2724. /**
  2725. $sj = $this->input->post('sj',true);
  2726. if($sj)
  2727. {
  2728. $sj = $this->input->post('sj',true);
  2729. }
  2730. else
  2731. {
  2732. $sj = "fullorder";
  2733. }
  2734. **/
  2735. $sj = "fullorderamz";
  2736. $where = "1=1";
  2737. if ($warehouse) {
  2738. $where .= " and type = '$warehouse'";
  2739. }
  2740. if ($timetk && $timetj) {
  2741. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2742. }
  2743. if ($orderinfo) {
  2744. $where .= " and orderinfo = '$orderinfo'";
  2745. }
  2746. if ($number) {
  2747. $where .= " and number = '$number'";
  2748. }
  2749. if ($express) {
  2750. $where .= " and express = '$express'";
  2751. }
  2752. if ($waybill) {
  2753. $where .= " and waybill = '$waybill'";
  2754. }
  2755. if ($library) {
  2756. $where .= " and library = '$library'";
  2757. }
  2758. if ($print) {
  2759. $where .= " and print = '$print'";
  2760. }
  2761. if ($libraryconfirm) {
  2762. $where .= " and libraryconfirm = '$libraryconfirm'";
  2763. }
  2764. if ($state) {
  2765. $where .= " and state = '$state'";
  2766. }
  2767. if ($shop) {
  2768. $where .= " and shop = '$shop'";
  2769. }
  2770. if ($country) {
  2771. $where .= " and country = '$country'";
  2772. }
  2773. if ($sfxh != '') {
  2774. $where .= " and sfxh = '$sfxh'";
  2775. }
  2776. if ($so) {
  2777. $where .= " and shipremarks like '%$so%'";
  2778. }
  2779. if ($source) {
  2780. if ($source == '2d') {
  2781. $where .= " and source >= '2'";
  2782. } else {
  2783. $where .= " and source = '$source'";
  2784. }
  2785. }
  2786. if (isset($_SESSION['api'])) {
  2787. foreach ($user as $value) {
  2788. $fgshop .= " shop = " . $value . " or";
  2789. }
  2790. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2791. }
  2792. if ($orderurl) {
  2793. $url = $this->orderurl->read($orderurl);
  2794. $where .= " and link like '%" . $url['url'] . "%'";
  2795. }
  2796. //数据排序
  2797. $order_str = "librarytime desc";
  2798. if (empty($page)) {
  2799. $start = 0;
  2800. $perpage = 1;
  2801. } else {
  2802. $start = ($page - 1) * $perpage;
  2803. }
  2804. //取得信息列表
  2805. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2806. //格式化数据
  2807. foreach ($info_list as $key => $value) {
  2808. $shop = $this->shop->read($value['shop']);
  2809. $info_list[$key]['shop'] = $shop['shopname'];
  2810. $express = $this->express->read($value['express']);
  2811. $info_list[$key]['express'] = $express['servicename'];
  2812. $warehouse = $this->warehouse->read($value['type']);
  2813. $info_list[$key]['type'] = $warehouse['title'];
  2814. if ($value['librarytime'] == '0') {
  2815. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2816. } else {
  2817. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2818. }
  2819. }
  2820. $total = $this->$sj->find_count($where);
  2821. $pagenum = ceil($total / $perpage);
  2822. $over = $total - ($start + $perpage);
  2823. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2824. echo json_encode($rows);
  2825. exit;
  2826. }
  2827. $this->data['express'] = $this->express->find_all();
  2828. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2829. $this->data['wlshop'] = $wlshop;
  2830. $user = $this->user->get_api($_SESSION['api']);
  2831. $powerid = $this->power->read($user['power']);
  2832. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2833. $pid = '';
  2834. foreach ($powertext as $v) {
  2835. $pid .= " id = " . $v . " or";
  2836. }
  2837. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2838. $this->data['fullorderexcel'] = $fullorderexcel;
  2839. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2840. $this->data['orderurl'] = $orderurl;
  2841. $this->_Template('whlabel_aoutorder', $this->data);
  2842. }
  2843. //速卖通出库订单
  2844. public function _soutorder()
  2845. {
  2846. if (isset($_SESSION['api'])) {
  2847. $user = $this->user->get_api($_SESSION['api']);
  2848. $usp = $user;
  2849. $fgshop = "";
  2850. $sid = "";
  2851. $user = explode('|', trim($user['shop'], '|'));
  2852. foreach ($user as $value) {
  2853. $sid .= " id = " . $value . " or";
  2854. }
  2855. }
  2856. $post = $this->input->post(NULL, TRUE);
  2857. if (isset($post['page'])) {
  2858. $page = $this->input->post('page', true);
  2859. $perpage = $this->input->post('perpage', true);
  2860. $warehouse = $this->input->post('warehouse', true);
  2861. $xztime = $this->input->post('xztime', true);
  2862. $timetk = $this->input->post('timetkk', true);
  2863. $timetj = $this->input->post('timetjj', true);
  2864. $shop = $this->input->post('shop', true);
  2865. $source = $this->input->post('source', true);
  2866. $orderinfo = $this->input->post('orderinfo', true);
  2867. $number = $this->input->post('number', true);
  2868. $express = $this->input->post('express', true);
  2869. $waybill = $this->input->post('waybill', true);
  2870. $library = $this->input->post('library', true);
  2871. $country = $this->input->post('country', true);
  2872. $sfxh = $this->input->post('sfxh', true);
  2873. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2874. $print = $this->input->post('print', true);
  2875. $state = $this->input->post('state', true);
  2876. $so = $this->input->post('so', true);
  2877. $timetk = strtotime($timetk);
  2878. $timetj = strtotime($timetj);
  2879. /**
  2880. $sj = $this->input->post('sj',true);
  2881. if($sj)
  2882. {
  2883. $sj = $this->input->post('sj',true);
  2884. }
  2885. else
  2886. {
  2887. $sj = "fullorder";
  2888. }
  2889. **/
  2890. $sj = "fullordersmt";
  2891. $where = "1=1";
  2892. if ($warehouse) {
  2893. $where .= " and type = '$warehouse'";
  2894. }
  2895. if ($timetk && $timetj) {
  2896. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2897. }
  2898. if ($orderinfo) {
  2899. $where .= " and orderinfo = '$orderinfo'";
  2900. }
  2901. if ($number) {
  2902. $where .= " and number = '$number'";
  2903. }
  2904. if ($express) {
  2905. $where .= " and express = '$express'";
  2906. }
  2907. if ($waybill) {
  2908. $where .= " and waybill = '$waybill'";
  2909. }
  2910. if ($library) {
  2911. $where .= " and library = '$library'";
  2912. }
  2913. if ($print) {
  2914. $where .= " and print = '$print'";
  2915. }
  2916. if ($libraryconfirm) {
  2917. $where .= " and libraryconfirm = '$libraryconfirm'";
  2918. }
  2919. if ($state) {
  2920. $where .= " and state = '$state'";
  2921. }
  2922. if ($shop) {
  2923. $where .= " and shop = '$shop'";
  2924. }
  2925. if ($sfxh != '') {
  2926. $where .= " and sfxh = '$sfxh'";
  2927. }
  2928. if ($so) {
  2929. $where .= " and shipremarks like '%$so%'";
  2930. }
  2931. if ($source) {
  2932. $where .= " and source = '$source'";
  2933. }
  2934. if ($country) {
  2935. $where .= " and country = '$country'";
  2936. } else {
  2937. if (isset($_SESSION['api'])) {
  2938. foreach ($user as $value) {
  2939. $fgshop .= " shop = " . $value . " or";
  2940. }
  2941. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2942. }
  2943. }
  2944. //数据排序
  2945. $order_str = "librarytime desc";
  2946. if (empty($page)) {
  2947. $start = 0;
  2948. $perpage = 1;
  2949. } else {
  2950. $start = ($page - 1) * $perpage;
  2951. }
  2952. //取得信息列表
  2953. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2954. //格式化数据
  2955. foreach ($info_list as $key => $value) {
  2956. $shop = $this->shop->read($value['shop']);
  2957. $info_list[$key]['shop'] = $shop['shopname'];
  2958. $express = $this->express->read($value['express']);
  2959. $info_list[$key]['express'] = $express['servicename'];
  2960. $warehouse = $this->warehouse->read($value['type']);
  2961. $info_list[$key]['type'] = $warehouse['title'];
  2962. if ($value['librarytime'] == '0') {
  2963. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2964. } else {
  2965. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2966. }
  2967. }
  2968. $total = $this->$sj->find_count($where);
  2969. $pagenum = ceil($total / $perpage);
  2970. $over = $total - ($start + $perpage);
  2971. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2972. echo json_encode($rows);
  2973. exit;
  2974. }
  2975. $this->data['express'] = $this->express->find_all();
  2976. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2977. $this->data['wlshop'] = $wlshop;
  2978. $user = $this->user->get_api($_SESSION['api']);
  2979. $powerid = $this->power->read($user['power']);
  2980. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2981. $pid = '';
  2982. foreach ($powertext as $v) {
  2983. $pid .= " id = " . $v . " or";
  2984. }
  2985. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2986. $this->data['fullorderexcel'] = $fullorderexcel;
  2987. $this->_Template('whlabel_soutorder', $this->data);
  2988. }
  2989. //订单退库
  2990. public function _retreat()
  2991. {
  2992. $post = $this->input->post(NULL, TRUE);
  2993. if (isset($post['page'])) {
  2994. $page = $this->input->post('page', true);
  2995. $perpage = $this->input->post('perpage', true);
  2996. $warehouse = $this->input->post('warehouse', true);
  2997. $timetk = $this->input->post('timetk', true);
  2998. $timetj = $this->input->post('timetj', true);
  2999. $shop = $this->input->post('shop', true);
  3000. $source = $this->input->post('source', true);
  3001. $state = $this->input->post('state', true);
  3002. $review = $this->input->post('review', true);
  3003. $state = $this->input->post('state', true);
  3004. $express = $this->input->post('express', true);
  3005. $orderinfo = $this->input->post('orderinfo', true);
  3006. $user = $this->input->post('user', true);
  3007. $name = $this->input->post('name', true);
  3008. $waybill = $this->input->post('waybill', true);
  3009. $timetk = strtotime($timetk);
  3010. $timetj = strtotime($timetj);
  3011. $where = "(state=206 or state=210) and mergeid = 0";
  3012. if ($warehouse) {
  3013. $where .= " and state = '$warehouse'";
  3014. }
  3015. if ($timetk && $timetj) {
  3016. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3017. }
  3018. if ($shop) {
  3019. $where .= " and shop = '$shop'";
  3020. }
  3021. if ($source) {
  3022. $where .= " and source = '$source'";
  3023. }
  3024. if ($state) {
  3025. $where .= " and state = '$state'";
  3026. }
  3027. if ($review) {
  3028. $where .= " and review = '$review'";
  3029. }
  3030. if ($state) {
  3031. $where .= " and state = '$state'";
  3032. }
  3033. if ($express) {
  3034. $where .= " and express = '$express'";
  3035. }
  3036. if ($orderinfo) {
  3037. $where .= " and orderinfo = '$orderinfo'";
  3038. }
  3039. if ($user) {
  3040. $where .= " and user = '$user'";
  3041. }
  3042. if ($name) {
  3043. $where .= " and name = '$name'";
  3044. }
  3045. if ($waybill) {
  3046. $where .= " and waybill = '$waybill'";
  3047. }
  3048. //数据排序
  3049. $order_str = "id desc";
  3050. if (empty($page)) {
  3051. $start = 0;
  3052. $perpage = 1;
  3053. } else {
  3054. $start = ($page - 1) * $perpage;
  3055. }
  3056. //取得信息列表
  3057. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3058. //格式化数据
  3059. foreach ($info_list as $key => $value) {
  3060. $shop = $this->shop->read($value['shop']);
  3061. $info_list[$key]['shop'] = $shop['shopname'];
  3062. $warehouse = $this->warehouse->read($value['warehouse']);
  3063. $info_list[$key]['warehouse'] = $warehouse['title'];
  3064. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3065. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3066. if ($value['waybill'] == 0) {
  3067. $info_list[$key]['waybill'] = "";
  3068. }
  3069. $express = $this->express->read($value['express']);
  3070. $info_list[$key]['express'] = $express['title'];
  3071. $typeclass = $this->typeclass->read($value['state']);
  3072. $info_list[$key]['state'] = $typeclass['title'];
  3073. }
  3074. $total = $this->fullorder->find_count($where);
  3075. $pagenum = ceil($total / $perpage);
  3076. $over = $total - ($start + $perpage);
  3077. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3078. echo json_encode($rows);
  3079. exit;
  3080. }
  3081. $this->data['express'] = $this->express->find_all();
  3082. $this->_Template('whlabel_retreat', $this->data);
  3083. }
  3084. //退库标签浏览
  3085. public function _retreatlk()
  3086. {
  3087. $post = $this->input->post(NULL, TRUE);
  3088. if (isset($post['page'])) {
  3089. $page = $this->input->post('page', true);
  3090. $perpage = $this->input->post('perpage', true);
  3091. $timetk = $this->input->post('timetk', true);
  3092. $timetj = $this->input->post('timetj', true);
  3093. $sku = $this->input->post('sku', true);
  3094. $warehouse = $this->input->post('warehouse', true);
  3095. $purchase = $this->input->post('purchase', true);
  3096. $orderinfo = $this->input->post('orderinfo', true);
  3097. $waybill = $this->input->post('waybill', true);
  3098. $category = $this->input->post('category', true);
  3099. $size = $this->input->post('size', true);
  3100. $grade = $this->input->post('grade', true);
  3101. $color = $this->input->post('color', true);
  3102. $lowe = $this->input->post('lowe', true);
  3103. $state = $this->input->post('state', true);
  3104. $timetk = strtotime($timetk);
  3105. $timetj = strtotime($timetj);
  3106. $where = "state=2";
  3107. if ($timetk && $timetj) {
  3108. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3109. }
  3110. if ($sku) {
  3111. $where .= " and sku = '$sku'";
  3112. }
  3113. if ($warehouse) {
  3114. $where .= " and warehouse = '$warehouse'";
  3115. }
  3116. if ($purchase) {
  3117. $where .= " and purchase = '$purchase'";
  3118. }
  3119. if ($orderinfo) {
  3120. $where .= " and orderinfo = '$orderinfo'";
  3121. }
  3122. if ($waybill) {
  3123. $where .= " and waybill = '$waybill'";
  3124. }
  3125. if ($category) {
  3126. $where .= " and features like '%-$category-%'";
  3127. }
  3128. if ($size) {
  3129. $where .= " and features like '%-$size-%'";
  3130. }
  3131. if ($grade) {
  3132. $where .= " and features like '%-$grade-%'";
  3133. }
  3134. if ($color) {
  3135. $where .= " and features like '%-$color-%'";
  3136. }
  3137. if ($lowe) {
  3138. $where .= " and features like '%-$lowe-%'";
  3139. }
  3140. //数据排序
  3141. $order_str = "time desc";
  3142. if (empty($page)) {
  3143. $start = 0;
  3144. $perpage = 1;
  3145. } else {
  3146. $start = ($page - 1) * $perpage;
  3147. }
  3148. //取得信息列表
  3149. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3150. foreach ($info_list as $key => $value) {
  3151. $warehouse = $this->warehouse->read($value['warehouse']);
  3152. $info_list[$key]['warehouse'] = $warehouse['title'];
  3153. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3154. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3155. $purchase = $this->purchase->read($value['purchase']);
  3156. $info_list[$key]['purchase'] = $purchase['title'];
  3157. if ($value['outk'] != 0) {
  3158. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3159. } else {
  3160. $info_list[$key]['outk'] = "";
  3161. }
  3162. if ($value['retreat'] != 0) {
  3163. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3164. } else {
  3165. $info_list[$key]['retreat'] = "";
  3166. }
  3167. if ($value['orderinfo'] == 0) {
  3168. $info_list[$key]['orderinfo'] = "";
  3169. }
  3170. if ($value['waybill'] == 0) {
  3171. $info_list[$key]['waybill'] = "";
  3172. }
  3173. }
  3174. $total = $this->whlabel->find_count($where);
  3175. $pagenum = ceil($total / $perpage);
  3176. $over = $total - ($start + $perpage);
  3177. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3178. echo json_encode($rows);
  3179. exit;
  3180. }
  3181. $this->_Template('whlabel_retreatlk', $this->data);
  3182. }
  3183. //更换标签及浏览
  3184. public function _change()
  3185. {
  3186. $post = $this->input->post(NULL, TRUE);
  3187. if (isset($post['page'])) {
  3188. $page = $this->input->post('page', true);
  3189. $perpage = $this->input->post('perpage', true);
  3190. $timetk = $this->input->post('timetk', true);
  3191. $timetj = $this->input->post('timetj', true);
  3192. $label = $this->input->post('label', true);
  3193. $oldlabel = $this->input->post('oldlabel', true);
  3194. $timetk = strtotime($timetk);
  3195. $timetj = strtotime($timetj);
  3196. $where = "state=10 ";
  3197. if ($timetk && $timetj) {
  3198. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3199. }
  3200. if ($label) {
  3201. $where .= " and label = '$label'";
  3202. }
  3203. if ($oldlabel) {
  3204. $where .= " and oldlabel = '$oldlabel'";
  3205. }
  3206. //数据排序
  3207. $order_str = "time asc";
  3208. if (empty($page)) {
  3209. $start = 0;
  3210. $perpage = 1;
  3211. } else {
  3212. $start = ($page - 1) * $perpage;
  3213. }
  3214. //取得信息列表
  3215. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3216. foreach ($info_list as $key => $value) {
  3217. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3218. }
  3219. $total = $this->whlabel->find_count($where);
  3220. $pagenum = ceil($total / $perpage);
  3221. $over = $total - ($start + $perpage);
  3222. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3223. echo json_encode($rows);
  3224. exit;
  3225. }
  3226. $this->_Template('whlabel_change', $this->data);
  3227. }
  3228. //产品标签
  3229. public function _cpbqdc()
  3230. {
  3231. if (isset($_GET['excel'])) {
  3232. $where = "1=1";
  3233. //数据排序
  3234. $order_str = "id desc";
  3235. if (empty($page)) {
  3236. $start = 0;
  3237. $perpage = 1;
  3238. } else {
  3239. $start = ($page - 1) * $perpage;
  3240. }
  3241. $warehouse = $this->input->get('warehouse', true);
  3242. $state = $this->input->get('state', true);
  3243. $timetk = $this->input->get('timetkk', true);
  3244. $timetj = $this->input->get('timetjj', true);
  3245. $timetk = strtotime($timetk);
  3246. $timetj = strtotime($timetj);
  3247. if ($warehouse) {
  3248. $where .= " and warehouse = '$warehouse'";
  3249. }
  3250. if ($state || $state == 0) {
  3251. $where .= " and state = '$state'";
  3252. }
  3253. if ($timetk && $timetj) {
  3254. $where .= " and time > '$timetk' and time < '$timetj'";
  3255. }
  3256. //取得信息列表
  3257. $info_list = $this->whlabel->find_all($where, '*');
  3258. $rows = array();
  3259. $list = array();
  3260. foreach ($info_list as $key => $value) {
  3261. $rows[$value['time']] = $value; //所有数据sku
  3262. }
  3263. foreach ($rows as $value) {
  3264. $warehouse = $this->warehouse->read($value['warehouse']);
  3265. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3266. $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);
  3267. }
  3268. $title = "产品标签统计表";
  3269. $titlename = "<table border=1>
  3270. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3271. <tr align='center'>
  3272. <td>仓库</td>
  3273. <td>SKU</td>
  3274. <td>产品</td>
  3275. <td>入库时间</td>
  3276. <td>操作时间</td>
  3277. <td>备注</td>
  3278. <td>数量</td>
  3279. </tr>
  3280. </table>";
  3281. $filename = $title . ".xls";
  3282. $tail = "";
  3283. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3284. }
  3285. }
  3286. //进销存导出
  3287. public function _exceljxc()
  3288. {
  3289. $classid = $this->classid->sku();
  3290. $pm = $classid;
  3291. $typeclass = array();
  3292. $tc = $this->typeclass->find_all();
  3293. foreach ($tc as $v) {
  3294. $typeclass[$v['id']] = $v;
  3295. }
  3296. $prc = array();
  3297. $purchase = $this->purchase->find_all();
  3298. foreach ($purchase as $k => $v) {
  3299. $prc[$v['id']] = $v['title'];
  3300. }
  3301. if (isset($_GET['excel'])) {
  3302. $where = "sku != 'Preset'";
  3303. //数据排序
  3304. $order_str = "id desc";
  3305. if (empty($page)) {
  3306. $start = 0;
  3307. $perpage = 1;
  3308. } else {
  3309. $start = ($page - 1) * $perpage;
  3310. }
  3311. $category = $this->input->get('category', true);
  3312. $warehouse = $this->input->get('warehouse', true);
  3313. $excelid = $this->input->get('sid', true);
  3314. if ($category) {
  3315. $where .= " and features like '%-$category-%'";
  3316. }
  3317. if ($warehouse) {
  3318. $where .= " and warehouse = '$warehouse'";
  3319. }
  3320. $xzid = '';
  3321. if ($excelid) {
  3322. $excelid = explode(',', trim($excelid, ','));
  3323. foreach ($excelid as $key => $value) {
  3324. $xzid .= " id = " . $value . " or";
  3325. }
  3326. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3327. }
  3328. //取得信息列表
  3329. /**
  3330. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3331. $rows = array();$list = array();
  3332. foreach ($info_list as $key=>$value)
  3333. {
  3334. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3335. }
  3336. **/
  3337. $wt = array();
  3338. $whlabel_type = $this->whlabel_type->find_all();
  3339. foreach ($whlabel_type as $v) {
  3340. $wt[$v['id']] = $v['title'];
  3341. }
  3342. $wh = array();
  3343. $w = $this->warehouse->find_all('1=1', 'id,title');
  3344. foreach ($w as $v) {
  3345. $wh[$v['id']] = $v['title'];
  3346. }
  3347. $list = array();
  3348. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3349. foreach ($rows as $key => $value) {
  3350. if (isset($wt[$value['type']])) {
  3351. $rows[$key]['type'] = $wt[$value['type']];
  3352. } else {
  3353. $rows[$key]['type'] = '未设置';
  3354. }
  3355. $bm = '03';
  3356. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3357. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3358. $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');
  3359. $details = array();
  3360. $cpid = array();
  3361. $cpbz = array();
  3362. $c = 0;
  3363. $g = 0;
  3364. $x = 0;
  3365. $t = 0;
  3366. $s = 0;
  3367. $q = 0;
  3368. foreach ($sd as $k => $v) {
  3369. if ($v['state'] == 0) {
  3370. $c++;
  3371. if ($v['cpid'] != 0) {
  3372. $cpid[$v['cpid']] = $v['cpid'];
  3373. }
  3374. if ($v['cpbz'] != '') {
  3375. $cpbz[$v['cpbz']] = $v['cpbz'];
  3376. }
  3377. }
  3378. if ($v['state'] != 9) {
  3379. $g++;
  3380. }
  3381. if ($v['state'] == 1) {
  3382. $x++;
  3383. }
  3384. if ($v['state'] == 2) {
  3385. $t++;
  3386. }
  3387. if ($v['state'] == 8) {
  3388. $s++;
  3389. }
  3390. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3391. $q++;
  3392. }
  3393. $details[$v['details']] = $v['details'];
  3394. }
  3395. $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'] . '"');
  3396. $rows[$key]['details'] = implode("、", $details);
  3397. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3398. $number = $value['number'];
  3399. $ftime = time() - 15 * 24 * 3600;
  3400. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3401. $rows[$key]['number'] = $g;
  3402. $rows[$key]['c'] = $c;
  3403. $rows[$key]['x'] = $x;
  3404. $rows[$key]['t'] = $t;
  3405. $rows[$key]['s'] = $s;
  3406. $rows[$key]['q'] = $q;
  3407. $rows[$key]['z'] = $z;
  3408. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3409. $features = explode('-', trim($features, '-'));
  3410. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3411. // $pm = $classid;
  3412. // $jm = $classid;
  3413. // foreach($features as $k=>$v)
  3414. // {
  3415. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3416. // {
  3417. // if($typeclass[$v]['bm'] != '')
  3418. // {
  3419. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3420. // }
  3421. // }
  3422. // if($v != 0)
  3423. // {
  3424. // if(!isset($typeclass[$v]))
  3425. // {
  3426. // continue;
  3427. // }
  3428. // if(isset($pm[$typeclass[$v]['classid']]))
  3429. // {
  3430. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3431. // {
  3432. // $tz = explode('|',$typeclass[$v]['zh']);
  3433. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3434. // }
  3435. // else
  3436. // {
  3437. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3438. // }
  3439. // }
  3440. // if(isset($jm[$typeclass[$v]['classid']]))
  3441. // {
  3442. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3443. // }
  3444. // }
  3445. // }
  3446. // $jm = array_filter($jm);
  3447. // $rows[$key]['bs'] = implode("-",$jm);
  3448. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3449. // $zh = implode(" ",$pm);
  3450. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3451. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3452. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3453. // $rows[$key]['features'] = $zh;
  3454. }
  3455. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3456. $final_list = [];
  3457. foreach ($list as $k => $v) {
  3458. if (empty($v['sku'])) {
  3459. continue;
  3460. }
  3461. $final_list[] = [
  3462. "warehouse" => $v["warehouse"],
  3463. "purchase" => $v["purchase"],
  3464. "details" => $v["details"],
  3465. "cpid" => $v["cpid"],
  3466. "dbcontent" => $v["dbcontent"],
  3467. "sku" => $v["sku"],
  3468. "cs" => $v["bm"],
  3469. "bs" => $v["jm"],
  3470. "title" => $v["title"],
  3471. "features" => $v["pm"],
  3472. "cpbz" => $v["cpbz"],
  3473. "sm" => $v["sm"],
  3474. "type" => $v["type"],
  3475. "number" => $v["number"],
  3476. "c" => $v["c"],
  3477. "x" => $v["x"],
  3478. "t" => $v["t"],
  3479. "s" => $v["s"],
  3480. "q" => $v["q"],
  3481. "z" => $v["z"],
  3482. "weight" => $v['weight'],
  3483. ];
  3484. }
  3485. $title = "总进销存统计表";
  3486. $titlename = "<table border=1>
  3487. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3488. <tr align='center'>
  3489. <td>仓库</td>
  3490. <td>供应商</td>
  3491. <td>位置</td>
  3492. <td>库存编码</td>
  3493. <td>类目</td>
  3494. <td>SKU</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>占单数量</td>
  3509. <td>重量(g)</td>
  3510. </tr>
  3511. </table>";
  3512. $filename = $title . ".xls";
  3513. $tail = "";
  3514. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3515. }
  3516. }
  3517. //入库导出
  3518. public function _excelr()
  3519. {
  3520. if (isset($_GET['excel'])) {
  3521. $category = $this->input->get('category', true);
  3522. $size = $this->input->get('size', true);
  3523. $grade = $this->input->get('grade', true);
  3524. $color = $this->input->get('color', true);
  3525. $lowe = $this->input->get('lowe', true);
  3526. $sku = $this->input->get('sku', true);
  3527. $warehouse = $this->input->get('warehouse', true);
  3528. $purchase = $this->input->get('purchase', true);
  3529. $ktime = $this->input->get('ktime', true);
  3530. $jtime = $this->input->get('jtime', true);
  3531. $ktime = strtotime($ktime);
  3532. $jtime = strtotime($jtime);
  3533. $where = "1=1";
  3534. $gj = "";
  3535. $ck = "";
  3536. if ($category) {
  3537. $where .= " and features like '%-$category-%'";
  3538. }
  3539. if ($size) {
  3540. $where .= " and features like '%-$size-%'";
  3541. }
  3542. if ($grade) {
  3543. $where .= " and features like '%-$grade-%'";
  3544. }
  3545. if ($color) {
  3546. $where .= " and features like '%-$color-%'";
  3547. }
  3548. if ($lowe) {
  3549. $where .= " and features like '%-$lowe-%'";
  3550. }
  3551. if ($warehouse) {
  3552. $where .= " and warehouse = '$warehouse'";
  3553. }
  3554. if ($purchase) {
  3555. $where .= " and purchase = '$purchase'";
  3556. }
  3557. if ($sku) {
  3558. $where .= " and sku = '$sku'";
  3559. }
  3560. if ($ktime && $jtime) {
  3561. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3562. }
  3563. //数据排序
  3564. $order_str = "id desc";
  3565. if (empty($page)) {
  3566. $start = 0;
  3567. $perpage = 1;
  3568. } else {
  3569. $start = ($page - 1) * $perpage;
  3570. }
  3571. $list = array();
  3572. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3573. foreach ($rows as $value) {
  3574. $ck = $this->warehouse->read($value['warehouse']);
  3575. $warehouse = $ck['title'];
  3576. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3577. $retreatwarehouse = $tkck['title'];
  3578. $gy = $this->purchase->read($value['purchase']);
  3579. $purchase = $gy['title'];
  3580. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3581. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3582. }
  3583. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3584. $titlename = "<table border=1>
  3585. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3586. <tr align='center'>
  3587. <td>仓库</td>
  3588. <td>SKU</td>
  3589. <td>产品</td>
  3590. <td>时间</td>
  3591. <td>数量</td>
  3592. </tr>
  3593. </table>";
  3594. $filename = $title . ".xls";
  3595. $tail = "";
  3596. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3597. }
  3598. }
  3599. //出库、退库导出
  3600. public function _excelct()
  3601. {
  3602. $classid = $this->classid->sku();
  3603. $pm = $classid;
  3604. $typeclass = array();
  3605. $tc = $this->typeclass->find_all();
  3606. foreach ($tc as $v) {
  3607. $typeclass[$v['id']] = $v;
  3608. }
  3609. $prc = array();
  3610. $purchase = $this->purchase->find_all();
  3611. foreach ($purchase as $k => $v) {
  3612. $prc[$v['id']] = $v['title'];
  3613. }
  3614. if (isset($_GET['excel'])) {
  3615. $wh = array();
  3616. $w = $this->warehouse->find_all('1=1', 'id,title');
  3617. foreach ($w as $v) {
  3618. $wh[$v['id']] = $v['title'];
  3619. }
  3620. $type = $this->input->get('excel', true);
  3621. $category = $this->input->get('category', true);
  3622. $size = $this->input->get('size', true);
  3623. $grade = $this->input->get('grade', true);
  3624. $color = $this->input->get('color', true);
  3625. $lowe = $this->input->get('lowe', true);
  3626. $sku = $this->input->get('sku', true);
  3627. $warehouse = $this->input->get('warehouse', true);
  3628. $lacetype = $this->input->get('lacetype', true);
  3629. $lacecolor = $this->input->get('lacecolor', true);
  3630. $density = $this->input->get('density', true);
  3631. $haircap = $this->input->get('haircap', true);
  3632. $purchase = $this->input->get('purchase', true);
  3633. $title = $this->input->get('title', true);
  3634. $state = $this->input->get('state', true);
  3635. $sid = $this->input->get('sid', true);
  3636. $ktime = $this->input->get('ktime', true);
  3637. $jtime = $this->input->get('jtime', true);
  3638. $ktime = strtotime($ktime);
  3639. $jtime = strtotime($jtime);
  3640. $where = "1=1";
  3641. $gj = "";
  3642. $ck = "";
  3643. if ($category) {
  3644. $where .= " and features like '%-$category-%'";
  3645. }
  3646. if ($size) {
  3647. $where .= " and features like '%-$size-%'";
  3648. }
  3649. if ($grade) {
  3650. $where .= " and features like '%-$grade-%'";
  3651. }
  3652. if ($color) {
  3653. $where .= " and features like '%-$color-%'";
  3654. }
  3655. if ($lowe) {
  3656. $where .= " and features like '%-$lowe-%'";
  3657. }
  3658. if ($warehouse) {
  3659. $where .= " and warehouse = '$warehouse'";
  3660. }
  3661. if ($purchase) {
  3662. $where .= " and purchase = '$purchase'";
  3663. }
  3664. if ($state) {
  3665. $where .= " and state = '$state'";
  3666. }
  3667. if ($lacetype) {
  3668. $where .= " and features like '%-$lacetype-%'";
  3669. }
  3670. if ($lacecolor) {
  3671. $where .= " and features like '%-$lacecolor-%'";
  3672. }
  3673. if ($density) {
  3674. $where .= " and features like '%-$density-%'";
  3675. }
  3676. if ($haircap) {
  3677. $where .= " and features like '%-$haircap-%'";
  3678. }
  3679. if ($title) {
  3680. $title = trim($title, ' ');
  3681. $title = trim($title, ' ');
  3682. $where .= " and title like '%$title%'";
  3683. }
  3684. if ($sku) {
  3685. $sku = trim($sku, ' ');
  3686. $sku = trim($sku, ' ');
  3687. $where .= " and sku like '%$sku%'";
  3688. }
  3689. if ($ktime && $jtime) {
  3690. if ($type == 1) {
  3691. $tl = '出库';
  3692. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3693. } else if ($type == 2) {
  3694. $tl = '退库';
  3695. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3696. } else if ($type == 3) {
  3697. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3698. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3699. } else if ($type == 4) {
  3700. $tl = '出库+零售';
  3701. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3702. } else if ($type == 5) {
  3703. $tl = '零售';
  3704. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3705. }
  3706. }
  3707. $sidwhere = '';
  3708. if ($sid) {
  3709. $sd = "";
  3710. $s = explode(',', trim($sid, ','));
  3711. foreach ($s as $value) {
  3712. $sd .= " id = " . $value . " or";
  3713. }
  3714. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3715. }
  3716. //数据排序
  3717. $order_str = "time desc";
  3718. if (empty($page)) {
  3719. $start = 0;
  3720. $perpage = 1;
  3721. } else {
  3722. $start = ($page - 1) * $perpage;
  3723. }
  3724. //取得信息列表
  3725. if ($type != 3 && $type != 5) {
  3726. if ($type == 1 || $type == 4) {
  3727. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3728. foreach ($info_list as $key => $value) {
  3729. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3730. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3731. $warehouse = $this->warehouse->read($value['warehouse']);
  3732. $info_list[$key]['warehouse'] = $warehouse['title'];
  3733. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3734. $features = explode('-', trim($features, '-'));
  3735. $pm = $classid;
  3736. foreach ($features as $k => $v) {
  3737. if ($v != 0) {
  3738. if (!isset($typeclass[$v])) {
  3739. continue;
  3740. }
  3741. if (isset($pm[$typeclass[$v]['classid']])) {
  3742. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3743. $tz = explode('|', $typeclass[$v]['zh']);
  3744. $pm[$typeclass[$v]['classid']] = $tz[0];
  3745. } else {
  3746. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3747. }
  3748. }
  3749. }
  3750. }
  3751. $zh = implode(" ", $pm);
  3752. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3753. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3754. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3755. $info_list[$key]['features'] = $zh;
  3756. }
  3757. $final_list = [];
  3758. foreach($info_list as $k=>$v){
  3759. $number = "";
  3760. if(!empty($v['orderinfo'])){
  3761. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3762. if(!empty($tmp_info['number'])){
  3763. $number = $tmp_info['number'];
  3764. }
  3765. }
  3766. $final_list[] = [
  3767. 'warehouse'=>$v['warehouse'],
  3768. 'purchase'=>$v['purchase'],
  3769. 'sku'=>$v['sku'],
  3770. 'title'=>$v['title'],
  3771. 'features'=>$v['features'],
  3772. 'label'=>$v['label'],
  3773. 'orderinfo'=>$v['orderinfo'],
  3774. 'number'=>$number,
  3775. 'waybill'=>$v['waybill'],
  3776. 'outk'=>$v['outk'],
  3777. ];
  3778. }
  3779. } else {
  3780. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3781. foreach ($info_list as $key => $value) {
  3782. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3783. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3784. $warehouse = $this->warehouse->read($value['warehouse']);
  3785. $info_list[$key]['warehouse'] = $warehouse['title'];
  3786. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3787. $features = explode('-', trim($features, '-'));
  3788. $pm = $classid;
  3789. foreach ($features as $k => $v) {
  3790. if ($v != 0) {
  3791. if (!isset($typeclass[$v])) {
  3792. continue;
  3793. }
  3794. if (isset($pm[$typeclass[$v]['classid']])) {
  3795. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3796. $tz = explode('|', $typeclass[$v]['zh']);
  3797. $pm[$typeclass[$v]['classid']] = $tz[0];
  3798. } else {
  3799. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3800. }
  3801. }
  3802. }
  3803. }
  3804. $zh = implode(" ", $pm);
  3805. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3806. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3807. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3808. $info_list[$key]['features'] = $zh;
  3809. }
  3810. $final_list = [];
  3811. foreach($info_list as $k=>$v){
  3812. $number = "";
  3813. if(!empty($v['orderinfo'])){
  3814. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3815. if(!empty($tmp_info['number'])){
  3816. $number = $tmp_info['number'];
  3817. }
  3818. }
  3819. $final_list[] = [
  3820. 'warehouse'=>$v['warehouse'],
  3821. 'purchase'=>$v['purchase'],
  3822. 'sku'=>$v['sku'],
  3823. 'title'=>$v['title'],
  3824. 'features'=>$v['features'],
  3825. 'label'=>$v['label'],
  3826. 'orderinfo'=>$v['orderinfo'],
  3827. 'number'=>$number,
  3828. 'waybill'=>$v['waybill'],
  3829. 'retreat'=>$v['retreat'],
  3830. ];
  3831. }
  3832. }
  3833. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3834. $titlename = "<table border=1>
  3835. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3836. <tr align='center'>
  3837. <td>仓库</td>
  3838. <td>供应商</td>
  3839. <td>SKU</td>
  3840. <td>商品名称</td>
  3841. <td>商品中文</td>
  3842. <td>标签</td>
  3843. <td>订单号</td>
  3844. <td>订单编码</td>
  3845. <td>运单号</td>
  3846. <td>" . $tl . "时间(中国时间)</td>
  3847. </tr>
  3848. </table>";
  3849. $filename = $title . ".xls";
  3850. $tail = "";
  3851. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3852. } else if ($type == 5) {
  3853. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3854. foreach ($info_list as $key => $value) {
  3855. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3856. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3857. $warehouse = $this->warehouse->read($value['warehouse']);
  3858. $info_list[$key]['warehouse'] = $warehouse['title'];
  3859. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3860. $features = explode('-', trim($features, '-'));
  3861. $pm = $classid;
  3862. foreach ($features as $k => $v) {
  3863. if ($v != 0) {
  3864. if (!isset($typeclass[$v])) {
  3865. continue;
  3866. }
  3867. if (isset($pm[$typeclass[$v]['classid']])) {
  3868. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3869. $tz = explode('|', $typeclass[$v]['zh']);
  3870. $pm[$typeclass[$v]['classid']] = $tz[0];
  3871. } else {
  3872. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3873. }
  3874. }
  3875. }
  3876. }
  3877. $zh = implode(" ", $pm);
  3878. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3879. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3880. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3881. $info_list[$key]['features'] = $zh;
  3882. }
  3883. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3884. $titlename = "<table border=1>
  3885. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3886. <tr align='center'>
  3887. <td>仓库</td>
  3888. <td>供应商</td>
  3889. <td>SKU</td>
  3890. <td>商品名称</td>
  3891. <td>商品中文</td>
  3892. <td>标签</td>
  3893. <td>" . $tl . "时间(中国时间)</td>
  3894. </tr>
  3895. </table>";
  3896. $filename = $title . ".xls";
  3897. $tail = "";
  3898. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3899. } else {
  3900. /**
  3901. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3902. $rows = array();$list = array();
  3903. foreach ($info_list as $key=>$value)
  3904. {
  3905. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3906. }
  3907. **/
  3908. $wh = array();
  3909. $w = $this->warehouse->find_all('1=1', 'id,title');
  3910. foreach ($w as $v) {
  3911. $wh[$v['id']] = $v['title'];
  3912. }
  3913. $wt = array();
  3914. $whlabel_type = $this->whlabel_type->find_all();
  3915. foreach ($whlabel_type as $v) {
  3916. $wt[$v['id']] = $v['title'];
  3917. }
  3918. $classid = $this->classid->sku();
  3919. $list = array();
  3920. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3921. foreach ($rows as $key => $value) {
  3922. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3923. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3924. $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');
  3925. $details = array();
  3926. $cpid = array();
  3927. $cpbz = array();
  3928. $c = 0;
  3929. $g = 0;
  3930. $x = 0;
  3931. $t = 0;
  3932. $s = 0;
  3933. $q = 0;
  3934. foreach ($sd as $k => $v) {
  3935. if ($v['state'] == 0) {
  3936. $c++;
  3937. }
  3938. if ($v['state'] != 9) {
  3939. $g++;
  3940. }
  3941. if ($v['outk'] > 1) {
  3942. $x++;
  3943. }
  3944. if ($v['retreat'] > 0) {
  3945. $t++;
  3946. }
  3947. if ($v['state'] == 8) {
  3948. $s++;
  3949. }
  3950. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3951. $q++;
  3952. }
  3953. $details[$v['details']] = $v['details'];
  3954. if ($v['cpid'] != 0) {
  3955. $cpid[$v['cpid']] = $v['cpid'];
  3956. }
  3957. if ($v['cpbz'] != '') {
  3958. $cpbz[$v['cpbz']] = $v['cpbz'];
  3959. }
  3960. }
  3961. if (isset($wt[$value['type']])) {
  3962. $rows[$key]['type'] = $wt[$value['type']];
  3963. } else {
  3964. $rows[$key]['type'] = '未设置';
  3965. }
  3966. $rows[$key]['details'] = implode("、", $details);
  3967. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3968. $ftime = time() - 15 * 24 * 3600;
  3969. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3970. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3971. $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);
  3972. $rows[$key]['c'] = $c;
  3973. $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);
  3974. $rows[$key]['t'] = $t;
  3975. $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'] . '"');
  3976. $rows[$key]['z'] = $z;
  3977. // $jm = $classid;
  3978. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3979. $features = explode('-', trim($features, '-'));
  3980. // $pm = $classid;
  3981. // foreach ($features as $k => $v) {
  3982. // if ($v != 0) {
  3983. // if (!isset($typeclass[$v])) {
  3984. // continue;
  3985. // }
  3986. // if (isset($pm[$typeclass[$v]['classid']])) {
  3987. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3988. // $tz = explode('|', $typeclass[$v]['zh']);
  3989. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3990. // } else {
  3991. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3992. // }
  3993. // if (isset($jm[$typeclass[$v]['classid']])) {
  3994. // if ($typeclass[$v]['jm']) {
  3995. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3996. // }
  3997. // }
  3998. // }
  3999. // }
  4000. // }
  4001. // $zh = implode(" ", $pm);
  4002. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4003. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4004. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4005. // $rows[$key]['features'] = $zh;
  4006. // $jm = array_filter($jm); //去除空值
  4007. // $jm = implode("-", $jm);
  4008. // $rows[$key]['jm'] = $jm;
  4009. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4010. }
  4011. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4012. // echo "<pre>";
  4013. // print_r($tmp_list);
  4014. // die;
  4015. $final_list =[];
  4016. foreach($tmp_list as $k=>$v){
  4017. $final_list[] = [
  4018. "warehouse"=>$v['warehouse'],
  4019. "purchase"=>$v['purchase'],
  4020. "details"=>$v['details'],
  4021. "cpid"=>$v['cpid'],
  4022. "sku"=>$v['sku'],
  4023. "title"=>$v['title'],
  4024. "features"=>$v['pm'],
  4025. "cpbz"=>$v['cpbz'],
  4026. "sm"=>$v['sm'],
  4027. "type"=>$v['type'],
  4028. "g"=>$v["g"],
  4029. "c"=>$v["c"],
  4030. "x"=>$v["x"],
  4031. "t"=>$v["t"],
  4032. "z"=>$v["z"],
  4033. "jm"=>$v["jm"],
  4034. "weight"=>$v["weight"],
  4035. "asd"=>$v["asd"],
  4036. ];
  4037. }
  4038. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4039. $titlename = "<table border=1>
  4040. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4041. <tr align='center'>
  4042. <td>仓库</td>
  4043. <td>供应商</td>
  4044. <td>位置</td>
  4045. <td>库存编码</td>
  4046. <td>SKU</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. <td>类目</td>
  4060. </tr>
  4061. </table>";
  4062. $filename = $title . ".xls";
  4063. $tail = "";
  4064. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4065. }
  4066. }
  4067. }
  4068. //出库+入库数据整合
  4069. public function _excelcr()
  4070. {
  4071. if (isset($_GET['excel'])) {
  4072. $type = $this->input->get('excel', true);
  4073. $category = $this->input->get('category', true);
  4074. $size = $this->input->get('size', true);
  4075. $grade = $this->input->get('grade', true);
  4076. $color = $this->input->get('color', true);
  4077. $lowe = $this->input->get('lowe', true);
  4078. $sku = $this->input->get('sku', true);
  4079. $warehouse = $this->input->get('warehouse', true);
  4080. $purchase = $this->input->get('purchase', true);
  4081. $state = $this->input->get('state', true);
  4082. $sid = $this->input->get('sid', true);
  4083. $ktime = $this->input->get('ktime', true);
  4084. $jtime = $this->input->get('jtime', true);
  4085. $ktime = strtotime($ktime);
  4086. $jtime = strtotime($jtime);
  4087. $where = "1=1";
  4088. $gj = "";
  4089. $ck = "";
  4090. if ($category) {
  4091. $where .= " and features like '%-$category-%'";
  4092. }
  4093. if ($size) {
  4094. $where .= " and features like '%-$size-%'";
  4095. }
  4096. if ($grade) {
  4097. $where .= " and features like '%-$grade-%'";
  4098. }
  4099. if ($color) {
  4100. $where .= " and features like '%-$color-%'";
  4101. }
  4102. if ($lowe) {
  4103. $where .= " and features like '%-$lowe-%'";
  4104. }
  4105. if ($warehouse) {
  4106. $where .= " and warehouse = '$warehouse'";
  4107. }
  4108. if ($purchase) {
  4109. $where .= " and purchase = '$purchase'";
  4110. }
  4111. if ($state) {
  4112. $where .= " and state = '$state'";
  4113. }
  4114. if ($sku) {
  4115. $where .= " and sku like '%$sku%'";
  4116. }
  4117. if ($ktime && $jtime) {
  4118. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4119. }
  4120. $sidwhere = '';
  4121. if ($sid) {
  4122. $sd = "";
  4123. $s = explode(',', trim($sid, ','));
  4124. foreach ($s as $value) {
  4125. $sd .= " id = " . $value . " or";
  4126. }
  4127. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4128. }
  4129. //取得信息列表
  4130. $timeread = $ktime;
  4131. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4132. $timelist = array();
  4133. for ($i = 0; $i < $timenum; $i++) {
  4134. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4135. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4136. }
  4137. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4138. //echo "<pre>";
  4139. //print_r($info_list);
  4140. //exit();
  4141. $rows = array();
  4142. $list = array();
  4143. foreach ($info_list as $key => $value) {
  4144. $thistime = $timelist;
  4145. if (isset($rows[strtolower($value['sku'])])) {
  4146. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4147. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4148. }
  4149. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4150. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4151. }
  4152. } else {
  4153. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4154. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4155. }
  4156. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4157. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4158. }
  4159. $rows[strtolower($value['sku'])] = $thistime;
  4160. }
  4161. }
  4162. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4163. <head>
  4164. <!--[if gte mso 9]><xml>
  4165. <x:ExcelWorkbook>
  4166. <x:ExcelWorksheets>
  4167. <x:ExcelWorksheet>
  4168. <x:Name>EXCEL</x:Name>
  4169. <x:WorksheetOptions>
  4170. <x:Print>
  4171. <x:ValidPrinterInfo />
  4172. </x:Print>
  4173. </x:WorksheetOptions>
  4174. </x:ExcelWorksheet>
  4175. </x:ExcelWorksheets>
  4176. </x:ExcelWorkbook>
  4177. </xml>
  4178. <![endif]-->
  4179. </head><body>";
  4180. $str .= "<table border=1><tr><td>SKU</td>";
  4181. foreach ($timelist as $k => $v) {
  4182. $str .= "<td>" . $k . "出库</td>";
  4183. $str .= "<td>" . $k . "入库</td>";
  4184. }
  4185. $str .= "</tr></table>";
  4186. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4187. foreach ($rows as $key => $val) {
  4188. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4189. foreach ($val as $k => $v) {
  4190. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4191. if ($val[$k]['r'] > 0) {
  4192. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4193. } else {
  4194. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4195. }
  4196. }
  4197. $str .= "</tr>";
  4198. }
  4199. $str .= "</table>";
  4200. $str .= "</body></html>";
  4201. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4202. header("Content-type: application/octet-stream");
  4203. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4204. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4205. header("Pragma: no-cache");
  4206. header("Expires: 0");
  4207. exit($str);
  4208. }
  4209. }
  4210. //数量调整模板导出
  4211. public function _presetout()
  4212. {
  4213. if (isset($_GET['excel'])) {
  4214. $where = "sku != 'Preset' and purchase != 0";
  4215. //数据排序
  4216. $order_str = "id desc";
  4217. if (empty($page)) {
  4218. $start = 0;
  4219. $perpage = 1;
  4220. } else {
  4221. $start = ($page - 1) * $perpage;
  4222. }
  4223. //取得信息列表
  4224. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4225. $rows = array();
  4226. $list = array();
  4227. foreach ($info_list as $value) {
  4228. $warehouse = $this->warehouse->read($value['warehouse']);
  4229. $number = $value['number'];
  4230. $ftime = time() - 15 * 24 * 3600;
  4231. $purchase = $this->purchase->read($value['purchase']);
  4232. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4233. }
  4234. $title = "库存模板";
  4235. $titlename = "<table border=1>
  4236. <tr align='center'>
  4237. <td>仓库</td>
  4238. <td>供应商编码</td>
  4239. <td>SKU</td>
  4240. <td>增减数量(正数或负数)</td>
  4241. <td>增减备注</td>
  4242. <td>扣减方式:0减少库存1删除库存</td>
  4243. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4244. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4245. </tr>
  4246. </table>";
  4247. $filename = $title . ".xls";
  4248. $tail = "";
  4249. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4250. }
  4251. }
  4252. //数量调整模板导入
  4253. public function _presetedit()
  4254. {
  4255. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4256. $config['upload_path'] = '.' . $dir;
  4257. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4258. $config['allowed_types'] = 'xls|xlsx|csv';
  4259. $config['max_size'] = 10240;
  4260. $this->load->library('upload', $config);
  4261. $this->upload->initialize($config);
  4262. if ($this->upload->do_upload('userfile')) {
  4263. $full_path = $dir . $this->upload->data('file_name');
  4264. $fileName = '.' . $full_path;
  4265. if (!file_exists($fileName)) {
  4266. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4267. exit;
  4268. } else {
  4269. require_once "./data/excel/PHPExcel/IOFactory.php";
  4270. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4271. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4272. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4273. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4274. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4275. ++$column; //如果列数大于26行
  4276. $list = array();
  4277. for ($i = 2; $i <= $row; $i++) // 行数循环
  4278. {
  4279. $data = array();
  4280. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4281. {
  4282. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4283. }
  4284. $list[] = $data;
  4285. }
  4286. }
  4287. $i = 0;
  4288. $j = 0;
  4289. $ed = array();
  4290. foreach ($list as $key => $value) {
  4291. $time = time();
  4292. if ($value['0'] == "") {
  4293. continue;
  4294. }
  4295. $warehouse = $this->warehouse->get_title($value['0']);
  4296. $purchase = $this->purchase->get_bm($value['1']);
  4297. $sku = $value['2'];
  4298. $num = $value['3']; //调整数量
  4299. $text = $value['4']; //扣减说明
  4300. $type = $value['5']; //调整方式0扣减1删除
  4301. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4302. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4303. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4304. if (!$purchase) //如果没有这个SKU
  4305. {
  4306. $ed[] = array($purchase . '-不存在此供应商编码');
  4307. $j++;
  4308. continue;
  4309. }
  4310. if (!$d) //如果没有这个SKU
  4311. {
  4312. $ed[] = array($sku . '-库存中不存在此SKU');
  4313. $j++;
  4314. continue;
  4315. }
  4316. if (!isset($warehouse['id'])) {
  4317. $ed[] = array($sku . '-仓库名错误!');
  4318. $j++;
  4319. continue;
  4320. }
  4321. if ($type != '0' && $type != '1') {
  4322. $ed[] = array($sku . '-扣减方式填写错误!');
  4323. $j++;
  4324. continue;
  4325. }
  4326. if ($num < 0) //扣减库存
  4327. {
  4328. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4329. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4330. $j++;
  4331. continue;
  4332. }
  4333. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4334. if (count($data) < abs($num)) {
  4335. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4336. $j++;
  4337. continue;
  4338. }
  4339. if ($type == 0) //如果扣减方式为 扣减库存
  4340. {
  4341. for ($i = 0; $i < abs($num); $i++) {
  4342. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4343. }
  4344. } else if ($type == 1) {
  4345. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4346. if (count($zt) > 0) {
  4347. $ed[] = array($sku . '-有在途库存无法删除!');
  4348. $j++;
  4349. continue;
  4350. }
  4351. for ($i = 0; $i < abs($num); $i++) {
  4352. $this->whlabel->remove($data[$i]['id']);
  4353. }
  4354. }
  4355. } else if ($num > 0) //增加库存
  4356. {
  4357. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4358. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4359. $j++;
  4360. continue;
  4361. }
  4362. $post['sku'] = $d['sku'];
  4363. $post['shop'] = $d['shop'];
  4364. $post['warehouse'] = $warehouse['id'];
  4365. $post['purchase'] = $purchase['id'];
  4366. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4367. $post['state'] = 0;
  4368. $post['title'] = $d['title'];
  4369. $post['number'] = $d['number'];
  4370. $post['features'] = $d['features'];
  4371. $post['enter'] = $time;
  4372. $post['time'] = $time; //操作时间
  4373. $post['rktype'] = $rktype;
  4374. for ($i = 0; $i < $num; $i++) {
  4375. $post['label'] = time() . rand(100, 999) . $i;
  4376. $this->whlabel->insert($post);
  4377. }
  4378. }
  4379. sleep(1); //防止入库时间一样,需要延迟1秒
  4380. }
  4381. if ($j > 0) {
  4382. $tt = date('Ymd', time());
  4383. $title = '库存导入错误信息-' . $tt;
  4384. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4385. $tail = "\n";
  4386. $filename = $title . ".xls";
  4387. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4388. $dir = '/data/excel/' . $time . '/';
  4389. $file_name = 'error_' . $time . rand(1000, 9999);
  4390. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4391. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4392. fwrite($myfile, $ecl);
  4393. fclose($myfile);
  4394. $error = $dir . $file_name . '.xls';
  4395. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4396. exit;
  4397. } else {
  4398. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4399. exit;
  4400. }
  4401. }
  4402. }
  4403. //笛卡儿积
  4404. function cp($ps, $sets, $list)
  4405. {
  4406. $result = array();
  4407. $j = 0;
  4408. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4409. if ($i == 0) {
  4410. $result = $sets[$i];
  4411. }
  4412. $tmp = array();
  4413. foreach ($result as $res) {
  4414. foreach ($sets[$i + 1] as $set) {
  4415. $tmp[] = $res . ',' . $set;
  4416. }
  4417. }
  4418. $result = $tmp;
  4419. }
  4420. $this->db->trans_begin();
  4421. foreach ($result as $v) {
  4422. $post = array();
  4423. $title = "";
  4424. $num = "";
  4425. $data = explode(',', $v);
  4426. for ($i = 0; $i < count($list); $i++) {
  4427. $post[$list[$i]] = $data[$i];
  4428. $typeclass = $this->typeclass->read($data[$i]);
  4429. $title = $title . $typeclass['title'] . " ";
  4430. if ($data[$i] != 0) {
  4431. $num .= $data[$i]; //所有数据ID拼接
  4432. }
  4433. }
  4434. foreach ($ps as $kp => $vp) {
  4435. $post[$kp] = $vp;
  4436. }
  4437. $post['number'] = $num;
  4438. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4439. if ($info_list) {
  4440. $j++;
  4441. } else {
  4442. $skunum = $this->whlabel->find_count();
  4443. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4444. $post['title'] = rtrim($title, ' ');
  4445. $this->whlabel->insert($post);
  4446. }
  4447. }
  4448. if ($this->db->trans_status() === FALSE) {
  4449. $this->db->trans_commit();
  4450. return NULL;
  4451. } else {
  4452. $this->db->trans_commit();
  4453. return $j;
  4454. }
  4455. }
  4456. public function _kj($arg_array)
  4457. {
  4458. if (isset($_POST['sku'])) {
  4459. $time = time();
  4460. $sku = $this->input->post('sku', true);
  4461. $warehouse = $this->input->post('warehouse', true);
  4462. $num = $this->input->post('num', true);
  4463. $text = $this->input->post('text', true);
  4464. $purchase = $this->input->post('purchase', true);
  4465. $cktype = $this->input->post('cktype', true);
  4466. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4467. if ($cktype != 1 && $text == '') {
  4468. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4469. exit;
  4470. }
  4471. if ($num > count($order)) {
  4472. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4473. exit;
  4474. } else {
  4475. for ($i = 0; $i < $num; $i++) {
  4476. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4477. }
  4478. }
  4479. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4480. exit;
  4481. }
  4482. $uid = $this->whlabel->read($arg_array[0]);
  4483. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4484. $this->data['data'] = $uid;
  4485. $this->_Template('whlabel_kj', $this->data);
  4486. }
  4487. public function _summary($arg_array)
  4488. {
  4489. $prc = array();
  4490. $purchase = $this->purchase->find_all();
  4491. foreach ($purchase as $k => $v) {
  4492. $prc[$v['id']] = $v['title'];
  4493. }
  4494. if (isset($_GET['excel'])) {
  4495. $ktime = $this->input->get('ktime', true);
  4496. $jtime = $this->input->get('jtime', true);
  4497. $ktime = strtotime($ktime);
  4498. $jtime = strtotime($jtime);
  4499. $where = "1=1";
  4500. if ($ktime && $jtime) {
  4501. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4502. }
  4503. //数据排序
  4504. $order_str = "time desc";
  4505. if (empty($page)) {
  4506. $start = 0;
  4507. $perpage = 1;
  4508. } else {
  4509. $start = ($page - 1) * $perpage;
  4510. }
  4511. //取得信息列表
  4512. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4513. foreach ($info_list as $key => $value) {
  4514. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4515. $warehouse = $this->warehouse->read($value['warehouse']);
  4516. $info_list[$key]['warehouse'] = $warehouse['title'];
  4517. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4518. $details = array();
  4519. $cpid = array();
  4520. foreach ($x as $k => $v) {
  4521. if ($v['details'] != '') {
  4522. $details[$v['details']] = $v['details'];
  4523. }
  4524. if ($v['cpid'] != 0) {
  4525. $cpid[$v['cpid']] = $v['cpid'];
  4526. }
  4527. }
  4528. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4529. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4530. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4531. $info_list[$key]['s'] = $s;
  4532. $info_list[$key]['x'] = count($x);
  4533. }
  4534. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4535. $titlename = "<table border=1>
  4536. <tr align='center'>
  4537. <td>仓库</td>
  4538. <td>供应商</td>
  4539. <td>出库位置</td>
  4540. <td>出库编码</td>
  4541. <td>SKU</td>
  4542. <td>产品名</td>
  4543. <td>总剩余库存</td>
  4544. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4545. </tr>
  4546. </table>";
  4547. $filename = $title . ".xls";
  4548. $tail = "";
  4549. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4550. }
  4551. }
  4552. //usps发货清单
  4553. public function _manifest()
  4554. {
  4555. if (isset($_POST['manifest'])) {
  4556. $wltext = $this->input->post('wltext', true);
  4557. $time = time() - 16 * 3600;
  4558. $ptime = strtotime(date('Y-m-d', $time));
  4559. $waybill = array();
  4560. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4561. foreach ($fullorder as $v) {
  4562. $waybill[$v['waybill']] = $v['waybill'];
  4563. }
  4564. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4565. foreach ($fullordersmt as $v) {
  4566. $waybill[$v['waybill']] = $v['waybill'];
  4567. }
  4568. $wltext = explode(';', $wltext);
  4569. foreach ($wltext as $v) {
  4570. if (isset($waybill[$v])) {
  4571. unset($waybill[$v]);
  4572. }
  4573. }
  4574. $data = $this->usps->get_manifest($waybill);
  4575. if (isset($data['Description'])) {
  4576. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4577. exit;
  4578. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4579. $bctime = date('Ymd', time());
  4580. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4581. echo json_encode(array('msg' => $pdf, 'success' => true));
  4582. exit;
  4583. } else {
  4584. echo json_encode(array('msg' => $data, 'success' => false));
  4585. exit;
  4586. }
  4587. }
  4588. }
  4589. public function _pdf($pdf, $title, $bctime)
  4590. {
  4591. $pdf_path = './data/pdf/' . $bctime . '/';
  4592. $file_base64 = $pdf;
  4593. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4594. $file_base64 = base64_decode($file_base64);
  4595. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4596. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4597. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4598. }
  4599. /**
  4600. *
  4601. *
  4602. *
  4603. 进销存占单异常索引
  4604. *
  4605. *
  4606. *
  4607. **/
  4608. public function _abnormal()
  4609. {
  4610. $post = $this->input->post(NULL, TRUE);
  4611. if (isset($post['page'])) {
  4612. $page = $this->input->post('page', true);
  4613. $perpage = $this->input->post('perpage', true);
  4614. $sku = $this->input->post('sku', true);
  4615. $where = "1=1";
  4616. //数据排序
  4617. $order_str = "id desc";
  4618. if (empty($page)) {
  4619. $start = 0;
  4620. $perpage = 1;
  4621. } else {
  4622. $start = ($page - 1) * $perpage;
  4623. }
  4624. //取得信息列表
  4625. $info_list = $this->whlabel->find_all($where, '*');
  4626. $rows = array();
  4627. $list = array();
  4628. foreach ($info_list as $key => $value) {
  4629. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4630. }
  4631. foreach ($rows as $value) {
  4632. $warehouse = $this->warehouse->read($value['warehouse']);
  4633. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4634. $number = $value['number'];
  4635. $ftime = time() - 15 * 24 * 3600;
  4636. if ($value['shop'] != '') {
  4637. $shop = $value['shop'];
  4638. $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');
  4639. $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');
  4640. $order = array_merge($orderdlz, $ordersmt);
  4641. $od = 0;
  4642. $a = '';
  4643. $orid = '';
  4644. foreach ($order as $v) {
  4645. $or = explode('|', ltrim($v['whlabel'], '|'));
  4646. for ($i = 0; $i < count($or); $i++) {
  4647. $orod = explode('-', $or[$i]);
  4648. if ($orod[0] == $number) {
  4649. $od += $orod[1];
  4650. }
  4651. }
  4652. $orid .= $v['number'] . '-';
  4653. }
  4654. } else {
  4655. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4656. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4657. $order = array_merge($orderdlz, $ordersmt);
  4658. $od = 0;
  4659. $a = '';
  4660. $orid = '';
  4661. $qt = array();
  4662. foreach ($order as $v) {
  4663. $or = explode('|', ltrim($v['whlabel'], '|'));
  4664. for ($i = 0; $i < count($or); $i++) {
  4665. $orod = explode('-', $or[$i]);
  4666. if ($orod[0] == $number) {
  4667. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4668. if ($czzs > 0) {
  4669. if (isset($qt[$v['shop']])) {
  4670. if ($qt[$v['shop']] < $orod[1]) {
  4671. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4672. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4673. } else {
  4674. $qt[$v['shop']] -= $orod[1];
  4675. }
  4676. } else {
  4677. $qt[$v['shop']] = $czzs;
  4678. }
  4679. } else {
  4680. $od += $orod[1];
  4681. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4682. }
  4683. }
  4684. }
  4685. }
  4686. }
  4687. $z = $od . '(' . $orid . ')'; //查看订单号
  4688. //$z = $od;
  4689. if ($od > $c) {
  4690. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4691. }
  4692. }
  4693. $listdata = array_slice($list, $start, $perpage);
  4694. $total = count($list);
  4695. $pagenum = ceil($total / $perpage);
  4696. $over = $total - ($start + $perpage);
  4697. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4698. echo json_encode($rows);
  4699. exit;
  4700. }
  4701. $this->_Template('whlabel_abnormal', $this->data);
  4702. }
  4703. /**
  4704. *
  4705. *
  4706. *
  4707. 进销存占单异常索引
  4708. *
  4709. *
  4710. *
  4711. **/
  4712. public function _error()
  4713. {
  4714. $post = $this->input->post(NULL, TRUE);
  4715. if (isset($post['page'])) {
  4716. $page = $this->input->post('page', true);
  4717. $perpage = $this->input->post('perpage', true);
  4718. $sku = $this->input->post('sku', true);
  4719. $warehouse = $this->input->post('warehouse', true);
  4720. $ktime = $this->input->post('ktime', true);
  4721. $jtime = $this->input->post('jtime', true);
  4722. $ktime = strtotime($ktime);
  4723. $jtime = strtotime($jtime);
  4724. $where = "sku != 'Preset'";
  4725. $gj = '';
  4726. if ($sku) {
  4727. $where .= " and sku like '%$sku%'";
  4728. } else {
  4729. if ($ktime && $jtime) {
  4730. $gj = " and time > '$ktime' and time < '$jtime'";
  4731. }
  4732. }
  4733. if ($warehouse) {
  4734. $where .= " and warehouse = '$warehouse'";
  4735. }
  4736. //数据排序
  4737. $order_str = "id desc";
  4738. if (empty($page)) {
  4739. $start = 0;
  4740. $perpage = 1;
  4741. } else {
  4742. $start = ($page - 1) * $perpage;
  4743. }
  4744. //取得信息列表
  4745. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4746. $rows = array();
  4747. $list = array();
  4748. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4749. // foreach ($info_list as $value)
  4750. // {
  4751. // $warehouse = $this->warehouse->read($value['warehouse']);
  4752. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4753. // $number = $value['number'];$ftime = time()-15*24*3600;
  4754. // if($c < 1)
  4755. // {
  4756. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4757. // }
  4758. // }
  4759. $warehouse_list = $this->warehouse->find_all();
  4760. $warehouse_list = array_column($warehouse_list, null, 'id');
  4761. foreach ($info_list as $value) {
  4762. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4763. 'title' => "",
  4764. ];
  4765. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4766. $number = $value['number'];
  4767. $ftime = time() - 15 * 24 * 3600;
  4768. if ($c < 1) {
  4769. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4770. }
  4771. }
  4772. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4773. // $query = $this->db->query($sql);
  4774. // $info_list = $query->result_array();
  4775. // $sql_two = "select title,id from crowd_warehouse";
  4776. // $query_two = $this->db->query($sql_two);
  4777. // $warehouse_list = $query_two->result_array();
  4778. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4779. // foreach ($info_list as $value)
  4780. // {
  4781. // if(isset($warehouse_arr[$value['warehouse']])){
  4782. // $warehouse = $warehouse_arr[$value['warehouse']];
  4783. // }else{
  4784. // $warehouse = [
  4785. // 'id'=>0,
  4786. // 'title'=>"异常",
  4787. // ];
  4788. // }
  4789. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4790. // $number = $value['number'];$ftime = time()-15*24*3600;
  4791. // if($c < 1)
  4792. // {
  4793. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4794. // }
  4795. // }
  4796. $listdata = array_slice($list, $start, $perpage);
  4797. $total = count($list);
  4798. $pagenum = ceil($total / $perpage);
  4799. $over = $total - ($start + $perpage);
  4800. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4801. echo json_encode($rows);
  4802. exit;
  4803. }
  4804. if (isset($post['s'])) {
  4805. $id_arr = $this->input->post('s');
  4806. $id_arr = explode(',', trim($id_arr, ','));
  4807. if (!$id_arr) {
  4808. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4809. exit;
  4810. }
  4811. //循环删除记录
  4812. foreach ($id_arr as $v) {
  4813. $dd = $this->whlabel->read($v);
  4814. if (!isset($dd['id'])) {
  4815. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4816. exit;
  4817. }
  4818. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4819. if (isset($zt[0])) {
  4820. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4821. exit;
  4822. }
  4823. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4824. foreach ($deldd as $vv) {
  4825. $this->whlabel->remove($vv['id']);
  4826. }
  4827. }
  4828. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4829. exit;
  4830. }
  4831. $this->_Template('whlabel_error', $this->data);
  4832. }
  4833. public function _errorexcel()
  4834. {
  4835. $post = $this->input->post(NULL, TRUE);
  4836. if (isset($_GET['page'])) {
  4837. $page = $this->input->get('page', true);
  4838. $perpage = $this->input->get('perpage', true);
  4839. $sku = $this->input->get('sku', true);
  4840. $warehouse = $this->input->get('warehouse', true);
  4841. $ktime = $this->input->get('ktime', true);
  4842. $jtime = $this->input->get('jtime', true);
  4843. $ktime = strtotime($ktime);
  4844. $jtime = strtotime($jtime);
  4845. $where = "sku != 'Preset'";
  4846. $gj = '';
  4847. if ($sku) {
  4848. $where .= " and sku like '%$sku%'";
  4849. } else {
  4850. if ($ktime && $jtime) {
  4851. $gj = " and time > '$ktime' and time < '$jtime'";
  4852. }
  4853. }
  4854. if ($warehouse) {
  4855. $where .= " and warehouse = '$warehouse'";
  4856. }
  4857. //数据排序
  4858. $order_str = "id desc";
  4859. if (empty($page)) {
  4860. $start = 0;
  4861. $perpage = 1;
  4862. } else {
  4863. $start = ($page - 1) * $perpage;
  4864. }
  4865. //取得信息列表
  4866. $rows = array();
  4867. $list = array();
  4868. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4869. foreach ($info_list as $value) {
  4870. $warehouse = $this->warehouse->read($value['warehouse']);
  4871. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4872. $number = $value['number'];
  4873. $ftime = time() - 15 * 24 * 3600;
  4874. if ($c < 1) {
  4875. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4876. }
  4877. }
  4878. $title = "0库存汇总";
  4879. $titlename = "<table border=1>
  4880. <tr align='center'>
  4881. <td>仓库</td>
  4882. <td>SKU</td>
  4883. <td>产品</td>
  4884. <td>当前库存</td>
  4885. </tr>
  4886. </table>";
  4887. $filename = $title . ".xls";
  4888. $tail = "";
  4889. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4890. }
  4891. }
  4892. /**
  4893. *
  4894. *
  4895. * 占单
  4896. *
  4897. *
  4898. **/
  4899. public function _kcyz()
  4900. {
  4901. $post = $this->input->post(NULL, TRUE);
  4902. if (isset($post['warehouse'])) {
  4903. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4904. exit; //不再使用
  4905. $warehouse = $this->input->post('warehouse', true);
  4906. $whlabel = $this->input->post('whlabel', true);
  4907. $id = $this->input->post('id', true);
  4908. $shop = $this->input->post('shop', true);
  4909. $number = $this->input->post('number', true);
  4910. if (!$whlabel || $whlabel == '|') {
  4911. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4912. exit;
  4913. }
  4914. $pp = explode('|', trim($whlabel, '|'));
  4915. $x = 0;
  4916. $save = array();
  4917. foreach ($pp as $va) {
  4918. $num = explode('-', $va);
  4919. if ($number) {
  4920. $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 = '')"); //通用
  4921. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4922. } else {
  4923. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4924. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4925. }
  4926. $x++;
  4927. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4928. $save[] = $x - 1;
  4929. continue; //提前先加X不然出错,所以要减1
  4930. }
  4931. }
  4932. if (isset($save[0])) {
  4933. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4934. exit;
  4935. } else {
  4936. echo json_encode(array('success' => true));
  4937. exit;
  4938. }
  4939. }
  4940. }
  4941. public function _db()
  4942. {
  4943. $post = $this->input->post(NULL, TRUE);
  4944. if (isset($post['page'])) {
  4945. $page = $this->input->post('page', true);
  4946. $perpage = $this->input->post('perpage', true);
  4947. $sku = $this->input->post('sku', true);
  4948. $number = $this->input->post('number', true);
  4949. $warehouse = $this->input->post('warehouse', true);
  4950. $purchase = $this->input->post('purchase', true);
  4951. $orderinfo = $this->input->post('orderinfo', true);
  4952. $waybill = $this->input->post('waybill', true);
  4953. $category = $this->input->post('category', true);
  4954. $size = $this->input->post('size', true);
  4955. $grade = $this->input->post('grade', true);
  4956. $color = $this->input->post('color', true);
  4957. $lowe = $this->input->post('lowe', true);
  4958. $state = $this->input->post('state', true);
  4959. $label = $this->input->post('label', true);
  4960. $timetk = $this->input->post('timetkk', true);
  4961. $timetj = $this->input->post('timetjj', true);
  4962. $timetk = strtotime($timetk);
  4963. $timetj = strtotime($timetj);
  4964. $where = "dbtime > 0";
  4965. if ($timetk && $timetj) {
  4966. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4967. }
  4968. if ($sku) {
  4969. $where .= " and sku = '$sku'";
  4970. }
  4971. if ($warehouse) {
  4972. $where .= " and warehouse = '$warehouse'";
  4973. if ($warehouse == 12) {
  4974. $w = 'specialstock';
  4975. } else {
  4976. $w = 'whlabel';
  4977. }
  4978. }
  4979. if ($purchase) {
  4980. $where .= " and purchase = '$purchase'";
  4981. }
  4982. if ($category) {
  4983. $where .= " and features like '%-$category-%'";
  4984. }
  4985. if ($size) {
  4986. $where .= " and features like '%-$size-%'";
  4987. }
  4988. if ($grade) {
  4989. $where .= " and features like '%-$grade-%'";
  4990. }
  4991. if ($color) {
  4992. $where .= " and features like '%-$color-%'";
  4993. }
  4994. if ($lowe) {
  4995. $where .= " and features like '%-$lowe-%'";
  4996. }
  4997. if ($state != '') {
  4998. $where .= " and state = '$state'";
  4999. }
  5000. //数据排序
  5001. $order_str = "dbtime desc";
  5002. if (empty($page)) {
  5003. $start = 0;
  5004. $perpage = 1;
  5005. } else {
  5006. $start = ($page - 1) * $perpage;
  5007. }
  5008. //取得信息列表
  5009. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5010. foreach ($info_list as $key => $value) {
  5011. $warehouse = $this->$w->read($value['warehouse']);
  5012. $info_list[$key]['warehouse'] = $warehouse['title'];
  5013. $purchase = $this->purchase->read($value['purchase']);
  5014. $info_list[$key]['purchase'] = $purchase['title'];
  5015. if ($value['enter'] != 0) {
  5016. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5017. } else {
  5018. $info_list[$key]['enter'] = "";
  5019. }
  5020. if ($value['dbtime'] != 0) {
  5021. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5022. } else {
  5023. $info_list[$key]['dbtime'] = "";
  5024. }
  5025. if ($value['state'] == 0) {
  5026. $info_list[$key]['state'] = "在库";
  5027. } else if ($value['state'] == 1) {
  5028. $info_list[$key]['state'] = "出库";
  5029. } else if ($value['state'] == 2) {
  5030. $info_list[$key]['state'] = "退库";
  5031. } else if ($value['state'] == 3) {
  5032. $info_list[$key]['state'] = "调拨中";
  5033. } else if ($value['state'] == 4) {
  5034. $info_list[$key]['state'] = "再加工";
  5035. } else if ($value['state'] == 5) {
  5036. $info_list[$key]['state'] = "维修中";
  5037. } else if ($value['state'] == 6) {
  5038. $info_list[$key]['state'] = "盘亏";
  5039. } else if ($value['state'] == 7) {
  5040. $info_list[$key]['state'] = "更换标签";
  5041. } else if ($value['state'] == 8) {
  5042. $info_list[$key]['state'] = "其它";
  5043. } else if ($value['state'] == 9) {
  5044. $info_list[$key]['state'] = "预设";
  5045. }
  5046. }
  5047. $total = $this->whlabel->find_count($where);
  5048. $pagenum = ceil($total / $perpage);
  5049. $over = $total - ($start + $perpage);
  5050. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5051. echo json_encode($rows);
  5052. exit;
  5053. }
  5054. if (isset($post['outsku'])) {
  5055. $time = time();
  5056. $cz = $this->input->post('cz', true);
  5057. $label = $this->input->post('outsku', true);
  5058. $sl = $this->input->post('sl', true);
  5059. $num = $this->input->post('num', true);
  5060. //$warehouse = $this->input->post('warehouse',true);
  5061. if (!$sl) {
  5062. $sl = 1;
  5063. }
  5064. if (!$warehouse) {
  5065. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5066. exit;
  5067. }
  5068. $dblabel = $this->whlabellabel->get_label($label);
  5069. if ($dblabel) {
  5070. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5071. if (count($data) < 1) {
  5072. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5073. exit;
  5074. }
  5075. if (count($data) < $num) {
  5076. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5077. exit;
  5078. }
  5079. for ($i = 0; $i < $sl; $i++) {
  5080. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5081. }
  5082. echo json_encode(array('success' => true));
  5083. exit;
  5084. } else {
  5085. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5086. exit;
  5087. }
  5088. }
  5089. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5090. $this->_Template('whlabel_db', $this->data);
  5091. }
  5092. public function _dbrk()
  5093. {
  5094. $post = $this->input->post(NULL, TRUE);
  5095. if (isset($post['page'])) {
  5096. $page = $this->input->post('page', true);
  5097. $perpage = $this->input->post('perpage', true);
  5098. $sku = $this->input->post('sku', true);
  5099. $number = $this->input->post('number', true);
  5100. $warehouse = $this->input->post('warehouse', true);
  5101. $purchase = $this->input->post('purchase', true);
  5102. $orderinfo = $this->input->post('orderinfo', true);
  5103. $waybill = $this->input->post('waybill', true);
  5104. $category = $this->input->post('category', true);
  5105. $size = $this->input->post('size', true);
  5106. $grade = $this->input->post('grade', true);
  5107. $color = $this->input->post('color', true);
  5108. $lowe = $this->input->post('lowe', true);
  5109. $state = $this->input->post('state', true);
  5110. $label = $this->input->post('label', true);
  5111. $ctime = $this->input->post('ctime', true);
  5112. $timetk = $this->input->post('timetkk', true);
  5113. $timetj = $this->input->post('timetjj', true);
  5114. $timetk = strtotime($timetk);
  5115. $timetj = strtotime($timetj);
  5116. $where = "dbtime > 0";
  5117. if ($timetk && $timetj) {
  5118. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5119. }
  5120. if ($sku) {
  5121. $where .= " and sku = '$sku'";
  5122. }
  5123. if ($warehouse) {
  5124. $where .= " and warehouse = '$warehouse'";
  5125. }
  5126. if ($purchase) {
  5127. $where .= " and purchase = '$purchase'";
  5128. }
  5129. if ($category) {
  5130. $where .= " and features like '%-$category-%'";
  5131. }
  5132. if ($size) {
  5133. $where .= " and features like '%-$size-%'";
  5134. }
  5135. if ($grade) {
  5136. $where .= " and features like '%-$grade-%'";
  5137. }
  5138. if ($color) {
  5139. $where .= " and features like '%-$color-%'";
  5140. }
  5141. if ($lowe) {
  5142. $where .= " and features like '%-$lowe-%'";
  5143. }
  5144. if ($state != '') {
  5145. $where .= " and state = '$state'";
  5146. }
  5147. //数据排序
  5148. $order_str = "dbtime desc";
  5149. if (empty($page)) {
  5150. $start = 0;
  5151. $perpage = 1;
  5152. } else {
  5153. $start = ($page - 1) * $perpage;
  5154. }
  5155. //取得信息列表
  5156. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5157. foreach ($info_list as $key => $value) {
  5158. $warehouse = $this->warehouse->read($value['warehouse']);
  5159. $info_list[$key]['warehouse'] = $warehouse['title'];
  5160. $purchase = $this->purchase->read($value['purchase']);
  5161. $info_list[$key]['purchase'] = $purchase['title'];
  5162. if ($value['enter'] != 0) {
  5163. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5164. } else {
  5165. $info_list[$key]['enter'] = "";
  5166. }
  5167. if ($value['dbtime'] != 0) {
  5168. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5169. } else {
  5170. $info_list[$key]['dbtime'] = "";
  5171. }
  5172. if ($value['state'] == 0) {
  5173. $info_list[$key]['state'] = "在库";
  5174. } else if ($value['state'] == 1) {
  5175. $info_list[$key]['state'] = "出库";
  5176. } else if ($value['state'] == 2) {
  5177. $info_list[$key]['state'] = "退库";
  5178. } else if ($value['state'] == 3) {
  5179. $info_list[$key]['state'] = "调拨中";
  5180. } else if ($value['state'] == 4) {
  5181. $info_list[$key]['state'] = "再加工";
  5182. } else if ($value['state'] == 5) {
  5183. $info_list[$key]['state'] = "维修中";
  5184. } else if ($value['state'] == 6) {
  5185. $info_list[$key]['state'] = "盘亏";
  5186. } else if ($value['state'] == 7) {
  5187. $info_list[$key]['state'] = "更换标签";
  5188. } else if ($value['state'] == 8) {
  5189. $info_list[$key]['state'] = "其它";
  5190. } else if ($value['state'] == 9) {
  5191. $info_list[$key]['state'] = "预设";
  5192. }
  5193. }
  5194. $total = $this->whlabel->find_count($where);
  5195. $pagenum = ceil($total / $perpage);
  5196. $over = $total - ($start + $perpage);
  5197. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5198. echo json_encode($rows);
  5199. exit;
  5200. }
  5201. if (isset($post['rsku'])) {
  5202. $cz = $this->input->post('cz', true);
  5203. $label = $this->input->post('rsku', true);
  5204. $sl = $this->input->post('sl', true);
  5205. $warehouse = $this->input->post('warehouse', true);
  5206. if (!$sl) {
  5207. $sl = 1;
  5208. }
  5209. if (!$warehouse) {
  5210. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5211. exit;
  5212. }
  5213. $dblabel = $this->whlabellabel->get_label($label);
  5214. if ($dblabel) {
  5215. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5216. if (count($data) < 1) {
  5217. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5218. exit;
  5219. }
  5220. if ($sl > count($data)) {
  5221. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5222. exit;
  5223. }
  5224. $time = time();
  5225. for ($i = 0; $i < $sl; $i++) {
  5226. $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']);
  5227. }
  5228. echo json_encode(array('success' => true));
  5229. exit;
  5230. } else {
  5231. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5232. exit;
  5233. }
  5234. }
  5235. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5236. $this->_Template('whlabel_dbrk', $this->data);
  5237. }
  5238. public function _whlabelczdc()
  5239. {
  5240. if (isset($_GET['excel'])) {
  5241. //数据排序
  5242. $order_str = "id desc";
  5243. if (empty($page)) {
  5244. $start = 0;
  5245. $perpage = 1;
  5246. } else {
  5247. $start = ($page - 1) * $perpage;
  5248. }
  5249. $state = $this->input->get('state', true);
  5250. $sku = $this->input->get('sku', true);
  5251. $ctime = $this->input->get('ctime', true);
  5252. $category = $this->input->get('category', true);
  5253. $size = $this->input->get('size', true);
  5254. $grade = $this->input->get('grade', true);
  5255. $color = $this->input->get('color', true);
  5256. $lowe = $this->input->get('lowe', true);
  5257. $timetk = $this->input->get('timetkk', true);
  5258. $timetj = $this->input->get('timetjj', true);
  5259. $timetk = strtotime($timetk);
  5260. $timetj = strtotime($timetj);
  5261. $where = "dbtime > 0";
  5262. if ($timetk && $timetj) {
  5263. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5264. }
  5265. if ($category) {
  5266. $where .= " and features like '%-$category-%'";
  5267. }
  5268. if ($size) {
  5269. $where .= " and features like '%-$size-%'";
  5270. }
  5271. if ($grade) {
  5272. $where .= " and features like '%-$grade-%'";
  5273. }
  5274. if ($color) {
  5275. $where .= " and features like '%-$color-%'";
  5276. }
  5277. if ($lowe) {
  5278. $where .= " and features like '%-$lowe-%'";
  5279. }
  5280. //取得信息列表
  5281. $info_list = $this->whlabel->find_all($where, '*');
  5282. $rows = array();
  5283. $list = array();
  5284. foreach ($info_list as $key => $value) {
  5285. $rows[$value['sku']] = $value; //所有数据sku
  5286. }
  5287. foreach ($rows as $value) {
  5288. $warehouse = $this->warehouse->read($value['warehouse']);
  5289. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5290. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5291. if ($value['orderinfo'] == 0) {
  5292. $info_list[$key]['orderinfo'] = "";
  5293. }
  5294. if ($value['waybill'] == 0) {
  5295. $info_list[$key]['waybill'] = "";
  5296. }
  5297. if ($value['state'] == 0) {
  5298. $value['state'] = "在库";
  5299. } else if ($value['state'] == 3) {
  5300. $value['state'] = "调拨中";
  5301. }
  5302. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5303. }
  5304. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5305. $titlename = "<table border=1>
  5306. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5307. <tr align='center'>
  5308. <td>SKU</td>
  5309. <td>产品</td>
  5310. <td>调拨数量</td>
  5311. <td>入库数量</td>
  5312. </tr>
  5313. </table>";
  5314. $filename = $title . ".xls";
  5315. $tail = "";
  5316. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5317. }
  5318. }
  5319. public function _print($arg_array)
  5320. {
  5321. if (isset($_SESSION['api'])) {
  5322. $user = $this->user->get_api($_SESSION['api']);
  5323. $usp = $user;
  5324. $fgshop = "";
  5325. $sid = "";
  5326. $wid = "";
  5327. $wtype = "";
  5328. $usersp = explode('|', trim($user['shop'], '|'));
  5329. $userwh = explode('|', trim($user['warehouse'], '|'));
  5330. foreach ($usersp as $value) {
  5331. $fgshop .= " shop = " . $value . " or";
  5332. $sid .= " id = " . $value . " or";
  5333. }
  5334. foreach ($userwh as $value) {
  5335. $wid .= " id = " . $value . " or";
  5336. $wtype .= " type = " . $value . " or";
  5337. }
  5338. }
  5339. $post = $this->input->post(NULL, TRUE);
  5340. if (isset($post['tmsku'])) {
  5341. $tmsku = $this->input->post('tmsku', true);
  5342. if (is_numeric($tmsku)) {
  5343. $yyh = $this->whlabellabel->get_label($tmsku);
  5344. } else {
  5345. $yyh = $this->whlabellabel->get_sku($tmsku);
  5346. }
  5347. if ($yyh) {
  5348. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5349. exit;
  5350. } else {
  5351. echo json_encode(array('success' => false));
  5352. exit;
  5353. }
  5354. }
  5355. $classid = $this->classid->sku();
  5356. $pm = $classid;
  5357. $scsku = $classid;
  5358. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5359. if (isset($post['warehouse'])) {
  5360. if ($post['warehouse']) {
  5361. $list = array();
  5362. $num = "";
  5363. $title = "";
  5364. $features = "";
  5365. $order = 0;
  5366. $post['shop'] = '';
  5367. $brand = $this->input->post('brand', true);
  5368. if ($brand != '0,') {
  5369. $b = $this->brand->read(rtrim($brand, ','));
  5370. if ($b) {
  5371. $post['shop'] = str_replace('|', ',', $b['shop']);
  5372. }
  5373. }
  5374. $post['details'] = $this->input->post('details', true); //打印数量
  5375. $xbqnum = $this->input->post('xbqnum', true);
  5376. $post['purchase'] = $this->input->post('purchase', true);
  5377. $post['warehouse'] = $this->input->post('warehouse', true);
  5378. $post['purchase'] = $this->input->post('purchase', true);
  5379. $post['retreatwarehouse'] = $post['warehouse'];
  5380. $post['cpbz'] = $this->input->post('cpbz', true);
  5381. $post['state'] = 9;
  5382. $category = $this->input->post('category', true);
  5383. $list['category'] = $category;
  5384. $list['hairtype'] = $this->input->post('hairtype', true);
  5385. $list['grade'] = $this->input->post('grade', true);
  5386. $size = $this->input->post('size', true);
  5387. $list['size'] = rtrim($size, ',');
  5388. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5389. $list['extension'] = $this->input->post('extension', true);
  5390. if ($category == 1297) {
  5391. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5392. }
  5393. if ($category == 1702) {
  5394. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5395. $list['syother'] = $this->input->post('syother', true);
  5396. }
  5397. if ($category == 133) {
  5398. $list['fittype'] = $this->input->post('fittype', true);
  5399. $list['acother'] = $this->input->post('acother', true);
  5400. }
  5401. $list['color'] = $this->input->post('color', true);
  5402. $list['lowe'] = $this->input->post('lowe', true);
  5403. if ($category == 127) {
  5404. $list['type'] = $this->input->post('type', true);
  5405. $list['headroad'] = $this->input->post('headroad', true);
  5406. $list['density'] = $this->input->post('density', true);
  5407. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5408. $list['lacesize'] = $this->input->post('lacesize', true);
  5409. }
  5410. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5411. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5412. }
  5413. if ($category == 128) {
  5414. $list['lacetype'] = $this->input->post('lacetype', true);
  5415. $list['haircap'] = $this->input->post('haircap', true);
  5416. $list['density'] = $this->input->post('density', true);
  5417. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5418. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5419. $list['wigother'] = $this->input->post('wigother', true);
  5420. $list['wigother1'] = $this->input->post('wigother1', true);
  5421. $list['wigother2'] = $this->input->post('wigother2', true);
  5422. }
  5423. if ($category == 129) {
  5424. $list['wide'] = $this->input->post('wide', true);
  5425. }
  5426. if ($category == 131) {
  5427. $list['gifttype'] = $this->input->post('gifttype', true);
  5428. $list['giftother'] = $this->input->post('giftother', true);
  5429. }
  5430. if ($category == 134) {
  5431. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5432. }
  5433. if ($category == 1297) {
  5434. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5435. $list['sywigother'] = $this->input->post('sywigother', true);
  5436. }
  5437. if ($category == 130 || $category == 133 || $category == 1702) {
  5438. $list['items'] = $this->input->post('items', true);
  5439. $list['weight'] = $this->input->post('weight', true);
  5440. }
  5441. if ($category == 1702) {
  5442. $list['syhairther'] = $this->input->post('syhairther', true);
  5443. }
  5444. foreach ($list as $k => $v) {
  5445. if ($v != 0) {
  5446. $num .= $v;
  5447. $features .= $v . '-';
  5448. $post[$k] = $v;
  5449. $typeclass = $this->typeclass->read($v);
  5450. if (isset($pm[$typeclass['classid']])) {
  5451. if (stripos($typeclass['zh'], '|') !== false) {
  5452. $exzh = explode('|', $typeclass['zh']);
  5453. $pm[$typeclass['classid']] = $exzh[0];
  5454. } else {
  5455. $pm[$typeclass['classid']] = $typeclass['zh'];
  5456. }
  5457. }
  5458. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5459. if ($k != 'size') {
  5460. $title .= $typeclass['title'] . " ";
  5461. }
  5462. }
  5463. }
  5464. $typeclass = $this->typeclass->read($list['size']);
  5465. $title .= $typeclass['title'];
  5466. $time = time();
  5467. $post['title'] = rtrim($title, ' ');
  5468. $post['number'] = $num;
  5469. $post['features'] = '-' . $features;
  5470. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5471. $featurespp = explode('-', trim($featurespp, '-'));
  5472. if (isset($featurespp[5])) {
  5473. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5474. } else {
  5475. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5476. }
  5477. $post['enter'] = $time;
  5478. $post['time'] = $time; //操作时间
  5479. $scsku = implode("-", $scsku);
  5480. $zh = implode(" ", $pm);
  5481. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5482. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5483. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5484. $post['sku'] = $bqsku;
  5485. $label = time() . rand(0, 9);
  5486. $post['label'] = $label;
  5487. $cpid = $this->whlabellabel->find_count();
  5488. $post['cpid'] = $cpid + 1;
  5489. $cpid = $post['cpid'];
  5490. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5491. //if($whlabelbarcode)
  5492. //{
  5493. //$post['label'] = $whlabelbarcode['label'];
  5494. //if(!$this->whlabellabel->insert($post))
  5495. //{
  5496. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5497. //}
  5498. //}
  5499. //else
  5500. //{
  5501. $this->db->trans_begin();
  5502. $this->whlabellabel->insert($post);
  5503. //$this->whlabelbarcode->insert($post);
  5504. if ($this->db->trans_status() === TRUE) {
  5505. $this->db->trans_commit();
  5506. } else {
  5507. $this->db->trans_rollback();
  5508. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5509. exit;
  5510. }
  5511. //}
  5512. $warehouse_name = "";
  5513. $warehouse = $post['warehouse'];
  5514. if($warehouse == 12){
  5515. $warehouse_name = "特殊库存库";
  5516. }
  5517. // if($warehouse == 13){
  5518. // $warehouse_name = "许昌仓";
  5519. // }
  5520. // if($warehouse == 5){
  5521. // $warehouse_name = "美国店";
  5522. // }
  5523. // if($warehouse == 16){
  5524. // $warehouse_name = "定制头套仓";
  5525. // }
  5526. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5527. if(!empty($warehouse_name)){
  5528. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5529. }
  5530. $purchase = $this->purchase->read($post['purchase']);
  5531. 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));
  5532. exit; //特殊仓目前不需要仓库选项
  5533. }
  5534. }
  5535. if (isset($_SESSION['api'])) {
  5536. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5537. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5538. $this->data['wlshop'] = $wlshop;
  5539. $this->data['warehouse'] = $warehouse;
  5540. }
  5541. $whlabelwz = $this->whlabelwz->find_all();
  5542. $this->data['whlabelwz'] = $whlabelwz;
  5543. $this->_Template('whlabel_print', $this->data);
  5544. }
  5545. public function _usaprint($arg_array)
  5546. {
  5547. if (isset($_SESSION['api'])) {
  5548. $user = $this->user->get_api($_SESSION['api']);
  5549. $usp = $user;
  5550. $fgshop = "";
  5551. $sid = "";
  5552. $wid = "";
  5553. $wtype = "";
  5554. $usersp = explode('|', trim($user['shop'], '|'));
  5555. $userwh = explode('|', trim($user['warehouse'], '|'));
  5556. foreach ($usersp as $value) {
  5557. $fgshop .= " shop = " . $value . " or";
  5558. $sid .= " id = " . $value . " or";
  5559. }
  5560. foreach ($userwh as $value) {
  5561. $wid .= " id = " . $value . " or";
  5562. $wtype .= " type = " . $value . " or";
  5563. }
  5564. }
  5565. $post = $this->input->post(NULL, TRUE);
  5566. if (isset($post['tmsku'])) {
  5567. $tmsku = $this->input->post('tmsku', true);
  5568. if (is_numeric($tmsku)) {
  5569. $yyh = $this->whlabellabel->get_label($tmsku);
  5570. } else {
  5571. $yyh = $this->whlabellabel->get_sku($tmsku);
  5572. }
  5573. if ($yyh) {
  5574. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5575. exit;
  5576. } else {
  5577. echo json_encode(array('success' => false));
  5578. exit;
  5579. }
  5580. }
  5581. $classid = $this->classid->sku();
  5582. $pm = $classid;
  5583. $scsku = $classid;
  5584. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5585. if (isset($post['warehouse'])) {
  5586. if ($post['warehouse']) {
  5587. $list = array();
  5588. $num = "";
  5589. $title = "";
  5590. $features = "";
  5591. $order = 0;
  5592. $post['shop'] = '';
  5593. $brand = $this->input->post('brand', true);
  5594. if ($brand != '0,') {
  5595. $b = $this->brand->read(rtrim($brand, ','));
  5596. if ($b) {
  5597. $post['shop'] = str_replace('|', ',', $b['shop']);
  5598. }
  5599. }
  5600. $post['details'] = $this->input->post('details', true); //打印数量
  5601. $xbqnum = $this->input->post('xbqnum', true);
  5602. $post['purchase'] = $this->input->post('purchase', true);
  5603. $post['warehouse'] = $this->input->post('warehouse', true);
  5604. $post['purchase'] = $this->input->post('purchase', true);
  5605. $post['retreatwarehouse'] = $post['warehouse'];
  5606. $post['cpbz'] = $this->input->post('cpbz', true);
  5607. $post['state'] = 9;
  5608. $category = $this->input->post('category', true);
  5609. $list['category'] = $category;
  5610. $list['hairtype'] = $this->input->post('hairtype', true);
  5611. $list['grade'] = $this->input->post('grade', true);
  5612. $size = $this->input->post('size', true);
  5613. $list['size'] = rtrim($size, ',');
  5614. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5615. $list['extension'] = $this->input->post('extension', true);
  5616. if ($category == 1297) {
  5617. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5618. }
  5619. if ($category == 1702) {
  5620. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5621. $list['syother'] = $this->input->post('syother', true);
  5622. }
  5623. if ($category == 133) {
  5624. $list['fittype'] = $this->input->post('fittype', true);
  5625. $list['acother'] = $this->input->post('acother', true);
  5626. }
  5627. $list['color'] = $this->input->post('color', true);
  5628. $list['lowe'] = $this->input->post('lowe', true);
  5629. if ($category == 127) {
  5630. $list['type'] = $this->input->post('type', true);
  5631. $list['headroad'] = $this->input->post('headroad', true);
  5632. $list['density'] = $this->input->post('density', true);
  5633. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5634. $list['lacesize'] = $this->input->post('lacesize', true);
  5635. }
  5636. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5637. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5638. }
  5639. if ($category == 128) {
  5640. $list['lacetype'] = $this->input->post('lacetype', true);
  5641. $list['haircap'] = $this->input->post('haircap', true);
  5642. $list['density'] = $this->input->post('density', true);
  5643. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5644. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5645. $list['wigother'] = $this->input->post('wigother', true);
  5646. $list['wigother1'] = $this->input->post('wigother1', true);
  5647. $list['wigother2'] = $this->input->post('wigother2', true);
  5648. }
  5649. if ($category == 129) {
  5650. $list['wide'] = $this->input->post('wide', true);
  5651. }
  5652. if ($category == 131) {
  5653. $list['gifttype'] = $this->input->post('gifttype', true);
  5654. $list['giftother'] = $this->input->post('giftother', true);
  5655. }
  5656. if ($category == 134) {
  5657. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5658. }
  5659. if ($category == 1297) {
  5660. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5661. $list['sywigother'] = $this->input->post('sywigother', true);
  5662. }
  5663. if ($category == 130 || $category == 133 || $category == 1702) {
  5664. $list['items'] = $this->input->post('items', true);
  5665. $list['weight'] = $this->input->post('weight', true);
  5666. }
  5667. if ($category == 1702) {
  5668. $list['syhairther'] = $this->input->post('syhairther', true);
  5669. }
  5670. foreach ($list as $k => $v) {
  5671. if ($v != 0) {
  5672. $num .= $v;
  5673. $features .= $v . '-';
  5674. $post[$k] = $v;
  5675. $typeclass = $this->typeclass->read($v);
  5676. if (isset($pm[$typeclass['classid']])) {
  5677. if (stripos($typeclass['zh'], '|') !== false) {
  5678. $exzh = explode('|', $typeclass['zh']);
  5679. $pm[$typeclass['classid']] = $exzh[0];
  5680. } else {
  5681. $pm[$typeclass['classid']] = $typeclass['zh'];
  5682. }
  5683. }
  5684. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5685. if ($k != 'size') {
  5686. $title .= $typeclass['title'] . " ";
  5687. }
  5688. }
  5689. }
  5690. $typeclass = $this->typeclass->read($list['size']);
  5691. $title .= $typeclass['title'];
  5692. $time = time();
  5693. $post['title'] = rtrim($title, ' ');
  5694. $post['number'] = $num;
  5695. $post['features'] = '-' . $features;
  5696. $fp = $this->whlabel->get_features($post['features']);
  5697. if (!$fp) {
  5698. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5699. exit;
  5700. }
  5701. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5702. $featurespp = explode('-', trim($featurespp, '-'));
  5703. if (isset($featurespp[5])) {
  5704. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5705. } else {
  5706. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5707. }
  5708. $post['enter'] = $time;
  5709. $post['time'] = $time; //操作时间
  5710. $scsku = implode("-", $scsku);
  5711. $zh = implode(" ", $pm);
  5712. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5713. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5714. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5715. $post['sku'] = $fp['sku'];
  5716. $post['label'] = $fp['sku'];
  5717. $cpid = $this->whlabellabel->find_count();
  5718. $post['cpid'] = $cpid + 1;
  5719. $cpid = $post['cpid'];
  5720. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5721. //if($whlabelbarcode)
  5722. //{
  5723. //$post['label'] = $whlabelbarcode['label'];
  5724. //if(!$this->whlabellabel->insert($post))
  5725. //{
  5726. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5727. //}
  5728. //}
  5729. //else
  5730. //{
  5731. $this->db->trans_begin();
  5732. $this->whlabellabel->insert($post);
  5733. //$this->whlabelbarcode->insert($post);
  5734. if ($this->db->trans_status() === TRUE) {
  5735. $this->db->trans_commit();
  5736. } else {
  5737. $this->db->trans_rollback();
  5738. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5739. exit;
  5740. }
  5741. //}
  5742. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5743. $purchase = $this->purchase->read($post['purchase']);
  5744. 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));
  5745. exit; //特殊仓目前不需要仓库选项
  5746. }
  5747. }
  5748. if (isset($_SESSION['api'])) {
  5749. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5750. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5751. $this->data['wlshop'] = $wlshop;
  5752. $this->data['warehouse'] = $warehouse;
  5753. }
  5754. $whlabelwz = $this->whlabelwz->find_all();
  5755. $this->data['whlabelwz'] = $whlabelwz;
  5756. $this->_Template('whlabel_usaprint', $this->data);
  5757. }
  5758. public function _printrk($arg_array)
  5759. {
  5760. $prc = array();
  5761. $purchase = $this->purchase->find_all();
  5762. foreach ($purchase as $k => $v) {
  5763. $prc[$v['id']] = $v['title'];
  5764. }
  5765. $post = $this->input->post(NULL, TRUE);
  5766. if (isset($post['page'])) {
  5767. $page = $this->input->post('page', true);
  5768. $perpage = $this->input->post('perpage', true);
  5769. $sku = $this->input->post('sku', true);
  5770. $bs = $this->input->post('bs', true);
  5771. $number = $this->input->post('number', true);
  5772. $warehouse = $this->input->post('warehouse', true);
  5773. $purchase = $this->input->post('purchase', true);
  5774. $orderinfo = $this->input->post('orderinfo', true);
  5775. $waybill = $this->input->post('waybill', true);
  5776. $category = $this->input->post('category', true);
  5777. $size = $this->input->post('size', true);
  5778. $grade = $this->input->post('grade', true);
  5779. $color = $this->input->post('color', true);
  5780. $lowe = $this->input->post('lowe', true);
  5781. $state = $this->input->post('state', true);
  5782. $label = $this->input->post('label', true);
  5783. $timetk = $this->input->post('ktime', true);
  5784. $timetj = $this->input->post('jtime', true);
  5785. $timetk = strtotime($timetk);
  5786. $timetj = strtotime($timetj);
  5787. $where = "1=1 ";
  5788. if ($timetk && $timetj) {
  5789. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5790. }
  5791. if ($sku) {
  5792. $where .= " and sku = '$sku'";
  5793. }
  5794. if ($bs != '') {
  5795. $where .= " and bs = '$bs'";
  5796. }
  5797. if ($number) {
  5798. $where .= " and number = '$number'";
  5799. }
  5800. if ($warehouse) {
  5801. $where .= " and warehouse = '$warehouse'";
  5802. }
  5803. if ($purchase) {
  5804. $where .= " and purchase = '$purchase'";
  5805. }
  5806. if ($orderinfo) {
  5807. $where .= " and orderinfo = '$orderinfo'";
  5808. }
  5809. if ($waybill) {
  5810. $where .= " and waybill = '$waybill'";
  5811. }
  5812. if ($category) {
  5813. $where .= " and features like '%-$category-%'";
  5814. }
  5815. if ($size) {
  5816. $where .= " and features like '%-$size-%'";
  5817. }
  5818. if ($grade) {
  5819. $where .= " and features like '%-$grade-%'";
  5820. }
  5821. if ($color) {
  5822. $where .= " and features like '%-$color-%'";
  5823. }
  5824. if ($lowe) {
  5825. $where .= " and features like '%-$lowe-%'";
  5826. }
  5827. if ($label) {
  5828. $where .= " and label = '$label'";
  5829. }
  5830. if ($state || $state == 0) {
  5831. $where .= " and state = '$state'";
  5832. }
  5833. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5834. //数据排序
  5835. $order_str = "enter desc";
  5836. if (empty($page)) {
  5837. $start = 0;
  5838. $perpage = 1;
  5839. } else {
  5840. $start = ($page - 1) * $perpage;
  5841. }
  5842. //取得信息列表
  5843. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5844. foreach ($info_list as $key => $value) {
  5845. $warehouse = $this->warehouse->read($value['warehouse']);
  5846. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5847. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5848. if ($value['state'] == 0) {
  5849. $info_list[$key]['state'] = "在库";
  5850. } else if ($value['state'] == 1) {
  5851. $info_list[$key]['state'] = "出库";
  5852. } else if ($value['state'] == 2) {
  5853. $info_list[$key]['state'] = "退库";
  5854. } else if ($value['state'] == 3) {
  5855. $info_list[$key]['state'] = "调拨中";
  5856. } else if ($value['state'] == 4) {
  5857. $info_list[$key]['state'] = "再加工";
  5858. } else if ($value['state'] == 5) {
  5859. $info_list[$key]['state'] = "维修中";
  5860. } else if ($value['state'] == 6) {
  5861. $info_list[$key]['state'] = "盘亏";
  5862. } else if ($value['state'] == 7) {
  5863. $info_list[$key]['state'] = "更换标签";
  5864. } else if ($value['state'] == 8) {
  5865. $info_list[$key]['state'] = "其它";
  5866. } else if ($value['state'] == 9) {
  5867. $info_list[$key]['state'] = "预设";
  5868. } else if ($value['state'] == 10) {
  5869. $info_list[$key]['state'] = "美店零售";
  5870. }
  5871. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5872. }
  5873. $total = $this->$ck->find_count($where);
  5874. $pagenum = ceil($total / $perpage);
  5875. $over = $total - ($start + $perpage);
  5876. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5877. echo json_encode($rows);
  5878. exit;
  5879. }
  5880. if (isset($post['tmsku'])) {
  5881. $time = time();
  5882. $tmsku = $this->input->post('tmsku', true);
  5883. //$post['shop'] = $this->input->post('shop',true);
  5884. $num = $this->input->post('num', true);
  5885. $rktype = $this->input->post('rktype', true);
  5886. if ($num > 200) {
  5887. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5888. exit;
  5889. }
  5890. if (!$rktype) {
  5891. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5892. }
  5893. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5894. /**
  5895. $wz = array();
  5896. foreach ($rk as $key=>$value)
  5897. {
  5898. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5899. }
  5900. if(count($wz) > 1)
  5901. {
  5902. $wz = array_values($wz);
  5903. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5904. }
  5905. **/
  5906. if (isset($rk[0]['purchase'])) {
  5907. $rk = $rk[0];
  5908. $j = 0;
  5909. $post['purchase'] = $rk['purchase'];
  5910. $post['warehouse'] = $rk['warehouse'];
  5911. $post['retreatwarehouse'] = $rk['warehouse'];
  5912. $post['sku'] = $rk['sku'];
  5913. $post['number'] = $rk['number'];
  5914. $post['features'] = $rk['features'];
  5915. $post['title'] = $rk['title'];
  5916. $post['enter'] = $time;
  5917. $post['time'] = $time;
  5918. $post['bs'] = 1;
  5919. $post['shop'] = $rk['shop'];
  5920. $post['details'] = $rk['details'];
  5921. $post['cpid'] = $rk['cpid'];
  5922. $post['cpbz'] = $rk['cpbz'];
  5923. //$post['rktype'] = $rktype;
  5924. $warehouse = $this->warehouse->read($rk['warehouse']);
  5925. if ($warehouse['bdck'] == '') {
  5926. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5927. exit;
  5928. } else {
  5929. $bdck = $warehouse['bdck'];
  5930. }
  5931. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5932. if (isset($pdwz['details'])) {
  5933. if ($pdwz['details'] != $post['details']) {
  5934. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5935. exit;
  5936. }
  5937. }
  5938. $post['featurespp'] = $rk['featurespp'];
  5939. if ($post['warehouse'] == '5') {
  5940. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5941. if ($yza) {
  5942. if ($post['features'] != $yza[0]['features']) {
  5943. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5944. exit;
  5945. }
  5946. }
  5947. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5948. if ($yzb) {
  5949. if ($post['sku'] != $yzb[0]['sku']) {
  5950. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5951. exit;
  5952. }
  5953. }
  5954. }
  5955. for ($i = 0; $i < $num; $i++) {
  5956. $post['label'] = time() . rand(100, 999) . $i;
  5957. if ($this->$bdck->insert($post)) {
  5958. $j++;
  5959. }
  5960. }
  5961. /**
  5962. if($post['warehouse'] != 12)
  5963. {
  5964. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5965. }
  5966. **/
  5967. if ($j == $num) {
  5968. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5969. exit;
  5970. } else {
  5971. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5972. exit;
  5973. }
  5974. } else {
  5975. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5976. exit;
  5977. }
  5978. }
  5979. $this->_Template('whlabel_printrk', $this->data);
  5980. }
  5981. public function _printxzrk($arg_array)
  5982. {
  5983. $post = $this->input->post(NULL, TRUE);
  5984. if (isset($post['wzid'])) {
  5985. $time = time();
  5986. $id = $this->input->post('wzid', true);
  5987. //$post['shop'] = $this->input->post('shop',true);
  5988. $num = 1;
  5989. $rk = $this->whlabellabel->read($id);
  5990. if (isset($rk['purchase'])) {
  5991. $x = 0;
  5992. $post['purchase'] = $rk['purchase'];
  5993. $post['warehouse'] = $rk['warehouse'];
  5994. $post['retreatwarehouse'] = $rk['warehouse'];
  5995. $post['sku'] = $rk['sku'];
  5996. $post['number'] = $rk['number'];
  5997. $post['features'] = $rk['features'];
  5998. $post['title'] = $rk['title'];
  5999. $post['enter'] = $time;
  6000. $post['time'] = $time;
  6001. $post['bs'] = 1;
  6002. $post['shop'] = $rk['shop'];
  6003. $post['details'] = $rk['details'];
  6004. $post['cpid'] = $rk['cpid'];
  6005. $post['cpbz'] = $rk['cpbz'];
  6006. $warehouse = $this->warehouse->read($rk['warehouse']);
  6007. if ($warehouse['bdck'] == '') {
  6008. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6009. exit;
  6010. } else {
  6011. $bdck = $warehouse['bdck'];
  6012. }
  6013. $post['featurespp'] = $rk['featurespp'];
  6014. $this->db->trans_begin();
  6015. for ($i = 0; $i < $num; $i++) {
  6016. $post['label'] = time() . rand(100, 999) . $i;
  6017. $this->$bdck->insert($post);
  6018. }
  6019. /**
  6020. if($post['warehouse'] != 12)
  6021. {
  6022. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6023. }
  6024. **/
  6025. if ($this->db->trans_status() === TRUE) {
  6026. $this->db->trans_commit();
  6027. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6028. exit;
  6029. } else {
  6030. $this->db->trans_rollback();
  6031. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6032. exit;
  6033. }
  6034. } else {
  6035. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6036. exit;
  6037. }
  6038. }
  6039. }
  6040. public function _printck($arg_array)
  6041. {
  6042. $prc = array();
  6043. $purchase = $this->purchase->find_all();
  6044. foreach ($purchase as $k => $v) {
  6045. $prc[$v['id']] = $v['title'];
  6046. }
  6047. $post = $this->input->post(NULL, TRUE);
  6048. if (isset($post['page'])) {
  6049. $page = $this->input->post('page', true);
  6050. $perpage = $this->input->post('perpage', true);
  6051. $sku = $this->input->post('sku', true);
  6052. $bs = $this->input->post('bs', true);
  6053. $number = $this->input->post('number', true);
  6054. $warehouse = $this->input->post('warehouse', true);
  6055. $purchase = $this->input->post('purchase', true);
  6056. $orderinfo = $this->input->post('orderinfo', true);
  6057. $waybill = $this->input->post('waybill', true);
  6058. $category = $this->input->post('category', true);
  6059. $size = $this->input->post('size', true);
  6060. $grade = $this->input->post('grade', true);
  6061. $color = $this->input->post('color', true);
  6062. $lowe = $this->input->post('lowe', true);
  6063. $state = $this->input->post('state', true);
  6064. $label = $this->input->post('label', true);
  6065. $timetk = $this->input->post('ktime', true);
  6066. $timetj = $this->input->post('jtime', true);
  6067. $timetk = strtotime($timetk);
  6068. $timetj = strtotime($timetj);
  6069. $where = "state=1 ";
  6070. if ($timetk && $timetj) {
  6071. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6072. }
  6073. if ($sku) {
  6074. $where .= " and sku = '$sku'";
  6075. }
  6076. if ($bs != '') {
  6077. $where .= " and bs = '$bs'";
  6078. }
  6079. if ($number) {
  6080. $where .= " and number = '$number'";
  6081. }
  6082. if ($warehouse) {
  6083. $where .= " and warehouse = '$warehouse'";
  6084. }
  6085. if ($purchase) {
  6086. $where .= " and purchase = '$purchase'";
  6087. }
  6088. if ($orderinfo) {
  6089. $where .= " and orderinfo = '$orderinfo'";
  6090. }
  6091. if ($waybill) {
  6092. $where .= " and waybill = '$waybill'";
  6093. }
  6094. if ($category) {
  6095. $where .= " and features like '%-$category-%'";
  6096. }
  6097. if ($size) {
  6098. $where .= " and features like '%-$size-%'";
  6099. }
  6100. if ($grade) {
  6101. $where .= " and features like '%-$grade-%'";
  6102. }
  6103. if ($color) {
  6104. $where .= " and features like '%-$color-%'";
  6105. }
  6106. if ($lowe) {
  6107. $where .= " and features like '%-$lowe-%'";
  6108. }
  6109. if ($label) {
  6110. $where .= " and label = '$label'";
  6111. }
  6112. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6113. //数据排序
  6114. $order_str = "outk desc";
  6115. if (empty($page)) {
  6116. $start = 0;
  6117. $perpage = 1;
  6118. } else {
  6119. $start = ($page - 1) * $perpage;
  6120. }
  6121. //取得信息列表
  6122. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6123. foreach ($info_list as $key => $value) {
  6124. $warehouse = $this->warehouse->read($value['warehouse']);
  6125. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6126. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6127. if ($value['state'] == 0) {
  6128. $info_list[$key]['state'] = "在库";
  6129. } else if ($value['state'] == 1) {
  6130. $info_list[$key]['state'] = "出库";
  6131. } else if ($value['state'] == 2) {
  6132. $info_list[$key]['state'] = "退库";
  6133. } else if ($value['state'] == 3) {
  6134. $info_list[$key]['state'] = "调拨中";
  6135. } else if ($value['state'] == 4) {
  6136. $info_list[$key]['state'] = "再加工";
  6137. } else if ($value['state'] == 5) {
  6138. $info_list[$key]['state'] = "维修中";
  6139. } else if ($value['state'] == 6) {
  6140. $info_list[$key]['state'] = "盘亏";
  6141. } else if ($value['state'] == 7) {
  6142. $info_list[$key]['state'] = "更换标签";
  6143. } else if ($value['state'] == 8) {
  6144. $info_list[$key]['state'] = "其它";
  6145. } else if ($value['state'] == 9) {
  6146. $info_list[$key]['state'] = "预设";
  6147. } else if ($value['state'] == 10) {
  6148. $info_list[$key]['state'] = "美店零售";
  6149. }
  6150. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6151. }
  6152. $total = $this->$ck->find_count($where);
  6153. $pagenum = ceil($total / $perpage);
  6154. $over = $total - ($start + $perpage);
  6155. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6156. echo json_encode($rows);
  6157. exit;
  6158. }
  6159. if (isset($post['tmsku'])) {
  6160. $time = time();
  6161. $tmsku = $this->input->post('tmsku', true);
  6162. //$post['shop'] = $this->input->post('shop',true);
  6163. $num = $this->input->post('num', true);
  6164. $cktype = $this->input->post('cktype', true);
  6165. $label = $this->whlabellabel->get_label($tmsku);
  6166. if (!$cktype) {
  6167. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6168. }
  6169. if (!isset($label['warehouse'])) {
  6170. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6171. exit;
  6172. }
  6173. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6174. if (stripos($label['features'], '-126-') !== false) {
  6175. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6176. } else {
  6177. $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 = ''");
  6178. }
  6179. $j = 0;
  6180. if (count($ck) >= $num) {
  6181. for ($i = 0; $i < $num; $i++) {
  6182. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6183. {
  6184. $j++;
  6185. }
  6186. }
  6187. if ($j == $num) {
  6188. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6189. exit;
  6190. } else {
  6191. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6192. exit;
  6193. }
  6194. } else {
  6195. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6196. exit;
  6197. }
  6198. }
  6199. if(isset($_SESSION['api']))
  6200. {
  6201. $user = $this->user->get_api($_SESSION['api']);
  6202. if(in_array($user['power'],[1,27])){
  6203. $vip = 1;
  6204. }
  6205. }
  6206. else
  6207. {
  6208. $vip = 0;
  6209. header('Location: /');exit;
  6210. }
  6211. $this->data['vip'] = $vip;
  6212. $this->_Template('whlabel_printck', $this->data);
  6213. }
  6214. public function _printexcel()
  6215. {
  6216. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6217. $config['upload_path'] = '.' . $dir;
  6218. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6219. $config['allowed_types'] = 'xls|xlsx|csv';
  6220. $config['max_size'] = 10240;
  6221. $this->load->library('upload', $config);
  6222. $this->upload->initialize($config);
  6223. if ($this->upload->do_upload('userfile')) {
  6224. $full_path = $dir . $this->upload->data('file_name');
  6225. $fileName = '.' . $full_path;
  6226. if (!file_exists($fileName)) {
  6227. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6228. exit;
  6229. } else {
  6230. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6231. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6232. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6233. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6234. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6235. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6236. ++$column; //如果列数大于26行
  6237. $list = array();
  6238. for ($i = 2; $i <= $row; $i++) // 行数循环
  6239. {
  6240. $data = array();
  6241. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6242. {
  6243. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6244. }
  6245. $list[] = $data;
  6246. }
  6247. }
  6248. $ed = array();
  6249. $i = 0;
  6250. $j = 0;
  6251. $dcdata = array();
  6252. $yc = '';
  6253. $cmf_arr = array_column($list, '1');
  6254. array_multisort($cmf_arr, SORT_ASC, $list);
  6255. foreach ($list as $key => $value) {
  6256. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6257. if ($typeclass) {
  6258. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6259. } else {
  6260. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6261. $i++;
  6262. continue;
  6263. }
  6264. }
  6265. if ($i > 0) {
  6266. $yc = $i . '条异常';
  6267. }
  6268. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6269. exit;
  6270. }
  6271. }
  6272. public function _uck()
  6273. {
  6274. if (isset($_GET['excel'])) {
  6275. $tc = array();
  6276. $typeclass = $this->typeclass->find_all();
  6277. foreach ($typeclass as $v) {
  6278. $tc[$v['id']] = $v['zh'];
  6279. }
  6280. $data = array();
  6281. $t = array();
  6282. $rq = '';
  6283. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6284. $ts = $ts / (24 * 3600);
  6285. for ($i = 0; $i < $ts; $i++) {
  6286. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6287. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6288. }
  6289. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6290. foreach ($info_list as $k => $v) {
  6291. $features = explode('-', trim($v['features'], '-'));
  6292. if (!isset($features[3]) || !isset($features[4])) {
  6293. continue;
  6294. }
  6295. $data[$k][0] = $tc[$features[0]]; //类型
  6296. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6297. $data[$k][2] = $tc[$features[4]]; //曲度
  6298. $data[$k][3] = '';
  6299. if (isset($data[$k][1])) {
  6300. $data[$k][3] .= $data[$k][1];
  6301. }
  6302. if (isset($data[$k][2])) {
  6303. $data[$k][3] .= $data[$k][2];
  6304. }
  6305. if (isset($features[5])) {
  6306. $data[$k][3] .= $tc[$features[5]];
  6307. }
  6308. if (isset($features[2])) {
  6309. $data[$k][3] .= $tc[$features[2]];
  6310. }
  6311. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6312. $data[$k][4] = $v['sku'];
  6313. $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())) . '))'); //月初库存
  6314. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6315. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6316. $ztrq = '';
  6317. $ztsl = '';
  6318. if (count($zt) > 0) {
  6319. foreach ($zt as $vv) {
  6320. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6321. $ztsl .= $vv['num'] . '<br>';
  6322. }
  6323. }
  6324. $data[$k][] = trim($ztsl, '<br>');
  6325. $data[$k][] = trim($ztrq, '<br>');
  6326. $byck = 0;
  6327. foreach ($t as $vv) {
  6328. $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));
  6329. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6330. $byck += $sl;
  6331. }
  6332. $data[$k][] = ($byck > 0) ? $byck : '';
  6333. }
  6334. $title = "详情 " . date("Y-m-d", time());
  6335. $titlename = "<table border=1>
  6336. <tr align='center'>
  6337. <td>类别</td>
  6338. <td>颜色</td>
  6339. <td>曲度</td>
  6340. <td>名称</td>
  6341. <td>SKU</td>
  6342. <td>月初库存</td>
  6343. <td>剩余库存</td>
  6344. <td>在途数量</td>
  6345. <td>预达日期</td>" .
  6346. $rq
  6347. . "<td>本月出库</td></tr>
  6348. </table>";
  6349. $filename = $title . ".xls";
  6350. $tail = "";
  6351. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6352. }
  6353. }
  6354. public function _whlabelexcelzh()
  6355. {
  6356. if (isset($_GET['excel'])) {
  6357. $where = "sku != 'Preset'";
  6358. //数据排序
  6359. $order_str = "id desc";
  6360. if (empty($page)) {
  6361. $start = 0;
  6362. $perpage = 1;
  6363. } else {
  6364. $start = ($page - 1) * $perpage;
  6365. }
  6366. $category = $this->input->get('category', true);
  6367. $warehouse = $this->input->get('warehouse', true);
  6368. $excelid = $this->input->get('sid', true);
  6369. if ($category) {
  6370. $where .= " and features like '%-$category-%'";
  6371. }
  6372. if ($warehouse) {
  6373. $where .= " and warehouse = '$warehouse'";
  6374. }
  6375. $xzid = '';
  6376. if ($excelid) {
  6377. $excelid = explode(',', trim($excelid, ','));
  6378. foreach ($excelid as $key => $value) {
  6379. $xzid .= " id = " . $value . " or";
  6380. }
  6381. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6382. }
  6383. //取得信息列表
  6384. /**
  6385. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6386. $rows = array();$list = array();
  6387. foreach ($info_list as $key=>$value)
  6388. {
  6389. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6390. }
  6391. **/
  6392. $list = array();
  6393. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6394. foreach ($rows as $key => $value) {
  6395. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6396. $zh = '';
  6397. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6398. foreach ($zt as $v) {
  6399. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6400. }
  6401. $zt = array_sum(array_column($zt, 'num'));
  6402. $number = $value['number'];
  6403. $ftime = time() - 15 * 24 * 3600;
  6404. $warehouse = $this->warehouse->read($value['warehouse']);
  6405. $rows[$key]['warehouse'] = $warehouse['title'];
  6406. $rows[$key]['number'] = $c;
  6407. $rows[$key]['features'] = $zh;
  6408. $rows[$key]['hb'] = $c + $zt;
  6409. }
  6410. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6411. $titlename = "<table border=1>
  6412. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6413. <tr align='center'>
  6414. <td>仓库</td>
  6415. <td>SKU</td>
  6416. <td>产品</td>
  6417. <td>库存数量</td>
  6418. <td>在途数量及预达日期</td>
  6419. <td>在途+库存数量</td>
  6420. </tr>
  6421. </table>";
  6422. $filename = $title . ".xls";
  6423. $tail = "";
  6424. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6425. }
  6426. if (isset($_GET['excel'])) {
  6427. $warehouse = $this->input->get('warehouse', true);
  6428. $sku = $this->input->get('sku', true);
  6429. $cz = $this->input->get('cz', true);
  6430. $text = $this->input->post('text', true);
  6431. $xztime = $this->input->get('xztime', true);
  6432. $timetk = $this->input->get('timetk', true);
  6433. $timetj = $this->input->get('timetj', true);
  6434. $timetk = strtotime($timetk);
  6435. $timetj = strtotime($timetj);
  6436. $where = "time = '0' ";
  6437. if ($warehouse) {
  6438. $where .= " and warehouse = '$warehouse'";
  6439. }
  6440. if ($sku) {
  6441. $where .= " and sku = '$sku'";
  6442. }
  6443. if ($text) {
  6444. $where .= " and text like '%$text%'";
  6445. }
  6446. if ($cz != '') {
  6447. $where .= " and cz = '$cz'";
  6448. }
  6449. if ($timetk && $timetj) {
  6450. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6451. }
  6452. //数据排序
  6453. $order_str = $xztime . " desc";
  6454. //取得信息列表
  6455. $zh = array();
  6456. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6457. foreach ($info_list as $v) {
  6458. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6459. $warehouse = $this->warehouse->read($v['warehouse']);
  6460. $v['warehouse'] = $warehouse['title'];
  6461. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6462. $v['stime'] = date('Y-m-d', $v['stime']);
  6463. if (isset($zh[$v['features']])) {
  6464. $zh[$v['features']]['num'] += $v['num'];
  6465. } else {
  6466. $zh[$v['features']] = $v;
  6467. }
  6468. $zh[$v['features']]['features'] = $c;
  6469. }
  6470. $title = "在途数据" . date('Y-m-d', time());
  6471. $titlename = "<table border=1>
  6472. <tr align='center'>
  6473. <td>仓库</td>
  6474. <td>SKU</td>
  6475. <td>名称</td>
  6476. <td>在途数量</td>
  6477. <td>库存数量</td>
  6478. <td>添加在途日期</td>
  6479. <td>预达日期</td>
  6480. <td>备注</td>
  6481. </tr>
  6482. </table>";
  6483. $filename = $title . ".xls";
  6484. $tail = "";
  6485. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6486. }
  6487. }
  6488. public function _fc()
  6489. {
  6490. $vip = 0;
  6491. if (isset($_SESSION['api'])) {
  6492. $user = $this->user->get_api($_SESSION['api']);
  6493. if ($user['vip'] == 1) {
  6494. $vip = 1;
  6495. }
  6496. } else {
  6497. header('Location: /');
  6498. exit;
  6499. }
  6500. $post = $this->input->post(NULL, TRUE);
  6501. if (isset($post['page'])) {
  6502. $page = $this->input->post('page', true);
  6503. $perpage = $this->input->post('perpage', true);
  6504. $category = $this->input->post('category', true);
  6505. $size = $this->input->post('size', true);
  6506. $grade = $this->input->post('grade', true);
  6507. $color = $this->input->post('color', true);
  6508. $lowe = $this->input->post('lowe', true);
  6509. $sku = $this->input->post('sku');
  6510. $title = $this->input->post('title');
  6511. $warehouse = $this->input->post('warehouse', true);
  6512. $usa = $this->input->post('usa', true);
  6513. $purchase = $this->input->post('purchase', true);
  6514. $lacetype = $this->input->post('lacetype', true);
  6515. $haircap = $this->input->post('haircap', true);
  6516. $density = $this->input->post('density', true);
  6517. $details = $this->input->post('details', true);
  6518. $state = $this->input->post('state', true);
  6519. $ktime = $this->input->post('ktime', true);
  6520. $jtime = $this->input->post('jtime', true);
  6521. $ktime = strtotime($ktime);
  6522. $jtime = strtotime($jtime);
  6523. $where = "state = '11'";
  6524. $gj = "";
  6525. $ck = "";
  6526. if ($lacetype) {
  6527. $where .= " and features like '%-$lacetype-%'";
  6528. }
  6529. if ($category) {
  6530. $where .= " and features like '%-$category-%'";
  6531. }
  6532. if ($size) {
  6533. $where .= " and features like '%-$size-%'";
  6534. }
  6535. if ($grade) {
  6536. $where .= " and features like '%-$grade-%'";
  6537. }
  6538. if ($color) {
  6539. $where .= " and features like '%-$color-%'";
  6540. }
  6541. if ($lowe) {
  6542. $where .= " and features like '%-$lowe-%'";
  6543. }
  6544. if ($haircap) {
  6545. $where .= " and features like '%-$haircap-%'";
  6546. }
  6547. if ($density) {
  6548. $where .= " and features like '%-$density-%'";
  6549. }
  6550. if ($usa) {
  6551. if (!$warehouse) {
  6552. $where .= " and (warehouse = '5' or warehouse = '8')";
  6553. }
  6554. }
  6555. if ($warehouse) {
  6556. $where .= " and warehouse = '$warehouse'";
  6557. }
  6558. if ($details) {
  6559. $where .= " and details = '$details'";
  6560. }
  6561. if ($purchase) {
  6562. $where .= " and purchase = '$purchase'";
  6563. }
  6564. if ($state) {
  6565. $where .= " and state = '$state'";
  6566. }
  6567. if ($ktime && $jtime) {
  6568. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6569. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6570. }
  6571. //数据排序
  6572. $order_str = "id desc";
  6573. if (empty($page)) {
  6574. $start = 0;
  6575. $perpage = 1;
  6576. } else {
  6577. $start = ($page - 1) * $perpage;
  6578. }
  6579. if ($sku) {
  6580. $sku = trim($sku, ' ');
  6581. $sku = trim($sku, ' ');
  6582. $where .= " and sku like '%$sku%'";
  6583. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6584. } else if ($title) {
  6585. $title = trim($title, ' ');
  6586. $title = trim($title, ' ');
  6587. $where .= " and title like '%$title%'";
  6588. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6589. } else {
  6590. //$where .= " and time > '$ktime' and time < '$jtime'";
  6591. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6592. }
  6593. //取得信息列表
  6594. $rows = array();
  6595. $list = array();
  6596. foreach ($info_list as $key => $value) {
  6597. $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'] . '"');
  6598. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6599. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6600. $warehouse = $this->warehouse->read($value['warehouse']);
  6601. $info_list[$key]['warehouse'] = $warehouse['title'];
  6602. $info_list[$key]['number'] = $g;
  6603. $info_list[$key]['features'] = $x;
  6604. $info_list[$key]['x'] = $s;
  6605. }
  6606. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6607. $pagenum = ceil($total / $perpage);
  6608. $over = $total - ($start + $perpage);
  6609. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6610. echo json_encode($rows);
  6611. exit;
  6612. }
  6613. $this->data['vip'] = $vip;
  6614. $this->_Template('whlabel_fc', $this->data);
  6615. }
  6616. public function _fcmb()
  6617. {
  6618. $where = "sku != 'Preset'";
  6619. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6620. foreach ($rows as $k => $v) {
  6621. $warehouse = $this->warehouse->read($v['warehouse']);
  6622. $rows[$k]['warehouse'] = $warehouse['title'];
  6623. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6624. $rows[$k]['t'] = '';
  6625. $rows[$k]['n'] = '';
  6626. }
  6627. $title = "封货产品数据导入模板";
  6628. $titlename = "<table border=1>
  6629. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6630. <tr align='center'>
  6631. <td>仓库</td>
  6632. <td>SKU</td>
  6633. <td>产品</td>
  6634. <td>封存产品总数量</td>
  6635. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6636. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6637. </tr>
  6638. </table>";
  6639. $filename = $title . ".xls";
  6640. $tail = "";
  6641. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6642. }
  6643. public function _fcexcel()
  6644. {
  6645. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6646. $config['upload_path'] = '.' . $dir;
  6647. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6648. $config['allowed_types'] = 'xls|xlsx|csv';
  6649. $config['max_size'] = 10240;
  6650. $this->load->library('upload', $config);
  6651. $this->upload->initialize($config);
  6652. if ($this->upload->do_upload('userfile')) {
  6653. $full_path = $dir . $this->upload->data('file_name');
  6654. $fileName = '.' . $full_path;
  6655. if (!file_exists($fileName)) {
  6656. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6657. exit;
  6658. } else {
  6659. libxml_use_internal_errors(true);
  6660. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6661. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6662. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6663. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6664. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6665. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6666. ++$column; //如果列数大于26行
  6667. $list = array();
  6668. for ($i = 2; $i <= $row; $i++) // 行数循环
  6669. {
  6670. $data = array();
  6671. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6672. {
  6673. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6674. }
  6675. $list[] = $data;
  6676. }
  6677. }
  6678. $i = 0;
  6679. $j = 0;
  6680. $ed = array();
  6681. foreach ($list as $key => $value) {
  6682. $time = time();
  6683. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6684. continue;
  6685. }
  6686. $warehouse = $this->warehouse->get_title($value['0']);
  6687. $sku = $value['1'];
  6688. $type = $value['4']; //调整方式0扣减1删除
  6689. $num = $value['5']; //调整数量
  6690. //$text = $value['4'];//扣减说明
  6691. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6692. if (!$d) //如果没有这个SKU
  6693. {
  6694. $ed[] = array($sku . '-库存中不存在此SKU');
  6695. $j++;
  6696. continue;
  6697. }
  6698. if (!isset($warehouse['id'])) {
  6699. $ed[] = array($sku . '-仓库名错误!');
  6700. $j++;
  6701. continue;
  6702. }
  6703. if ($type == 1 || $type == 2) //扣减库存
  6704. {
  6705. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6706. if (count($data) < abs($num)) {
  6707. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6708. $j++;
  6709. continue;
  6710. }
  6711. if ($type == 1) //转入库存
  6712. {
  6713. for ($i = 0; $i < abs($num); $i++) {
  6714. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6715. }
  6716. } else if ($type == 2) //删除
  6717. {
  6718. for ($i = 0; $i < abs($num); $i++) {
  6719. $this->whlabel->remove($data[$i]['id']);
  6720. }
  6721. }
  6722. } else if ($type == 0) //增加库存
  6723. {
  6724. $post['sku'] = $d['sku'];
  6725. $post['shop'] = '';
  6726. $post['warehouse'] = $warehouse['id'];
  6727. $post['purchase'] = $d['purchase'];
  6728. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6729. $post['state'] = 11;
  6730. $post['title'] = $d['title'];
  6731. $post['number'] = $d['number'];
  6732. $post['features'] = $d['features'];
  6733. $post['enter'] = $time;
  6734. $post['time'] = $time; //操作时间
  6735. for ($i = 0; $i < $num; $i++) {
  6736. $post['label'] = time() . rand(100, 999) . $i;
  6737. $this->whlabel->insert($post);
  6738. }
  6739. }
  6740. sleep(1); //防止入库时间一样,需要延迟1秒
  6741. }
  6742. if ($j > 0) {
  6743. $tt = date('Ymd', time());
  6744. $title = '库存导入错误信息-' . $tt;
  6745. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6746. $tail = "\n";
  6747. $filename = $title . ".xls";
  6748. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6749. $dir = '/data/excel/' . $time . '/';
  6750. $file_name = 'error_' . $time . rand(1000, 9999);
  6751. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6752. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6753. fwrite($myfile, $ecl);
  6754. fclose($myfile);
  6755. $error = $dir . $file_name . '.xls';
  6756. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6757. exit;
  6758. } else {
  6759. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6760. exit;
  6761. }
  6762. }
  6763. }
  6764. public function _fcjxc($arg_array)
  6765. {
  6766. if (isset($_GET['excel'])) {
  6767. $category = $this->input->get('category', true);
  6768. $size = $this->input->get('size', true);
  6769. $grade = $this->input->get('grade', true);
  6770. $color = $this->input->get('color', true);
  6771. $lowe = $this->input->get('lowe', true);
  6772. $sku = $this->input->get('sku');
  6773. $title = $this->input->get('title');
  6774. $warehouse = $arg_array[0];
  6775. $usa = $this->input->get('usa', true);
  6776. $purchase = $this->input->get('purchase', true);
  6777. $lacetype = $this->input->get('lacetype', true);
  6778. $haircap = $this->input->get('haircap', true);
  6779. $density = $this->input->get('density', true);
  6780. $title = $this->input->get('title', true);
  6781. $state = $this->input->get('state', true);
  6782. $ktime = $this->input->get('ktime', true);
  6783. $jtime = $this->input->get('jtime', true);
  6784. $where = "state=11";
  6785. $gj = "";
  6786. $ck = "";
  6787. if ($lacetype) {
  6788. $where .= " and features like '%-$lacetype-%'";
  6789. }
  6790. if ($category) {
  6791. $where .= " and features like '%-$category-%'";
  6792. }
  6793. if ($size) {
  6794. $where .= " and features like '%-$size-%'";
  6795. }
  6796. if ($grade) {
  6797. $where .= " and features like '%-$grade-%'";
  6798. }
  6799. if ($color) {
  6800. $where .= " and features like '%-$color-%'";
  6801. }
  6802. if ($lowe) {
  6803. $where .= " and features like '%-$lowe-%'";
  6804. }
  6805. if ($haircap) {
  6806. $where .= " and features like '%-$haircap-%'";
  6807. }
  6808. if ($density) {
  6809. $where .= " and features like '%-$density-%'";
  6810. }
  6811. if ($usa) {
  6812. if (!$warehouse) {
  6813. $where .= " and (warehouse = '5' or warehouse = '8')";
  6814. }
  6815. }
  6816. if ($warehouse) {
  6817. $where .= " and warehouse = '$warehouse'";
  6818. }
  6819. if ($purchase) {
  6820. $where .= " and purchase = '$purchase'";
  6821. }
  6822. if ($state) {
  6823. $where .= " and state = '$state'";
  6824. }
  6825. $order_str = "id desc";
  6826. if ($sku) {
  6827. $sku = trim($sku, ' ');
  6828. $sku = trim($sku, ' ');
  6829. $where .= " and sku like '%$sku%'";
  6830. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6831. } else if ($title) {
  6832. $title = trim($title, ' ');
  6833. $title = trim($title, ' ');
  6834. $where .= " and title like '%$title%'";
  6835. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6836. } else {
  6837. //$where .= " and time > '$ktime' and time < '$jtime'";
  6838. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6839. }
  6840. //取得信息列表
  6841. $rows = array();
  6842. $list = array();
  6843. foreach ($info_list as $key => $value) {
  6844. $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'] . '"');
  6845. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6846. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6847. $rows[$key] = $value;
  6848. $warehouse = $this->warehouse->read($value['warehouse']);
  6849. $rows[$key]['warehouse'] = $warehouse['title'];
  6850. $rows[$key]['features'] = $g;
  6851. $rows[$key]['a'] = $x;
  6852. $rows[$key]['b'] = $s;
  6853. }
  6854. $title = "总统计表";
  6855. $titlename = "<table border=1>
  6856. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6857. <tr align='center'>
  6858. <td>仓库</td>
  6859. <td>SKU</td>
  6860. <td>产品名称</td>
  6861. <td>录入总量</td>
  6862. <td>取出总量</td>
  6863. <td>剩余总量</td>
  6864. </tr>
  6865. </table>";
  6866. $filename = $title . ".xls";
  6867. $tail = "";
  6868. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6869. }
  6870. $vip = 0;
  6871. if (isset($_SESSION['api'])) {
  6872. $user = $this->user->get_api($_SESSION['api']);
  6873. if ($user['vip'] == 1) {
  6874. $vip = 1;
  6875. }
  6876. } else {
  6877. header('Location: /');
  6878. exit;
  6879. }
  6880. $post = $this->input->post(NULL, TRUE);
  6881. if (isset($post['page'])) {
  6882. $page = $this->input->post('page', true);
  6883. $perpage = $this->input->post('perpage', true);
  6884. $category = $this->input->post('category', true);
  6885. $size = $this->input->post('size', true);
  6886. $grade = $this->input->post('grade', true);
  6887. $color = $this->input->post('color', true);
  6888. $lowe = $this->input->post('lowe', true);
  6889. $sku = $this->input->post('sku');
  6890. $title = $this->input->post('title');
  6891. $warehouse = $arg_array[0];
  6892. $usa = $this->input->post('usa', true);
  6893. $purchase = $this->input->post('purchase', true);
  6894. $lacetype = $this->input->post('lacetype', true);
  6895. $haircap = $this->input->post('haircap', true);
  6896. $density = $this->input->post('density', true);
  6897. $title = $this->input->post('title', true);
  6898. $state = $this->input->post('state', true);
  6899. $ktime = $this->input->post('ktime', true);
  6900. $jtime = $this->input->post('jtime', true);
  6901. $ktime = strtotime($ktime);
  6902. $jtime = strtotime($jtime);
  6903. $where = "state=11";
  6904. $gj = "";
  6905. $ck = "";
  6906. if ($lacetype) {
  6907. $where .= " and features like '%-$lacetype-%'";
  6908. }
  6909. if ($category) {
  6910. $where .= " and features like '%-$category-%'";
  6911. }
  6912. if ($size) {
  6913. $where .= " and features like '%-$size-%'";
  6914. }
  6915. if ($grade) {
  6916. $where .= " and features like '%-$grade-%'";
  6917. }
  6918. if ($color) {
  6919. $where .= " and features like '%-$color-%'";
  6920. }
  6921. if ($lowe) {
  6922. $where .= " and features like '%-$lowe-%'";
  6923. }
  6924. if ($haircap) {
  6925. $where .= " and features like '%-$haircap-%'";
  6926. }
  6927. if ($density) {
  6928. $where .= " and features like '%-$density-%'";
  6929. }
  6930. if ($usa) {
  6931. if (!$warehouse) {
  6932. $where .= " and (warehouse = '5' or warehouse = '8')";
  6933. }
  6934. }
  6935. if ($warehouse) {
  6936. $where .= " and warehouse = '$warehouse'";
  6937. }
  6938. if ($purchase) {
  6939. $where .= " and purchase = '$purchase'";
  6940. }
  6941. if ($state) {
  6942. $where .= " and state = '$state'";
  6943. }
  6944. if ($ktime && $jtime) {
  6945. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6946. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6947. }
  6948. //数据排序
  6949. $order_str = "id desc";
  6950. $xs = 0;
  6951. $rows = array();
  6952. $list = array();
  6953. if (empty($page)) {
  6954. $start = 0;
  6955. $perpage = 1;
  6956. } else {
  6957. $start = ($page - 1) * $perpage;
  6958. }
  6959. if ($sku || $title) {
  6960. if ($title) {
  6961. $title = trim($title, ' ');
  6962. $title = trim($title, ' ');
  6963. $where .= " and title like '%$title%'";
  6964. } else {
  6965. $sku = trim($sku, ' ');
  6966. $sku = trim($sku, ' ');
  6967. $where .= " and sku like '%$sku%'";
  6968. }
  6969. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6970. foreach ($info_list as $key => $value) {
  6971. $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'] . '"');
  6972. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6973. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6974. $rows[$key] = $value;
  6975. $warehouse = $this->warehouse->read($value['warehouse']);
  6976. $rows[$key]['warehouse'] = $warehouse['title'];
  6977. $rows[$key]['features'] = $g;
  6978. $rows[$key]['a'] = $x;
  6979. $rows[$key]['b'] = $s;
  6980. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6981. $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天销量
  6982. $yj = $c / ($xl / 30);
  6983. if ($yj < 7) {
  6984. $rows[$key]['y'] = round($yj) . '天销量';
  6985. } else {
  6986. $rows[$key]['y'] = '正常';
  6987. }
  6988. }
  6989. } else {
  6990. //$where .= " and time > '$ktime' and time < '$jtime'";
  6991. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6992. foreach ($info_list as $key => $value) {
  6993. $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'] . '"');
  6994. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6995. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6996. $zs[$key] = $value;
  6997. $warehouse = $this->warehouse->read($value['warehouse']);
  6998. $zs[$key]['warehouse'] = $warehouse['title'];
  6999. $zs[$key]['features'] = $g;
  7000. $zs[$key]['a'] = $x;
  7001. $zs[$key]['b'] = $s;
  7002. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7003. $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天销量
  7004. $yj = $c / ($xl / 30);
  7005. if ($yj < 7) {
  7006. $zs[$key]['y'] = round($yj) . '天销量';
  7007. $rows[$key] = $zs[$key];
  7008. }
  7009. }
  7010. }
  7011. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7012. $pagenum = ceil($total / $perpage);
  7013. $over = $total - ($start + $perpage);
  7014. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7015. echo json_encode($rows);
  7016. exit;
  7017. }
  7018. $this->data['arg_array'] = $arg_array[0];
  7019. $this->_Template('whlabel_fcjxc', $this->data);
  7020. }
  7021. public function _0kcdel()
  7022. {
  7023. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7024. $config['upload_path'] = '.' . $dir;
  7025. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7026. $config['allowed_types'] = 'xls|xlsx|csv';
  7027. $config['max_size'] = 10240;
  7028. $this->load->library('upload', $config);
  7029. $this->upload->initialize($config);
  7030. if ($this->upload->do_upload('userfile')) {
  7031. $full_path = $dir . $this->upload->data('file_name');
  7032. $fileName = '.' . $full_path;
  7033. if (!file_exists($fileName)) {
  7034. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7035. exit;
  7036. } else {
  7037. require_once "./data/excel/PHPExcel/IOFactory.php";
  7038. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7039. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7040. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7041. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7042. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7043. ++$column; //如果列数大于26行
  7044. $list = array();
  7045. for ($i = 2; $i <= $row; $i++) // 行数循环
  7046. {
  7047. $data = array();
  7048. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7049. {
  7050. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7051. }
  7052. $list[] = $data;
  7053. }
  7054. }
  7055. $i = 0;
  7056. $j = 0;
  7057. $ed = array();
  7058. foreach ($list as $key => $value) {
  7059. $time = time();
  7060. if ($value['0'] == "" || $value['1'] == "") {
  7061. continue;
  7062. }
  7063. $warehouse = $this->warehouse->get_title($value['0']);
  7064. $sku = $value['1'];
  7065. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7066. if (!$d) //如果没有这个SKU
  7067. {
  7068. $ed[] = array($sku . '-库存中不存在此SKU');
  7069. $j++;
  7070. continue;
  7071. }
  7072. if (!isset($warehouse['id'])) {
  7073. $ed[] = array($sku . '-仓库名错误!');
  7074. $j++;
  7075. continue;
  7076. }
  7077. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7078. if ($z < 1) {
  7079. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7080. foreach ($z as $v) {
  7081. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7082. if (count($zt) > 0) {
  7083. $ed[] = array($sku . '-有在途库存无法删除!');
  7084. $j++;
  7085. continue;
  7086. }
  7087. $this->whlabel->remove($v['id']);
  7088. }
  7089. } else {
  7090. $ed[] = array($sku . '-非0库存!');
  7091. $j++;
  7092. continue;
  7093. }
  7094. }
  7095. if ($j > 0) {
  7096. $tt = date('Ymd', time());
  7097. $title = '删除0库存错误信息-' . $tt;
  7098. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7099. $tail = "\n";
  7100. $filename = $title . ".xls";
  7101. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7102. $dir = '/data/excel/' . $time . '/';
  7103. $file_name = 'error_' . $time . rand(1000, 9999);
  7104. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7105. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7106. fwrite($myfile, $ecl);
  7107. fclose($myfile);
  7108. $error = $dir . $file_name . '.xls';
  7109. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7110. exit;
  7111. } else {
  7112. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7113. exit;
  7114. }
  7115. }
  7116. }
  7117. public function _gbhtype()
  7118. {
  7119. $post = $this->input->post(NULL, TRUE);
  7120. if (isset($post['s'])) {
  7121. $n = $this->input->post('n');
  7122. $d = $this->input->post('s');
  7123. if (!$d) {
  7124. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7125. exit;
  7126. }
  7127. $d = explode(',', trim($d, ','));
  7128. $t = $this->whlabel_type->read($n);
  7129. //循环删除记录
  7130. foreach ($d as $v) {
  7131. $u = $this->whlabel->read($v);
  7132. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7133. foreach ($data as $val) {
  7134. $this->whlabel->save(array('type' => $n), $val['id']);
  7135. }
  7136. }
  7137. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7138. }
  7139. }
  7140. //出库、退库导出
  7141. public function _dccrtype()
  7142. {
  7143. $classid = $this->classid->sku();
  7144. $pm = $classid;
  7145. $typeclass = array();
  7146. $tc = $this->typeclass->find_all();
  7147. foreach ($tc as $v) {
  7148. $typeclass[$v['id']] = $v;
  7149. }
  7150. $prc = array();
  7151. $purchase = $this->purchase->find_all();
  7152. foreach ($purchase as $k => $v) {
  7153. $prc[$v['id']] = $v['title'];
  7154. }
  7155. if (isset($_GET['sid'])) {
  7156. $wh = array();
  7157. $w = $this->warehouse->find_all('1=1', 'id,title');
  7158. foreach ($w as $v) {
  7159. $wh[$v['id']] = $v['title'];
  7160. }
  7161. $type = $this->input->get('excel', true);
  7162. $category = $this->input->get('category', true);
  7163. $size = $this->input->get('size', true);
  7164. $grade = $this->input->get('grade', true);
  7165. $color = $this->input->get('color', true);
  7166. $lowe = $this->input->get('lowe', true);
  7167. $sku = $this->input->get('sku', true);
  7168. $warehouse = $this->input->get('warehouse', true);
  7169. $lacetype = $this->input->get('lacetype', true);
  7170. $lacecolor = $this->input->get('lacecolor', true);
  7171. $density = $this->input->get('density', true);
  7172. $haircap = $this->input->get('haircap', true);
  7173. $purchase = $this->input->get('purchase', true);
  7174. $title = $this->input->get('title', true);
  7175. $state = $this->input->get('state', true);
  7176. $sid = $this->input->get('sid', true);
  7177. $ktime = $this->input->get('ktime', true);
  7178. $jtime = $this->input->get('jtime', true);
  7179. $ktime = strtotime($ktime);
  7180. $jtime = strtotime($jtime);
  7181. $where = "1=1";
  7182. $gj = "";
  7183. $ck = "";
  7184. if ($category) {
  7185. $where .= " and features like '%-$category-%'";
  7186. }
  7187. if ($size) {
  7188. $where .= " and features like '%-$size-%'";
  7189. }
  7190. if ($grade) {
  7191. $where .= " and features like '%-$grade-%'";
  7192. }
  7193. if ($color) {
  7194. $where .= " and features like '%-$color-%'";
  7195. }
  7196. if ($lowe) {
  7197. $where .= " and features like '%-$lowe-%'";
  7198. }
  7199. if ($warehouse) {
  7200. $where .= " and warehouse = '$warehouse'";
  7201. }
  7202. if ($purchase) {
  7203. $where .= " and purchase = '$purchase'";
  7204. }
  7205. if ($state) {
  7206. $where .= " and state = '$state'";
  7207. }
  7208. if ($lacetype) {
  7209. $where .= " and features like '%-$lacetype-%'";
  7210. }
  7211. if ($lacecolor) {
  7212. $where .= " and features like '%-$lacecolor-%'";
  7213. }
  7214. if ($density) {
  7215. $where .= " and features like '%-$density-%'";
  7216. }
  7217. if ($haircap) {
  7218. $where .= " and features like '%-$haircap-%'";
  7219. }
  7220. if ($title) {
  7221. $title = trim($title, ' ');
  7222. $title = trim($title, ' ');
  7223. $where .= " and title like '%$title%'";
  7224. }
  7225. if ($sku) {
  7226. $sku = trim($sku, ' ');
  7227. $sku = trim($sku, ' ');
  7228. $where .= " and sku like '%$sku%'";
  7229. }
  7230. if ($ktime && $jtime) {
  7231. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7232. }
  7233. $sidwhere = '';
  7234. if ($sid) {
  7235. $sd = "";
  7236. $s = explode(',', trim($sid, ','));
  7237. foreach ($s as $value) {
  7238. $sd .= " id = " . $value . " or";
  7239. }
  7240. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7241. }
  7242. //数据排序
  7243. $order_str = "time desc";
  7244. if (empty($page)) {
  7245. $start = 0;
  7246. $perpage = 1;
  7247. } else {
  7248. $start = ($page - 1) * $perpage;
  7249. }
  7250. $wh = array();
  7251. $w = $this->warehouse->find_all('1=1', 'id,title');
  7252. foreach ($w as $v) {
  7253. $wh[$v['id']] = $v['title'];
  7254. }
  7255. $wt = array();
  7256. $whlabel_type = $this->whlabel_type->find_all();
  7257. foreach ($whlabel_type as $v) {
  7258. $wt[$v['id']] = $v['title'];
  7259. }
  7260. $classid = $this->classid->sku();
  7261. $list = array();
  7262. $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');
  7263. foreach ($rows_r as $key => $value) {
  7264. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7265. $pm = $classid;
  7266. $jm = $classid;
  7267. $rows_r[$key]['enter'] = '入库';
  7268. $rows_r[$key]['time'] = $value['enter'];
  7269. if ($value['rktype'] == 1) {
  7270. $rows_r[$key]['rktype'] = '采购入库';
  7271. } else if ($value['rktype'] == 2) {
  7272. $rows_r[$key]['rktype'] = '盘盈调整';
  7273. } else if ($value['rktype'] == 3) {
  7274. $rows_r[$key]['rktype'] = '其他调整入库';
  7275. } else if ($value['rktype'] == 4) {
  7276. $rows_r[$key]['rktype'] = '其他调整入库';
  7277. } else if ($value['rktype'] == 5) {
  7278. $rows_r[$key]['rktype'] = '退库入库';
  7279. } else if ($value['rktype'] == 6) {
  7280. $rows_r[$key]['rktype'] = '退货可用入库';
  7281. } else if ($value['rktype'] == 7) {
  7282. $rows_r[$key]['rktype'] = '形态转换入库';
  7283. } else {
  7284. $rows_r[$key]['rktype'] = '';
  7285. }
  7286. $features = explode('-', trim($value['features'], '-'));
  7287. foreach ($features as $v) {
  7288. if (isset($typeclass[$v])) {
  7289. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7290. $pm[$typeclass[$v]['classid']] = $zh[0];
  7291. }
  7292. if (isset($typeclass[$v])) {
  7293. if (isset($jm[$typeclass[$v]['classid']])) {
  7294. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7295. }
  7296. }
  7297. }
  7298. $zh = implode(" ", $pm);
  7299. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7300. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7301. $rows_r[$key]['zh'] = $zh;
  7302. $jm = array_filter($jm);
  7303. $rows_r[$key]['features'] = implode("-", $jm);
  7304. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7305. }
  7306. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7307. foreach ($rows_c as $key => $value) {
  7308. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7309. $pm = $classid;
  7310. $jm = $classid;
  7311. $rows_c[$key]['time'] = $value['outk'];
  7312. $rows_c[$key]['outk'] = '出库';
  7313. if ($value['cktype'] == 1) {
  7314. $rows_c[$key]['cktype'] = '销售出库';
  7315. } else if ($value['cktype'] == 2) {
  7316. $rows_c[$key]['cktype'] = '销售美国出库';
  7317. } else if ($value['cktype'] == 3) {
  7318. $rows_c[$key]['cktype'] = '盘亏调整';
  7319. } else if ($value['cktype'] == 4) {
  7320. $rows_c[$key]['cktype'] = '其他调整出库';
  7321. } else if ($value['cktype'] == 5) {
  7322. $rows_c[$key]['cktype'] = '形态转换出库';
  7323. } else {
  7324. $rows_c[$key]['cktype'] = '';
  7325. }
  7326. $features = explode('-', trim($value['features'], '-'));
  7327. foreach ($features as $v) {
  7328. if (isset($typeclass[$v])) {
  7329. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7330. $pm[$typeclass[$v]['classid']] = $zh[0];
  7331. }
  7332. if (isset($typeclass[$v])) {
  7333. if (isset($jm[$typeclass[$v]['classid']])) {
  7334. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7335. }
  7336. }
  7337. }
  7338. $zh = implode(" ", $pm);
  7339. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7340. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7341. $rows_c[$key]['zh'] = $zh;
  7342. $jm = array_filter($jm);
  7343. $rows_c[$key]['features'] = implode("-", $jm);
  7344. $rows_c[$key]['number'] = 1;
  7345. }
  7346. $merged = $rows_r;
  7347. foreach ($rows_c as $key => $value) {
  7348. if (isset($merged[$key])) {
  7349. $merged[] = $value;
  7350. } else {
  7351. $merged[$key] = $value;
  7352. }
  7353. }
  7354. usort($merged, function ($a, $b) {
  7355. return $a['time'] - $b['time'];
  7356. });
  7357. foreach ($merged as $key => $value) {
  7358. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7359. }
  7360. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7361. $titlename = "<table border=1>
  7362. <tr align='center'>
  7363. <td>仓库</td>
  7364. <td>SKU</td>
  7365. <td>商品名称</td>
  7366. <td>仓库品名</td>
  7367. <td>料号</td>
  7368. <td>时间</td>
  7369. <td>操作</td>
  7370. <td>类型</td>
  7371. <td>数量</td>
  7372. <td>备注</td>
  7373. </tr>
  7374. </table>";
  7375. $filename = $title . ".xlsx";
  7376. $tail = "";
  7377. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7378. }
  7379. }
  7380. }