Whlabel.php 265 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. }else if($arg == "w_t_cs"){
  192. $this->_w_t_cs(); //首页
  193. }else {
  194. $this->_index();
  195. }
  196. }
  197. public function _w_t_cs(){
  198. $vip = 0;
  199. if (isset($_SESSION['api'])) {
  200. $user = $this->user->get_api($_SESSION['api']);
  201. $fgshop = "";
  202. $sid = "";
  203. $usersp = explode('|', trim($user['shop'], '|'));
  204. foreach ($usersp as $value) {
  205. $fgshop .= " shop = " . $value . " or";
  206. $sid .= " id = " . $value . " or";
  207. }
  208. if ($user['vip'] == 1) {
  209. $vip = 1;
  210. }
  211. } else {
  212. header('Location: /');
  213. exit;
  214. }
  215. $prc = array();
  216. $purchase = $this->purchase->find_all();
  217. foreach ($purchase as $k => $v) {
  218. $prc[$v['id']] = $v['title'];
  219. }
  220. $company = array();
  221. $ct = $this->company->find_all();
  222. foreach ($ct as $k => $v) {
  223. $company[$v['id']] = $v['title'];
  224. }
  225. $sp = array();
  226. $s = $this->shop->find_all('1=1', 'id,shopname');
  227. foreach ($s as $v) {
  228. $sp[$v['id']] = $v['shopname'];
  229. }
  230. $wh = array();
  231. $w = $this->warehouse->find_all('1=1', 'id,title');
  232. foreach ($w as $v) {
  233. $wh[$v['id']] = $v['title'];
  234. }
  235. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  236. $this->data['shop'] = $wlshop;
  237. $this->data['vip'] = $vip;
  238. $this->_Template('whlabel_typejs', $this->data);
  239. }
  240. //管理
  241. public function _index()
  242. {
  243. $post = $this->input->post(NULL, TRUE);
  244. if (isset($post['page'])) {
  245. $page = $this->input->post('page', true);
  246. $perpage = $this->input->post('perpage', true);
  247. $sku = $this->input->post('sku', true);
  248. $number = $this->input->post('number', true);
  249. $warehouse = $this->input->post('warehouse', true);
  250. $purchase = $this->input->post('purchase', true);
  251. $orderinfo = $this->input->post('orderinfo', true);
  252. $waybill = $this->input->post('waybill', true);
  253. $category = $this->input->post('category', true);
  254. $size = $this->input->post('size', true);
  255. $grade = $this->input->post('grade', true);
  256. $color = $this->input->post('color', true);
  257. $lowe = $this->input->post('lowe', true);
  258. $state = $this->input->post('state', true);
  259. $label = $this->input->post('label', true);
  260. $timetk = $this->input->post('timetkk', true);
  261. $timetj = $this->input->post('timetjj', true);
  262. $timetk = strtotime($timetk);
  263. $timetj = strtotime($timetj);
  264. $where = "1=1 ";
  265. if ($timetk && $timetj) {
  266. $where .= " and time > '$timetk' and time < '$timetj'";
  267. }
  268. if ($sku) {
  269. $where .= " and sku = '$sku'";
  270. }
  271. if ($number) {
  272. $where .= " and number = '$number'";
  273. }
  274. if ($warehouse) {
  275. $where .= " and warehouse = '$warehouse'";
  276. }
  277. if ($purchase) {
  278. $where .= " and purchase = '$purchase'";
  279. }
  280. if ($orderinfo) {
  281. $where .= " and orderinfo = '$orderinfo'";
  282. }
  283. if ($waybill) {
  284. $where .= " and waybill = '$waybill'";
  285. }
  286. if ($category) {
  287. $where .= " and features like '%-$category-%'";
  288. }
  289. if ($size) {
  290. $where .= " and features like '%-$size-%'";
  291. }
  292. if ($grade) {
  293. $where .= " and features like '%-$grade-%'";
  294. }
  295. if ($color) {
  296. $where .= " and features like '%-$color-%'";
  297. }
  298. if ($lowe) {
  299. $where .= " and features like '%-$lowe-%'";
  300. }
  301. if ($label) {
  302. $where .= " and label = '$label'";
  303. }
  304. if ($state != '') {
  305. $where .= " and state = '$state'";
  306. }
  307. //数据排序
  308. $order_str = "time desc";
  309. if (empty($page)) {
  310. $start = 0;
  311. $perpage = 1;
  312. } else {
  313. $start = ($page - 1) * $perpage;
  314. }
  315. //取得信息列表
  316. $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);
  317. foreach ($info_list as $key => $value) {
  318. $warehouse = $this->warehouse->read($value['warehouse']);
  319. $info_list[$key]['warehouse'] = $warehouse['title'];
  320. $purchase = $this->purchase->read($value['purchase']);
  321. $info_list[$key]['purchase'] = $purchase['title'];
  322. if ($value['enter'] != 0) {
  323. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  324. } else {
  325. $info_list[$key]['enter'] = "";
  326. }
  327. if ($value['outk'] != 0) {
  328. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  329. } else {
  330. $info_list[$key]['outk'] = "";
  331. }
  332. if ($value['printing'] != 0) {
  333. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  334. } else {
  335. $info_list[$key]['printing'] = "";
  336. }
  337. if ($value['orderinfo'] == 0) {
  338. $info_list[$key]['orderinfo'] = "";
  339. }
  340. if ($value['waybill'] == 0) {
  341. $info_list[$key]['waybill'] = "";
  342. }
  343. if ($value['state'] == 0) {
  344. $info_list[$key]['state'] = "在库";
  345. } else if ($value['state'] == 1) {
  346. $info_list[$key]['state'] = "出库";
  347. } else if ($value['state'] == 2) {
  348. $info_list[$key]['state'] = "退库";
  349. } else if ($value['state'] == 3) {
  350. $info_list[$key]['state'] = "调拨中";
  351. } else if ($value['state'] == 4) {
  352. $info_list[$key]['state'] = "再加工";
  353. } else if ($value['state'] == 5) {
  354. $info_list[$key]['state'] = "维修中";
  355. } else if ($value['state'] == 6) {
  356. $info_list[$key]['state'] = "盘亏";
  357. } else if ($value['state'] == 7) {
  358. $info_list[$key]['state'] = "更换标签";
  359. } else if ($value['state'] == 8) {
  360. $info_list[$key]['state'] = "其它";
  361. } else if ($value['state'] == 9) {
  362. $info_list[$key]['state'] = "预设";
  363. } else if ($value['state'] == 10) {
  364. $info_list[$key]['state'] = "美店零售";
  365. }
  366. if ($value['text'] == "") {
  367. $info_list[$key]['text'] = "";
  368. }
  369. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  370. }
  371. $total = $this->whlabel->find_count($where);
  372. $pagenum = ceil($total / $perpage);
  373. $over = $total - ($start + $perpage);
  374. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  375. echo json_encode($rows);
  376. exit;
  377. }
  378. if (isset($post['outsku'])) {
  379. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  380. $cz = $this->input->post('cz', true);
  381. if ($cz == '1') {
  382. $sku = $this->input->post('outsku', true);
  383. if ($sku) {
  384. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  385. if (count($data) < 1) {
  386. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  387. exit;
  388. }
  389. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  390. echo json_encode(array('success' => true));
  391. exit;
  392. }
  393. } else {
  394. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  395. exit;
  396. $sku = $this->input->post('outsku', true);
  397. if ($sku) {
  398. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  399. if (count($data) < 1) {
  400. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  401. exit;
  402. }
  403. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  404. echo json_encode(array('success' => true));
  405. exit;
  406. }
  407. }
  408. }
  409. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  410. $this->_Template('whlabel', $this->data);
  411. }
  412. //在库标签
  413. public function _existence()
  414. {
  415. $post = $this->input->post(NULL, TRUE);
  416. if (isset($post['s'])) {
  417. $id_arr = $this->input->post('s');
  418. $id_arr = explode(',', $id_arr);
  419. if (!$id_arr) {
  420. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  421. exit;
  422. }
  423. //循环删除记录
  424. foreach ($id_arr as $v) {
  425. $sid = $this->whlabel->read($v);
  426. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  427. if ($count > 0) {
  428. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  429. exit;
  430. }
  431. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  432. if (count($zt) > 0) {
  433. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  434. exit;
  435. }
  436. $this->whlabel->remove($v);
  437. }
  438. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  439. exit;
  440. }
  441. if (isset($post['page'])) {
  442. $page = $this->input->post('page', true);
  443. $perpage = $this->input->post('perpage', true);
  444. $warehouse = $this->input->post('warehouse', true);
  445. $label = $this->input->post('label', true);
  446. $where = "1=1 and state = 0";
  447. if ($warehouse) {
  448. $where .= " and warehouse = '$warehouse'";
  449. }
  450. if ($label) {
  451. $where .= " and label = '$label'";
  452. }
  453. //数据排序
  454. $order_str = "time asc";
  455. if (empty($page)) {
  456. $start = 0;
  457. $perpage = 1;
  458. } else {
  459. $start = ($page - 1) * $perpage;
  460. }
  461. //取得信息列表
  462. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  463. foreach ($info_list as $key => $value) {
  464. if ($value['enter'] != 0) {
  465. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  466. } else {
  467. $info_list[$key]['enter'] = "";
  468. }
  469. if ($value['printing'] != 0) {
  470. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  471. } else {
  472. $info_list[$key]['printing'] = "";
  473. }
  474. }
  475. $total = $this->whlabel->find_count($where);
  476. $pagenum = ceil($total / $perpage);
  477. $over = $total - ($start + $perpage);
  478. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  479. echo json_encode($rows);
  480. exit;
  481. }
  482. $this->_Template('whlabel_existence', $this->data);
  483. }
  484. //进销存浏览
  485. public function _typedy($arg_array)
  486. {
  487. $prc = array();
  488. $purchase = $this->purchase->find_all();
  489. foreach ($purchase as $k => $v) {
  490. $prc[$v['id']] = $v['title'];
  491. }
  492. $post = $this->input->post(NULL, TRUE);
  493. if (isset($post['page'])) {
  494. $page = $this->input->post('page', true);
  495. $perpage = $this->input->post('perpage', true);
  496. $category = $this->input->post('category', true);
  497. $size = $this->input->post('size', true);
  498. $grade = $this->input->post('grade', true);
  499. $color = $this->input->post('color', true);
  500. $lowe = $this->input->post('lowe', true);
  501. $sku = $this->input->post('sku');
  502. $title = $this->input->post('title');
  503. $warehouse = $this->input->post('warehouse', true);
  504. $usa = $this->input->post('usa', true);
  505. $purchase = $this->input->post('purchase', true);
  506. $lacetype = $this->input->post('lacetype', true);
  507. $haircap = $this->input->post('haircap', true);
  508. $density = $this->input->post('density', true);
  509. $details = $this->input->post('details', true);
  510. $state = $this->input->post('state', true);
  511. $lacecolor = $this->input->post('lacecolor', true);
  512. $hairnumber = $this->input->post('hairnumber', true);
  513. $cklx = $this->input->post('cklx', true);
  514. $ktime = $this->input->post('ktime', true);
  515. $jtime = $this->input->post('jtime', true);
  516. $sm = $this->input->post('sm', true);
  517. $cpbz = $this->input->post('cpbz', true);
  518. $type = $this->input->post('type', true);
  519. $ktime = strtotime($ktime);
  520. $jtime = strtotime($jtime);
  521. $where = "1=1";
  522. $gj = "";
  523. $ck = "";
  524. if ($usa) {
  525. if (!$warehouse) {
  526. $where .= " and (warehouse = '5' or warehouse = '8')";
  527. }
  528. }
  529. if ($warehouse) {
  530. $where .= " and warehouse = '$warehouse'";
  531. }
  532. if ($details) {
  533. $where .= " and details = '$details'";
  534. }
  535. if ($purchase) {
  536. $where .= " and purchase = '$purchase'";
  537. }
  538. if (isset($state)) {
  539. if($state >-1){
  540. $where .= " and state = '$state'";
  541. }
  542. }
  543. if ($lacetype) {
  544. $where .= " and features like '%-$lacetype-%'";
  545. }
  546. if ($category) {
  547. $where .= " and features like '%-$category-%'";
  548. }
  549. if ($size) {
  550. $where .= " and features like '%-$size-%'";
  551. }
  552. if ($grade) {
  553. $where .= " and features like '%-$grade-%'";
  554. }
  555. if ($color) {
  556. $where .= " and features like '%-$color-%'";
  557. }
  558. if ($lowe) {
  559. $where .= " and features like '%-$lowe-%'";
  560. }
  561. if ($haircap) {
  562. $where .= " and features like '%-$haircap-%'";
  563. }
  564. if ($density) {
  565. $where .= " and features like '%-$density-%'";
  566. }
  567. if ($lacecolor) {
  568. $where .= " and features like '%-$lacecolor-%'";
  569. }
  570. if($sm){
  571. $where .= " and sm like '%".$sm."%'";
  572. }
  573. if($cpbz){
  574. $where .= " and cpbz like '%".$cpbz."%'";
  575. }
  576. if($type){
  577. $where .= " and type = ".$type."";
  578. }
  579. if (!empty($hairnumber)) {
  580. $where .= " and features like '%-128-%' ";
  581. if ($hairnumber < 0) {
  582. $class_list = $this->typeclass->find_all('classid = 43');
  583. foreach ($class_list as $v) {
  584. $where .= " and features not like '%-" . $v['id'] . "-%'";
  585. }
  586. } else {
  587. $where .= " and features like '%-$hairnumber-%'";
  588. }
  589. }
  590. $where_add = '';
  591. if ($cklx) {
  592. $shop = $this->shop->read($cklx);
  593. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  594. }
  595. if ($ktime && $jtime) {
  596. $gj = " and enter > '$ktime' and enter < '$jtime'";
  597. $ck = " and outk > '$ktime' and outk < '$jtime'";
  598. }
  599. //数据排序
  600. $order_str = "id desc";
  601. if (empty($page)) {
  602. $start = 0;
  603. $perpage = 1;
  604. } else {
  605. $start = ($page - 1) * $perpage;
  606. }
  607. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  608. if ($sku) {
  609. $sku = trim($sku, ' ');
  610. $sku = trim($sku, ' ');
  611. $where .= " and sku like '%$sku%'";
  612. $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);
  613. } else if ($title) {
  614. $title = trim($title, ' ');
  615. $title = trim($title, ' ');
  616. $where .= " and title like '%$title%'";
  617. $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);
  618. } else {
  619. //$where .= " and time > '$ktime' and time < '$jtime'";
  620. $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);
  621. }
  622. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  623. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  624. foreach ($info_list as $k => $v) {
  625. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  626. unset($info_list[$k]['pm']);
  627. unset($info_list[$k]['jm']);
  628. unset($info_list[$k]['bm']);
  629. }
  630. //取得信息列表
  631. $rows = array();
  632. $list = array();
  633. foreach ($info_list as $key => $value) {
  634. $warehouse = $this->warehouse->read($value['warehouse']);
  635. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  636. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  637. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  638. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  639. $info_list[$key]['label'] = $value['sm'];
  640. $number = $value['number'];
  641. $ftime = time() - 15 * 24 * 3600;
  642. $info_list[$key]['warehouse'] = $warehouse['title'];
  643. $info_list[$key]['features'] = count($c);
  644. $z = count($z); //查看订单号
  645. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  646. $ztdata = '';
  647. if (count($zt) > 0) {
  648. foreach ($zt as $vv) {
  649. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  650. }
  651. }
  652. $info_list[$key]['number'] = $ztdata;
  653. $info_list[$key]['sm'] = $z;
  654. $details = array();
  655. $cpid = array();
  656. foreach ($c as $k => $v) {
  657. $details[$v['details']] = $v['details'];
  658. if ($v['cpid'] != 0) {
  659. $cpid[$v['cpid']] = $v['cpid'];
  660. }
  661. }
  662. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  663. if ($value['shop'] != '') {
  664. $shop = explode(',', trim($value['shop'], ','));
  665. $shop = $this->shop->read($shop[0]);
  666. $info_list[$key]['shop'] = $shop['shopname'];
  667. }
  668. }
  669. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  670. $pagenum = ceil($total / $perpage);
  671. $over = $total - ($start + $perpage);
  672. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  673. echo json_encode($rows);
  674. exit;
  675. }
  676. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  677. $this->_Template('whlabel_typedy', $this->data);
  678. }
  679. //进销存浏览
  680. public function _typedy_ck($arg_array)
  681. {
  682. $prc = array();
  683. $purchase = $this->purchase->find_all();
  684. foreach ($purchase as $k => $v) {
  685. $prc[$v['id']] = $v['title'];
  686. }
  687. $post = $this->input->post(NULL, TRUE);
  688. if (isset($post['page'])) {
  689. $page = $this->input->post('page', true);
  690. $perpage = $this->input->post('perpage', true);
  691. $category = $this->input->post('category', true);
  692. $size = $this->input->post('size', true);
  693. $grade = $this->input->post('grade', true);
  694. $color = $this->input->post('color', true);
  695. $lowe = $this->input->post('lowe', true);
  696. $sku = $this->input->post('sku');
  697. $title = $this->input->post('title');
  698. $warehouse = $this->input->post('warehouse', true);
  699. $usa = $this->input->post('usa', true);
  700. $purchase = $this->input->post('purchase', true);
  701. $lacetype = $this->input->post('lacetype', true);
  702. $haircap = $this->input->post('haircap', true);
  703. $density = $this->input->post('density', true);
  704. $details = $this->input->post('details', true);
  705. $state = $this->input->post('state', true);
  706. $lacecolor = $this->input->post('lacecolor', true);
  707. $cklx = $this->input->post('cklx', true);
  708. $ktime = $this->input->post('ktime', true);
  709. $jtime = $this->input->post('jtime', true);
  710. $ktime = strtotime($ktime);
  711. $jtime = strtotime($jtime);
  712. $where = "1=1";
  713. $gj = "";
  714. $ck = "";
  715. if ($lacetype) {
  716. $where .= " and features like '%-$lacetype-%'";
  717. }
  718. if ($category) {
  719. $where .= " and features like '%-$category-%'";
  720. }
  721. if ($size) {
  722. $where .= " and features like '%-$size-%'";
  723. }
  724. if ($grade) {
  725. $where .= " and features like '%-$grade-%'";
  726. }
  727. if ($color) {
  728. $where .= " and features like '%-$color-%'";
  729. }
  730. if ($lowe) {
  731. $where .= " and features like '%-$lowe-%'";
  732. }
  733. if ($haircap) {
  734. $where .= " and features like '%-$haircap-%'";
  735. }
  736. if ($density) {
  737. $where .= " and features like '%-$density-%'";
  738. }
  739. if ($lacecolor) {
  740. $where .= " and features like '%-$lacecolor-%'";
  741. }
  742. if ($usa) {
  743. if (!$warehouse) {
  744. $where .= " and (warehouse = '5' or warehouse = '8')";
  745. }
  746. }
  747. if ($warehouse) {
  748. $where .= " and warehouse = '$warehouse'";
  749. }
  750. if ($details) {
  751. $where .= " and details = '$details'";
  752. }
  753. if ($purchase) {
  754. $where .= " and purchase = '$purchase'";
  755. }
  756. if ($state) {
  757. $where .= " and state = '$state'";
  758. }
  759. $where_add = '';
  760. if ($cklx) {
  761. $shop = $this->shop->read($cklx);
  762. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  763. }
  764. if ($ktime && $jtime) {
  765. $gj = " and enter > '$ktime' and enter < '$jtime'";
  766. $ck = " and outk > '$ktime' and outk < '$jtime'";
  767. }
  768. //数据排序
  769. $order_str = "id desc";
  770. if (empty($page)) {
  771. $start = 0;
  772. $perpage = 1;
  773. } else {
  774. $start = ($page - 1) * $perpage;
  775. }
  776. if ($sku) {
  777. $sku = trim($sku, ' ');
  778. $sku = trim($sku, ' ');
  779. $where .= " and sku like '%$sku%'";
  780. $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);
  781. } else if ($title) {
  782. $title = trim($title, ' ');
  783. $title = trim($title, ' ');
  784. $where .= " and title like '%$title%'";
  785. $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);
  786. } else {
  787. //$where .= " and time > '$ktime' and time < '$jtime'";
  788. $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);
  789. }
  790. //取得信息列表
  791. $rows = array();
  792. $list = array();
  793. foreach ($info_list as $key => $value) {
  794. $warehouse = $this->warehouse->read($value['warehouse']);
  795. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  796. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  797. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  798. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  799. $ftime = time() - 15 * 24 * 3600;
  800. $info_list[$key]['warehouse'] = $warehouse['title'];
  801. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  802. //$z = count($z);//查看订单号
  803. //$info_list[$key]['zd'] = $z;
  804. $details = array();
  805. $cpid = array();
  806. foreach ($c as $k => $v) {
  807. $details[$v['details']] = $v['details'];
  808. if ($v['cpid'] != 0) {
  809. $cpid[$v['cpid']] = $v['cpid'];
  810. }
  811. }
  812. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  813. if ($value['shop'] != '') {
  814. $shop = explode(',', trim($value['shop'], ','));
  815. $shop = $this->shop->read($shop[0]);
  816. $info_list[$key]['shop'] = $shop['shopname'];
  817. }
  818. }
  819. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  820. $pagenum = ceil($total / $perpage);
  821. $over = $total - ($start + $perpage);
  822. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  823. echo json_encode($rows);
  824. exit;
  825. }
  826. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  827. $this->_Template('whlabel_typedy_ck', $this->data);
  828. }
  829. public function _typeck($arg_array)
  830. {
  831. $prc = array();
  832. $purchase = $this->purchase->find_all();
  833. foreach ($purchase as $k => $v) {
  834. $prc[$v['id']] = $v['title'];
  835. }
  836. $post = $this->input->post(NULL, TRUE);
  837. if (isset($post['page'])) {
  838. $page = $this->input->post('page', true);
  839. $perpage = $this->input->post('perpage', true);
  840. $category = $this->input->post('category', true);
  841. $size = $this->input->post('size', true);
  842. $grade = $this->input->post('grade', true);
  843. $color = $this->input->post('color', true);
  844. $lacecolor = $this->input->post('lacecolor', true);
  845. $lowe = $this->input->post('lowe', true);
  846. $sku = $this->input->post('sku');
  847. $title = $this->input->post('title');
  848. $warehouse = 13;
  849. $usa = $this->input->post('usa', true);
  850. $purchase = $this->input->post('purchase', true);
  851. $lacetype = $this->input->post('lacetype', true);
  852. $haircap = $this->input->post('haircap', true);
  853. $density = $this->input->post('density', true);
  854. $details = $this->input->post('details', true);
  855. $state = $this->input->post('state', true);
  856. $ktime = $this->input->post('ktime', true);
  857. $jtime = $this->input->post('jtime', true);
  858. $ktime = strtotime($ktime);
  859. $jtime = strtotime($jtime);
  860. $where = "1=1";
  861. $gj = "";
  862. $ck = "";
  863. if ($lacetype) {
  864. $where .= " and features like '%-$lacetype-%'";
  865. }
  866. if ($category) {
  867. $where .= " and features like '%-$category-%'";
  868. }
  869. if ($size) {
  870. $where .= " and features like '%-$size-%'";
  871. }
  872. if ($grade) {
  873. $where .= " and features like '%-$grade-%'";
  874. }
  875. if ($color) {
  876. $where .= " and features like '%-$color-%'";
  877. }
  878. if ($lacecolor) {
  879. $where .= " and features like '%-$lacecolor-%'";
  880. }
  881. if ($lowe) {
  882. $where .= " and features like '%-$lowe-%'";
  883. }
  884. if ($haircap) {
  885. $where .= " and features like '%-$haircap-%'";
  886. }
  887. if ($density) {
  888. $where .= " and features like '%-$density-%'";
  889. }
  890. if ($warehouse) {
  891. $where .= " and warehouse = '$warehouse'";
  892. }
  893. if ($details) {
  894. $where .= " and details = '$details'";
  895. }
  896. if ($purchase) {
  897. $where .= " and purchase = '$purchase'";
  898. }
  899. if ($state) {
  900. $where .= " and state = '$state'";
  901. }
  902. if ($ktime && $jtime) {
  903. $gj = " and enter > '$ktime' and enter < '$jtime'";
  904. $ck = " and outk > '$ktime' and outk < '$jtime'";
  905. }
  906. //数据排序
  907. $order_str = "id desc";
  908. if (empty($page)) {
  909. $start = 0;
  910. $perpage = 1;
  911. } else {
  912. $start = ($page - 1) * $perpage;
  913. }
  914. if ($sku) {
  915. $sku = trim($sku, ' ');
  916. $sku = trim($sku, ' ');
  917. $where .= " and sku like '%$sku%'";
  918. } else if ($title) {
  919. $title = trim($title, ' ');
  920. $title = trim($title, ' ');
  921. $where .= " and title like '%$title%'";
  922. }
  923. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  924. //取得信息列表
  925. $t = array();
  926. $typeclass = $this->typeclass->find_all();
  927. foreach ($typeclass as $v) {
  928. $t[$v['id']] = $v;
  929. }
  930. $rows = array();
  931. $list = array();
  932. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  933. foreach ($info_list as $key => $value) {
  934. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  935. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  936. $warehouse = $this->warehouse->read($value['warehouse']);
  937. $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');
  938. $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'] . '"');
  939. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  940. $number = $value['number'];
  941. $ftime = time() - 15 * 24 * 3600;
  942. $z = count($z); //查看订单号
  943. $info_list[$key]['warehouse'] = $warehouse['title'];
  944. $info_list[$key]['features'] = count($c);
  945. $info_list[$key]['number'] = $z;
  946. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  947. $details = array();
  948. $cpid = array();
  949. foreach ($c as $k => $v) {
  950. $details[$v['details']] = $v['details'];
  951. if ($v['cpid'] != 0) {
  952. $cpid[$v['cpid']] = $v['cpid'];
  953. }
  954. }
  955. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  956. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  957. unset($info_list[$key]['pm']);
  958. unset($info_list[$key]['jm']);
  959. unset($info_list[$key]['bm']);
  960. }
  961. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  962. $pagenum = ceil($total / $perpage);
  963. $over = $total - ($start + $perpage);
  964. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  965. echo json_encode($rows);
  966. exit;
  967. }
  968. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  969. $this->_Template('whlabel_typeck', $this->data);
  970. }
  971. //进销存导出
  972. public function _whlabeckdc()
  973. {
  974. $prc = array();
  975. $purchase = $this->purchase->find_all();
  976. foreach ($purchase as $k => $v) {
  977. $prc[$v['id']] = $v['title'];
  978. }
  979. if (isset($_GET['excel'])) {
  980. $where = "sku != 'Preset'";
  981. //数据排序
  982. $order_str = "id desc";
  983. if (empty($page)) {
  984. $start = 0;
  985. $perpage = 1;
  986. } else {
  987. $start = ($page - 1) * $perpage;
  988. }
  989. $category = $this->input->get('category', true);
  990. $color = $this->input->get('color', true);
  991. $lowe = $this->input->get('lowe', true);
  992. $lacetype = $this->input->get('lacetype', true);
  993. $size = $this->input->get('size', true);
  994. $density = $this->input->get('density', true);
  995. $haircap = $this->input->get('haircap', true);
  996. $sku = $this->input->get('sku', true);
  997. $details = $this->input->get('details', true);
  998. $warehouse = 13;
  999. $excelid = $this->input->get('sid', true);
  1000. if ($category) {
  1001. $where .= " and features like '%-$category-%'";
  1002. }
  1003. if ($color) {
  1004. $where .= " and features like '%-$color-%'";
  1005. }
  1006. if ($lowe) {
  1007. $where .= " and features like '%-$lowe-%'";
  1008. }
  1009. if ($lacetype) {
  1010. $where .= " and features like '%-$lacetype-%'";
  1011. }
  1012. if ($size) {
  1013. $where .= " and features like '%-$size-%'";
  1014. }
  1015. if ($density) {
  1016. $where .= " and features like '%-$density-%'";
  1017. }
  1018. if ($haircap) {
  1019. $where .= " and features like '%-$haircap-%'";
  1020. }
  1021. if ($warehouse) {
  1022. $where .= " and warehouse = '$warehouse'";
  1023. }
  1024. if ($sku) {
  1025. $where .= " and sku like '%$sku%'";
  1026. }
  1027. if ($details) {
  1028. $where .= " and details = '$details'";
  1029. }
  1030. $xzid = '';
  1031. if ($excelid) {
  1032. $excelid = explode(',', trim($excelid, ','));
  1033. foreach ($excelid as $key => $value) {
  1034. $xzid .= " id = " . $value . " or";
  1035. }
  1036. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1037. }
  1038. //取得信息列表
  1039. /**
  1040. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1041. $rows = array();$list = array();
  1042. foreach ($info_list as $key=>$value)
  1043. {
  1044. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1045. }
  1046. **/
  1047. $wh = array();
  1048. $w = $this->warehouse->find_all('1=1', 'id,title');
  1049. foreach ($w as $v) {
  1050. $wh[$v['id']] = $v['title'];
  1051. }
  1052. $tc = array();
  1053. $tcdata = array();
  1054. $list = array();
  1055. $classid = $this->classid->sku();
  1056. $tcall = $this->typeclass->find_all();
  1057. $typeclass = array();
  1058. foreach ($tcall as $v)
  1059. {
  1060. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1061. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1062. }
  1063. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1064. foreach ($rows as $key => $value) {
  1065. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1066. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1067. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1068. $rows[$key]['cpbz'] = $u9_info['bm'];
  1069. $rows[$key]['cs'] = $u9_info['jm'];
  1070. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1071. $details = array();
  1072. $cpid = array();
  1073. $cpbz = array();
  1074. $c = 0;
  1075. $g = 0;
  1076. $x = 0;
  1077. $t = 0;
  1078. $s = 0;
  1079. $q = 0;
  1080. foreach ($sd as $k => $v) {
  1081. if ($v['state'] == 0) {
  1082. $c++;
  1083. }
  1084. if ($v['state'] != 9) {
  1085. $g++;
  1086. }
  1087. if ($v['state'] == 1) {
  1088. $x++;
  1089. }
  1090. if ($v['state'] == 2) {
  1091. $t++;
  1092. }
  1093. if ($v['state'] == 8) {
  1094. $s++;
  1095. }
  1096. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1097. $q++;
  1098. }
  1099. $details[$v['details']] = $v['details'];
  1100. if ($v['cpid'] != 0) {
  1101. $cpid[$v['cpid']] = $v['cpid'];
  1102. }
  1103. if ($v['cpbz'] != '') {
  1104. $cpbz[$v['cpbz']] = $v['cpbz'];
  1105. }
  1106. }
  1107. $rows[$key]['details'] = implode("、", $details);
  1108. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1109. $number = $value['number'];
  1110. $ftime = time() - 15 * 24 * 3600;
  1111. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1112. $rows[$key]['number'] = $g;
  1113. $rows[$key]['features'] = $c;
  1114. $rows[$key]['x'] = $x;
  1115. $rows[$key]['t'] = $t;
  1116. $rows[$key]['s'] = $s;
  1117. $rows[$key]['q'] = $q;
  1118. $rows[$key]['wzsl'] = count($details);
  1119. }
  1120. $title = "进销存统计表" . date('Y-m-d', time());
  1121. $titlename = "<table border=1>
  1122. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1123. <tr align='center'>
  1124. <td>仓库</td>
  1125. <td>供应商</td>
  1126. <td>位置</td>
  1127. <td>库存编码</td>
  1128. <td>SKU</td>
  1129. <td>用友编码</td>
  1130. <td>用友料号</td>
  1131. <td>产品英文名</td>
  1132. <td>产品中文名</td>
  1133. <td>入库总量</td>
  1134. <td>库存数量</td>
  1135. <td>销售数量</td>
  1136. <td>退货数量</td>
  1137. <td>删除数量</td>
  1138. <td>其它操作</td>
  1139. <td>位置数量</td>
  1140. </tr>
  1141. </table>";
  1142. $filename = $title . ".xls";
  1143. $tail = "";
  1144. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1145. }
  1146. }
  1147. public function _type()
  1148. {
  1149. $vip = 0;
  1150. if (isset($_SESSION['api'])) {
  1151. $user = $this->user->get_api($_SESSION['api']);
  1152. $fgshop = "";
  1153. $sid = "";
  1154. $usersp = explode('|', trim($user['shop'], '|'));
  1155. foreach ($usersp as $value) {
  1156. $fgshop .= " shop = " . $value . " or";
  1157. $sid .= " id = " . $value . " or";
  1158. }
  1159. if ($user['vip'] == 1) {
  1160. $vip = 1;
  1161. }
  1162. } else {
  1163. header('Location: /');
  1164. exit;
  1165. }
  1166. $prc = array();
  1167. $purchase = $this->purchase->find_all();
  1168. foreach ($purchase as $k => $v) {
  1169. $prc[$v['id']] = $v['title'];
  1170. }
  1171. $company = array();
  1172. $ct = $this->company->find_all();
  1173. foreach ($ct as $k => $v) {
  1174. $company[$v['id']] = $v['title'];
  1175. }
  1176. $sp = array();
  1177. $s = $this->shop->find_all('1=1', 'id,shopname');
  1178. foreach ($s as $v) {
  1179. $sp[$v['id']] = $v['shopname'];
  1180. }
  1181. $wh = array();
  1182. $w = $this->warehouse->find_all('1=1', 'id,title');
  1183. foreach ($w as $v) {
  1184. $wh[$v['id']] = $v['title'];
  1185. }
  1186. $post = $this->input->post(NULL, TRUE);
  1187. if (isset($post['page'])) {
  1188. $page = $this->input->post('page', true);
  1189. $perpage = $this->input->post('perpage', true);
  1190. $category = $this->input->post('category', true);
  1191. $size = $this->input->post('size', true);
  1192. $grade = $this->input->post('grade', true);
  1193. $color = $this->input->post('color', true);
  1194. $lowe = $this->input->post('lowe', true);
  1195. $sku = $this->input->post('sku');
  1196. $title = $this->input->post('title');
  1197. $warehouse = $this->input->post('warehouse', true);
  1198. $usa = $this->input->post('usa', true);
  1199. $purchase = $this->input->post('purchase', true);
  1200. $lacetype = $this->input->post('lacetype', true);
  1201. $haircap = $this->input->post('haircap', true);
  1202. $density = $this->input->post('density', true);
  1203. $details = $this->input->post('details', true);
  1204. $state = $this->input->post('state', true);
  1205. $shop = $this->input->post('shop', true);
  1206. $lacecolor = $this->input->post('lacecolor', true);
  1207. $hairnumber = $this->input->post('hairnumber', true);
  1208. $type = $this->input->post('type', true);
  1209. $ktime = $this->input->post('ktime', true);
  1210. $jtime = $this->input->post('jtime', true);
  1211. $ktime = strtotime($ktime);
  1212. $jtime = strtotime($jtime);
  1213. $cpbz = $this->input->post('cpbz', true);
  1214. $sm = $this->input->post('sm', true);
  1215. $where = "1=1";
  1216. $gj = "";
  1217. $ck = "";
  1218. if ($usa) {
  1219. if (!$warehouse) {
  1220. $where .= " and (warehouse = '5' or warehouse = '8')";
  1221. }
  1222. }
  1223. if ($warehouse) {
  1224. $where .= " and warehouse = '$warehouse'";
  1225. }
  1226. if ($details) {
  1227. $where .= " and details = '$details'";
  1228. }
  1229. if ($purchase) {
  1230. $where .= " and purchase = '$purchase'";
  1231. }
  1232. if ($state) {
  1233. $where .= " and state = '$state'";
  1234. }
  1235. if ($shop) {
  1236. $where .= " and shop like '%$shop%'";
  1237. }
  1238. if ($type) {
  1239. $where .= " and type = '$type'";
  1240. }
  1241. if ($ktime && $jtime) {
  1242. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1243. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1244. }
  1245. if ($cpbz) {
  1246. $where .= " and cpbz like '%$cpbz%' ";
  1247. }
  1248. if ($sm) {
  1249. $where .= " and sm like '%$sm%' ";
  1250. }
  1251. if ($lacecolor) {
  1252. $where .= " and features like '%-$lacecolor-%'";
  1253. }
  1254. if ($lacetype) {
  1255. $where .= " and features like '%-$lacetype-%'";
  1256. }
  1257. if ($category) {
  1258. $where .= " and features like '%-$category-%'";
  1259. }
  1260. if ($size) {
  1261. $where .= " and features like '%-$size-%'";
  1262. }
  1263. if ($grade) {
  1264. $where .= " and features like '%-$grade-%'";
  1265. }
  1266. if ($color) {
  1267. $where .= " and features like '%-$color-%'";
  1268. }
  1269. if ($lowe) {
  1270. $where .= " and features like '%-$lowe-%'";
  1271. }
  1272. if ($haircap) {
  1273. $where .= " and features like '%-$haircap-%'";
  1274. }
  1275. if ($density) {
  1276. $where .= " and features like '%-$density-%'";
  1277. }
  1278. if (!empty($hairnumber)) {
  1279. $where .= " and features like '%-128-%' ";
  1280. if ($hairnumber < 0) {
  1281. $class_list = $this->typeclass->find_all('classid = 43');
  1282. foreach ($class_list as $v) {
  1283. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1284. }
  1285. } else {
  1286. $where .= " and features like '%-$hairnumber-%'";
  1287. }
  1288. }
  1289. //数据排序
  1290. $order_str = "id desc";
  1291. if (empty($page)) {
  1292. $start = 0;
  1293. $perpage = 1;
  1294. } else {
  1295. $start = ($page - 1) * $perpage;
  1296. }
  1297. $fjnr = '';
  1298. if ($sku) {
  1299. $sku = trim($sku, ' ');
  1300. $sku = trim($sku, ' ');
  1301. $fjnr .= " and sku like '%$sku%'";
  1302. }
  1303. if ($title) {
  1304. $title = trim($title, ' ');
  1305. $title = trim($title, ' ');
  1306. $fjnr .= " and title like '%$title%'";
  1307. }
  1308. $wt = array();
  1309. $whlabel_type = $this->whlabel_type->find_all();
  1310. foreach ($whlabel_type as $v) {
  1311. $wt[$v['id']] = $v['title'];
  1312. }
  1313. //$where .= " and time > '$ktime' and time < '$jtime'";
  1314. $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
  1315. //取得信息列表
  1316. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1317. $rows = array();
  1318. $list = array();
  1319. foreach ($info_list as $key => $value) {
  1320. if (isset($wt[$value['type']])) {
  1321. $info_list[$key]['type'] = $wt[$value['type']];
  1322. } else {
  1323. $info_list[$key]['type'] = '未设置';
  1324. }
  1325. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1326. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1327. $ztdata = '';
  1328. if (count($zt) > 0) {
  1329. foreach ($zt as $vv) {
  1330. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1331. }
  1332. }
  1333. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1334. $cdata = array_filter($qbdata, function ($item) {
  1335. return $item['state'] < 1;
  1336. });
  1337. $c = array_sum(array_column($cdata, 'jnum'));
  1338. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1339. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1340. });
  1341. $g = array_sum(array_column($gdata, 'jnum'));
  1342. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1343. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1344. });
  1345. $x = array_sum(array_column($xdata, 'jnum'));
  1346. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1347. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1348. });
  1349. $t = array_sum(array_column($tdata, 'jnum'));
  1350. // $zdata = array_filter($qbdata, function ($item) {
  1351. // return $item['zd'] != "" && $item['state'] < 1;
  1352. // });
  1353. // $z = array_sum(array_column($zdata, 'jnum'));
  1354. $zdata = array_filter($qbdata, function ($item) {
  1355. return $item['zd'] != "" && $item['state'] < 1;
  1356. });
  1357. $z = array_sum(array_column($zdata, 'jnum'));
  1358. //$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');
  1359. //$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'].'"');
  1360. //$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'].'"');
  1361. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1362. //$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'].'"');
  1363. $details = array();
  1364. $cpid = array();
  1365. $od = array();
  1366. $odid = '';
  1367. $companytitle = '';
  1368. $shop_list = [];
  1369. foreach ($qbdata as $v) {
  1370. if ($v['zd'] != "" && $v['state'] < 1) {
  1371. if (!isset($od[$v['zd']])) {
  1372. $od[$v['zd']] = 1; //所有数据sku
  1373. } else {
  1374. $od[$v['zd']] = $od[$v['zd']] + 1;
  1375. }
  1376. }
  1377. if ($v['state'] < 1) {
  1378. $details[$v['details']] = $v['details'];
  1379. if ($v['cpid'] != 0) {
  1380. $cpid[$v['cpid']] = $v['cpid'];
  1381. }
  1382. }
  1383. if($v['state'] == 0){
  1384. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1385. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1386. }
  1387. if ($v['shop'] != '') {
  1388. $shop = explode(',', trim($v['shop'], ','));
  1389. foreach ($shop as $vv) {
  1390. if (!in_array($vv, $shop_list)) {
  1391. $shop_list[] = $vv;
  1392. }
  1393. }
  1394. }
  1395. }
  1396. }
  1397. foreach ($od as $k => $vv) {
  1398. $odid .= $k . '数量' . $vv;
  1399. }
  1400. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1401. $info_list[$key]['label'] = $value['sm'];
  1402. $number = $value['number'];
  1403. $ftime = time() - 15 * 24 * 3600;
  1404. $z = $z . '(' . $odid . ')'; //查看订单号
  1405. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1406. $info_list[$key]['features'] = $c;
  1407. $info_list[$key]['number'] = $ztdata;
  1408. $info_list[$key]['sm'] = $g;
  1409. $info_list[$key]['x'] = $x;
  1410. $info_list[$key]['t'] = $t;
  1411. $info_list[$key]['z'] = $z;
  1412. /**
  1413. foreach ($cdata as $k=>$v)
  1414. {
  1415. $details[$v['details']] = $v['details'];
  1416. if($v['cpid'] != 0)
  1417. {
  1418. $cpid[$v['cpid']] = $v['cpid'];
  1419. }
  1420. }
  1421. **/
  1422. $info_list[$key]['shop'] = '';
  1423. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1424. // if ($value['shop'] != '') {
  1425. // $shop = explode(',', trim($value['shop'], ','));
  1426. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1427. // }
  1428. $shop_list = array_unique($shop_list);
  1429. $shop_str = '';
  1430. foreach ($shop_list as $v) {
  1431. if(isset($sp[$v])){
  1432. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1433. }
  1434. }
  1435. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1436. /**
  1437. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1438. if(isset($companytitle[0]))
  1439. {
  1440. foreach ($companytitle as $k=>$v)
  1441. {
  1442. if($v['companytitle'] != '')
  1443. {
  1444. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1445. }
  1446. }
  1447. }
  1448. **/
  1449. }
  1450. $final_all_list = [];
  1451. foreach ($info_list as $k => $v) {
  1452. $final_all_list[] = [
  1453. 'id' => $v['id'],
  1454. "warehouse" => $v["warehouse"],
  1455. "purchase" => $v["purchase"],
  1456. "sku" => $v["sku"],
  1457. "title" => $v["title"] . "<br/>" . $v["pm"],
  1458. "details" => $v["details"],
  1459. "shop" => $v["shop"],
  1460. "cpbz" => $v["cpbz"],
  1461. 'label' => $v['label'],
  1462. "type" => $v["type"],
  1463. "features" => $v["features"],
  1464. "number" => $v["number"],
  1465. "sm" => $v["sm"],
  1466. "x" => $v["x"],
  1467. "t" => $v["t"],
  1468. "z" => $v["z"]
  1469. ];
  1470. }
  1471. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1472. $pagenum = ceil($total / $perpage);
  1473. $over = $total - ($start + $perpage);
  1474. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1475. echo json_encode($rows);
  1476. exit;
  1477. }
  1478. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1479. $this->data['shop'] = $wlshop;
  1480. $this->data['vip'] = $vip;
  1481. $this->_Template('whlabel_type', $this->data);
  1482. }
  1483. //美仓进销存浏览
  1484. public function _usatype()
  1485. {
  1486. if (isset($_SESSION['api'])) {
  1487. $user = $this->user->get_api($_SESSION['api']);
  1488. $usp = $user;
  1489. $fgshop = "";
  1490. $sid = "";
  1491. $wid = "";
  1492. $wtype = "";
  1493. $userwh = explode('|', trim($user['warehouse'], '|'));
  1494. foreach ($userwh as $value) {
  1495. $wid .= " id = " . $value . " or";
  1496. $wtype .= " type = " . $value . " or";
  1497. }
  1498. }
  1499. $prc = array();
  1500. $purchase = $this->purchase->find_all();
  1501. foreach ($purchase as $k => $v) {
  1502. $prc[$v['id']] = $v['title'];
  1503. }
  1504. $post = $this->input->post(NULL, TRUE);
  1505. if (isset($post['page'])) {
  1506. $page = $this->input->post('page', true);
  1507. $perpage = $this->input->post('perpage', true);
  1508. $category = $this->input->post('category', true);
  1509. $size = $this->input->post('size', true);
  1510. $grade = $this->input->post('grade', true);
  1511. $color = $this->input->post('color', true);
  1512. $lowe = $this->input->post('lowe', true);
  1513. $sku = $this->input->post('sku');
  1514. $title = $this->input->post('title');
  1515. $warehouse = $this->input->post('warehouse', true);
  1516. $usa = $this->input->post('usa', true);
  1517. $purchase = $this->input->post('purchase', true);
  1518. $lacetype = $this->input->post('lacetype', true);
  1519. $haircap = $this->input->post('haircap', true);
  1520. $density = $this->input->post('density', true);
  1521. $details = $this->input->post('details', true);
  1522. $state = $this->input->post('state', true);
  1523. $lacecolor = $this->input->post('lacecolor', true);
  1524. $cklx = $this->input->post('cklx', true);
  1525. $ktime = $this->input->post('ktime', true);
  1526. $jtime = $this->input->post('jtime', true);
  1527. $ktime = strtotime($ktime);
  1528. $jtime = strtotime($jtime);
  1529. $where = "1=1";
  1530. $gj = "";
  1531. $ck = "";
  1532. if ($lacetype) {
  1533. $where .= " and features like '%-$lacetype-%'";
  1534. }
  1535. if ($category) {
  1536. $where .= " and features like '%-$category-%'";
  1537. }
  1538. if ($size) {
  1539. $where .= " and features like '%-$size-%'";
  1540. }
  1541. if ($grade) {
  1542. $where .= " and features like '%-$grade-%'";
  1543. }
  1544. if ($color) {
  1545. $where .= " and features like '%-$color-%'";
  1546. }
  1547. if ($lowe) {
  1548. $where .= " and features like '%-$lowe-%'";
  1549. }
  1550. if ($haircap) {
  1551. $where .= " and features like '%-$haircap-%'";
  1552. }
  1553. if ($density) {
  1554. $where .= " and features like '%-$density-%'";
  1555. }
  1556. if ($lacecolor) {
  1557. $where .= " and features like '%-$lacecolor-%'";
  1558. }
  1559. if ($usa) {
  1560. if (!$warehouse) {
  1561. $where .= " and (warehouse = '5' or warehouse = '8')";
  1562. }
  1563. }
  1564. if ($warehouse) {
  1565. $where .= " and warehouse = '$warehouse'";
  1566. }
  1567. if ($details) {
  1568. $where .= " and details = '$details'";
  1569. }
  1570. if ($purchase) {
  1571. $where .= " and purchase = '$purchase'";
  1572. }
  1573. if ($state) {
  1574. $where .= " and state = '$state'";
  1575. }
  1576. $where_add = '';
  1577. if ($cklx) {
  1578. $shop = $this->shop->read($cklx);
  1579. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1580. }
  1581. if ($ktime && $jtime) {
  1582. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1583. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1584. }
  1585. //数据排序
  1586. $order_str = "id desc";
  1587. if (empty($page)) {
  1588. $start = 0;
  1589. $perpage = 1;
  1590. } else {
  1591. $start = ($page - 1) * $perpage;
  1592. }
  1593. if ($sku) {
  1594. $sku = trim($sku, ' ');
  1595. $sku = trim($sku, ' ');
  1596. $where .= " and sku like '%$sku%'";
  1597. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1598. } else if ($title) {
  1599. $title = trim($title, ' ');
  1600. $title = trim($title, ' ');
  1601. $where .= " and title like '%$title%'";
  1602. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1603. } else {
  1604. //$where .= " and time > '$ktime' and time < '$jtime'";
  1605. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1606. }
  1607. //取得信息列表
  1608. $rows = array();
  1609. $list = array();
  1610. foreach ($info_list as $key => $value) {
  1611. $warehouse = $this->warehouse->read($value['warehouse']);
  1612. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1613. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1614. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1615. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1616. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1617. $od = array();
  1618. $odid = '';
  1619. foreach ($z as $v) {
  1620. if (!isset($od[$v['zd']])) {
  1621. $od[$v['zd']] = 1; //所有数据sku
  1622. } else {
  1623. $od[$v['zd']] = $od[$v['zd']] + 1;
  1624. }
  1625. }
  1626. foreach ($od as $k => $vv) {
  1627. $odid .= $k . '数量' . $vv . ' ';
  1628. }
  1629. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1630. $info_list[$key]['features'] = $c;
  1631. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1632. $ztdata = '';
  1633. if (count($zt) > 0) {
  1634. foreach ($zt as $vv) {
  1635. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1636. }
  1637. }
  1638. $info_list[$key]['warehouse'] = $ztdata;
  1639. $info_list[$key]['g'] = $g;
  1640. $info_list[$key]['x'] = $x;
  1641. $info_list[$key]['t'] = $t;
  1642. $info_list[$key]['z'] = $z;
  1643. }
  1644. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1645. $pagenum = ceil($total / $perpage);
  1646. $over = $total - ($start + $perpage);
  1647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1648. echo json_encode($rows);
  1649. exit;
  1650. }
  1651. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1652. $this->data['warehouse'] = $warehouse;
  1653. $this->_Template('whlabel_typeusa', $this->data);
  1654. }
  1655. //美仓进销存浏览
  1656. public function _usatypeapp()
  1657. {
  1658. $post = $this->input->post(NULL, TRUE);
  1659. if (isset($post['page'])) {
  1660. $page = $this->input->post('page', true);
  1661. $perpage = $this->input->post('perpage', true);
  1662. $sku = $this->input->post('sku', true);
  1663. $warehouse = 5;
  1664. $title = $this->input->post('title', true);
  1665. $state = $this->input->post('state', true);
  1666. $ktime = $this->input->post('ktime', true);
  1667. $jtime = $this->input->post('jtime', true);
  1668. $ktime = strtotime($ktime);
  1669. $jtime = strtotime($jtime);
  1670. $where = "1=1";
  1671. $gj = "";
  1672. $ck = "";
  1673. if ($title) {
  1674. $st = explode(' ', trim($title, ' '));
  1675. foreach ($st as $v) {
  1676. $where .= " and title like '%$v%'";
  1677. }
  1678. }
  1679. if ($warehouse) {
  1680. $where .= " and warehouse = '$warehouse'";
  1681. }
  1682. if ($state) {
  1683. $where .= " and state = '$state'";
  1684. }
  1685. if ($sku) {
  1686. $where .= " and sku like '%$sku%'";
  1687. }
  1688. if ($ktime && $jtime) {
  1689. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1690. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1691. }
  1692. //数据排序
  1693. $order_str = "id desc";
  1694. if (empty($page)) {
  1695. $start = 0;
  1696. $perpage = 1;
  1697. } else {
  1698. $start = ($page - 1) * $perpage;
  1699. }
  1700. //取得信息列表
  1701. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1702. $rows = array();
  1703. $list = array();
  1704. foreach ($info_list as $key => $value) {
  1705. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1706. }
  1707. $rowsdq = array_slice($rows, $start, $perpage);
  1708. foreach ($rowsdq as $value) {
  1709. $warehouse = $this->warehouse->read($value['warehouse']);
  1710. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1711. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1712. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1713. $od = array();
  1714. $odid = '';
  1715. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1716. }
  1717. $total = count($rows);
  1718. $pagenum = ceil($total / $perpage);
  1719. $over = $total - ($start + $perpage);
  1720. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1721. echo json_encode($rows);
  1722. exit;
  1723. }
  1724. $this->_Template('phone/p_usatypeapp', $this->data);
  1725. }
  1726. //入库操作
  1727. public function _enteradd()
  1728. {
  1729. $dt = 0;
  1730. if (isset($_SESSION['api'])) {
  1731. $user = $this->user->get_api($_SESSION['api']);
  1732. $usp = $user;
  1733. $fgshop = "";
  1734. $sid = "";
  1735. $user = explode('|', trim($user['shop'], '|'));
  1736. foreach ($user as $value) {
  1737. $fgshop .= " shop = " . $value . " or";
  1738. $sid .= " id = " . $value . " or";
  1739. }
  1740. }
  1741. $tc = $this->typeclass->find_all();
  1742. $typeclass = array();
  1743. foreach ($tc as $v) {
  1744. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1745. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1746. }
  1747. $post = $this->input->post(NULL, TRUE);
  1748. if (isset($post['sku'])) {
  1749. $list = array();
  1750. $num = "";
  1751. $title = "";
  1752. $features = "";
  1753. $order = $this->input->post('order', true);
  1754. $shop = $this->input->post('shop', true);
  1755. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1756. $sku = $this->input->post('sku', true);
  1757. $post['sm'] = $this->input->post('sm', true);
  1758. $post['warehouse'] = $this->input->post('warehouse', true);
  1759. $post['purchase'] = $this->input->post('purchase', true);
  1760. $post['retreatwarehouse'] = $post['warehouse'];
  1761. $post['state'] = $this->input->post('state', true);
  1762. $post['rktype'] = $this->input->post('rktype', true);
  1763. $post['text'] = $this->input->post('text', true);
  1764. $category = $this->input->post('category', true);
  1765. $list['category'] = $category;
  1766. $list['hairtype'] = $this->input->post('hairtype', true);
  1767. $list['grade'] = $this->input->post('grade', true);
  1768. $size = $this->input->post('size', true);
  1769. $xzsku = $this->input->post('xzsku', true);
  1770. $list['size'] = rtrim($size, ',');
  1771. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1772. $list['extension'] = $this->input->post('extension', true);
  1773. if ($category == 1297) {
  1774. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1775. }
  1776. if ($category == 1702) {
  1777. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1778. $list['syother'] = $this->input->post('syother', true);
  1779. }
  1780. if ($category == 133) {
  1781. $list['fittype'] = $this->input->post('fittype', true);
  1782. $list['acother'] = $this->input->post('acother', true);
  1783. }
  1784. $list['color'] = $this->input->post('color', true);
  1785. $list['lowe'] = $this->input->post('lowe', true);
  1786. if (!$post['purchase']) {
  1787. $post['purchase'] = 1;
  1788. }
  1789. if ($category == 127) {
  1790. $list['type'] = $this->input->post('type', true);
  1791. $list['headroad'] = $this->input->post('headroad', true);
  1792. $list['density'] = $this->input->post('density', true);
  1793. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1794. $list['lacesize'] = $this->input->post('lacesize', true);
  1795. }
  1796. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1797. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1798. }
  1799. if ($category == 128) {
  1800. $list['lacetype'] = $this->input->post('lacetype', true);
  1801. $list['haircap'] = $this->input->post('haircap', true);
  1802. $list['density'] = $this->input->post('density', true);
  1803. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1804. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1805. $list['wigother'] = $this->input->post('wigother', true);
  1806. $list['wigother1'] = $this->input->post('wigother1', true);
  1807. $list['wigother2'] = $this->input->post('wigother2', true);
  1808. }
  1809. if ($category == 129) {
  1810. $list['wide'] = $this->input->post('wide', true);
  1811. }
  1812. if ($category == 131) {
  1813. $list['gifttype'] = $this->input->post('gifttype', true);
  1814. $list['giftother'] = $this->input->post('giftother', true);
  1815. }
  1816. if ($category == 134) {
  1817. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1818. }
  1819. if ($category == 1297) {
  1820. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1821. $list['sywigother'] = $this->input->post('sywigother', true);
  1822. }
  1823. if ($category == 130 || $category == 133 || $category == 1702) {
  1824. $list['items'] = $this->input->post('items', true);
  1825. $list['weight'] = $this->input->post('weight', true);
  1826. }
  1827. if ($category == 1702) {
  1828. $list['syhairther'] = $this->input->post('syhairther', true);
  1829. }
  1830. $classid = $this->classid->sku();
  1831. $scsku = $classid;
  1832. $pm = $classid;
  1833. foreach ($list as $k => $v) {
  1834. if ($v != 0) {
  1835. $num .= $v;
  1836. $features .= $v . '-';
  1837. $post[$k] = $v;
  1838. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1839. if ($k != 'size') {
  1840. $title .= $typeclass[$v]['title'] . " ";
  1841. }
  1842. if (isset($pm[$typeclass[$v]['classid']])) {
  1843. if ($typeclass[$v]['title'] == '9A') {
  1844. $pm[$typeclass[$v]['classid']] = '9A';
  1845. } else if ($typeclass[$v]['title'] == '10A') {
  1846. $pm[$typeclass[$v]['classid']] = '10A';
  1847. } else {
  1848. $clzh = $typeclass[$v]['zh'];
  1849. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1850. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1851. $clzh = $clzh[0];
  1852. }
  1853. $pm[$typeclass[$v]['classid']] = $clzh;
  1854. }
  1855. }
  1856. }
  1857. }
  1858. $zh = implode(" ", $pm);
  1859. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1860. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1861. if ($list['size']) {
  1862. $typeclass = $this->typeclass->read($list['size']);
  1863. $title .= $typeclass['title'];
  1864. }
  1865. $time = time();
  1866. if ($xzsku) {
  1867. $scsku = implode("-", $scsku);
  1868. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1869. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1870. $post['sku'] = trim($scsku, ' ');
  1871. } else {
  1872. $post['sku'] = $sku;
  1873. }
  1874. //$post['sku'] = trim($sku,' ');
  1875. $post['title'] = rtrim($title, ' ');
  1876. $post['number'] = $num;
  1877. $post['features'] = '-' . $features;
  1878. $post['enter'] = $time;
  1879. $post['time'] = $time; //操作时间
  1880. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1881. if ($yza) {
  1882. if ($post['features'] != $yza[0]['features']) {
  1883. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1884. exit;
  1885. }
  1886. }
  1887. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1888. if ($yzb) {
  1889. if ($post['sku'] != $yzb[0]['sku']) {
  1890. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1891. exit;
  1892. }
  1893. }
  1894. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1895. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1896. exit;
  1897. }
  1898. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1899. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1900. exit;
  1901. }
  1902. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1903. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1904. exit;
  1905. }
  1906. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1907. if (isset($yz[0]['type'])) {
  1908. $post['type'] = $yz[0]['type'];
  1909. }
  1910. if ($post['state'] == 9) //如果选择预设库存
  1911. {
  1912. $this->whlabel->insert($post);
  1913. } else {
  1914. /**
  1915. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1916. if($ljg == 1)
  1917. {
  1918. for($i=0;$i<$order;$i++)
  1919. {
  1920. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1921. $this->whlabel->insert($post);
  1922. }
  1923. }
  1924. **/
  1925. //if($post['warehouse'] == '5')
  1926. //{
  1927. //}
  1928. $yydata = $post;
  1929. $yydata['zh'] = $zh;
  1930. /**
  1931. $wl = $this->apiyy->get_cjlp($yydata);
  1932. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1933. {
  1934. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1935. }
  1936. if($wl['Data'][0]['m_isSucess'] != 1)
  1937. {
  1938. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1939. }
  1940. **/
  1941. for ($i = 0; $i < $order; $i++) {
  1942. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1943. $this->whlabel->insert($post);
  1944. }
  1945. }
  1946. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1947. exit;
  1948. }
  1949. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1950. $this->data['wlshop'] = $wlshop;
  1951. $this->_Template('whlabel_enteradd', $this->data);
  1952. }
  1953. //修改产品
  1954. public function _enteredit($arg_array)
  1955. {
  1956. $dt = 0;
  1957. if (isset($_SESSION['api'])) {
  1958. $user = $this->user->get_api($_SESSION['api']);
  1959. $usp = $user;
  1960. $fgshop = "";
  1961. $sid = "";
  1962. $user = explode('|', trim($user['shop'], '|'));
  1963. foreach ($user as $value) {
  1964. $fgshop .= " shop = " . $value . " or";
  1965. $sid .= " id = " . $value . " or";
  1966. }
  1967. }
  1968. $post = $this->input->post(NULL, TRUE);
  1969. if (isset($post['sku'])) {
  1970. $list = array();
  1971. $num = "";
  1972. $title = "";
  1973. $features = "";
  1974. $id = $this->input->post('id', true);
  1975. $order = $this->input->post('order', true);
  1976. $shop = $this->input->post('shop', true);
  1977. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1978. $post['sku'] = $this->input->post('sku', true);
  1979. $post['sm'] = $this->input->post('sm', true);
  1980. $post['warehouse'] = $this->input->post('warehouse', true);
  1981. $post['purchase'] = $this->input->post('purchase', true);
  1982. $post['retreatwarehouse'] = $post['warehouse'];
  1983. $category = $this->input->post('category', true);
  1984. $list['category'] = $category;
  1985. $list['hairtype'] = $this->input->post('hairtype', true);
  1986. $list['grade'] = $this->input->post('grade', true);
  1987. $size = $this->input->post('size', true);
  1988. $list['size'] = rtrim($size, ',');
  1989. $post['rktype'] = $this->input->post('rktype', true);
  1990. $post['text'] = $this->input->post('text', true);
  1991. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1992. $list['extension'] = $this->input->post('extension', true);
  1993. if ($category == 1297) {
  1994. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1995. }
  1996. if ($category == 1702) {
  1997. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1998. $list['syother'] = $this->input->post('syother', true);
  1999. }
  2000. if ($category == 133) {
  2001. $list['fittype'] = $this->input->post('fittype', true);
  2002. $list['acother'] = $this->input->post('acother', true);
  2003. }
  2004. $list['color'] = $this->input->post('color', true);
  2005. $list['lowe'] = $this->input->post('lowe', true);
  2006. if (!$post['purchase']) {
  2007. $post['purchase'] = 1;
  2008. }
  2009. if ($category == 127) {
  2010. $list['type'] = $this->input->post('type', true);
  2011. $list['headroad'] = $this->input->post('headroad', true);
  2012. $list['density'] = $this->input->post('density', true);
  2013. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2014. $list['lacesize'] = $this->input->post('lacesize', true);
  2015. }
  2016. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2017. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2018. }
  2019. if ($category == 128) {
  2020. $list['lacetype'] = $this->input->post('lacetype', true);
  2021. $list['haircap'] = $this->input->post('haircap', true);
  2022. $list['density'] = $this->input->post('density', true);
  2023. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2024. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2025. $list['wigother'] = $this->input->post('wigother', true);
  2026. $list['wigother1'] = $this->input->post('wigother1', true);
  2027. $list['wigother2'] = $this->input->post('wigother2', true);
  2028. }
  2029. if ($category == 129) {
  2030. $list['wide'] = $this->input->post('wide', true);
  2031. }
  2032. if ($category == 131) {
  2033. $list['gifttype'] = $this->input->post('gifttype', true);
  2034. $list['giftother'] = $this->input->post('giftother', true);
  2035. }
  2036. if ($category == 134) {
  2037. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2038. }
  2039. if ($category == 1297) {
  2040. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2041. $list['sywigother'] = $this->input->post('sywigother', true);
  2042. }
  2043. if ($category == 130 || $category == 133 || $category == 1702) {
  2044. $list['items'] = $this->input->post('items', true);
  2045. $list['weight'] = $this->input->post('weight', true);
  2046. }
  2047. if ($category == 1702) {
  2048. $list['syhairther'] = $this->input->post('syhairther', true);
  2049. }
  2050. foreach ($list as $k => $v) {
  2051. if ($v != 0) {
  2052. $num .= $v;
  2053. $features .= $v . '-';
  2054. $typeclass = $this->typeclass->read($v);
  2055. if ($k != 'size') {
  2056. $title .= $typeclass['title'] . " ";
  2057. }
  2058. }
  2059. }
  2060. $typeclass = $this->typeclass->read($list['size']);
  2061. $title .= $typeclass['title'];
  2062. $time = time();
  2063. $post['title'] = rtrim($title, ' ');
  2064. $post['number'] = $num;
  2065. $post['features'] = '-' . $features;
  2066. $post['time'] = $time; //操作时间
  2067. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2068. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2069. exit;
  2070. }
  2071. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2072. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2073. exit;
  2074. }
  2075. $uid = $this->whlabel->read($id);
  2076. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2077. if ($datanum > 0) {
  2078. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2079. exit;
  2080. }
  2081. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2082. {
  2083. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2084. if ($yza) {
  2085. if ($post['features'] != $yza[0]['features']) {
  2086. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2087. exit;
  2088. }
  2089. }
  2090. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2091. if ($yzb) {
  2092. if ($post['sku'] != $yzb[0]['sku']) {
  2093. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2094. exit;
  2095. }
  2096. }
  2097. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2098. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2099. exit;
  2100. }
  2101. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2102. foreach ($data as $v) {
  2103. $post['id'] = $v['id'];
  2104. $this->whlabel->save($post, $v['id']);
  2105. }
  2106. } else {
  2107. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2108. if ($data > 0) {
  2109. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2110. exit;
  2111. } else {
  2112. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2113. foreach ($data as $v) {
  2114. $post['id'] = $v['id'];
  2115. $this->whlabel->save($post, $v['id']);
  2116. }
  2117. }
  2118. }
  2119. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2120. exit;
  2121. }
  2122. $uid = $this->whlabel->read($arg_array[0]);
  2123. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2124. $this->data['enter'] = $uid;
  2125. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2126. $this->data['wlshop'] = $wlshop;
  2127. $this->_Template('whlabel_enteredit', $this->data);
  2128. }
  2129. //入库浏览
  2130. public function _enter()
  2131. {
  2132. $post = $this->input->post(NULL, TRUE);
  2133. if (isset($post['s'])) {
  2134. $id_arr = $this->input->post('s');
  2135. $id_arr = explode(',', $id_arr);
  2136. if (!$id_arr) {
  2137. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2138. exit;
  2139. }
  2140. //循环删除记录
  2141. foreach ($id_arr as $v) {
  2142. $sid = $this->whlabel->read($v);
  2143. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2144. if ($count > 0) {
  2145. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2146. exit;
  2147. }
  2148. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2149. foreach ($info_list as $va) {
  2150. $this->whlabel->remove($va['id']);
  2151. }
  2152. }
  2153. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2154. exit;
  2155. }
  2156. $sp = array();
  2157. $s = $this->shop->find_all('1=1', 'id,shopname');
  2158. foreach ($s as $v) {
  2159. $sp[$v['id']] = $v['shopname'];
  2160. }
  2161. $wh = array();
  2162. $w = $this->warehouse->find_all('1=1', 'id,title');
  2163. foreach ($w as $v) {
  2164. $wh[$v['id']] = $v['title'];
  2165. }
  2166. if (isset($post['page'])) {
  2167. $page = $this->input->post('page', true);
  2168. $perpage = $this->input->post('perpage', true);
  2169. $category = $this->input->post('category', true);
  2170. $size = $this->input->post('size', true);
  2171. $grade = $this->input->post('grade', true);
  2172. $color = $this->input->post('color', true);
  2173. $lowe = $this->input->post('lowe', true);
  2174. $sku = $this->input->post('sku', true);
  2175. $warehouse = $this->input->post('warehouse', true);
  2176. $purchase = $this->input->post('purchase', true);
  2177. $ktime = $this->input->post('ktime', true);
  2178. $jtime = $this->input->post('jtime', true);
  2179. $ktime = strtotime($ktime);
  2180. $jtime = strtotime($jtime);
  2181. $where = "1=1";
  2182. $gj = "";
  2183. $ck = "";
  2184. if ($category) {
  2185. $where .= " and features like '%-$category-%'";
  2186. }
  2187. if ($size) {
  2188. $where .= " and features like '%-$size-%'";
  2189. }
  2190. if ($grade) {
  2191. $where .= " and features like '%-$grade-%'";
  2192. }
  2193. if ($color) {
  2194. $where .= " and features like '%-$color-%'";
  2195. }
  2196. if ($lowe) {
  2197. $where .= " and features like '%-$lowe-%'";
  2198. }
  2199. if ($warehouse) {
  2200. $where .= " and warehouse = '$warehouse'";
  2201. }
  2202. if ($purchase) {
  2203. $where .= " and purchase = '$purchase'";
  2204. }
  2205. if ($sku) {
  2206. $where .= " and sku like '%$sku%'";
  2207. }
  2208. if ($ktime && $jtime) {
  2209. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2210. }
  2211. //数据排序
  2212. $order_str = "enter desc";
  2213. if (empty($page)) {
  2214. $start = 0;
  2215. $perpage = 1;
  2216. } else {
  2217. $start = ($page - 1) * $perpage;
  2218. }
  2219. //取得信息列表
  2220. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2221. foreach ($info_list as $k => $v) {
  2222. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2223. if ($v['shop'] == '') {
  2224. $s = '通用';
  2225. } else {
  2226. $info_list[$k]['shop'] = '';
  2227. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2228. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2229. }
  2230. }
  2231. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2232. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2233. $info_list[$k]['g'] = $g;
  2234. }
  2235. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2236. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2237. $pagenum = ceil($total / $perpage);
  2238. $over = $total - ($start + $perpage);
  2239. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2240. echo json_encode($rows);
  2241. exit;
  2242. }
  2243. $this->_Template('whlabel_enter', $this->data);
  2244. }
  2245. //出库浏览
  2246. public function _out()
  2247. {
  2248. $post = $this->input->post(NULL, TRUE);
  2249. if (isset($post['page'])) {
  2250. $page = $this->input->post('page', true);
  2251. $perpage = $this->input->post('perpage', true);
  2252. $category = $this->input->post('category', true);
  2253. $size = $this->input->post('size', true);
  2254. $grade = $this->input->post('grade', true);
  2255. $color = $this->input->post('color', true);
  2256. $lowe = $this->input->post('lowe', true);
  2257. $sku = $this->input->post('sku', true);
  2258. $warehouse = $this->input->post('warehouse', true);
  2259. $purchase = $this->input->post('purchase', true);
  2260. $state = $this->input->post('state', true);
  2261. $ktime = $this->input->post('ktime', true);
  2262. $jtime = $this->input->post('jtime', true);
  2263. $ktime = strtotime($ktime);
  2264. $jtime = strtotime($jtime);
  2265. $where = "state=3";
  2266. $gj = "";
  2267. $ck = "";
  2268. if ($category) {
  2269. $where .= " and features like '%-$category-%'";
  2270. }
  2271. if ($size) {
  2272. $where .= " and features like '%-$size-%'";
  2273. }
  2274. if ($grade) {
  2275. $where .= " and features like '%-$grade-%'";
  2276. }
  2277. if ($color) {
  2278. $where .= " and features like '%-$color-%'";
  2279. }
  2280. if ($lowe) {
  2281. $where .= " and features like '%-$lowe-%'";
  2282. }
  2283. if ($state) {
  2284. $where .= " and state = '$state'";
  2285. }
  2286. if ($warehouse) {
  2287. $where .= " and warehouse = '$warehouse'";
  2288. }
  2289. if ($purchase) {
  2290. $where .= " and purchase = '$purchase'";
  2291. }
  2292. if ($sku) {
  2293. $where .= " and sku = '$sku'";
  2294. }
  2295. if ($ktime && $jtime) {
  2296. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2297. }
  2298. //数据排序
  2299. $order_str = "id desc";
  2300. if (empty($page)) {
  2301. $start = 0;
  2302. $perpage = 1;
  2303. } else {
  2304. $start = ($page - 1) * $perpage;
  2305. }
  2306. //取得信息列表
  2307. $info_list = $this->whlabel->find_all($where, 'sku');
  2308. $rows = array();
  2309. $list = array();
  2310. foreach ($info_list as $key => $value) {
  2311. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2312. }
  2313. $rows = array_unique($rows); //删除重复记录
  2314. foreach ($rows as $key => $value) {
  2315. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2316. $ck = $this->warehouse->read($data['warehouse']);
  2317. $warehouse = $ck['title'];
  2318. $gy = $this->purchase->read($data['purchase']);
  2319. $purchase = $gy['purchase'];
  2320. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2321. $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);
  2322. }
  2323. $total = count($list);
  2324. $pagenum = ceil($total / $perpage);
  2325. $over = $total - ($start + $perpage);
  2326. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2328. echo json_encode($rows);
  2329. exit;
  2330. }
  2331. $this->_Template('whlabel_out', $this->data);
  2332. }
  2333. //出库标签浏览
  2334. public function _label()
  2335. {
  2336. $post = $this->input->post(NULL, TRUE);
  2337. if (isset($post['page'])) {
  2338. $page = $this->input->post('page', true);
  2339. $perpage = $this->input->post('perpage', true);
  2340. $sku = $this->input->post('sku', true);
  2341. $warehouse = $this->input->post('warehouse', true);
  2342. $purchase = $this->input->post('purchase', true);
  2343. $orderinfo = $this->input->post('orderinfo', true);
  2344. $waybill = $this->input->post('waybill', true);
  2345. $category = $this->input->post('category', true);
  2346. $size = $this->input->post('size', true);
  2347. $grade = $this->input->post('grade', true);
  2348. $color = $this->input->post('color', true);
  2349. $lowe = $this->input->post('lowe', true);
  2350. $where = "state=1";
  2351. if ($sku) {
  2352. $where .= " and sku = '$sku'";
  2353. }
  2354. if ($warehouse) {
  2355. $where .= " and warehouse = '$warehouse'";
  2356. }
  2357. if ($purchase) {
  2358. $where .= " and purchase = '$purchase'";
  2359. }
  2360. if ($orderinfo) {
  2361. $where .= " and orderinfo = '$orderinfo'";
  2362. }
  2363. if ($waybill) {
  2364. $where .= " and waybill = '$waybill'";
  2365. }
  2366. if ($category) {
  2367. $where .= " and features like '%-$category-%'";
  2368. }
  2369. if ($size) {
  2370. $where .= " and features like '%-$size-%'";
  2371. }
  2372. if ($grade) {
  2373. $where .= " and features like '%-$grade-%'";
  2374. }
  2375. if ($color) {
  2376. $where .= " and features like '%-$color-%'";
  2377. }
  2378. if ($lowe) {
  2379. $where .= " and features like '%-$lowe-%'";
  2380. }
  2381. //数据排序
  2382. $order_str = "outk desc";
  2383. if (empty($page)) {
  2384. $start = 0;
  2385. $perpage = 1;
  2386. } else {
  2387. $start = ($page - 1) * $perpage;
  2388. }
  2389. //取得信息列表
  2390. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2391. foreach ($info_list as $key => $value) {
  2392. $warehouse = $this->warehouse->read($value['warehouse']);
  2393. $info_list[$key]['warehouse'] = $warehouse['title'];
  2394. $purchase = $this->purchase->read($value['purchase']);
  2395. $info_list[$key]['purchase'] = $purchase['title'];
  2396. if ($value['outk'] != 0) {
  2397. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2398. } else {
  2399. $info_list[$key]['outk'] = "";
  2400. }
  2401. if ($value['orderinfo'] == 0) {
  2402. $info_list[$key]['orderinfo'] = "";
  2403. }
  2404. if ($value['waybill'] == 0) {
  2405. $info_list[$key]['waybill'] = "";
  2406. }
  2407. }
  2408. $total = $this->whlabel->find_count($where);
  2409. $pagenum = ceil($total / $perpage);
  2410. $over = $total - ($start + $perpage);
  2411. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2412. echo json_encode($rows);
  2413. exit;
  2414. }
  2415. $this->_Template('whlabel_label', $this->data);
  2416. }
  2417. //独立站出库订单
  2418. public function _outorder()
  2419. {
  2420. if (isset($_SESSION['api'])) {
  2421. $user = $this->user->get_api($_SESSION['api']);
  2422. $usp = $user;
  2423. $fgshop = "";
  2424. $sid = "";
  2425. $user = explode('|', trim($user['shop'], '|'));
  2426. foreach ($user as $value) {
  2427. $fgshop .= " shop = " . $value . " or";
  2428. $sid .= " id = " . $value . " or";
  2429. }
  2430. } else {
  2431. echo "请重新登录";
  2432. }
  2433. $post = $this->input->post(NULL, TRUE);
  2434. if (isset($post['page'])) {
  2435. $page = $this->input->post('page', true);
  2436. $perpage = $this->input->post('perpage', true);
  2437. $warehouse = $this->input->post('warehouse', true);
  2438. $xztime = $this->input->post('xztime', true);
  2439. $timetk = $this->input->post('timetkk', true);
  2440. $timetj = $this->input->post('timetjj', true);
  2441. $shop = $this->input->post('shop', true);
  2442. $source = $this->input->post('source', true);
  2443. $orderinfo = $this->input->post('orderinfo', true);
  2444. $number = $this->input->post('number', true);
  2445. $sfxh = $this->input->post('sfxh', true);
  2446. $express = $this->input->post('express', true);
  2447. $waybill = $this->input->post('waybill', true);
  2448. $library = $this->input->post('library', true);
  2449. $country = $this->input->post('country', true);
  2450. $so = $this->input->post('so', true);
  2451. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2452. $print = $this->input->post('print', true);
  2453. $state = $this->input->post('state', true);
  2454. $orderurl = $this->input->post('orderurl', true);
  2455. $productid = $this->input->post('productid', true);
  2456. $timetk = strtotime($timetk);
  2457. $timetj = strtotime($timetj);
  2458. /**
  2459. $sj = $this->input->post('sj',true);
  2460. if($sj)
  2461. {
  2462. $sj = $this->input->post('sj',true);
  2463. }
  2464. else
  2465. {
  2466. $sj = "fullorder";
  2467. }
  2468. **/
  2469. $sj = "fullorder";
  2470. $where = "1=1";
  2471. if ($warehouse) {
  2472. $where .= " and type = '$warehouse'";
  2473. }
  2474. if ($timetk && $timetj) {
  2475. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2476. }
  2477. if ($orderinfo) {
  2478. $where .= " and orderinfo = '$orderinfo'";
  2479. }
  2480. if ($number) {
  2481. $where .= " and number = '$number'";
  2482. }
  2483. if ($express) {
  2484. $where .= " and express = '$express'";
  2485. }
  2486. if ($waybill) {
  2487. $where .= " and waybill = '$waybill'";
  2488. }
  2489. if ($library) {
  2490. $where .= " and library = '$library'";
  2491. }
  2492. if ($print) {
  2493. $where .= " and print = '$print'";
  2494. }
  2495. if ($libraryconfirm) {
  2496. $where .= " and libraryconfirm = '$libraryconfirm'";
  2497. }
  2498. if ($state) {
  2499. $where .= " and state = '$state'";
  2500. }
  2501. if ($shop) {
  2502. $where .= " and shop = '$shop'";
  2503. }
  2504. if ($country) {
  2505. $where .= " and country = '$country'";
  2506. }
  2507. if ($sfxh != '') {
  2508. $where .= " and sfxh = '$sfxh'";
  2509. }
  2510. if ($so) {
  2511. $where .= " and shipremarks like '%$so%'";
  2512. }
  2513. if ($source) {
  2514. if ($source == '2d') {
  2515. $where .= " and source >= '2'";
  2516. } else {
  2517. $where .= " and source = '$source'";
  2518. }
  2519. }
  2520. if (isset($_SESSION['api'])) {
  2521. foreach ($user as $value) {
  2522. $fgshop .= " shop = " . $value . " or";
  2523. }
  2524. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2525. }
  2526. if ($orderurl) {
  2527. $url = $this->orderurl->read($orderurl);
  2528. $where .= " and link like '%" . $url['url'] . "%'";
  2529. }
  2530. if($productid){
  2531. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2532. }
  2533. //数据排序
  2534. $order_str = "librarytime desc";
  2535. if (empty($page)) {
  2536. $start = 0;
  2537. $perpage = 1;
  2538. } else {
  2539. $start = ($page - 1) * $perpage;
  2540. }
  2541. //取得信息列表
  2542. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2543. //格式化数据
  2544. foreach ($info_list as $key => $value) {
  2545. $shop = $this->shop->read($value['shop']);
  2546. $info_list[$key]['shop'] = $shop['shopname'];
  2547. $express = $this->express->read($value['express']);
  2548. $info_list[$key]['express'] = $express['servicename'];
  2549. $warehouse = $this->warehouse->read($value['type']);
  2550. $info_list[$key]['type'] = $warehouse['title'];
  2551. if ($value['librarytime'] == '0') {
  2552. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2553. } else {
  2554. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2555. }
  2556. }
  2557. $total = $this->$sj->find_count($where);
  2558. $pagenum = ceil($total / $perpage);
  2559. $over = $total - ($start + $perpage);
  2560. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2561. echo json_encode($rows);
  2562. exit;
  2563. }
  2564. $this->data['express'] = $this->express->find_all();
  2565. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2566. $this->data['wlshop'] = $wlshop;
  2567. $user = $this->user->get_api($_SESSION['api']);
  2568. $powerid = $this->power->read($user['power']);
  2569. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2570. $pid = '';
  2571. foreach ($powertext as $v) {
  2572. $pid .= " id = " . $v . " or";
  2573. }
  2574. $fullorderexcel = $this->fullorderexcel->find_all("1=1"); //导出模板
  2575. $this->data['fullorderexcel'] = $fullorderexcel;
  2576. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2577. $this->data['orderurl'] = $orderurl;
  2578. $this->_Template('whlabel_outorder', $this->data);
  2579. }
  2580. //tt出库
  2581. public function _toutorder()
  2582. {
  2583. $fgshop = "";
  2584. $sid = "";
  2585. if (isset($_SESSION['api'])) {
  2586. $user = $this->user->get_api($_SESSION['api']);
  2587. $usp = $user;
  2588. $user = explode('|', trim($user['shop'], '|'));
  2589. foreach ($user as $value) {
  2590. $fgshop .= " shop = " . $value . " or";
  2591. $sid .= " id = " . $value . " or";
  2592. }
  2593. } else {
  2594. echo "请重新登录";
  2595. die;
  2596. }
  2597. $post = $this->input->post(NULL, TRUE);
  2598. if (isset($post['page'])) {
  2599. $page = $this->input->post('page', true);
  2600. $perpage = $this->input->post('perpage', true);
  2601. $warehouse = $this->input->post('warehouse', true);
  2602. $xztime = $this->input->post('xztime', true);
  2603. $timetk = $this->input->post('timetkk', true);
  2604. $timetj = $this->input->post('timetjj', true);
  2605. $shop = $this->input->post('shop', true);
  2606. $source = $this->input->post('source', true);
  2607. $orderinfo = $this->input->post('orderinfo', true);
  2608. $number = $this->input->post('number', true);
  2609. $sfxh = $this->input->post('sfxh', true);
  2610. $express = $this->input->post('express', true);
  2611. $waybill = $this->input->post('waybill', true);
  2612. $library = $this->input->post('library', true);
  2613. $country = $this->input->post('country', true);
  2614. $so = $this->input->post('so', true);
  2615. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2616. $print = $this->input->post('print', true);
  2617. $state = $this->input->post('state', true);
  2618. $orderurl = $this->input->post('orderurl', true);
  2619. $timetk = strtotime($timetk);
  2620. $timetj = strtotime($timetj);
  2621. /**
  2622. $sj = $this->input->post('sj',true);
  2623. if($sj)
  2624. {
  2625. $sj = $this->input->post('sj',true);
  2626. }
  2627. else
  2628. {
  2629. $sj = "fullorder";
  2630. }
  2631. **/
  2632. $sj = "fullordertt";
  2633. $where = "1=1";
  2634. if ($warehouse) {
  2635. $where .= " and type = '$warehouse'";
  2636. }
  2637. if ($timetk && $timetj) {
  2638. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2639. }
  2640. if ($orderinfo) {
  2641. $where .= " and orderinfo = '$orderinfo'";
  2642. }
  2643. if ($number) {
  2644. $where .= " and number = '$number'";
  2645. }
  2646. if ($express) {
  2647. $where .= " and express = '$express'";
  2648. }
  2649. if ($waybill) {
  2650. $where .= " and waybill = '$waybill'";
  2651. }
  2652. if ($library) {
  2653. $where .= " and library = '$library'";
  2654. }
  2655. if ($print) {
  2656. $where .= " and print = '$print'";
  2657. }
  2658. if ($libraryconfirm) {
  2659. $where .= " and libraryconfirm = '$libraryconfirm'";
  2660. }
  2661. if ($state) {
  2662. $where .= " and state = '$state'";
  2663. }
  2664. if ($shop) {
  2665. $where .= " and shop = '$shop'";
  2666. }
  2667. if ($country) {
  2668. $where .= " and country = '$country'";
  2669. }
  2670. if ($sfxh != '') {
  2671. $where .= " and sfxh = '$sfxh'";
  2672. }
  2673. if ($so) {
  2674. $where .= " and shipremarks like '%$so%'";
  2675. }
  2676. if ($source) {
  2677. if ($source == '2d') {
  2678. $where .= " and source >= '2'";
  2679. } else {
  2680. $where .= " and source = '$source'";
  2681. }
  2682. }
  2683. if (isset($_SESSION['api'])) {
  2684. foreach ($user as $value) {
  2685. $fgshop .= " shop = " . $value . " or";
  2686. }
  2687. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2688. }
  2689. if ($orderurl) {
  2690. $url = $this->orderurl->read($orderurl);
  2691. $where .= " and link like '%" . $url['url'] . "%'";
  2692. }
  2693. //数据排序
  2694. $order_str = "librarytime desc";
  2695. if (empty($page)) {
  2696. $start = 0;
  2697. $perpage = 1;
  2698. } else {
  2699. $start = ($page - 1) * $perpage;
  2700. }
  2701. //取得信息列表
  2702. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2703. //格式化数据
  2704. foreach ($info_list as $key => $value) {
  2705. $shop = $this->shop->read($value['shop']);
  2706. $info_list[$key]['shop'] = $shop['shopname'];
  2707. $express = $this->express->read($value['express']);
  2708. $info_list[$key]['express'] = $express['servicename'];
  2709. $warehouse = $this->warehouse->read($value['type']);
  2710. $info_list[$key]['type'] = $warehouse['title'];
  2711. if ($value['librarytime'] == '0') {
  2712. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2713. } else {
  2714. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2715. }
  2716. }
  2717. $total = $this->$sj->find_count($where);
  2718. $pagenum = ceil($total / $perpage);
  2719. $over = $total - ($start + $perpage);
  2720. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2721. echo json_encode($rows);
  2722. exit;
  2723. }
  2724. $this->data['express'] = $this->express->find_all();
  2725. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2726. $this->data['wlshop'] = $wlshop;
  2727. $user = $this->user->get_api($_SESSION['api']);
  2728. $powerid = $this->power->read($user['power']);
  2729. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2730. $pid = '';
  2731. foreach ($powertext as $v) {
  2732. $pid .= " id = " . $v . " or";
  2733. }
  2734. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2735. $this->data['fullorderexcel'] = $fullorderexcel;
  2736. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2737. $this->data['orderurl'] = $orderurl;
  2738. $this->_Template('whlabel_toutorder', $this->data);
  2739. }
  2740. //tt出库
  2741. public function _aoutorder()
  2742. {
  2743. if (isset($_SESSION['api'])) {
  2744. $user = $this->user->get_api($_SESSION['api']);
  2745. $usp = $user;
  2746. $fgshop = "";
  2747. $sid = "";
  2748. $user = explode('|', trim($user['shop'], '|'));
  2749. foreach ($user as $value) {
  2750. $fgshop .= " shop = " . $value . " or";
  2751. $sid .= " id = " . $value . " or";
  2752. }
  2753. } else {
  2754. echo "请重新登录";
  2755. }
  2756. $post = $this->input->post(NULL, TRUE);
  2757. if (isset($post['page'])) {
  2758. $page = $this->input->post('page', true);
  2759. $perpage = $this->input->post('perpage', true);
  2760. $warehouse = $this->input->post('warehouse', true);
  2761. $xztime = $this->input->post('xztime', true);
  2762. $timetk = $this->input->post('timetkk', true);
  2763. $timetj = $this->input->post('timetjj', true);
  2764. $shop = $this->input->post('shop', true);
  2765. $source = $this->input->post('source', true);
  2766. $orderinfo = $this->input->post('orderinfo', true);
  2767. $number = $this->input->post('number', true);
  2768. $sfxh = $this->input->post('sfxh', true);
  2769. $express = $this->input->post('express', true);
  2770. $waybill = $this->input->post('waybill', true);
  2771. $library = $this->input->post('library', true);
  2772. $country = $this->input->post('country', true);
  2773. $so = $this->input->post('so', true);
  2774. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2775. $print = $this->input->post('print', true);
  2776. $state = $this->input->post('state', true);
  2777. $orderurl = $this->input->post('orderurl', true);
  2778. $timetk = strtotime($timetk);
  2779. $timetj = strtotime($timetj);
  2780. /**
  2781. $sj = $this->input->post('sj',true);
  2782. if($sj)
  2783. {
  2784. $sj = $this->input->post('sj',true);
  2785. }
  2786. else
  2787. {
  2788. $sj = "fullorder";
  2789. }
  2790. **/
  2791. $sj = "fullorderamz";
  2792. $where = "1=1";
  2793. if ($warehouse) {
  2794. $where .= " and type = '$warehouse'";
  2795. }
  2796. if ($timetk && $timetj) {
  2797. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2798. }
  2799. if ($orderinfo) {
  2800. $where .= " and orderinfo = '$orderinfo'";
  2801. }
  2802. if ($number) {
  2803. $where .= " and number = '$number'";
  2804. }
  2805. if ($express) {
  2806. $where .= " and express = '$express'";
  2807. }
  2808. if ($waybill) {
  2809. $where .= " and waybill = '$waybill'";
  2810. }
  2811. if ($library) {
  2812. $where .= " and library = '$library'";
  2813. }
  2814. if ($print) {
  2815. $where .= " and print = '$print'";
  2816. }
  2817. if ($libraryconfirm) {
  2818. $where .= " and libraryconfirm = '$libraryconfirm'";
  2819. }
  2820. if ($state) {
  2821. $where .= " and state = '$state'";
  2822. }
  2823. if ($shop) {
  2824. $where .= " and shop = '$shop'";
  2825. }
  2826. if ($country) {
  2827. $where .= " and country = '$country'";
  2828. }
  2829. if ($sfxh != '') {
  2830. $where .= " and sfxh = '$sfxh'";
  2831. }
  2832. if ($so) {
  2833. $where .= " and shipremarks like '%$so%'";
  2834. }
  2835. if ($source) {
  2836. if ($source == '2d') {
  2837. $where .= " and source >= '2'";
  2838. } else {
  2839. $where .= " and source = '$source'";
  2840. }
  2841. }
  2842. if (isset($_SESSION['api'])) {
  2843. foreach ($user as $value) {
  2844. $fgshop .= " shop = " . $value . " or";
  2845. }
  2846. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2847. }
  2848. if ($orderurl) {
  2849. $url = $this->orderurl->read($orderurl);
  2850. $where .= " and link like '%" . $url['url'] . "%'";
  2851. }
  2852. //数据排序
  2853. $order_str = "librarytime desc";
  2854. if (empty($page)) {
  2855. $start = 0;
  2856. $perpage = 1;
  2857. } else {
  2858. $start = ($page - 1) * $perpage;
  2859. }
  2860. //取得信息列表
  2861. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2862. //格式化数据
  2863. foreach ($info_list as $key => $value) {
  2864. $shop = $this->shop->read($value['shop']);
  2865. $info_list[$key]['shop'] = $shop['shopname'];
  2866. $express = $this->express->read($value['express']);
  2867. $info_list[$key]['express'] = $express['servicename'];
  2868. $warehouse = $this->warehouse->read($value['type']);
  2869. $info_list[$key]['type'] = $warehouse['title'];
  2870. if ($value['librarytime'] == '0') {
  2871. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2872. } else {
  2873. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2874. }
  2875. }
  2876. $total = $this->$sj->find_count($where);
  2877. $pagenum = ceil($total / $perpage);
  2878. $over = $total - ($start + $perpage);
  2879. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2880. echo json_encode($rows);
  2881. exit;
  2882. }
  2883. $this->data['express'] = $this->express->find_all();
  2884. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2885. $this->data['wlshop'] = $wlshop;
  2886. $user = $this->user->get_api($_SESSION['api']);
  2887. $powerid = $this->power->read($user['power']);
  2888. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2889. $pid = '';
  2890. foreach ($powertext as $v) {
  2891. $pid .= " id = " . $v . " or";
  2892. }
  2893. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2894. $this->data['fullorderexcel'] = $fullorderexcel;
  2895. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2896. $this->data['orderurl'] = $orderurl;
  2897. $this->_Template('whlabel_aoutorder', $this->data);
  2898. }
  2899. //速卖通出库订单
  2900. public function _soutorder()
  2901. {
  2902. if (isset($_SESSION['api'])) {
  2903. $user = $this->user->get_api($_SESSION['api']);
  2904. $usp = $user;
  2905. $fgshop = "";
  2906. $sid = "";
  2907. $user = explode('|', trim($user['shop'], '|'));
  2908. foreach ($user as $value) {
  2909. $sid .= " id = " . $value . " or";
  2910. }
  2911. }
  2912. $post = $this->input->post(NULL, TRUE);
  2913. if (isset($post['page'])) {
  2914. $page = $this->input->post('page', true);
  2915. $perpage = $this->input->post('perpage', true);
  2916. $warehouse = $this->input->post('warehouse', true);
  2917. $xztime = $this->input->post('xztime', true);
  2918. $timetk = $this->input->post('timetkk', true);
  2919. $timetj = $this->input->post('timetjj', true);
  2920. $shop = $this->input->post('shop', true);
  2921. $source = $this->input->post('source', true);
  2922. $orderinfo = $this->input->post('orderinfo', true);
  2923. $number = $this->input->post('number', true);
  2924. $express = $this->input->post('express', true);
  2925. $waybill = $this->input->post('waybill', true);
  2926. $library = $this->input->post('library', true);
  2927. $country = $this->input->post('country', true);
  2928. $sfxh = $this->input->post('sfxh', true);
  2929. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2930. $print = $this->input->post('print', true);
  2931. $state = $this->input->post('state', true);
  2932. $so = $this->input->post('so', true);
  2933. $timetk = strtotime($timetk);
  2934. $timetj = strtotime($timetj);
  2935. /**
  2936. $sj = $this->input->post('sj',true);
  2937. if($sj)
  2938. {
  2939. $sj = $this->input->post('sj',true);
  2940. }
  2941. else
  2942. {
  2943. $sj = "fullorder";
  2944. }
  2945. **/
  2946. $sj = "fullordersmt";
  2947. $where = "1=1";
  2948. if ($warehouse) {
  2949. $where .= " and type = '$warehouse'";
  2950. }
  2951. if ($timetk && $timetj) {
  2952. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2953. }
  2954. if ($orderinfo) {
  2955. $where .= " and orderinfo = '$orderinfo'";
  2956. }
  2957. if ($number) {
  2958. $where .= " and number = '$number'";
  2959. }
  2960. if ($express) {
  2961. $where .= " and express = '$express'";
  2962. }
  2963. if ($waybill) {
  2964. $where .= " and waybill = '$waybill'";
  2965. }
  2966. if ($library) {
  2967. $where .= " and library = '$library'";
  2968. }
  2969. if ($print) {
  2970. $where .= " and print = '$print'";
  2971. }
  2972. if ($libraryconfirm) {
  2973. $where .= " and libraryconfirm = '$libraryconfirm'";
  2974. }
  2975. if ($state) {
  2976. $where .= " and state = '$state'";
  2977. }
  2978. if ($shop) {
  2979. $where .= " and shop = '$shop'";
  2980. }
  2981. if ($sfxh != '') {
  2982. $where .= " and sfxh = '$sfxh'";
  2983. }
  2984. if ($so) {
  2985. $where .= " and shipremarks like '%$so%'";
  2986. }
  2987. if ($source) {
  2988. $where .= " and source = '$source'";
  2989. }
  2990. if ($country) {
  2991. $where .= " and country = '$country'";
  2992. } else {
  2993. if (isset($_SESSION['api'])) {
  2994. foreach ($user as $value) {
  2995. $fgshop .= " shop = " . $value . " or";
  2996. }
  2997. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2998. }
  2999. }
  3000. //数据排序
  3001. $order_str = "librarytime desc";
  3002. if (empty($page)) {
  3003. $start = 0;
  3004. $perpage = 1;
  3005. } else {
  3006. $start = ($page - 1) * $perpage;
  3007. }
  3008. //取得信息列表
  3009. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3010. //格式化数据
  3011. foreach ($info_list as $key => $value) {
  3012. $shop = $this->shop->read($value['shop']);
  3013. $info_list[$key]['shop'] = $shop['shopname'];
  3014. $express = $this->express->read($value['express']);
  3015. $info_list[$key]['express'] = $express['servicename'];
  3016. $warehouse = $this->warehouse->read($value['type']);
  3017. $info_list[$key]['type'] = $warehouse['title'];
  3018. if ($value['librarytime'] == '0') {
  3019. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3020. } else {
  3021. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3022. }
  3023. }
  3024. $total = $this->$sj->find_count($where);
  3025. $pagenum = ceil($total / $perpage);
  3026. $over = $total - ($start + $perpage);
  3027. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3028. echo json_encode($rows);
  3029. exit;
  3030. }
  3031. $this->data['express'] = $this->express->find_all();
  3032. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3033. $this->data['wlshop'] = $wlshop;
  3034. $user = $this->user->get_api($_SESSION['api']);
  3035. $powerid = $this->power->read($user['power']);
  3036. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3037. $pid = '';
  3038. foreach ($powertext as $v) {
  3039. $pid .= " id = " . $v . " or";
  3040. }
  3041. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3042. $this->data['fullorderexcel'] = $fullorderexcel;
  3043. $this->_Template('whlabel_soutorder', $this->data);
  3044. }
  3045. //订单退库
  3046. public function _retreat()
  3047. {
  3048. $post = $this->input->post(NULL, TRUE);
  3049. if (isset($post['page'])) {
  3050. $page = $this->input->post('page', true);
  3051. $perpage = $this->input->post('perpage', true);
  3052. $warehouse = $this->input->post('warehouse', true);
  3053. $timetk = $this->input->post('timetk', true);
  3054. $timetj = $this->input->post('timetj', true);
  3055. $shop = $this->input->post('shop', true);
  3056. $source = $this->input->post('source', true);
  3057. $state = $this->input->post('state', true);
  3058. $review = $this->input->post('review', true);
  3059. $state = $this->input->post('state', true);
  3060. $express = $this->input->post('express', true);
  3061. $orderinfo = $this->input->post('orderinfo', true);
  3062. $user = $this->input->post('user', true);
  3063. $name = $this->input->post('name', true);
  3064. $waybill = $this->input->post('waybill', true);
  3065. $timetk = strtotime($timetk);
  3066. $timetj = strtotime($timetj);
  3067. $where = "(state=206 or state=210) and mergeid = 0";
  3068. if ($warehouse) {
  3069. $where .= " and state = '$warehouse'";
  3070. }
  3071. if ($timetk && $timetj) {
  3072. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3073. }
  3074. if ($shop) {
  3075. $where .= " and shop = '$shop'";
  3076. }
  3077. if ($source) {
  3078. $where .= " and source = '$source'";
  3079. }
  3080. if ($state) {
  3081. $where .= " and state = '$state'";
  3082. }
  3083. if ($review) {
  3084. $where .= " and review = '$review'";
  3085. }
  3086. if ($state) {
  3087. $where .= " and state = '$state'";
  3088. }
  3089. if ($express) {
  3090. $where .= " and express = '$express'";
  3091. }
  3092. if ($orderinfo) {
  3093. $where .= " and orderinfo = '$orderinfo'";
  3094. }
  3095. if ($user) {
  3096. $where .= " and user = '$user'";
  3097. }
  3098. if ($name) {
  3099. $where .= " and name = '$name'";
  3100. }
  3101. if ($waybill) {
  3102. $where .= " and waybill = '$waybill'";
  3103. }
  3104. //数据排序
  3105. $order_str = "id desc";
  3106. if (empty($page)) {
  3107. $start = 0;
  3108. $perpage = 1;
  3109. } else {
  3110. $start = ($page - 1) * $perpage;
  3111. }
  3112. //取得信息列表
  3113. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3114. //格式化数据
  3115. foreach ($info_list as $key => $value) {
  3116. $shop = $this->shop->read($value['shop']);
  3117. $info_list[$key]['shop'] = $shop['shopname'];
  3118. $warehouse = $this->warehouse->read($value['warehouse']);
  3119. $info_list[$key]['warehouse'] = $warehouse['title'];
  3120. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3121. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3122. if ($value['waybill'] == 0) {
  3123. $info_list[$key]['waybill'] = "";
  3124. }
  3125. $express = $this->express->read($value['express']);
  3126. $info_list[$key]['express'] = $express['title'];
  3127. $typeclass = $this->typeclass->read($value['state']);
  3128. $info_list[$key]['state'] = $typeclass['title'];
  3129. }
  3130. $total = $this->fullorder->find_count($where);
  3131. $pagenum = ceil($total / $perpage);
  3132. $over = $total - ($start + $perpage);
  3133. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3134. echo json_encode($rows);
  3135. exit;
  3136. }
  3137. $this->data['express'] = $this->express->find_all();
  3138. $this->_Template('whlabel_retreat', $this->data);
  3139. }
  3140. //退库标签浏览
  3141. public function _retreatlk()
  3142. {
  3143. $post = $this->input->post(NULL, TRUE);
  3144. if (isset($post['page'])) {
  3145. $page = $this->input->post('page', true);
  3146. $perpage = $this->input->post('perpage', true);
  3147. $timetk = $this->input->post('timetk', true);
  3148. $timetj = $this->input->post('timetj', true);
  3149. $sku = $this->input->post('sku', true);
  3150. $warehouse = $this->input->post('warehouse', true);
  3151. $purchase = $this->input->post('purchase', true);
  3152. $orderinfo = $this->input->post('orderinfo', true);
  3153. $waybill = $this->input->post('waybill', true);
  3154. $category = $this->input->post('category', true);
  3155. $size = $this->input->post('size', true);
  3156. $grade = $this->input->post('grade', true);
  3157. $color = $this->input->post('color', true);
  3158. $lowe = $this->input->post('lowe', true);
  3159. $state = $this->input->post('state', true);
  3160. $timetk = strtotime($timetk);
  3161. $timetj = strtotime($timetj);
  3162. $where = "state=2";
  3163. if ($timetk && $timetj) {
  3164. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3165. }
  3166. if ($sku) {
  3167. $where .= " and sku = '$sku'";
  3168. }
  3169. if ($warehouse) {
  3170. $where .= " and warehouse = '$warehouse'";
  3171. }
  3172. if ($purchase) {
  3173. $where .= " and purchase = '$purchase'";
  3174. }
  3175. if ($orderinfo) {
  3176. $where .= " and orderinfo = '$orderinfo'";
  3177. }
  3178. if ($waybill) {
  3179. $where .= " and waybill = '$waybill'";
  3180. }
  3181. if ($category) {
  3182. $where .= " and features like '%-$category-%'";
  3183. }
  3184. if ($size) {
  3185. $where .= " and features like '%-$size-%'";
  3186. }
  3187. if ($grade) {
  3188. $where .= " and features like '%-$grade-%'";
  3189. }
  3190. if ($color) {
  3191. $where .= " and features like '%-$color-%'";
  3192. }
  3193. if ($lowe) {
  3194. $where .= " and features like '%-$lowe-%'";
  3195. }
  3196. //数据排序
  3197. $order_str = "time desc";
  3198. if (empty($page)) {
  3199. $start = 0;
  3200. $perpage = 1;
  3201. } else {
  3202. $start = ($page - 1) * $perpage;
  3203. }
  3204. //取得信息列表
  3205. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3206. foreach ($info_list as $key => $value) {
  3207. $warehouse = $this->warehouse->read($value['warehouse']);
  3208. $info_list[$key]['warehouse'] = $warehouse['title'];
  3209. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3210. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3211. $purchase = $this->purchase->read($value['purchase']);
  3212. $info_list[$key]['purchase'] = $purchase['title'];
  3213. if ($value['outk'] != 0) {
  3214. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3215. } else {
  3216. $info_list[$key]['outk'] = "";
  3217. }
  3218. if ($value['retreat'] != 0) {
  3219. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3220. } else {
  3221. $info_list[$key]['retreat'] = "";
  3222. }
  3223. if ($value['orderinfo'] == 0) {
  3224. $info_list[$key]['orderinfo'] = "";
  3225. }
  3226. if ($value['waybill'] == 0) {
  3227. $info_list[$key]['waybill'] = "";
  3228. }
  3229. }
  3230. $total = $this->whlabel->find_count($where);
  3231. $pagenum = ceil($total / $perpage);
  3232. $over = $total - ($start + $perpage);
  3233. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3234. echo json_encode($rows);
  3235. exit;
  3236. }
  3237. $this->_Template('whlabel_retreatlk', $this->data);
  3238. }
  3239. //更换标签及浏览
  3240. public function _change()
  3241. {
  3242. $post = $this->input->post(NULL, TRUE);
  3243. if (isset($post['page'])) {
  3244. $page = $this->input->post('page', true);
  3245. $perpage = $this->input->post('perpage', true);
  3246. $timetk = $this->input->post('timetk', true);
  3247. $timetj = $this->input->post('timetj', true);
  3248. $label = $this->input->post('label', true);
  3249. $oldlabel = $this->input->post('oldlabel', true);
  3250. $timetk = strtotime($timetk);
  3251. $timetj = strtotime($timetj);
  3252. $where = "state=10 ";
  3253. if ($timetk && $timetj) {
  3254. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3255. }
  3256. if ($label) {
  3257. $where .= " and label = '$label'";
  3258. }
  3259. if ($oldlabel) {
  3260. $where .= " and oldlabel = '$oldlabel'";
  3261. }
  3262. //数据排序
  3263. $order_str = "time asc";
  3264. if (empty($page)) {
  3265. $start = 0;
  3266. $perpage = 1;
  3267. } else {
  3268. $start = ($page - 1) * $perpage;
  3269. }
  3270. //取得信息列表
  3271. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3272. foreach ($info_list as $key => $value) {
  3273. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3274. }
  3275. $total = $this->whlabel->find_count($where);
  3276. $pagenum = ceil($total / $perpage);
  3277. $over = $total - ($start + $perpage);
  3278. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3279. echo json_encode($rows);
  3280. exit;
  3281. }
  3282. $this->_Template('whlabel_change', $this->data);
  3283. }
  3284. //产品标签
  3285. public function _cpbqdc()
  3286. {
  3287. if (isset($_GET['excel'])) {
  3288. $where = "1=1";
  3289. //数据排序
  3290. $order_str = "id desc";
  3291. if (empty($page)) {
  3292. $start = 0;
  3293. $perpage = 1;
  3294. } else {
  3295. $start = ($page - 1) * $perpage;
  3296. }
  3297. $warehouse = $this->input->get('warehouse', true);
  3298. $state = $this->input->get('state', true);
  3299. $timetk = $this->input->get('timetkk', true);
  3300. $timetj = $this->input->get('timetjj', true);
  3301. $timetk = strtotime($timetk);
  3302. $timetj = strtotime($timetj);
  3303. if ($warehouse) {
  3304. $where .= " and warehouse = '$warehouse'";
  3305. }
  3306. if ($state || $state == 0) {
  3307. $where .= " and state = '$state'";
  3308. }
  3309. if ($timetk && $timetj) {
  3310. $where .= " and time > '$timetk' and time < '$timetj'";
  3311. }
  3312. //取得信息列表
  3313. $info_list = $this->whlabel->find_all($where, '*');
  3314. $rows = array();
  3315. $list = array();
  3316. foreach ($info_list as $key => $value) {
  3317. $rows[$value['time']] = $value; //所有数据sku
  3318. }
  3319. foreach ($rows as $value) {
  3320. $warehouse = $this->warehouse->read($value['warehouse']);
  3321. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3322. $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);
  3323. }
  3324. $title = "产品标签统计表";
  3325. $titlename = "<table border=1>
  3326. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3327. <tr align='center'>
  3328. <td>仓库</td>
  3329. <td>SKU</td>
  3330. <td>产品</td>
  3331. <td>入库时间</td>
  3332. <td>操作时间</td>
  3333. <td>备注</td>
  3334. <td>数量</td>
  3335. </tr>
  3336. </table>";
  3337. $filename = $title . ".xls";
  3338. $tail = "";
  3339. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3340. }
  3341. }
  3342. //进销存导出
  3343. public function _exceljxc()
  3344. {
  3345. $classid = $this->classid->sku();
  3346. $pm = $classid;
  3347. $typeclass = array();
  3348. $tc = $this->typeclass->find_all();
  3349. foreach ($tc as $v) {
  3350. $typeclass[$v['id']] = $v;
  3351. }
  3352. $prc = array();
  3353. $purchase = $this->purchase->find_all();
  3354. foreach ($purchase as $k => $v) {
  3355. $prc[$v['id']] = $v['title'];
  3356. }
  3357. if (isset($_GET['excel'])) {
  3358. $where = "sku != 'Preset'";
  3359. //数据排序
  3360. $order_str = "id desc";
  3361. if (empty($page)) {
  3362. $start = 0;
  3363. $perpage = 1;
  3364. } else {
  3365. $start = ($page - 1) * $perpage;
  3366. }
  3367. $category = $this->input->get('category', true);
  3368. $warehouse = $this->input->get('warehouse', true);
  3369. $excelid = $this->input->get('sid', true);
  3370. if ($category) {
  3371. $where .= " and features like '%-$category-%'";
  3372. }
  3373. if ($warehouse) {
  3374. $where .= " and warehouse = '$warehouse'";
  3375. }
  3376. $xzid = '';
  3377. if ($excelid) {
  3378. $excelid = explode(',', trim($excelid, ','));
  3379. foreach ($excelid as $key => $value) {
  3380. $xzid .= " id = " . $value . " or";
  3381. }
  3382. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3383. }
  3384. //取得信息列表
  3385. /**
  3386. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3387. $rows = array();$list = array();
  3388. foreach ($info_list as $key=>$value)
  3389. {
  3390. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3391. }
  3392. **/
  3393. $wt = array();
  3394. $whlabel_type = $this->whlabel_type->find_all();
  3395. foreach ($whlabel_type as $v) {
  3396. $wt[$v['id']] = $v['title'];
  3397. }
  3398. $wh = array();
  3399. $w = $this->warehouse->find_all('1=1', 'id,title');
  3400. foreach ($w as $v) {
  3401. $wh[$v['id']] = $v['title'];
  3402. }
  3403. $list = array();
  3404. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3405. foreach ($rows as $key => $value) {
  3406. if (isset($wt[$value['type']])) {
  3407. $rows[$key]['type'] = $wt[$value['type']];
  3408. } else {
  3409. $rows[$key]['type'] = '未设置';
  3410. }
  3411. $bm = '03';
  3412. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3413. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3414. $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');
  3415. $details = array();
  3416. $cpid = array();
  3417. $cpbz = array();
  3418. $c = 0;
  3419. $g = 0;
  3420. $x = 0;
  3421. $t = 0;
  3422. $s = 0;
  3423. $q = 0;
  3424. foreach ($sd as $k => $v) {
  3425. if ($v['state'] == 0) {
  3426. $c++;
  3427. if ($v['cpid'] != 0) {
  3428. $cpid[$v['cpid']] = $v['cpid'];
  3429. }
  3430. if ($v['cpbz'] != '') {
  3431. $cpbz[$v['cpbz']] = $v['cpbz'];
  3432. }
  3433. }
  3434. if ($v['state'] != 9) {
  3435. $g++;
  3436. }
  3437. if ($v['state'] == 1) {
  3438. $x++;
  3439. }
  3440. if ($v['state'] == 2) {
  3441. $t++;
  3442. }
  3443. if ($v['state'] == 8) {
  3444. $s++;
  3445. }
  3446. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3447. $q++;
  3448. }
  3449. $details[$v['details']] = $v['details'];
  3450. }
  3451. $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'] . '"');
  3452. $rows[$key]['details'] = implode("、", $details);
  3453. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3454. $number = $value['number'];
  3455. $ftime = time() - 15 * 24 * 3600;
  3456. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3457. $rows[$key]['number'] = $g;
  3458. $rows[$key]['c'] = $c;
  3459. $rows[$key]['x'] = $x;
  3460. $rows[$key]['t'] = $t;
  3461. $rows[$key]['s'] = $s;
  3462. $rows[$key]['q'] = $q;
  3463. $rows[$key]['z'] = $z;
  3464. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3465. $features = explode('-', trim($features, '-'));
  3466. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3467. // $pm = $classid;
  3468. // $jm = $classid;
  3469. // foreach($features as $k=>$v)
  3470. // {
  3471. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3472. // {
  3473. // if($typeclass[$v]['bm'] != '')
  3474. // {
  3475. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3476. // }
  3477. // }
  3478. // if($v != 0)
  3479. // {
  3480. // if(!isset($typeclass[$v]))
  3481. // {
  3482. // continue;
  3483. // }
  3484. // if(isset($pm[$typeclass[$v]['classid']]))
  3485. // {
  3486. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3487. // {
  3488. // $tz = explode('|',$typeclass[$v]['zh']);
  3489. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3490. // }
  3491. // else
  3492. // {
  3493. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3494. // }
  3495. // }
  3496. // if(isset($jm[$typeclass[$v]['classid']]))
  3497. // {
  3498. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3499. // }
  3500. // }
  3501. // }
  3502. // $jm = array_filter($jm);
  3503. // $rows[$key]['bs'] = implode("-",$jm);
  3504. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3505. // $zh = implode(" ",$pm);
  3506. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3507. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3508. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3509. // $rows[$key]['features'] = $zh;
  3510. }
  3511. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3512. $final_list = [];
  3513. foreach ($list as $k => $v) {
  3514. if (empty($v['sku'])) {
  3515. continue;
  3516. }
  3517. $final_list[] = [
  3518. "warehouse" => $v["warehouse"],
  3519. "purchase" => $v["purchase"],
  3520. "details" => $v["details"],
  3521. "cpid" => $v["cpid"],
  3522. "dbcontent" => $v["dbcontent"],
  3523. "sku" => $v["sku"],
  3524. "cs" => $v["bm"],
  3525. "bs" => $v["jm"],
  3526. "title" => $v["title"],
  3527. "features" => $v["pm"],
  3528. "cpbz" => $v["cpbz"],
  3529. "sm" => $v["sm"],
  3530. "type" => $v["type"],
  3531. "number" => $v["number"],
  3532. "c" => $v["c"],
  3533. "x" => $v["x"],
  3534. "t" => $v["t"],
  3535. "s" => $v["s"],
  3536. "q" => $v["q"],
  3537. "z" => $v["z"],
  3538. "weight" => $v['weight'],
  3539. ];
  3540. }
  3541. $title = "总进销存统计表";
  3542. $titlename = "<table border=1>
  3543. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3544. <tr align='center'>
  3545. <td>仓库</td>
  3546. <td>供应商</td>
  3547. <td>位置</td>
  3548. <td>库存编码</td>
  3549. <td>类目</td>
  3550. <td>SKU</td>
  3551. <td>用友编码</td>
  3552. <td>用友料号</td>
  3553. <td>商品名称</td>
  3554. <td>商品中文</td>
  3555. <td>产品备注</td>
  3556. <td>说明</td>
  3557. <td>类型</td>
  3558. <td>入库总量</td>
  3559. <td>库存数量</td>
  3560. <td>销售数量</td>
  3561. <td>退货数量</td>
  3562. <td>删除数量</td>
  3563. <td>其它操作</td>
  3564. <td>占单数量</td>
  3565. <td>重量(g)</td>
  3566. </tr>
  3567. </table>";
  3568. $filename = $title . ".xls";
  3569. $tail = "";
  3570. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3571. }
  3572. }
  3573. //入库导出
  3574. public function _excelr()
  3575. {
  3576. if (isset($_GET['excel'])) {
  3577. $category = $this->input->get('category', true);
  3578. $size = $this->input->get('size', true);
  3579. $grade = $this->input->get('grade', true);
  3580. $color = $this->input->get('color', true);
  3581. $lowe = $this->input->get('lowe', true);
  3582. $sku = $this->input->get('sku', true);
  3583. $warehouse = $this->input->get('warehouse', true);
  3584. $purchase = $this->input->get('purchase', true);
  3585. $ktime = $this->input->get('ktime', true);
  3586. $jtime = $this->input->get('jtime', true);
  3587. $ktime = strtotime($ktime);
  3588. $jtime = strtotime($jtime);
  3589. $where = "1=1";
  3590. $gj = "";
  3591. $ck = "";
  3592. if ($category) {
  3593. $where .= " and features like '%-$category-%'";
  3594. }
  3595. if ($size) {
  3596. $where .= " and features like '%-$size-%'";
  3597. }
  3598. if ($grade) {
  3599. $where .= " and features like '%-$grade-%'";
  3600. }
  3601. if ($color) {
  3602. $where .= " and features like '%-$color-%'";
  3603. }
  3604. if ($lowe) {
  3605. $where .= " and features like '%-$lowe-%'";
  3606. }
  3607. if ($warehouse) {
  3608. $where .= " and warehouse = '$warehouse'";
  3609. }
  3610. if ($purchase) {
  3611. $where .= " and purchase = '$purchase'";
  3612. }
  3613. if ($sku) {
  3614. $where .= " and sku = '$sku'";
  3615. }
  3616. if ($ktime && $jtime) {
  3617. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3618. }
  3619. //数据排序
  3620. $order_str = "id desc";
  3621. if (empty($page)) {
  3622. $start = 0;
  3623. $perpage = 1;
  3624. } else {
  3625. $start = ($page - 1) * $perpage;
  3626. }
  3627. $list = array();
  3628. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3629. foreach ($rows as $value) {
  3630. $ck = $this->warehouse->read($value['warehouse']);
  3631. $warehouse = $ck['title'];
  3632. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3633. $retreatwarehouse = $tkck['title'];
  3634. $gy = $this->purchase->read($value['purchase']);
  3635. $purchase = $gy['title'];
  3636. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3637. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3638. }
  3639. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3640. $titlename = "<table border=1>
  3641. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3642. <tr align='center'>
  3643. <td>仓库</td>
  3644. <td>SKU</td>
  3645. <td>产品</td>
  3646. <td>时间</td>
  3647. <td>数量</td>
  3648. </tr>
  3649. </table>";
  3650. $filename = $title . ".xls";
  3651. $tail = "";
  3652. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3653. }
  3654. }
  3655. //出库、退库导出
  3656. public function _excelct()
  3657. {
  3658. $classid = $this->classid->sku();
  3659. $pm = $classid;
  3660. $typeclass = array();
  3661. $tc = $this->typeclass->find_all();
  3662. foreach ($tc as $v) {
  3663. $typeclass[$v['id']] = $v;
  3664. }
  3665. $prc = array();
  3666. $purchase = $this->purchase->find_all();
  3667. foreach ($purchase as $k => $v) {
  3668. $prc[$v['id']] = $v['title'];
  3669. }
  3670. if (isset($_GET['excel'])) {
  3671. $wh = array();
  3672. $w = $this->warehouse->find_all('1=1', 'id,title');
  3673. foreach ($w as $v) {
  3674. $wh[$v['id']] = $v['title'];
  3675. }
  3676. $type = $this->input->get('excel', true);
  3677. $category = $this->input->get('category', true);
  3678. $size = $this->input->get('size', true);
  3679. $grade = $this->input->get('grade', true);
  3680. $color = $this->input->get('color', true);
  3681. $lowe = $this->input->get('lowe', true);
  3682. $sku = $this->input->get('sku', true);
  3683. $title = $this->input->get('title', true);
  3684. $warehouse = $this->input->get('warehouse', true);
  3685. $purchase = $this->input->get('purchase', true);
  3686. $lacetype = $this->input->get('lacetype', true);
  3687. $haircap = $this->input->get('haircap', true);
  3688. $lacecolor = $this->input->get('lacecolor', true);
  3689. $density = $this->input->get('density', true);
  3690. $details = $this->input->get('details', true);
  3691. $state = $this->input->get('state', true);
  3692. $shop = $this->input->get('shop', true);
  3693. $hairnumber = $this->input->get('hairnumber', true);
  3694. $type_leixi = $this->input->get('type', true);
  3695. $cpbz = $this->input->get('cpbz', true);
  3696. $sm = $this->input->get('sm', true);
  3697. $sid = $this->input->get('sid', true);
  3698. $ktime = $this->input->get('ktime', true);
  3699. $jtime = $this->input->get('jtime', true);
  3700. $ktime = strtotime($ktime);
  3701. $jtime = strtotime($jtime);
  3702. //$where = " 1=1 ";
  3703. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3704. $where = " sku != '' ";
  3705. $gj = "";
  3706. $ck = "";
  3707. if ($category) {
  3708. $where .= " and features like '%-$category-%'";
  3709. }
  3710. if ($size) {
  3711. $where .= " and features like '%-$size-%'";
  3712. }
  3713. if ($grade) {
  3714. $where .= " and features like '%-$grade-%'";
  3715. }
  3716. if ($color) {
  3717. $where .= " and features like '%-$color-%'";
  3718. }
  3719. if ($lowe) {
  3720. $where .= " and features like '%-$lowe-%'";
  3721. }
  3722. if ($warehouse) {
  3723. $where .= " and warehouse = '$warehouse'";
  3724. }
  3725. if ($purchase) {
  3726. $where .= " and purchase = '$purchase'";
  3727. }
  3728. if ($state) {
  3729. $where .= " and state = '$state'";
  3730. }
  3731. if ($lacetype) {
  3732. $where .= " and features like '%-$lacetype-%'";
  3733. }
  3734. if ($lacecolor) {
  3735. $where .= " and features like '%-$lacecolor-%'";
  3736. }
  3737. if ($density) {
  3738. $where .= " and features like '%-$density-%'";
  3739. }
  3740. if ($haircap) {
  3741. $where .= " and features like '%-$haircap-%'";
  3742. }
  3743. if ($details) {
  3744. $where .= " and details = '$details'";
  3745. }
  3746. if ($shop) {
  3747. $where .= " and shop like '%$shop%'";
  3748. }
  3749. if ($title) {
  3750. $title = trim($title, ' ');
  3751. $title = trim($title, ' ');
  3752. $where .= " and title like '%$title%'";
  3753. }
  3754. if (!empty($hairnumber)) {
  3755. $where .= " and features like '%-128-%' ";
  3756. if ($hairnumber < 0) {
  3757. $class_list = $this->typeclass->find_all('classid = 43');
  3758. foreach ($class_list as $v) {
  3759. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3760. }
  3761. } else {
  3762. $where .= " and features like '%-$hairnumber-%'";
  3763. }
  3764. }
  3765. if ($type_leixi) {
  3766. $where .= " and type = '$type_leixi'";
  3767. }
  3768. if ($cpbz) {
  3769. $where .= " and cpbz like '%$cpbz%' ";
  3770. }
  3771. if ($sm) {
  3772. $where .= " and sm like '%$sm%' ";
  3773. }
  3774. if ($sku) {
  3775. $sku = trim($sku, ' ');
  3776. $sku = trim($sku, ' ');
  3777. $where .= " and sku like '%$sku%'";
  3778. }
  3779. if ($ktime && $jtime) {
  3780. if ($type == 1) {
  3781. $tl = '出库';
  3782. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3783. } else if ($type == 2) {
  3784. $tl = '退库';
  3785. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3786. } else if ($type == 3) {
  3787. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3788. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3789. } else if ($type == 4) {
  3790. $tl = '出库+零售';
  3791. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3792. } else if ($type == 5) {
  3793. $tl = '零售';
  3794. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3795. }
  3796. }
  3797. $sidwhere = '';
  3798. if ($sid) {
  3799. $sd = "";
  3800. $s = explode(',', trim($sid, ','));
  3801. foreach ($s as $value) {
  3802. $sd .= " id = " . $value . " or";
  3803. }
  3804. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3805. }
  3806. //数据排序
  3807. $order_str = "time desc";
  3808. if (empty($page)) {
  3809. $start = 0;
  3810. $perpage = 1;
  3811. } else {
  3812. $start = ($page - 1) * $perpage;
  3813. }
  3814. //取得信息列表
  3815. if ($type != 3 && $type != 5) {
  3816. if ($type == 1 || $type == 4) {
  3817. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3818. foreach ($info_list as $key => $value) {
  3819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3820. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3821. $warehouse = $this->warehouse->read($value['warehouse']);
  3822. $info_list[$key]['warehouse'] = $warehouse['title'];
  3823. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3824. $features = explode('-', trim($features, '-'));
  3825. $pm = $classid;
  3826. foreach ($features as $k => $v) {
  3827. if ($v != 0) {
  3828. if (!isset($typeclass[$v])) {
  3829. continue;
  3830. }
  3831. if (isset($pm[$typeclass[$v]['classid']])) {
  3832. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3833. $tz = explode('|', $typeclass[$v]['zh']);
  3834. $pm[$typeclass[$v]['classid']] = $tz[0];
  3835. } else {
  3836. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3837. }
  3838. }
  3839. }
  3840. }
  3841. $zh = implode(" ", $pm);
  3842. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3843. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3844. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3845. $info_list[$key]['features'] = $zh;
  3846. }
  3847. $final_list = [];
  3848. foreach($info_list as $k=>$v){
  3849. $number = "";
  3850. if(!empty($v['orderinfo'])){
  3851. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3852. if(!empty($tmp_info['number'])){
  3853. $number = $tmp_info['number'];
  3854. }
  3855. }
  3856. $final_list[] = [
  3857. 'warehouse'=>$v['warehouse'],
  3858. 'purchase'=>$v['purchase'],
  3859. 'sku'=>$v['sku'],
  3860. 'title'=>$v['title'],
  3861. 'features'=>$v['features'],
  3862. 'label'=>$v['label'],
  3863. 'orderinfo'=>$v['orderinfo'],
  3864. 'number'=>$number,
  3865. 'waybill'=>$v['waybill'],
  3866. 'outk'=>$v['outk'],
  3867. ];
  3868. }
  3869. } else {
  3870. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3871. foreach ($info_list as $key => $value) {
  3872. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3873. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3874. $warehouse = $this->warehouse->read($value['warehouse']);
  3875. $info_list[$key]['warehouse'] = $warehouse['title'];
  3876. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3877. $features = explode('-', trim($features, '-'));
  3878. $pm = $classid;
  3879. foreach ($features as $k => $v) {
  3880. if ($v != 0) {
  3881. if (!isset($typeclass[$v])) {
  3882. continue;
  3883. }
  3884. if (isset($pm[$typeclass[$v]['classid']])) {
  3885. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3886. $tz = explode('|', $typeclass[$v]['zh']);
  3887. $pm[$typeclass[$v]['classid']] = $tz[0];
  3888. } else {
  3889. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3890. }
  3891. }
  3892. }
  3893. }
  3894. $zh = implode(" ", $pm);
  3895. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3896. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3897. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3898. $info_list[$key]['features'] = $zh;
  3899. }
  3900. $final_list = [];
  3901. foreach($info_list as $k=>$v){
  3902. $number = "";
  3903. if(!empty($v['orderinfo'])){
  3904. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3905. if(!empty($tmp_info['number'])){
  3906. $number = $tmp_info['number'];
  3907. }
  3908. }
  3909. $final_list[] = [
  3910. 'warehouse'=>$v['warehouse'],
  3911. 'purchase'=>$v['purchase'],
  3912. 'sku'=>$v['sku'],
  3913. 'title'=>$v['title'],
  3914. 'features'=>$v['features'],
  3915. 'label'=>$v['label'],
  3916. 'orderinfo'=>$v['orderinfo'],
  3917. 'number'=>$number,
  3918. 'waybill'=>$v['waybill'],
  3919. 'retreat'=>$v['retreat'],
  3920. ];
  3921. }
  3922. }
  3923. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3924. $titlename = "<table border=1>
  3925. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3926. <tr align='center'>
  3927. <td>仓库</td>
  3928. <td>供应商</td>
  3929. <td>SKU</td>
  3930. <td>商品名称</td>
  3931. <td>商品中文</td>
  3932. <td>标签</td>
  3933. <td>订单号</td>
  3934. <td>订单编码</td>
  3935. <td>运单号</td>
  3936. <td>" . $tl . "时间(中国时间)</td>
  3937. </tr>
  3938. </table>";
  3939. $filename = $title . ".xls";
  3940. $tail = "";
  3941. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3942. } else if ($type == 5) {
  3943. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3944. foreach ($info_list as $key => $value) {
  3945. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3946. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3947. $warehouse = $this->warehouse->read($value['warehouse']);
  3948. $info_list[$key]['warehouse'] = $warehouse['title'];
  3949. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3950. $features = explode('-', trim($features, '-'));
  3951. $pm = $classid;
  3952. foreach ($features as $k => $v) {
  3953. if ($v != 0) {
  3954. if (!isset($typeclass[$v])) {
  3955. continue;
  3956. }
  3957. if (isset($pm[$typeclass[$v]['classid']])) {
  3958. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3959. $tz = explode('|', $typeclass[$v]['zh']);
  3960. $pm[$typeclass[$v]['classid']] = $tz[0];
  3961. } else {
  3962. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3963. }
  3964. }
  3965. }
  3966. }
  3967. $zh = implode(" ", $pm);
  3968. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3969. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3970. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3971. $info_list[$key]['features'] = $zh;
  3972. }
  3973. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3974. $titlename = "<table border=1>
  3975. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3976. <tr align='center'>
  3977. <td>仓库</td>
  3978. <td>供应商</td>
  3979. <td>SKU</td>
  3980. <td>商品名称</td>
  3981. <td>商品中文</td>
  3982. <td>标签</td>
  3983. <td>" . $tl . "时间(中国时间)</td>
  3984. </tr>
  3985. </table>";
  3986. $filename = $title . ".xls";
  3987. $tail = "";
  3988. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3989. } else {
  3990. /**
  3991. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3992. $rows = array();$list = array();
  3993. foreach ($info_list as $key=>$value)
  3994. {
  3995. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3996. }
  3997. **/
  3998. $wh = array();
  3999. $w = $this->warehouse->find_all('1=1', 'id,title');
  4000. foreach ($w as $v) {
  4001. $wh[$v['id']] = $v['title'];
  4002. }
  4003. $wt = array();
  4004. $whlabel_type = $this->whlabel_type->find_all();
  4005. foreach ($whlabel_type as $v) {
  4006. $wt[$v['id']] = $v['title'];
  4007. }
  4008. $classid = $this->classid->sku();
  4009. $list = array();
  4010. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4011. foreach ($rows as $key => $value) {
  4012. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4013. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4014. $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');
  4015. $details = array();
  4016. $cpid = array();
  4017. $cpbz = array();
  4018. $c = 0;
  4019. $g = 0;
  4020. $x = 0;
  4021. $t = 0;
  4022. $s = 0;
  4023. $q = 0;
  4024. foreach ($sd as $k => $v) {
  4025. if ($v['state'] == 0) {
  4026. $c++;
  4027. }
  4028. if ($v['state'] != 9) {
  4029. $g++;
  4030. }
  4031. if ($v['outk'] > 1) {
  4032. $x++;
  4033. }
  4034. if ($v['retreat'] > 0) {
  4035. $t++;
  4036. }
  4037. if ($v['state'] == 8) {
  4038. $s++;
  4039. }
  4040. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4041. $q++;
  4042. }
  4043. $details[$v['details']] = $v['details'];
  4044. if ($v['cpid'] != 0) {
  4045. $cpid[$v['cpid']] = $v['cpid'];
  4046. }
  4047. if ($v['cpbz'] != '') {
  4048. $cpbz[$v['cpbz']] = $v['cpbz'];
  4049. }
  4050. }
  4051. if (isset($wt[$value['type']])) {
  4052. $rows[$key]['type'] = $wt[$value['type']];
  4053. } else {
  4054. $rows[$key]['type'] = '未设置';
  4055. }
  4056. $rows[$key]['details'] = implode("、", $details);
  4057. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4058. $ftime = time() - 15 * 24 * 3600;
  4059. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4060. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4061. $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);
  4062. $rows[$key]['c'] = $c;
  4063. $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);
  4064. $rows[$key]['t'] = $t;
  4065. $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'] . '"');
  4066. $rows[$key]['z'] = $z;
  4067. // $jm = $classid;
  4068. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4069. $features = explode('-', trim($features, '-'));
  4070. // $pm = $classid;
  4071. // foreach ($features as $k => $v) {
  4072. // if ($v != 0) {
  4073. // if (!isset($typeclass[$v])) {
  4074. // continue;
  4075. // }
  4076. // if (isset($pm[$typeclass[$v]['classid']])) {
  4077. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4078. // $tz = explode('|', $typeclass[$v]['zh']);
  4079. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4080. // } else {
  4081. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4082. // }
  4083. // if (isset($jm[$typeclass[$v]['classid']])) {
  4084. // if ($typeclass[$v]['jm']) {
  4085. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4086. // }
  4087. // }
  4088. // }
  4089. // }
  4090. // }
  4091. // $zh = implode(" ", $pm);
  4092. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4093. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4094. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4095. // $rows[$key]['features'] = $zh;
  4096. // $jm = array_filter($jm); //去除空值
  4097. // $jm = implode("-", $jm);
  4098. // $rows[$key]['jm'] = $jm;
  4099. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4100. }
  4101. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4102. // echo "<pre>";
  4103. // print_r($tmp_list);
  4104. // die;
  4105. $final_list =[];
  4106. foreach($tmp_list as $k=>$v){
  4107. $final_list[] = [
  4108. "warehouse"=>$v['warehouse'],
  4109. "purchase"=>$v['purchase'],
  4110. "details"=>$v['details'],
  4111. "cpid"=>$v['cpid'],
  4112. "sku"=>$v['sku'],
  4113. "title"=>$v['title'],
  4114. "features"=>$v['pm'],
  4115. "cpbz"=>$v['cpbz'],
  4116. "sm"=>$v['sm'],
  4117. "type"=>$v['type'],
  4118. "g"=>$v["g"],
  4119. "c"=>$v["c"],
  4120. "x"=>$v["x"],
  4121. "t"=>$v["t"],
  4122. "z"=>$v["z"],
  4123. "jm"=>$v["jm"],
  4124. "weight"=>$v["weight"],
  4125. "asd"=>$v["asd"],
  4126. ];
  4127. }
  4128. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4129. $titlename = "<table border=1>
  4130. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4131. <tr align='center'>
  4132. <td>仓库</td>
  4133. <td>供应商</td>
  4134. <td>位置</td>
  4135. <td>库存编码</td>
  4136. <td>SKU</td>
  4137. <td>商品名称</td>
  4138. <td>商品中文</td>
  4139. <td>产品备注</td>
  4140. <td>说明</td>
  4141. <td>类型</td>
  4142. <td>入库总量</td>
  4143. <td>库存数量</td>
  4144. <td>销售数量</td>
  4145. <td>退货数量</td>
  4146. <td>占单数量</td>
  4147. <td>料号</td>
  4148. <td>重量</td>
  4149. <td>类目</td>
  4150. </tr>
  4151. </table>";
  4152. $filename = $title . ".xls";
  4153. $tail = "";
  4154. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4155. }
  4156. }
  4157. }
  4158. //出库+入库数据整合
  4159. public function _excelcr()
  4160. {
  4161. if (isset($_GET['excel'])) {
  4162. $type = $this->input->get('excel', true);
  4163. $category = $this->input->get('category', true);
  4164. $size = $this->input->get('size', true);
  4165. $grade = $this->input->get('grade', true);
  4166. $color = $this->input->get('color', true);
  4167. $lowe = $this->input->get('lowe', true);
  4168. $sku = $this->input->get('sku', true);
  4169. $warehouse = $this->input->get('warehouse', true);
  4170. $purchase = $this->input->get('purchase', true);
  4171. $state = $this->input->get('state', true);
  4172. $sid = $this->input->get('sid', true);
  4173. $ktime = $this->input->get('ktime', true);
  4174. $jtime = $this->input->get('jtime', true);
  4175. $ktime = strtotime($ktime);
  4176. $jtime = strtotime($jtime);
  4177. $where = "1=1";
  4178. $gj = "";
  4179. $ck = "";
  4180. if ($category) {
  4181. $where .= " and features like '%-$category-%'";
  4182. }
  4183. if ($size) {
  4184. $where .= " and features like '%-$size-%'";
  4185. }
  4186. if ($grade) {
  4187. $where .= " and features like '%-$grade-%'";
  4188. }
  4189. if ($color) {
  4190. $where .= " and features like '%-$color-%'";
  4191. }
  4192. if ($lowe) {
  4193. $where .= " and features like '%-$lowe-%'";
  4194. }
  4195. if ($warehouse) {
  4196. $where .= " and warehouse = '$warehouse'";
  4197. }
  4198. if ($purchase) {
  4199. $where .= " and purchase = '$purchase'";
  4200. }
  4201. if ($state) {
  4202. $where .= " and state = '$state'";
  4203. }
  4204. if ($sku) {
  4205. $where .= " and sku like '%$sku%'";
  4206. }
  4207. if ($ktime && $jtime) {
  4208. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4209. }
  4210. $sidwhere = '';
  4211. if ($sid) {
  4212. $sd = "";
  4213. $s = explode(',', trim($sid, ','));
  4214. foreach ($s as $value) {
  4215. $sd .= " id = " . $value . " or";
  4216. }
  4217. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4218. }
  4219. //取得信息列表
  4220. $timeread = $ktime;
  4221. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4222. $timelist = array();
  4223. for ($i = 0; $i < $timenum; $i++) {
  4224. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4225. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4226. }
  4227. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4228. //echo "<pre>";
  4229. //print_r($info_list);
  4230. //exit();
  4231. $rows = array();
  4232. $list = array();
  4233. foreach ($info_list as $key => $value) {
  4234. $thistime = $timelist;
  4235. if (isset($rows[strtolower($value['sku'])])) {
  4236. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4237. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4238. }
  4239. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4240. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4241. }
  4242. } else {
  4243. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4244. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4245. }
  4246. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4247. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4248. }
  4249. $rows[strtolower($value['sku'])] = $thistime;
  4250. }
  4251. }
  4252. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4253. <head>
  4254. <!--[if gte mso 9]><xml>
  4255. <x:ExcelWorkbook>
  4256. <x:ExcelWorksheets>
  4257. <x:ExcelWorksheet>
  4258. <x:Name>EXCEL</x:Name>
  4259. <x:WorksheetOptions>
  4260. <x:Print>
  4261. <x:ValidPrinterInfo />
  4262. </x:Print>
  4263. </x:WorksheetOptions>
  4264. </x:ExcelWorksheet>
  4265. </x:ExcelWorksheets>
  4266. </x:ExcelWorkbook>
  4267. </xml>
  4268. <![endif]-->
  4269. </head><body>";
  4270. $str .= "<table border=1><tr><td>SKU</td>";
  4271. foreach ($timelist as $k => $v) {
  4272. $str .= "<td>" . $k . "出库</td>";
  4273. $str .= "<td>" . $k . "入库</td>";
  4274. }
  4275. $str .= "</tr></table>";
  4276. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4277. foreach ($rows as $key => $val) {
  4278. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4279. foreach ($val as $k => $v) {
  4280. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4281. if ($val[$k]['r'] > 0) {
  4282. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4283. } else {
  4284. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4285. }
  4286. }
  4287. $str .= "</tr>";
  4288. }
  4289. $str .= "</table>";
  4290. $str .= "</body></html>";
  4291. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4292. header("Content-type: application/octet-stream");
  4293. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4294. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4295. header("Pragma: no-cache");
  4296. header("Expires: 0");
  4297. exit($str);
  4298. }
  4299. }
  4300. //数量调整模板导出
  4301. public function _presetout()
  4302. {
  4303. if (isset($_GET['excel'])) {
  4304. $where = "sku != 'Preset' and purchase != 0";
  4305. //数据排序
  4306. $order_str = "id desc";
  4307. if (empty($page)) {
  4308. $start = 0;
  4309. $perpage = 1;
  4310. } else {
  4311. $start = ($page - 1) * $perpage;
  4312. }
  4313. //取得信息列表
  4314. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4315. $rows = array();
  4316. $list = array();
  4317. foreach ($info_list as $value) {
  4318. $warehouse = $this->warehouse->read($value['warehouse']);
  4319. $number = $value['number'];
  4320. $ftime = time() - 15 * 24 * 3600;
  4321. $purchase = $this->purchase->read($value['purchase']);
  4322. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4323. }
  4324. $title = "库存模板";
  4325. $titlename = "<table border=1>
  4326. <tr align='center'>
  4327. <td>仓库</td>
  4328. <td>供应商编码</td>
  4329. <td>SKU</td>
  4330. <td>增减数量(正数或负数)</td>
  4331. <td>增减备注</td>
  4332. <td>扣减方式:0减少库存1删除库存</td>
  4333. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4334. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4335. </tr>
  4336. </table>";
  4337. $filename = $title . ".xls";
  4338. $tail = "";
  4339. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4340. }
  4341. }
  4342. //数量调整模板导入
  4343. public function _presetedit()
  4344. {
  4345. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4346. $config['upload_path'] = '.' . $dir;
  4347. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4348. $config['allowed_types'] = 'xls|xlsx|csv';
  4349. $config['max_size'] = 10240;
  4350. $this->load->library('upload', $config);
  4351. $this->upload->initialize($config);
  4352. if ($this->upload->do_upload('userfile')) {
  4353. $full_path = $dir . $this->upload->data('file_name');
  4354. $fileName = '.' . $full_path;
  4355. if (!file_exists($fileName)) {
  4356. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4357. exit;
  4358. } else {
  4359. require_once "./data/excel/PHPExcel/IOFactory.php";
  4360. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4361. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4362. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4363. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4364. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4365. ++$column; //如果列数大于26行
  4366. $list = array();
  4367. for ($i = 2; $i <= $row; $i++) // 行数循环
  4368. {
  4369. $data = array();
  4370. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4371. {
  4372. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4373. }
  4374. $list[] = $data;
  4375. }
  4376. }
  4377. $i = 0;
  4378. $j = 0;
  4379. $ed = array();
  4380. foreach ($list as $key => $value) {
  4381. $time = time();
  4382. if ($value['0'] == "") {
  4383. continue;
  4384. }
  4385. $warehouse = $this->warehouse->get_title($value['0']);
  4386. $purchase = $this->purchase->get_bm($value['1']);
  4387. $sku = $value['2'];
  4388. $num = $value['3']; //调整数量
  4389. $text = $value['4']; //扣减说明
  4390. $type = $value['5']; //调整方式0扣减1删除
  4391. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4392. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4393. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4394. if (!$purchase) //如果没有这个SKU
  4395. {
  4396. $ed[] = array($purchase . '-不存在此供应商编码');
  4397. $j++;
  4398. continue;
  4399. }
  4400. if (!$d) //如果没有这个SKU
  4401. {
  4402. $ed[] = array($sku . '-库存中不存在此SKU');
  4403. $j++;
  4404. continue;
  4405. }
  4406. if (!isset($warehouse['id'])) {
  4407. $ed[] = array($sku . '-仓库名错误!');
  4408. $j++;
  4409. continue;
  4410. }
  4411. if ($type != '0' && $type != '1') {
  4412. $ed[] = array($sku . '-扣减方式填写错误!');
  4413. $j++;
  4414. continue;
  4415. }
  4416. if ($num < 0) //扣减库存
  4417. {
  4418. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4419. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4420. $j++;
  4421. continue;
  4422. }
  4423. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4424. if (count($data) < abs($num)) {
  4425. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4426. $j++;
  4427. continue;
  4428. }
  4429. if ($type == 0) //如果扣减方式为 扣减库存
  4430. {
  4431. for ($i = 0; $i < abs($num); $i++) {
  4432. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4433. }
  4434. } else if ($type == 1) {
  4435. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4436. if (count($zt) > 0) {
  4437. $ed[] = array($sku . '-有在途库存无法删除!');
  4438. $j++;
  4439. continue;
  4440. }
  4441. for ($i = 0; $i < abs($num); $i++) {
  4442. $this->whlabel->remove($data[$i]['id']);
  4443. }
  4444. }
  4445. } else if ($num > 0) //增加库存
  4446. {
  4447. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4448. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4449. $j++;
  4450. continue;
  4451. }
  4452. $post['sku'] = $d['sku'];
  4453. $post['shop'] = $d['shop'];
  4454. $post['warehouse'] = $warehouse['id'];
  4455. $post['purchase'] = $purchase['id'];
  4456. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4457. $post['state'] = 0;
  4458. $post['title'] = $d['title'];
  4459. $post['number'] = $d['number'];
  4460. $post['features'] = $d['features'];
  4461. $post['enter'] = $time;
  4462. $post['time'] = $time; //操作时间
  4463. $post['rktype'] = $rktype;
  4464. for ($i = 0; $i < $num; $i++) {
  4465. $post['label'] = time() . rand(100, 999) . $i;
  4466. $this->whlabel->insert($post);
  4467. }
  4468. }
  4469. sleep(1); //防止入库时间一样,需要延迟1秒
  4470. }
  4471. if ($j > 0) {
  4472. $tt = date('Ymd', time());
  4473. $title = '库存导入错误信息-' . $tt;
  4474. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4475. $tail = "\n";
  4476. $filename = $title . ".xls";
  4477. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4478. $dir = '/data/excel/' . $time . '/';
  4479. $file_name = 'error_' . $time . rand(1000, 9999);
  4480. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4481. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4482. fwrite($myfile, $ecl);
  4483. fclose($myfile);
  4484. $error = $dir . $file_name . '.xls';
  4485. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4486. exit;
  4487. } else {
  4488. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4489. exit;
  4490. }
  4491. }
  4492. }
  4493. //笛卡儿积
  4494. function cp($ps, $sets, $list)
  4495. {
  4496. $result = array();
  4497. $j = 0;
  4498. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4499. if ($i == 0) {
  4500. $result = $sets[$i];
  4501. }
  4502. $tmp = array();
  4503. foreach ($result as $res) {
  4504. foreach ($sets[$i + 1] as $set) {
  4505. $tmp[] = $res . ',' . $set;
  4506. }
  4507. }
  4508. $result = $tmp;
  4509. }
  4510. $this->db->trans_begin();
  4511. foreach ($result as $v) {
  4512. $post = array();
  4513. $title = "";
  4514. $num = "";
  4515. $data = explode(',', $v);
  4516. for ($i = 0; $i < count($list); $i++) {
  4517. $post[$list[$i]] = $data[$i];
  4518. $typeclass = $this->typeclass->read($data[$i]);
  4519. $title = $title . $typeclass['title'] . " ";
  4520. if ($data[$i] != 0) {
  4521. $num .= $data[$i]; //所有数据ID拼接
  4522. }
  4523. }
  4524. foreach ($ps as $kp => $vp) {
  4525. $post[$kp] = $vp;
  4526. }
  4527. $post['number'] = $num;
  4528. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4529. if ($info_list) {
  4530. $j++;
  4531. } else {
  4532. $skunum = $this->whlabel->find_count();
  4533. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4534. $post['title'] = rtrim($title, ' ');
  4535. $this->whlabel->insert($post);
  4536. }
  4537. }
  4538. if ($this->db->trans_status() === FALSE) {
  4539. $this->db->trans_commit();
  4540. return NULL;
  4541. } else {
  4542. $this->db->trans_commit();
  4543. return $j;
  4544. }
  4545. }
  4546. public function _kj($arg_array)
  4547. {
  4548. if (isset($_POST['sku'])) {
  4549. $time = time();
  4550. $sku = $this->input->post('sku', true);
  4551. $warehouse = $this->input->post('warehouse', true);
  4552. $num = $this->input->post('num', true);
  4553. $text = $this->input->post('text', true);
  4554. $purchase = $this->input->post('purchase', true);
  4555. $cktype = $this->input->post('cktype', true);
  4556. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4557. if ($cktype != 1 && $text == '') {
  4558. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4559. exit;
  4560. }
  4561. if ($num > count($order)) {
  4562. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4563. exit;
  4564. } else {
  4565. for ($i = 0; $i < $num; $i++) {
  4566. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4567. }
  4568. }
  4569. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4570. exit;
  4571. }
  4572. $uid = $this->whlabel->read($arg_array[0]);
  4573. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4574. $this->data['data'] = $uid;
  4575. $this->_Template('whlabel_kj', $this->data);
  4576. }
  4577. public function _summary($arg_array)
  4578. {
  4579. $prc = array();
  4580. $purchase = $this->purchase->find_all();
  4581. foreach ($purchase as $k => $v) {
  4582. $prc[$v['id']] = $v['title'];
  4583. }
  4584. if (isset($_GET['excel'])) {
  4585. $ktime = $this->input->get('ktime', true);
  4586. $jtime = $this->input->get('jtime', true);
  4587. $ktime = strtotime($ktime);
  4588. $jtime = strtotime($jtime);
  4589. $where = "1=1";
  4590. if ($ktime && $jtime) {
  4591. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4592. }
  4593. //数据排序
  4594. $order_str = "time desc";
  4595. if (empty($page)) {
  4596. $start = 0;
  4597. $perpage = 1;
  4598. } else {
  4599. $start = ($page - 1) * $perpage;
  4600. }
  4601. //取得信息列表
  4602. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4603. foreach ($info_list as $key => $value) {
  4604. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4605. $warehouse = $this->warehouse->read($value['warehouse']);
  4606. $info_list[$key]['warehouse'] = $warehouse['title'];
  4607. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4608. $details = array();
  4609. $cpid = array();
  4610. foreach ($x as $k => $v) {
  4611. if ($v['details'] != '') {
  4612. $details[$v['details']] = $v['details'];
  4613. }
  4614. if ($v['cpid'] != 0) {
  4615. $cpid[$v['cpid']] = $v['cpid'];
  4616. }
  4617. }
  4618. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4619. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4620. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4621. $info_list[$key]['s'] = $s;
  4622. $info_list[$key]['x'] = count($x);
  4623. }
  4624. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4625. $titlename = "<table border=1>
  4626. <tr align='center'>
  4627. <td>仓库</td>
  4628. <td>供应商</td>
  4629. <td>出库位置</td>
  4630. <td>出库编码</td>
  4631. <td>SKU</td>
  4632. <td>产品名</td>
  4633. <td>总剩余库存</td>
  4634. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4635. </tr>
  4636. </table>";
  4637. $filename = $title . ".xls";
  4638. $tail = "";
  4639. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4640. }
  4641. }
  4642. //usps发货清单
  4643. public function _manifest()
  4644. {
  4645. if (isset($_POST['manifest'])) {
  4646. $wltext = $this->input->post('wltext', true);
  4647. $time = time() - 16 * 3600;
  4648. $ptime = strtotime(date('Y-m-d', $time));
  4649. $waybill = array();
  4650. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4651. foreach ($fullorder as $v) {
  4652. $waybill[$v['waybill']] = $v['waybill'];
  4653. }
  4654. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4655. foreach ($fullordersmt as $v) {
  4656. $waybill[$v['waybill']] = $v['waybill'];
  4657. }
  4658. $wltext = explode(';', $wltext);
  4659. foreach ($wltext as $v) {
  4660. if (isset($waybill[$v])) {
  4661. unset($waybill[$v]);
  4662. }
  4663. }
  4664. $data = $this->usps->get_manifest($waybill);
  4665. if (isset($data['Description'])) {
  4666. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4667. exit;
  4668. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4669. $bctime = date('Ymd', time());
  4670. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4671. echo json_encode(array('msg' => $pdf, 'success' => true));
  4672. exit;
  4673. } else {
  4674. echo json_encode(array('msg' => $data, 'success' => false));
  4675. exit;
  4676. }
  4677. }
  4678. }
  4679. public function _pdf($pdf, $title, $bctime)
  4680. {
  4681. $pdf_path = './data/pdf/' . $bctime . '/';
  4682. $file_base64 = $pdf;
  4683. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4684. $file_base64 = base64_decode($file_base64);
  4685. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4686. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4687. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4688. }
  4689. /**
  4690. *
  4691. *
  4692. *
  4693. 进销存占单异常索引
  4694. *
  4695. *
  4696. *
  4697. **/
  4698. public function _abnormal()
  4699. {
  4700. $post = $this->input->post(NULL, TRUE);
  4701. if (isset($post['page'])) {
  4702. $page = $this->input->post('page', true);
  4703. $perpage = $this->input->post('perpage', true);
  4704. $sku = $this->input->post('sku', true);
  4705. $where = "1=1";
  4706. //数据排序
  4707. $order_str = "id desc";
  4708. if (empty($page)) {
  4709. $start = 0;
  4710. $perpage = 1;
  4711. } else {
  4712. $start = ($page - 1) * $perpage;
  4713. }
  4714. //取得信息列表
  4715. $info_list = $this->whlabel->find_all($where, '*');
  4716. $rows = array();
  4717. $list = array();
  4718. foreach ($info_list as $key => $value) {
  4719. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4720. }
  4721. foreach ($rows as $value) {
  4722. $warehouse = $this->warehouse->read($value['warehouse']);
  4723. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4724. $number = $value['number'];
  4725. $ftime = time() - 15 * 24 * 3600;
  4726. if ($value['shop'] != '') {
  4727. $shop = $value['shop'];
  4728. $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');
  4729. $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');
  4730. $order = array_merge($orderdlz, $ordersmt);
  4731. $od = 0;
  4732. $a = '';
  4733. $orid = '';
  4734. foreach ($order as $v) {
  4735. $or = explode('|', ltrim($v['whlabel'], '|'));
  4736. for ($i = 0; $i < count($or); $i++) {
  4737. $orod = explode('-', $or[$i]);
  4738. if ($orod[0] == $number) {
  4739. $od += $orod[1];
  4740. }
  4741. }
  4742. $orid .= $v['number'] . '-';
  4743. }
  4744. } else {
  4745. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4746. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4747. $order = array_merge($orderdlz, $ordersmt);
  4748. $od = 0;
  4749. $a = '';
  4750. $orid = '';
  4751. $qt = array();
  4752. foreach ($order as $v) {
  4753. $or = explode('|', ltrim($v['whlabel'], '|'));
  4754. for ($i = 0; $i < count($or); $i++) {
  4755. $orod = explode('-', $or[$i]);
  4756. if ($orod[0] == $number) {
  4757. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4758. if ($czzs > 0) {
  4759. if (isset($qt[$v['shop']])) {
  4760. if ($qt[$v['shop']] < $orod[1]) {
  4761. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4762. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4763. } else {
  4764. $qt[$v['shop']] -= $orod[1];
  4765. }
  4766. } else {
  4767. $qt[$v['shop']] = $czzs;
  4768. }
  4769. } else {
  4770. $od += $orod[1];
  4771. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4772. }
  4773. }
  4774. }
  4775. }
  4776. }
  4777. $z = $od . '(' . $orid . ')'; //查看订单号
  4778. //$z = $od;
  4779. if ($od > $c) {
  4780. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4781. }
  4782. }
  4783. $listdata = array_slice($list, $start, $perpage);
  4784. $total = count($list);
  4785. $pagenum = ceil($total / $perpage);
  4786. $over = $total - ($start + $perpage);
  4787. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4788. echo json_encode($rows);
  4789. exit;
  4790. }
  4791. $this->_Template('whlabel_abnormal', $this->data);
  4792. }
  4793. /**
  4794. *
  4795. *
  4796. *
  4797. 进销存占单异常索引
  4798. *
  4799. *
  4800. *
  4801. **/
  4802. public function _error()
  4803. {
  4804. $post = $this->input->post(NULL, TRUE);
  4805. if (isset($post['page'])) {
  4806. $page = $this->input->post('page', true);
  4807. $perpage = $this->input->post('perpage', true);
  4808. $sku = $this->input->post('sku', true);
  4809. $warehouse = $this->input->post('warehouse', true);
  4810. $ktime = $this->input->post('ktime', true);
  4811. $jtime = $this->input->post('jtime', true);
  4812. $ktime = strtotime($ktime);
  4813. $jtime = strtotime($jtime);
  4814. $where = "sku != 'Preset'";
  4815. $gj = '';
  4816. if ($sku) {
  4817. $where .= " and sku like '%$sku%'";
  4818. } else {
  4819. if ($ktime && $jtime) {
  4820. $gj = " and time > '$ktime' and time < '$jtime'";
  4821. }
  4822. }
  4823. if ($warehouse) {
  4824. $where .= " and warehouse = '$warehouse'";
  4825. }
  4826. //数据排序
  4827. $order_str = "id desc";
  4828. if (empty($page)) {
  4829. $start = 0;
  4830. $perpage = 1;
  4831. } else {
  4832. $start = ($page - 1) * $perpage;
  4833. }
  4834. //取得信息列表
  4835. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4836. $rows = array();
  4837. $list = array();
  4838. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4839. // foreach ($info_list as $value)
  4840. // {
  4841. // $warehouse = $this->warehouse->read($value['warehouse']);
  4842. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4843. // $number = $value['number'];$ftime = time()-15*24*3600;
  4844. // if($c < 1)
  4845. // {
  4846. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4847. // }
  4848. // }
  4849. $warehouse_list = $this->warehouse->find_all();
  4850. $warehouse_list = array_column($warehouse_list, null, 'id');
  4851. foreach ($info_list as $value) {
  4852. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4853. 'title' => "",
  4854. ];
  4855. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4856. $number = $value['number'];
  4857. $ftime = time() - 15 * 24 * 3600;
  4858. if ($c < 1) {
  4859. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4860. }
  4861. }
  4862. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4863. // $query = $this->db->query($sql);
  4864. // $info_list = $query->result_array();
  4865. // $sql_two = "select title,id from crowd_warehouse";
  4866. // $query_two = $this->db->query($sql_two);
  4867. // $warehouse_list = $query_two->result_array();
  4868. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4869. // foreach ($info_list as $value)
  4870. // {
  4871. // if(isset($warehouse_arr[$value['warehouse']])){
  4872. // $warehouse = $warehouse_arr[$value['warehouse']];
  4873. // }else{
  4874. // $warehouse = [
  4875. // 'id'=>0,
  4876. // 'title'=>"异常",
  4877. // ];
  4878. // }
  4879. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4880. // $number = $value['number'];$ftime = time()-15*24*3600;
  4881. // if($c < 1)
  4882. // {
  4883. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4884. // }
  4885. // }
  4886. $listdata = array_slice($list, $start, $perpage);
  4887. $total = count($list);
  4888. $pagenum = ceil($total / $perpage);
  4889. $over = $total - ($start + $perpage);
  4890. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4891. echo json_encode($rows);
  4892. exit;
  4893. }
  4894. if (isset($post['s'])) {
  4895. $id_arr = $this->input->post('s');
  4896. $id_arr = explode(',', trim($id_arr, ','));
  4897. if (!$id_arr) {
  4898. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4899. exit;
  4900. }
  4901. //循环删除记录
  4902. foreach ($id_arr as $v) {
  4903. $dd = $this->whlabel->read($v);
  4904. if (!isset($dd['id'])) {
  4905. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4906. exit;
  4907. }
  4908. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4909. if (isset($zt[0])) {
  4910. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4911. exit;
  4912. }
  4913. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4914. foreach ($deldd as $vv) {
  4915. $this->whlabel->remove($vv['id']);
  4916. }
  4917. }
  4918. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4919. exit;
  4920. }
  4921. $this->_Template('whlabel_error', $this->data);
  4922. }
  4923. public function _errorexcel()
  4924. {
  4925. $post = $this->input->post(NULL, TRUE);
  4926. if (isset($_GET['page'])) {
  4927. $page = $this->input->get('page', true);
  4928. $perpage = $this->input->get('perpage', true);
  4929. $sku = $this->input->get('sku', true);
  4930. $warehouse = $this->input->get('warehouse', true);
  4931. $ktime = $this->input->get('ktime', true);
  4932. $jtime = $this->input->get('jtime', true);
  4933. $ktime = strtotime($ktime);
  4934. $jtime = strtotime($jtime);
  4935. $where = "sku != 'Preset'";
  4936. $gj = '';
  4937. if ($sku) {
  4938. $where .= " and sku like '%$sku%'";
  4939. } else {
  4940. if ($ktime && $jtime) {
  4941. $gj = " and time > '$ktime' and time < '$jtime'";
  4942. }
  4943. }
  4944. if ($warehouse) {
  4945. $where .= " and warehouse = '$warehouse'";
  4946. }
  4947. //数据排序
  4948. $order_str = "id desc";
  4949. if (empty($page)) {
  4950. $start = 0;
  4951. $perpage = 1;
  4952. } else {
  4953. $start = ($page - 1) * $perpage;
  4954. }
  4955. //取得信息列表
  4956. $rows = array();
  4957. $list = array();
  4958. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4959. foreach ($info_list as $value) {
  4960. $warehouse = $this->warehouse->read($value['warehouse']);
  4961. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4962. $number = $value['number'];
  4963. $ftime = time() - 15 * 24 * 3600;
  4964. if ($c < 1) {
  4965. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4966. }
  4967. }
  4968. $title = "0库存汇总";
  4969. $titlename = "<table border=1>
  4970. <tr align='center'>
  4971. <td>仓库</td>
  4972. <td>SKU</td>
  4973. <td>产品</td>
  4974. <td>当前库存</td>
  4975. </tr>
  4976. </table>";
  4977. $filename = $title . ".xls";
  4978. $tail = "";
  4979. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4980. }
  4981. }
  4982. /**
  4983. *
  4984. *
  4985. * 占单
  4986. *
  4987. *
  4988. **/
  4989. public function _kcyz()
  4990. {
  4991. $post = $this->input->post(NULL, TRUE);
  4992. if (isset($post['warehouse'])) {
  4993. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4994. exit; //不再使用
  4995. $warehouse = $this->input->post('warehouse', true);
  4996. $whlabel = $this->input->post('whlabel', true);
  4997. $id = $this->input->post('id', true);
  4998. $shop = $this->input->post('shop', true);
  4999. $number = $this->input->post('number', true);
  5000. if (!$whlabel || $whlabel == '|') {
  5001. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5002. exit;
  5003. }
  5004. $pp = explode('|', trim($whlabel, '|'));
  5005. $x = 0;
  5006. $save = array();
  5007. foreach ($pp as $va) {
  5008. $num = explode('-', $va);
  5009. if ($number) {
  5010. $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 = '')"); //通用
  5011. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5012. } else {
  5013. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5014. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5015. }
  5016. $x++;
  5017. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5018. $save[] = $x - 1;
  5019. continue; //提前先加X不然出错,所以要减1
  5020. }
  5021. }
  5022. if (isset($save[0])) {
  5023. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5024. exit;
  5025. } else {
  5026. echo json_encode(array('success' => true));
  5027. exit;
  5028. }
  5029. }
  5030. }
  5031. public function _db()
  5032. {
  5033. $post = $this->input->post(NULL, TRUE);
  5034. if (isset($post['page'])) {
  5035. $page = $this->input->post('page', true);
  5036. $perpage = $this->input->post('perpage', true);
  5037. $sku = $this->input->post('sku', true);
  5038. $number = $this->input->post('number', true);
  5039. $warehouse = $this->input->post('warehouse', true);
  5040. $purchase = $this->input->post('purchase', true);
  5041. $orderinfo = $this->input->post('orderinfo', true);
  5042. $waybill = $this->input->post('waybill', true);
  5043. $category = $this->input->post('category', true);
  5044. $size = $this->input->post('size', true);
  5045. $grade = $this->input->post('grade', true);
  5046. $color = $this->input->post('color', true);
  5047. $lowe = $this->input->post('lowe', true);
  5048. $state = $this->input->post('state', true);
  5049. $label = $this->input->post('label', true);
  5050. $timetk = $this->input->post('timetkk', true);
  5051. $timetj = $this->input->post('timetjj', true);
  5052. $timetk = strtotime($timetk);
  5053. $timetj = strtotime($timetj);
  5054. $where = "dbtime > 0";
  5055. if ($timetk && $timetj) {
  5056. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5057. }
  5058. if ($sku) {
  5059. $where .= " and sku = '$sku'";
  5060. }
  5061. if ($warehouse) {
  5062. $where .= " and warehouse = '$warehouse'";
  5063. if ($warehouse == 12) {
  5064. $w = 'specialstock';
  5065. } else {
  5066. $w = 'whlabel';
  5067. }
  5068. }
  5069. if ($purchase) {
  5070. $where .= " and purchase = '$purchase'";
  5071. }
  5072. if ($category) {
  5073. $where .= " and features like '%-$category-%'";
  5074. }
  5075. if ($size) {
  5076. $where .= " and features like '%-$size-%'";
  5077. }
  5078. if ($grade) {
  5079. $where .= " and features like '%-$grade-%'";
  5080. }
  5081. if ($color) {
  5082. $where .= " and features like '%-$color-%'";
  5083. }
  5084. if ($lowe) {
  5085. $where .= " and features like '%-$lowe-%'";
  5086. }
  5087. if ($state != '') {
  5088. $where .= " and state = '$state'";
  5089. }
  5090. //数据排序
  5091. $order_str = "dbtime desc";
  5092. if (empty($page)) {
  5093. $start = 0;
  5094. $perpage = 1;
  5095. } else {
  5096. $start = ($page - 1) * $perpage;
  5097. }
  5098. //取得信息列表
  5099. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5100. foreach ($info_list as $key => $value) {
  5101. $warehouse = $this->$w->read($value['warehouse']);
  5102. $info_list[$key]['warehouse'] = $warehouse['title'];
  5103. $purchase = $this->purchase->read($value['purchase']);
  5104. $info_list[$key]['purchase'] = $purchase['title'];
  5105. if ($value['enter'] != 0) {
  5106. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5107. } else {
  5108. $info_list[$key]['enter'] = "";
  5109. }
  5110. if ($value['dbtime'] != 0) {
  5111. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5112. } else {
  5113. $info_list[$key]['dbtime'] = "";
  5114. }
  5115. if ($value['state'] == 0) {
  5116. $info_list[$key]['state'] = "在库";
  5117. } else if ($value['state'] == 1) {
  5118. $info_list[$key]['state'] = "出库";
  5119. } else if ($value['state'] == 2) {
  5120. $info_list[$key]['state'] = "退库";
  5121. } else if ($value['state'] == 3) {
  5122. $info_list[$key]['state'] = "调拨中";
  5123. } else if ($value['state'] == 4) {
  5124. $info_list[$key]['state'] = "再加工";
  5125. } else if ($value['state'] == 5) {
  5126. $info_list[$key]['state'] = "维修中";
  5127. } else if ($value['state'] == 6) {
  5128. $info_list[$key]['state'] = "盘亏";
  5129. } else if ($value['state'] == 7) {
  5130. $info_list[$key]['state'] = "更换标签";
  5131. } else if ($value['state'] == 8) {
  5132. $info_list[$key]['state'] = "其它";
  5133. } else if ($value['state'] == 9) {
  5134. $info_list[$key]['state'] = "预设";
  5135. }
  5136. }
  5137. $total = $this->whlabel->find_count($where);
  5138. $pagenum = ceil($total / $perpage);
  5139. $over = $total - ($start + $perpage);
  5140. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5141. echo json_encode($rows);
  5142. exit;
  5143. }
  5144. if (isset($post['outsku'])) {
  5145. $time = time();
  5146. $cz = $this->input->post('cz', true);
  5147. $label = $this->input->post('outsku', true);
  5148. $sl = $this->input->post('sl', true);
  5149. $num = $this->input->post('num', true);
  5150. //$warehouse = $this->input->post('warehouse',true);
  5151. if (!$sl) {
  5152. $sl = 1;
  5153. }
  5154. if (!$warehouse) {
  5155. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5156. exit;
  5157. }
  5158. $dblabel = $this->whlabellabel->get_label($label);
  5159. if ($dblabel) {
  5160. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5161. if (count($data) < 1) {
  5162. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5163. exit;
  5164. }
  5165. if (count($data) < $num) {
  5166. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5167. exit;
  5168. }
  5169. for ($i = 0; $i < $sl; $i++) {
  5170. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5171. }
  5172. echo json_encode(array('success' => true));
  5173. exit;
  5174. } else {
  5175. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5176. exit;
  5177. }
  5178. }
  5179. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5180. $this->_Template('whlabel_db', $this->data);
  5181. }
  5182. public function _dbrk()
  5183. {
  5184. $post = $this->input->post(NULL, TRUE);
  5185. if (isset($post['page'])) {
  5186. $page = $this->input->post('page', true);
  5187. $perpage = $this->input->post('perpage', true);
  5188. $sku = $this->input->post('sku', true);
  5189. $number = $this->input->post('number', true);
  5190. $warehouse = $this->input->post('warehouse', true);
  5191. $purchase = $this->input->post('purchase', true);
  5192. $orderinfo = $this->input->post('orderinfo', true);
  5193. $waybill = $this->input->post('waybill', true);
  5194. $category = $this->input->post('category', true);
  5195. $size = $this->input->post('size', true);
  5196. $grade = $this->input->post('grade', true);
  5197. $color = $this->input->post('color', true);
  5198. $lowe = $this->input->post('lowe', true);
  5199. $state = $this->input->post('state', true);
  5200. $label = $this->input->post('label', true);
  5201. $ctime = $this->input->post('ctime', true);
  5202. $timetk = $this->input->post('timetkk', true);
  5203. $timetj = $this->input->post('timetjj', true);
  5204. $timetk = strtotime($timetk);
  5205. $timetj = strtotime($timetj);
  5206. $where = "dbtime > 0";
  5207. if ($timetk && $timetj) {
  5208. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5209. }
  5210. if ($sku) {
  5211. $where .= " and sku = '$sku'";
  5212. }
  5213. if ($warehouse) {
  5214. $where .= " and warehouse = '$warehouse'";
  5215. }
  5216. if ($purchase) {
  5217. $where .= " and purchase = '$purchase'";
  5218. }
  5219. if ($category) {
  5220. $where .= " and features like '%-$category-%'";
  5221. }
  5222. if ($size) {
  5223. $where .= " and features like '%-$size-%'";
  5224. }
  5225. if ($grade) {
  5226. $where .= " and features like '%-$grade-%'";
  5227. }
  5228. if ($color) {
  5229. $where .= " and features like '%-$color-%'";
  5230. }
  5231. if ($lowe) {
  5232. $where .= " and features like '%-$lowe-%'";
  5233. }
  5234. if ($state != '') {
  5235. $where .= " and state = '$state'";
  5236. }
  5237. //数据排序
  5238. $order_str = "dbtime desc";
  5239. if (empty($page)) {
  5240. $start = 0;
  5241. $perpage = 1;
  5242. } else {
  5243. $start = ($page - 1) * $perpage;
  5244. }
  5245. //取得信息列表
  5246. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5247. foreach ($info_list as $key => $value) {
  5248. $warehouse = $this->warehouse->read($value['warehouse']);
  5249. $info_list[$key]['warehouse'] = $warehouse['title'];
  5250. $purchase = $this->purchase->read($value['purchase']);
  5251. $info_list[$key]['purchase'] = $purchase['title'];
  5252. if ($value['enter'] != 0) {
  5253. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5254. } else {
  5255. $info_list[$key]['enter'] = "";
  5256. }
  5257. if ($value['dbtime'] != 0) {
  5258. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5259. } else {
  5260. $info_list[$key]['dbtime'] = "";
  5261. }
  5262. if ($value['state'] == 0) {
  5263. $info_list[$key]['state'] = "在库";
  5264. } else if ($value['state'] == 1) {
  5265. $info_list[$key]['state'] = "出库";
  5266. } else if ($value['state'] == 2) {
  5267. $info_list[$key]['state'] = "退库";
  5268. } else if ($value['state'] == 3) {
  5269. $info_list[$key]['state'] = "调拨中";
  5270. } else if ($value['state'] == 4) {
  5271. $info_list[$key]['state'] = "再加工";
  5272. } else if ($value['state'] == 5) {
  5273. $info_list[$key]['state'] = "维修中";
  5274. } else if ($value['state'] == 6) {
  5275. $info_list[$key]['state'] = "盘亏";
  5276. } else if ($value['state'] == 7) {
  5277. $info_list[$key]['state'] = "更换标签";
  5278. } else if ($value['state'] == 8) {
  5279. $info_list[$key]['state'] = "其它";
  5280. } else if ($value['state'] == 9) {
  5281. $info_list[$key]['state'] = "预设";
  5282. }
  5283. }
  5284. $total = $this->whlabel->find_count($where);
  5285. $pagenum = ceil($total / $perpage);
  5286. $over = $total - ($start + $perpage);
  5287. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5288. echo json_encode($rows);
  5289. exit;
  5290. }
  5291. if (isset($post['rsku'])) {
  5292. $cz = $this->input->post('cz', true);
  5293. $label = $this->input->post('rsku', true);
  5294. $sl = $this->input->post('sl', true);
  5295. $warehouse = $this->input->post('warehouse', true);
  5296. if (!$sl) {
  5297. $sl = 1;
  5298. }
  5299. if (!$warehouse) {
  5300. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5301. exit;
  5302. }
  5303. $dblabel = $this->whlabellabel->get_label($label);
  5304. if ($dblabel) {
  5305. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5306. if (count($data) < 1) {
  5307. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5308. exit;
  5309. }
  5310. if ($sl > count($data)) {
  5311. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5312. exit;
  5313. }
  5314. $time = time();
  5315. for ($i = 0; $i < $sl; $i++) {
  5316. $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']);
  5317. }
  5318. echo json_encode(array('success' => true));
  5319. exit;
  5320. } else {
  5321. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5322. exit;
  5323. }
  5324. }
  5325. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5326. $this->_Template('whlabel_dbrk', $this->data);
  5327. }
  5328. public function _whlabelczdc()
  5329. {
  5330. if (isset($_GET['excel'])) {
  5331. //数据排序
  5332. $order_str = "id desc";
  5333. if (empty($page)) {
  5334. $start = 0;
  5335. $perpage = 1;
  5336. } else {
  5337. $start = ($page - 1) * $perpage;
  5338. }
  5339. $state = $this->input->get('state', true);
  5340. $sku = $this->input->get('sku', true);
  5341. $ctime = $this->input->get('ctime', true);
  5342. $category = $this->input->get('category', true);
  5343. $size = $this->input->get('size', true);
  5344. $grade = $this->input->get('grade', true);
  5345. $color = $this->input->get('color', true);
  5346. $lowe = $this->input->get('lowe', true);
  5347. $timetk = $this->input->get('timetkk', true);
  5348. $timetj = $this->input->get('timetjj', true);
  5349. $timetk = strtotime($timetk);
  5350. $timetj = strtotime($timetj);
  5351. $where = "dbtime > 0";
  5352. if ($timetk && $timetj) {
  5353. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5354. }
  5355. if ($category) {
  5356. $where .= " and features like '%-$category-%'";
  5357. }
  5358. if ($size) {
  5359. $where .= " and features like '%-$size-%'";
  5360. }
  5361. if ($grade) {
  5362. $where .= " and features like '%-$grade-%'";
  5363. }
  5364. if ($color) {
  5365. $where .= " and features like '%-$color-%'";
  5366. }
  5367. if ($lowe) {
  5368. $where .= " and features like '%-$lowe-%'";
  5369. }
  5370. //取得信息列表
  5371. $info_list = $this->whlabel->find_all($where, '*');
  5372. $rows = array();
  5373. $list = array();
  5374. foreach ($info_list as $key => $value) {
  5375. $rows[$value['sku']] = $value; //所有数据sku
  5376. }
  5377. foreach ($rows as $value) {
  5378. $warehouse = $this->warehouse->read($value['warehouse']);
  5379. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5380. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5381. if ($value['orderinfo'] == 0) {
  5382. $info_list[$key]['orderinfo'] = "";
  5383. }
  5384. if ($value['waybill'] == 0) {
  5385. $info_list[$key]['waybill'] = "";
  5386. }
  5387. if ($value['state'] == 0) {
  5388. $value['state'] = "在库";
  5389. } else if ($value['state'] == 3) {
  5390. $value['state'] = "调拨中";
  5391. }
  5392. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5393. }
  5394. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5395. $titlename = "<table border=1>
  5396. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5397. <tr align='center'>
  5398. <td>SKU</td>
  5399. <td>产品</td>
  5400. <td>调拨数量</td>
  5401. <td>入库数量</td>
  5402. </tr>
  5403. </table>";
  5404. $filename = $title . ".xls";
  5405. $tail = "";
  5406. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5407. }
  5408. }
  5409. public function _print($arg_array)
  5410. {
  5411. if (isset($_SESSION['api'])) {
  5412. $user = $this->user->get_api($_SESSION['api']);
  5413. $usp = $user;
  5414. $fgshop = "";
  5415. $sid = "";
  5416. $wid = "";
  5417. $wtype = "";
  5418. $usersp = explode('|', trim($user['shop'], '|'));
  5419. $userwh = explode('|', trim($user['warehouse'], '|'));
  5420. foreach ($usersp as $value) {
  5421. $fgshop .= " shop = " . $value . " or";
  5422. $sid .= " id = " . $value . " or";
  5423. }
  5424. foreach ($userwh as $value) {
  5425. $wid .= " id = " . $value . " or";
  5426. $wtype .= " type = " . $value . " or";
  5427. }
  5428. }
  5429. $post = $this->input->post(NULL, TRUE);
  5430. if (isset($post['tmsku'])) {
  5431. $tmsku = $this->input->post('tmsku', true);
  5432. if (is_numeric($tmsku)) {
  5433. $yyh = $this->whlabellabel->get_label($tmsku);
  5434. } else {
  5435. $yyh = $this->whlabellabel->get_sku($tmsku);
  5436. }
  5437. if ($yyh) {
  5438. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5439. exit;
  5440. } else {
  5441. echo json_encode(array('success' => false));
  5442. exit;
  5443. }
  5444. }
  5445. $classid = $this->classid->sku();
  5446. $pm = $classid;
  5447. $scsku = $classid;
  5448. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5449. if (isset($post['warehouse'])) {
  5450. if ($post['warehouse']) {
  5451. $list = array();
  5452. $num = "";
  5453. $title = "";
  5454. $features = "";
  5455. $order = 0;
  5456. $post['shop'] = '';
  5457. $brand = $this->input->post('brand', true);
  5458. if ($brand != '0,') {
  5459. $b = $this->brand->read(rtrim($brand, ','));
  5460. if ($b) {
  5461. $post['shop'] = str_replace('|', ',', $b['shop']);
  5462. }
  5463. }
  5464. $post['details'] = $this->input->post('details', true); //打印数量
  5465. $xbqnum = $this->input->post('xbqnum', true);
  5466. $post['purchase'] = $this->input->post('purchase', true);
  5467. $post['warehouse'] = $this->input->post('warehouse', true);
  5468. $post['purchase'] = $this->input->post('purchase', true);
  5469. $post['retreatwarehouse'] = $post['warehouse'];
  5470. $post['cpbz'] = $this->input->post('cpbz', true);
  5471. $post['state'] = 9;
  5472. $category = $this->input->post('category', true);
  5473. $list['category'] = $category;
  5474. $list['hairtype'] = $this->input->post('hairtype', true);
  5475. $list['grade'] = $this->input->post('grade', true);
  5476. $size = $this->input->post('size', true);
  5477. $list['size'] = rtrim($size, ',');
  5478. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5479. $list['extension'] = $this->input->post('extension', true);
  5480. if ($category == 1297) {
  5481. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5482. }
  5483. if ($category == 1702) {
  5484. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5485. $list['syother'] = $this->input->post('syother', true);
  5486. }
  5487. if ($category == 133) {
  5488. $list['fittype'] = $this->input->post('fittype', true);
  5489. $list['acother'] = $this->input->post('acother', true);
  5490. }
  5491. $list['color'] = $this->input->post('color', true);
  5492. $list['lowe'] = $this->input->post('lowe', true);
  5493. if ($category == 127) {
  5494. $list['type'] = $this->input->post('type', true);
  5495. $list['headroad'] = $this->input->post('headroad', true);
  5496. $list['density'] = $this->input->post('density', true);
  5497. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5498. $list['lacesize'] = $this->input->post('lacesize', true);
  5499. }
  5500. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5501. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5502. }
  5503. if ($category == 128) {
  5504. $list['lacetype'] = $this->input->post('lacetype', true);
  5505. $list['haircap'] = $this->input->post('haircap', true);
  5506. $list['density'] = $this->input->post('density', true);
  5507. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5508. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5509. $list['wigother'] = $this->input->post('wigother', true);
  5510. $list['wigother1'] = $this->input->post('wigother1', true);
  5511. $list['wigother2'] = $this->input->post('wigother2', true);
  5512. }
  5513. if ($category == 129) {
  5514. $list['wide'] = $this->input->post('wide', true);
  5515. }
  5516. if ($category == 131) {
  5517. $list['gifttype'] = $this->input->post('gifttype', true);
  5518. $list['giftother'] = $this->input->post('giftother', true);
  5519. }
  5520. if ($category == 134) {
  5521. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5522. }
  5523. if ($category == 1297) {
  5524. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5525. $list['sywigother'] = $this->input->post('sywigother', true);
  5526. }
  5527. if ($category == 130 || $category == 133 || $category == 1702) {
  5528. $list['items'] = $this->input->post('items', true);
  5529. $list['weight'] = $this->input->post('weight', true);
  5530. }
  5531. if ($category == 1702) {
  5532. $list['syhairther'] = $this->input->post('syhairther', true);
  5533. }
  5534. foreach ($list as $k => $v) {
  5535. if ($v != 0) {
  5536. $num .= $v;
  5537. $features .= $v . '-';
  5538. $post[$k] = $v;
  5539. $typeclass = $this->typeclass->read($v);
  5540. if (isset($pm[$typeclass['classid']])) {
  5541. if (stripos($typeclass['zh'], '|') !== false) {
  5542. $exzh = explode('|', $typeclass['zh']);
  5543. $pm[$typeclass['classid']] = $exzh[0];
  5544. } else {
  5545. $pm[$typeclass['classid']] = $typeclass['zh'];
  5546. }
  5547. }
  5548. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5549. if ($k != 'size') {
  5550. $title .= $typeclass['title'] . " ";
  5551. }
  5552. }
  5553. }
  5554. $typeclass = $this->typeclass->read($list['size']);
  5555. $title .= $typeclass['title'];
  5556. $time = time();
  5557. $post['title'] = rtrim($title, ' ');
  5558. $post['number'] = $num;
  5559. $post['features'] = '-' . $features;
  5560. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5561. $featurespp = explode('-', trim($featurespp, '-'));
  5562. if (isset($featurespp[5])) {
  5563. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5564. } else {
  5565. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5566. }
  5567. $post['enter'] = $time;
  5568. $post['time'] = $time; //操作时间
  5569. $scsku = implode("-", $scsku);
  5570. $zh = implode(" ", $pm);
  5571. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5572. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5573. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5574. $post['sku'] = $bqsku;
  5575. $label = time() . rand(0, 9);
  5576. $post['label'] = $label;
  5577. $cpid = $this->whlabellabel->find_count();
  5578. $post['cpid'] = $cpid + 1;
  5579. $cpid = $post['cpid'];
  5580. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5581. //if($whlabelbarcode)
  5582. //{
  5583. //$post['label'] = $whlabelbarcode['label'];
  5584. //if(!$this->whlabellabel->insert($post))
  5585. //{
  5586. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5587. //}
  5588. //}
  5589. //else
  5590. //{
  5591. $this->db->trans_begin();
  5592. $this->whlabellabel->insert($post);
  5593. //$this->whlabelbarcode->insert($post);
  5594. if ($this->db->trans_status() === TRUE) {
  5595. $this->db->trans_commit();
  5596. } else {
  5597. $this->db->trans_rollback();
  5598. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5599. exit;
  5600. }
  5601. //}
  5602. $warehouse_name = "";
  5603. $warehouse = $post['warehouse'];
  5604. if($warehouse == 12){
  5605. $warehouse_name = "特殊库存库";
  5606. }
  5607. // if($warehouse == 13){
  5608. // $warehouse_name = "许昌仓";
  5609. // }
  5610. // if($warehouse == 5){
  5611. // $warehouse_name = "美国店";
  5612. // }
  5613. // if($warehouse == 16){
  5614. // $warehouse_name = "定制头套仓";
  5615. // }
  5616. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5617. if(!empty($warehouse_name)){
  5618. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5619. }
  5620. $purchase = $this->purchase->read($post['purchase']);
  5621. 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));
  5622. exit; //特殊仓目前不需要仓库选项
  5623. }
  5624. }
  5625. if (isset($_SESSION['api'])) {
  5626. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5627. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5628. $this->data['wlshop'] = $wlshop;
  5629. $this->data['warehouse'] = $warehouse;
  5630. }
  5631. $whlabelwz = $this->whlabelwz->find_all();
  5632. $this->data['whlabelwz'] = $whlabelwz;
  5633. $this->_Template('whlabel_print', $this->data);
  5634. }
  5635. public function _usaprint($arg_array)
  5636. {
  5637. if (isset($_SESSION['api'])) {
  5638. $user = $this->user->get_api($_SESSION['api']);
  5639. $usp = $user;
  5640. $fgshop = "";
  5641. $sid = "";
  5642. $wid = "";
  5643. $wtype = "";
  5644. $usersp = explode('|', trim($user['shop'], '|'));
  5645. $userwh = explode('|', trim($user['warehouse'], '|'));
  5646. foreach ($usersp as $value) {
  5647. $fgshop .= " shop = " . $value . " or";
  5648. $sid .= " id = " . $value . " or";
  5649. }
  5650. foreach ($userwh as $value) {
  5651. $wid .= " id = " . $value . " or";
  5652. $wtype .= " type = " . $value . " or";
  5653. }
  5654. }
  5655. $post = $this->input->post(NULL, TRUE);
  5656. if (isset($post['tmsku'])) {
  5657. $tmsku = $this->input->post('tmsku', true);
  5658. if (is_numeric($tmsku)) {
  5659. $yyh = $this->whlabellabel->get_label($tmsku);
  5660. } else {
  5661. $yyh = $this->whlabellabel->get_sku($tmsku);
  5662. }
  5663. if ($yyh) {
  5664. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5665. exit;
  5666. } else {
  5667. echo json_encode(array('success' => false));
  5668. exit;
  5669. }
  5670. }
  5671. $classid = $this->classid->sku();
  5672. $pm = $classid;
  5673. $scsku = $classid;
  5674. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5675. if (isset($post['warehouse'])) {
  5676. if ($post['warehouse']) {
  5677. $list = array();
  5678. $num = "";
  5679. $title = "";
  5680. $features = "";
  5681. $order = 0;
  5682. $post['shop'] = '';
  5683. $brand = $this->input->post('brand', true);
  5684. if ($brand != '0,') {
  5685. $b = $this->brand->read(rtrim($brand, ','));
  5686. if ($b) {
  5687. $post['shop'] = str_replace('|', ',', $b['shop']);
  5688. }
  5689. }
  5690. $post['details'] = $this->input->post('details', true); //打印数量
  5691. $xbqnum = $this->input->post('xbqnum', true);
  5692. $post['purchase'] = $this->input->post('purchase', true);
  5693. $post['warehouse'] = $this->input->post('warehouse', true);
  5694. $post['purchase'] = $this->input->post('purchase', true);
  5695. $post['retreatwarehouse'] = $post['warehouse'];
  5696. $post['cpbz'] = $this->input->post('cpbz', true);
  5697. $post['state'] = 9;
  5698. $category = $this->input->post('category', true);
  5699. $list['category'] = $category;
  5700. $list['hairtype'] = $this->input->post('hairtype', true);
  5701. $list['grade'] = $this->input->post('grade', true);
  5702. $size = $this->input->post('size', true);
  5703. $list['size'] = rtrim($size, ',');
  5704. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5705. $list['extension'] = $this->input->post('extension', true);
  5706. if ($category == 1297) {
  5707. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5708. }
  5709. if ($category == 1702) {
  5710. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5711. $list['syother'] = $this->input->post('syother', true);
  5712. }
  5713. if ($category == 133) {
  5714. $list['fittype'] = $this->input->post('fittype', true);
  5715. $list['acother'] = $this->input->post('acother', true);
  5716. }
  5717. $list['color'] = $this->input->post('color', true);
  5718. $list['lowe'] = $this->input->post('lowe', true);
  5719. if ($category == 127) {
  5720. $list['type'] = $this->input->post('type', true);
  5721. $list['headroad'] = $this->input->post('headroad', true);
  5722. $list['density'] = $this->input->post('density', true);
  5723. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5724. $list['lacesize'] = $this->input->post('lacesize', true);
  5725. }
  5726. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5727. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5728. }
  5729. if ($category == 128) {
  5730. $list['lacetype'] = $this->input->post('lacetype', true);
  5731. $list['haircap'] = $this->input->post('haircap', true);
  5732. $list['density'] = $this->input->post('density', true);
  5733. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5734. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5735. $list['wigother'] = $this->input->post('wigother', true);
  5736. $list['wigother1'] = $this->input->post('wigother1', true);
  5737. $list['wigother2'] = $this->input->post('wigother2', true);
  5738. }
  5739. if ($category == 129) {
  5740. $list['wide'] = $this->input->post('wide', true);
  5741. }
  5742. if ($category == 131) {
  5743. $list['gifttype'] = $this->input->post('gifttype', true);
  5744. $list['giftother'] = $this->input->post('giftother', true);
  5745. }
  5746. if ($category == 134) {
  5747. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5748. }
  5749. if ($category == 1297) {
  5750. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5751. $list['sywigother'] = $this->input->post('sywigother', true);
  5752. }
  5753. if ($category == 130 || $category == 133 || $category == 1702) {
  5754. $list['items'] = $this->input->post('items', true);
  5755. $list['weight'] = $this->input->post('weight', true);
  5756. }
  5757. if ($category == 1702) {
  5758. $list['syhairther'] = $this->input->post('syhairther', true);
  5759. }
  5760. foreach ($list as $k => $v) {
  5761. if ($v != 0) {
  5762. $num .= $v;
  5763. $features .= $v . '-';
  5764. $post[$k] = $v;
  5765. $typeclass = $this->typeclass->read($v);
  5766. if (isset($pm[$typeclass['classid']])) {
  5767. if (stripos($typeclass['zh'], '|') !== false) {
  5768. $exzh = explode('|', $typeclass['zh']);
  5769. $pm[$typeclass['classid']] = $exzh[0];
  5770. } else {
  5771. $pm[$typeclass['classid']] = $typeclass['zh'];
  5772. }
  5773. }
  5774. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5775. if ($k != 'size') {
  5776. $title .= $typeclass['title'] . " ";
  5777. }
  5778. }
  5779. }
  5780. $typeclass = $this->typeclass->read($list['size']);
  5781. $title .= $typeclass['title'];
  5782. $time = time();
  5783. $post['title'] = rtrim($title, ' ');
  5784. $post['number'] = $num;
  5785. $post['features'] = '-' . $features;
  5786. $fp = $this->whlabel->get_features($post['features']);
  5787. if (!$fp) {
  5788. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5789. exit;
  5790. }
  5791. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5792. $featurespp = explode('-', trim($featurespp, '-'));
  5793. if (isset($featurespp[5])) {
  5794. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5795. } else {
  5796. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5797. }
  5798. $post['enter'] = $time;
  5799. $post['time'] = $time; //操作时间
  5800. $scsku = implode("-", $scsku);
  5801. $zh = implode(" ", $pm);
  5802. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5803. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5804. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5805. $post['sku'] = $fp['sku'];
  5806. $post['label'] = $fp['sku'];
  5807. $cpid = $this->whlabellabel->find_count();
  5808. $post['cpid'] = $cpid + 1;
  5809. $cpid = $post['cpid'];
  5810. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5811. //if($whlabelbarcode)
  5812. //{
  5813. //$post['label'] = $whlabelbarcode['label'];
  5814. //if(!$this->whlabellabel->insert($post))
  5815. //{
  5816. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5817. //}
  5818. //}
  5819. //else
  5820. //{
  5821. $this->db->trans_begin();
  5822. $this->whlabellabel->insert($post);
  5823. //$this->whlabelbarcode->insert($post);
  5824. if ($this->db->trans_status() === TRUE) {
  5825. $this->db->trans_commit();
  5826. } else {
  5827. $this->db->trans_rollback();
  5828. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5829. exit;
  5830. }
  5831. //}
  5832. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5833. $purchase = $this->purchase->read($post['purchase']);
  5834. 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));
  5835. exit; //特殊仓目前不需要仓库选项
  5836. }
  5837. }
  5838. if (isset($_SESSION['api'])) {
  5839. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5840. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5841. $this->data['wlshop'] = $wlshop;
  5842. $this->data['warehouse'] = $warehouse;
  5843. }
  5844. $whlabelwz = $this->whlabelwz->find_all();
  5845. $this->data['whlabelwz'] = $whlabelwz;
  5846. $this->_Template('whlabel_usaprint', $this->data);
  5847. }
  5848. public function _printrk($arg_array)
  5849. {
  5850. $prc = array();
  5851. $purchase = $this->purchase->find_all();
  5852. foreach ($purchase as $k => $v) {
  5853. $prc[$v['id']] = $v['title'];
  5854. }
  5855. $post = $this->input->post(NULL, TRUE);
  5856. if (isset($post['page'])) {
  5857. $page = $this->input->post('page', true);
  5858. $perpage = $this->input->post('perpage', true);
  5859. $sku = $this->input->post('sku', true);
  5860. $bs = $this->input->post('bs', true);
  5861. $number = $this->input->post('number', true);
  5862. $warehouse = $this->input->post('warehouse', true);
  5863. $purchase = $this->input->post('purchase', true);
  5864. $orderinfo = $this->input->post('orderinfo', true);
  5865. $waybill = $this->input->post('waybill', true);
  5866. $category = $this->input->post('category', true);
  5867. $size = $this->input->post('size', true);
  5868. $grade = $this->input->post('grade', true);
  5869. $color = $this->input->post('color', true);
  5870. $lowe = $this->input->post('lowe', true);
  5871. $state = $this->input->post('state', true);
  5872. $label = $this->input->post('label', true);
  5873. $timetk = $this->input->post('ktime', true);
  5874. $timetj = $this->input->post('jtime', true);
  5875. $timetk = strtotime($timetk);
  5876. $timetj = strtotime($timetj);
  5877. $where = "1=1 ";
  5878. if ($timetk && $timetj) {
  5879. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5880. }
  5881. if ($sku) {
  5882. $where .= " and sku = '$sku'";
  5883. }
  5884. if ($bs != '') {
  5885. $where .= " and bs = '$bs'";
  5886. }
  5887. if ($number) {
  5888. $where .= " and number = '$number'";
  5889. }
  5890. if ($warehouse) {
  5891. $where .= " and warehouse = '$warehouse'";
  5892. }
  5893. if ($purchase) {
  5894. $where .= " and purchase = '$purchase'";
  5895. }
  5896. if ($orderinfo) {
  5897. $where .= " and orderinfo = '$orderinfo'";
  5898. }
  5899. if ($waybill) {
  5900. $where .= " and waybill = '$waybill'";
  5901. }
  5902. if ($category) {
  5903. $where .= " and features like '%-$category-%'";
  5904. }
  5905. if ($size) {
  5906. $where .= " and features like '%-$size-%'";
  5907. }
  5908. if ($grade) {
  5909. $where .= " and features like '%-$grade-%'";
  5910. }
  5911. if ($color) {
  5912. $where .= " and features like '%-$color-%'";
  5913. }
  5914. if ($lowe) {
  5915. $where .= " and features like '%-$lowe-%'";
  5916. }
  5917. if ($label) {
  5918. $where .= " and label = '$label'";
  5919. }
  5920. if ($state || $state == 0) {
  5921. $where .= " and state = '$state'";
  5922. }
  5923. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5924. //数据排序
  5925. $order_str = "enter desc";
  5926. if (empty($page)) {
  5927. $start = 0;
  5928. $perpage = 1;
  5929. } else {
  5930. $start = ($page - 1) * $perpage;
  5931. }
  5932. //取得信息列表
  5933. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5934. foreach ($info_list as $key => $value) {
  5935. $warehouse = $this->warehouse->read($value['warehouse']);
  5936. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5937. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5938. if ($value['state'] == 0) {
  5939. $info_list[$key]['state'] = "在库";
  5940. } else if ($value['state'] == 1) {
  5941. $info_list[$key]['state'] = "出库";
  5942. } else if ($value['state'] == 2) {
  5943. $info_list[$key]['state'] = "退库";
  5944. } else if ($value['state'] == 3) {
  5945. $info_list[$key]['state'] = "调拨中";
  5946. } else if ($value['state'] == 4) {
  5947. $info_list[$key]['state'] = "再加工";
  5948. } else if ($value['state'] == 5) {
  5949. $info_list[$key]['state'] = "维修中";
  5950. } else if ($value['state'] == 6) {
  5951. $info_list[$key]['state'] = "盘亏";
  5952. } else if ($value['state'] == 7) {
  5953. $info_list[$key]['state'] = "更换标签";
  5954. } else if ($value['state'] == 8) {
  5955. $info_list[$key]['state'] = "其它";
  5956. } else if ($value['state'] == 9) {
  5957. $info_list[$key]['state'] = "预设";
  5958. } else if ($value['state'] == 10) {
  5959. $info_list[$key]['state'] = "美店零售";
  5960. }
  5961. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5962. }
  5963. $total = $this->$ck->find_count($where);
  5964. $pagenum = ceil($total / $perpage);
  5965. $over = $total - ($start + $perpage);
  5966. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5967. echo json_encode($rows);
  5968. exit;
  5969. }
  5970. if (isset($post['tmsku'])) {
  5971. $time = time();
  5972. $tmsku = $this->input->post('tmsku', true);
  5973. //$post['shop'] = $this->input->post('shop',true);
  5974. $num = $this->input->post('num', true);
  5975. $rktype = $this->input->post('rktype', true);
  5976. if ($num > 200) {
  5977. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5978. exit;
  5979. }
  5980. if (!$rktype) {
  5981. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5982. }
  5983. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5984. /**
  5985. $wz = array();
  5986. foreach ($rk as $key=>$value)
  5987. {
  5988. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5989. }
  5990. if(count($wz) > 1)
  5991. {
  5992. $wz = array_values($wz);
  5993. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5994. }
  5995. **/
  5996. if (isset($rk[0]['purchase'])) {
  5997. $rk = $rk[0];
  5998. $j = 0;
  5999. $post['purchase'] = $rk['purchase'];
  6000. $post['warehouse'] = $rk['warehouse'];
  6001. $post['retreatwarehouse'] = $rk['warehouse'];
  6002. $post['sku'] = $rk['sku'];
  6003. $post['number'] = $rk['number'];
  6004. $post['features'] = $rk['features'];
  6005. $post['title'] = $rk['title'];
  6006. $post['enter'] = $time;
  6007. $post['time'] = $time;
  6008. $post['bs'] = 1;
  6009. $post['shop'] = $rk['shop'];
  6010. $post['details'] = $rk['details'];
  6011. $post['cpid'] = $rk['cpid'];
  6012. $post['cpbz'] = $rk['cpbz'];
  6013. //$post['rktype'] = $rktype;
  6014. $warehouse = $this->warehouse->read($rk['warehouse']);
  6015. if ($warehouse['bdck'] == '') {
  6016. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6017. exit;
  6018. } else {
  6019. $bdck = $warehouse['bdck'];
  6020. }
  6021. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6022. if (isset($pdwz['details'])) {
  6023. if ($pdwz['details'] != $post['details']) {
  6024. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6025. exit;
  6026. }
  6027. }
  6028. $post['featurespp'] = $rk['featurespp'];
  6029. if ($post['warehouse'] == '5') {
  6030. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6031. if ($yza) {
  6032. if ($post['features'] != $yza[0]['features']) {
  6033. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6034. exit;
  6035. }
  6036. }
  6037. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6038. if ($yzb) {
  6039. if ($post['sku'] != $yzb[0]['sku']) {
  6040. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6041. exit;
  6042. }
  6043. }
  6044. }
  6045. for ($i = 0; $i < $num; $i++) {
  6046. $post['label'] = time() . rand(100, 999) . $i;
  6047. if ($this->$bdck->insert($post)) {
  6048. $j++;
  6049. }
  6050. }
  6051. /**
  6052. if($post['warehouse'] != 12)
  6053. {
  6054. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6055. }
  6056. **/
  6057. if ($j == $num) {
  6058. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6059. exit;
  6060. } else {
  6061. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6062. exit;
  6063. }
  6064. } else {
  6065. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6066. exit;
  6067. }
  6068. }
  6069. $this->_Template('whlabel_printrk', $this->data);
  6070. }
  6071. public function _printxzrk($arg_array)
  6072. {
  6073. $post = $this->input->post(NULL, TRUE);
  6074. if (isset($post['wzid'])) {
  6075. $time = time();
  6076. $id = $this->input->post('wzid', true);
  6077. //$post['shop'] = $this->input->post('shop',true);
  6078. $num = 1;
  6079. $rk = $this->whlabellabel->read($id);
  6080. if (isset($rk['purchase'])) {
  6081. $x = 0;
  6082. $post['purchase'] = $rk['purchase'];
  6083. $post['warehouse'] = $rk['warehouse'];
  6084. $post['retreatwarehouse'] = $rk['warehouse'];
  6085. $post['sku'] = $rk['sku'];
  6086. $post['number'] = $rk['number'];
  6087. $post['features'] = $rk['features'];
  6088. $post['title'] = $rk['title'];
  6089. $post['enter'] = $time;
  6090. $post['time'] = $time;
  6091. $post['bs'] = 1;
  6092. $post['shop'] = $rk['shop'];
  6093. $post['details'] = $rk['details'];
  6094. $post['cpid'] = $rk['cpid'];
  6095. $post['cpbz'] = $rk['cpbz'];
  6096. $warehouse = $this->warehouse->read($rk['warehouse']);
  6097. if ($warehouse['bdck'] == '') {
  6098. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6099. exit;
  6100. } else {
  6101. $bdck = $warehouse['bdck'];
  6102. }
  6103. $post['featurespp'] = $rk['featurespp'];
  6104. $this->db->trans_begin();
  6105. for ($i = 0; $i < $num; $i++) {
  6106. $post['label'] = time() . rand(100, 999) . $i;
  6107. $this->$bdck->insert($post);
  6108. }
  6109. /**
  6110. if($post['warehouse'] != 12)
  6111. {
  6112. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6113. }
  6114. **/
  6115. if ($this->db->trans_status() === TRUE) {
  6116. $this->db->trans_commit();
  6117. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6118. exit;
  6119. } else {
  6120. $this->db->trans_rollback();
  6121. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6122. exit;
  6123. }
  6124. } else {
  6125. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6126. exit;
  6127. }
  6128. }
  6129. }
  6130. public function _printck($arg_array)
  6131. {
  6132. $prc = array();
  6133. $purchase = $this->purchase->find_all();
  6134. foreach ($purchase as $k => $v) {
  6135. $prc[$v['id']] = $v['title'];
  6136. }
  6137. $post = $this->input->post(NULL, TRUE);
  6138. if (isset($post['page'])) {
  6139. $page = $this->input->post('page', true);
  6140. $perpage = $this->input->post('perpage', true);
  6141. $sku = $this->input->post('sku', true);
  6142. $bs = $this->input->post('bs', true);
  6143. $number = $this->input->post('number', true);
  6144. $warehouse = $this->input->post('warehouse', true);
  6145. $purchase = $this->input->post('purchase', true);
  6146. $orderinfo = $this->input->post('orderinfo', true);
  6147. $waybill = $this->input->post('waybill', true);
  6148. $category = $this->input->post('category', true);
  6149. $size = $this->input->post('size', true);
  6150. $grade = $this->input->post('grade', true);
  6151. $color = $this->input->post('color', true);
  6152. $lowe = $this->input->post('lowe', true);
  6153. $state = $this->input->post('state', true);
  6154. $label = $this->input->post('label', true);
  6155. $timetk = $this->input->post('ktime', true);
  6156. $timetj = $this->input->post('jtime', true);
  6157. $timetk = strtotime($timetk);
  6158. $timetj = strtotime($timetj);
  6159. $where = "state=1 ";
  6160. if ($timetk && $timetj) {
  6161. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6162. }
  6163. if ($sku) {
  6164. $where .= " and sku = '$sku'";
  6165. }
  6166. if ($bs != '') {
  6167. $where .= " and bs = '$bs'";
  6168. }
  6169. if ($number) {
  6170. $where .= " and number = '$number'";
  6171. }
  6172. if ($warehouse) {
  6173. $where .= " and warehouse = '$warehouse'";
  6174. }
  6175. if ($purchase) {
  6176. $where .= " and purchase = '$purchase'";
  6177. }
  6178. if ($orderinfo) {
  6179. $where .= " and orderinfo = '$orderinfo'";
  6180. }
  6181. if ($waybill) {
  6182. $where .= " and waybill = '$waybill'";
  6183. }
  6184. if ($category) {
  6185. $where .= " and features like '%-$category-%'";
  6186. }
  6187. if ($size) {
  6188. $where .= " and features like '%-$size-%'";
  6189. }
  6190. if ($grade) {
  6191. $where .= " and features like '%-$grade-%'";
  6192. }
  6193. if ($color) {
  6194. $where .= " and features like '%-$color-%'";
  6195. }
  6196. if ($lowe) {
  6197. $where .= " and features like '%-$lowe-%'";
  6198. }
  6199. if ($label) {
  6200. $where .= " and label = '$label'";
  6201. }
  6202. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6203. //数据排序
  6204. $order_str = "outk desc";
  6205. if (empty($page)) {
  6206. $start = 0;
  6207. $perpage = 1;
  6208. } else {
  6209. $start = ($page - 1) * $perpage;
  6210. }
  6211. //取得信息列表
  6212. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6213. foreach ($info_list as $key => $value) {
  6214. $warehouse = $this->warehouse->read($value['warehouse']);
  6215. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6216. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6217. if ($value['state'] == 0) {
  6218. $info_list[$key]['state'] = "在库";
  6219. } else if ($value['state'] == 1) {
  6220. $info_list[$key]['state'] = "出库";
  6221. } else if ($value['state'] == 2) {
  6222. $info_list[$key]['state'] = "退库";
  6223. } else if ($value['state'] == 3) {
  6224. $info_list[$key]['state'] = "调拨中";
  6225. } else if ($value['state'] == 4) {
  6226. $info_list[$key]['state'] = "再加工";
  6227. } else if ($value['state'] == 5) {
  6228. $info_list[$key]['state'] = "维修中";
  6229. } else if ($value['state'] == 6) {
  6230. $info_list[$key]['state'] = "盘亏";
  6231. } else if ($value['state'] == 7) {
  6232. $info_list[$key]['state'] = "更换标签";
  6233. } else if ($value['state'] == 8) {
  6234. $info_list[$key]['state'] = "其它";
  6235. } else if ($value['state'] == 9) {
  6236. $info_list[$key]['state'] = "预设";
  6237. } else if ($value['state'] == 10) {
  6238. $info_list[$key]['state'] = "美店零售";
  6239. }
  6240. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6241. }
  6242. $total = $this->$ck->find_count($where);
  6243. $pagenum = ceil($total / $perpage);
  6244. $over = $total - ($start + $perpage);
  6245. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6246. echo json_encode($rows);
  6247. exit;
  6248. }
  6249. if (isset($post['tmsku'])) {
  6250. $time = time();
  6251. $tmsku = $this->input->post('tmsku', true);
  6252. //$post['shop'] = $this->input->post('shop',true);
  6253. $num = $this->input->post('num', true);
  6254. $cktype = $this->input->post('cktype', true);
  6255. $label = $this->whlabellabel->get_label($tmsku);
  6256. if (!$cktype) {
  6257. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6258. }
  6259. if (!isset($label['warehouse'])) {
  6260. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6261. exit;
  6262. }
  6263. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6264. if (stripos($label['features'], '-126-') !== false) {
  6265. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6266. } else {
  6267. $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 = ''");
  6268. }
  6269. $j = 0;
  6270. if (count($ck) >= $num) {
  6271. for ($i = 0; $i < $num; $i++) {
  6272. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6273. {
  6274. $j++;
  6275. }
  6276. }
  6277. if ($j == $num) {
  6278. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6279. exit;
  6280. } else {
  6281. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6282. exit;
  6283. }
  6284. } else {
  6285. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6286. exit;
  6287. }
  6288. }
  6289. if(isset($_SESSION['api']))
  6290. {
  6291. $user = $this->user->get_api($_SESSION['api']);
  6292. if(in_array($user['power'],[1,27])){
  6293. $vip = 1;
  6294. }
  6295. }
  6296. else
  6297. {
  6298. $vip = 0;
  6299. header('Location: /');exit;
  6300. }
  6301. $this->data['vip'] = $vip;
  6302. $this->_Template('whlabel_printck', $this->data);
  6303. }
  6304. public function _printexcel()
  6305. {
  6306. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6307. $config['upload_path'] = '.' . $dir;
  6308. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6309. $config['allowed_types'] = 'xls|xlsx|csv';
  6310. $config['max_size'] = 10240;
  6311. $this->load->library('upload', $config);
  6312. $this->upload->initialize($config);
  6313. if ($this->upload->do_upload('userfile')) {
  6314. $full_path = $dir . $this->upload->data('file_name');
  6315. $fileName = '.' . $full_path;
  6316. if (!file_exists($fileName)) {
  6317. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6318. exit;
  6319. } else {
  6320. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6321. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6322. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6323. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6324. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6325. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6326. ++$column; //如果列数大于26行
  6327. $list = array();
  6328. for ($i = 2; $i <= $row; $i++) // 行数循环
  6329. {
  6330. $data = array();
  6331. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6332. {
  6333. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6334. }
  6335. $list[] = $data;
  6336. }
  6337. }
  6338. $ed = array();
  6339. $i = 0;
  6340. $j = 0;
  6341. $dcdata = array();
  6342. $yc = '';
  6343. $cmf_arr = array_column($list, '1');
  6344. array_multisort($cmf_arr, SORT_ASC, $list);
  6345. foreach ($list as $key => $value) {
  6346. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6347. if ($typeclass) {
  6348. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6349. } else {
  6350. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6351. $i++;
  6352. continue;
  6353. }
  6354. }
  6355. if ($i > 0) {
  6356. $yc = $i . '条异常';
  6357. }
  6358. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6359. exit;
  6360. }
  6361. }
  6362. public function _uck()
  6363. {
  6364. if (isset($_GET['excel'])) {
  6365. $tc = array();
  6366. $typeclass = $this->typeclass->find_all();
  6367. foreach ($typeclass as $v) {
  6368. $tc[$v['id']] = $v['zh'];
  6369. }
  6370. $data = array();
  6371. $t = array();
  6372. $rq = '';
  6373. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6374. $ts = $ts / (24 * 3600);
  6375. for ($i = 0; $i < $ts; $i++) {
  6376. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6377. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6378. }
  6379. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6380. foreach ($info_list as $k => $v) {
  6381. $features = explode('-', trim($v['features'], '-'));
  6382. if (!isset($features[3]) || !isset($features[4])) {
  6383. continue;
  6384. }
  6385. $data[$k][0] = $tc[$features[0]]; //类型
  6386. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6387. $data[$k][2] = $tc[$features[4]]; //曲度
  6388. $data[$k][3] = '';
  6389. if (isset($data[$k][1])) {
  6390. $data[$k][3] .= $data[$k][1];
  6391. }
  6392. if (isset($data[$k][2])) {
  6393. $data[$k][3] .= $data[$k][2];
  6394. }
  6395. if (isset($features[5])) {
  6396. $data[$k][3] .= $tc[$features[5]];
  6397. }
  6398. if (isset($features[2])) {
  6399. $data[$k][3] .= $tc[$features[2]];
  6400. }
  6401. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6402. $data[$k][4] = $v['sku'];
  6403. $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())) . '))'); //月初库存
  6404. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6405. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6406. $ztrq = '';
  6407. $ztsl = '';
  6408. if (count($zt) > 0) {
  6409. foreach ($zt as $vv) {
  6410. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6411. $ztsl .= $vv['num'] . '<br>';
  6412. }
  6413. }
  6414. $data[$k][] = trim($ztsl, '<br>');
  6415. $data[$k][] = trim($ztrq, '<br>');
  6416. $byck = 0;
  6417. foreach ($t as $vv) {
  6418. $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));
  6419. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6420. $byck += $sl;
  6421. }
  6422. $data[$k][] = ($byck > 0) ? $byck : '';
  6423. }
  6424. $title = "详情 " . date("Y-m-d", time());
  6425. $titlename = "<table border=1>
  6426. <tr align='center'>
  6427. <td>类别</td>
  6428. <td>颜色</td>
  6429. <td>曲度</td>
  6430. <td>名称</td>
  6431. <td>SKU</td>
  6432. <td>月初库存</td>
  6433. <td>剩余库存</td>
  6434. <td>在途数量</td>
  6435. <td>预达日期</td>" .
  6436. $rq
  6437. . "<td>本月出库</td></tr>
  6438. </table>";
  6439. $filename = $title . ".xls";
  6440. $tail = "";
  6441. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6442. }
  6443. }
  6444. public function _whlabelexcelzh()
  6445. {
  6446. if (isset($_GET['excel'])) {
  6447. $where = "sku != 'Preset'";
  6448. //数据排序
  6449. $order_str = "id desc";
  6450. if (empty($page)) {
  6451. $start = 0;
  6452. $perpage = 1;
  6453. } else {
  6454. $start = ($page - 1) * $perpage;
  6455. }
  6456. $category = $this->input->get('category', true);
  6457. $warehouse = $this->input->get('warehouse', true);
  6458. $excelid = $this->input->get('sid', true);
  6459. if ($category) {
  6460. $where .= " and features like '%-$category-%'";
  6461. }
  6462. if ($warehouse) {
  6463. $where .= " and warehouse = '$warehouse'";
  6464. }
  6465. $xzid = '';
  6466. if ($excelid) {
  6467. $excelid = explode(',', trim($excelid, ','));
  6468. foreach ($excelid as $key => $value) {
  6469. $xzid .= " id = " . $value . " or";
  6470. }
  6471. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6472. }
  6473. //取得信息列表
  6474. /**
  6475. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6476. $rows = array();$list = array();
  6477. foreach ($info_list as $key=>$value)
  6478. {
  6479. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6480. }
  6481. **/
  6482. $list = array();
  6483. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6484. foreach ($rows as $key => $value) {
  6485. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6486. $zh = '';
  6487. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6488. foreach ($zt as $v) {
  6489. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6490. }
  6491. $zt = array_sum(array_column($zt, 'num'));
  6492. $number = $value['number'];
  6493. $ftime = time() - 15 * 24 * 3600;
  6494. $warehouse = $this->warehouse->read($value['warehouse']);
  6495. $rows[$key]['warehouse'] = $warehouse['title'];
  6496. $rows[$key]['number'] = $c;
  6497. $rows[$key]['features'] = $zh;
  6498. $rows[$key]['hb'] = $c + $zt;
  6499. }
  6500. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6501. $titlename = "<table border=1>
  6502. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6503. <tr align='center'>
  6504. <td>仓库</td>
  6505. <td>SKU</td>
  6506. <td>产品</td>
  6507. <td>库存数量</td>
  6508. <td>在途数量及预达日期</td>
  6509. <td>在途+库存数量</td>
  6510. </tr>
  6511. </table>";
  6512. $filename = $title . ".xls";
  6513. $tail = "";
  6514. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6515. }
  6516. if (isset($_GET['excel'])) {
  6517. $warehouse = $this->input->get('warehouse', true);
  6518. $sku = $this->input->get('sku', true);
  6519. $cz = $this->input->get('cz', true);
  6520. $text = $this->input->post('text', true);
  6521. $xztime = $this->input->get('xztime', true);
  6522. $timetk = $this->input->get('timetk', true);
  6523. $timetj = $this->input->get('timetj', true);
  6524. $timetk = strtotime($timetk);
  6525. $timetj = strtotime($timetj);
  6526. $where = "time = '0' ";
  6527. if ($warehouse) {
  6528. $where .= " and warehouse = '$warehouse'";
  6529. }
  6530. if ($sku) {
  6531. $where .= " and sku = '$sku'";
  6532. }
  6533. if ($text) {
  6534. $where .= " and text like '%$text%'";
  6535. }
  6536. if ($cz != '') {
  6537. $where .= " and cz = '$cz'";
  6538. }
  6539. if ($timetk && $timetj) {
  6540. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6541. }
  6542. //数据排序
  6543. $order_str = $xztime . " desc";
  6544. //取得信息列表
  6545. $zh = array();
  6546. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6547. foreach ($info_list as $v) {
  6548. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6549. $warehouse = $this->warehouse->read($v['warehouse']);
  6550. $v['warehouse'] = $warehouse['title'];
  6551. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6552. $v['stime'] = date('Y-m-d', $v['stime']);
  6553. if (isset($zh[$v['features']])) {
  6554. $zh[$v['features']]['num'] += $v['num'];
  6555. } else {
  6556. $zh[$v['features']] = $v;
  6557. }
  6558. $zh[$v['features']]['features'] = $c;
  6559. }
  6560. $title = "在途数据" . date('Y-m-d', time());
  6561. $titlename = "<table border=1>
  6562. <tr align='center'>
  6563. <td>仓库</td>
  6564. <td>SKU</td>
  6565. <td>名称</td>
  6566. <td>在途数量</td>
  6567. <td>库存数量</td>
  6568. <td>添加在途日期</td>
  6569. <td>预达日期</td>
  6570. <td>备注</td>
  6571. </tr>
  6572. </table>";
  6573. $filename = $title . ".xls";
  6574. $tail = "";
  6575. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6576. }
  6577. }
  6578. public function _fc()
  6579. {
  6580. $vip = 0;
  6581. if (isset($_SESSION['api'])) {
  6582. $user = $this->user->get_api($_SESSION['api']);
  6583. if ($user['vip'] == 1) {
  6584. $vip = 1;
  6585. }
  6586. } else {
  6587. header('Location: /');
  6588. exit;
  6589. }
  6590. $post = $this->input->post(NULL, TRUE);
  6591. if (isset($post['page'])) {
  6592. $page = $this->input->post('page', true);
  6593. $perpage = $this->input->post('perpage', true);
  6594. $category = $this->input->post('category', true);
  6595. $size = $this->input->post('size', true);
  6596. $grade = $this->input->post('grade', true);
  6597. $color = $this->input->post('color', true);
  6598. $lowe = $this->input->post('lowe', true);
  6599. $sku = $this->input->post('sku');
  6600. $title = $this->input->post('title');
  6601. $warehouse = $this->input->post('warehouse', true);
  6602. $usa = $this->input->post('usa', true);
  6603. $purchase = $this->input->post('purchase', true);
  6604. $lacetype = $this->input->post('lacetype', true);
  6605. $haircap = $this->input->post('haircap', true);
  6606. $density = $this->input->post('density', true);
  6607. $details = $this->input->post('details', true);
  6608. $state = $this->input->post('state', true);
  6609. $ktime = $this->input->post('ktime', true);
  6610. $jtime = $this->input->post('jtime', true);
  6611. $ktime = strtotime($ktime);
  6612. $jtime = strtotime($jtime);
  6613. $where = "state = '11'";
  6614. $gj = "";
  6615. $ck = "";
  6616. if ($lacetype) {
  6617. $where .= " and features like '%-$lacetype-%'";
  6618. }
  6619. if ($category) {
  6620. $where .= " and features like '%-$category-%'";
  6621. }
  6622. if ($size) {
  6623. $where .= " and features like '%-$size-%'";
  6624. }
  6625. if ($grade) {
  6626. $where .= " and features like '%-$grade-%'";
  6627. }
  6628. if ($color) {
  6629. $where .= " and features like '%-$color-%'";
  6630. }
  6631. if ($lowe) {
  6632. $where .= " and features like '%-$lowe-%'";
  6633. }
  6634. if ($haircap) {
  6635. $where .= " and features like '%-$haircap-%'";
  6636. }
  6637. if ($density) {
  6638. $where .= " and features like '%-$density-%'";
  6639. }
  6640. if ($usa) {
  6641. if (!$warehouse) {
  6642. $where .= " and (warehouse = '5' or warehouse = '8')";
  6643. }
  6644. }
  6645. if ($warehouse) {
  6646. $where .= " and warehouse = '$warehouse'";
  6647. }
  6648. if ($details) {
  6649. $where .= " and details = '$details'";
  6650. }
  6651. if ($purchase) {
  6652. $where .= " and purchase = '$purchase'";
  6653. }
  6654. if ($state) {
  6655. $where .= " and state = '$state'";
  6656. }
  6657. if ($ktime && $jtime) {
  6658. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6659. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6660. }
  6661. //数据排序
  6662. $order_str = "id desc";
  6663. if (empty($page)) {
  6664. $start = 0;
  6665. $perpage = 1;
  6666. } else {
  6667. $start = ($page - 1) * $perpage;
  6668. }
  6669. if ($sku) {
  6670. $sku = trim($sku, ' ');
  6671. $sku = trim($sku, ' ');
  6672. $where .= " and sku like '%$sku%'";
  6673. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6674. } else if ($title) {
  6675. $title = trim($title, ' ');
  6676. $title = trim($title, ' ');
  6677. $where .= " and title like '%$title%'";
  6678. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6679. } else {
  6680. //$where .= " and time > '$ktime' and time < '$jtime'";
  6681. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6682. }
  6683. //取得信息列表
  6684. $rows = array();
  6685. $list = array();
  6686. foreach ($info_list as $key => $value) {
  6687. $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'] . '"');
  6688. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6689. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6690. $warehouse = $this->warehouse->read($value['warehouse']);
  6691. $info_list[$key]['warehouse'] = $warehouse['title'];
  6692. $info_list[$key]['number'] = $g;
  6693. $info_list[$key]['features'] = $x;
  6694. $info_list[$key]['x'] = $s;
  6695. }
  6696. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6697. $pagenum = ceil($total / $perpage);
  6698. $over = $total - ($start + $perpage);
  6699. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6700. echo json_encode($rows);
  6701. exit;
  6702. }
  6703. $this->data['vip'] = $vip;
  6704. $this->_Template('whlabel_fc', $this->data);
  6705. }
  6706. public function _fcmb()
  6707. {
  6708. $where = "sku != 'Preset'";
  6709. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6710. foreach ($rows as $k => $v) {
  6711. $warehouse = $this->warehouse->read($v['warehouse']);
  6712. $rows[$k]['warehouse'] = $warehouse['title'];
  6713. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6714. $rows[$k]['t'] = '';
  6715. $rows[$k]['n'] = '';
  6716. }
  6717. $title = "封货产品数据导入模板";
  6718. $titlename = "<table border=1>
  6719. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6720. <tr align='center'>
  6721. <td>仓库</td>
  6722. <td>SKU</td>
  6723. <td>产品</td>
  6724. <td>封存产品总数量</td>
  6725. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6726. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6727. </tr>
  6728. </table>";
  6729. $filename = $title . ".xls";
  6730. $tail = "";
  6731. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6732. }
  6733. public function _fcexcel()
  6734. {
  6735. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6736. $config['upload_path'] = '.' . $dir;
  6737. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6738. $config['allowed_types'] = 'xls|xlsx|csv';
  6739. $config['max_size'] = 10240;
  6740. $this->load->library('upload', $config);
  6741. $this->upload->initialize($config);
  6742. if ($this->upload->do_upload('userfile')) {
  6743. $full_path = $dir . $this->upload->data('file_name');
  6744. $fileName = '.' . $full_path;
  6745. if (!file_exists($fileName)) {
  6746. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6747. exit;
  6748. } else {
  6749. libxml_use_internal_errors(true);
  6750. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6751. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6752. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6753. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6754. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6755. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6756. ++$column; //如果列数大于26行
  6757. $list = array();
  6758. for ($i = 2; $i <= $row; $i++) // 行数循环
  6759. {
  6760. $data = array();
  6761. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6762. {
  6763. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6764. }
  6765. $list[] = $data;
  6766. }
  6767. }
  6768. $i = 0;
  6769. $j = 0;
  6770. $ed = array();
  6771. foreach ($list as $key => $value) {
  6772. $time = time();
  6773. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6774. continue;
  6775. }
  6776. $warehouse = $this->warehouse->get_title($value['0']);
  6777. $sku = $value['1'];
  6778. $type = $value['4']; //调整方式0扣减1删除
  6779. $num = $value['5']; //调整数量
  6780. //$text = $value['4'];//扣减说明
  6781. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6782. if (!$d) //如果没有这个SKU
  6783. {
  6784. $ed[] = array($sku . '-库存中不存在此SKU');
  6785. $j++;
  6786. continue;
  6787. }
  6788. if (!isset($warehouse['id'])) {
  6789. $ed[] = array($sku . '-仓库名错误!');
  6790. $j++;
  6791. continue;
  6792. }
  6793. if ($type == 1 || $type == 2) //扣减库存
  6794. {
  6795. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6796. if (count($data) < abs($num)) {
  6797. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6798. $j++;
  6799. continue;
  6800. }
  6801. if ($type == 1) //转入库存
  6802. {
  6803. for ($i = 0; $i < abs($num); $i++) {
  6804. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6805. }
  6806. } else if ($type == 2) //删除
  6807. {
  6808. for ($i = 0; $i < abs($num); $i++) {
  6809. $this->whlabel->remove($data[$i]['id']);
  6810. }
  6811. }
  6812. } else if ($type == 0) //增加库存
  6813. {
  6814. $post['sku'] = $d['sku'];
  6815. $post['shop'] = '';
  6816. $post['warehouse'] = $warehouse['id'];
  6817. $post['purchase'] = $d['purchase'];
  6818. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6819. $post['state'] = 11;
  6820. $post['title'] = $d['title'];
  6821. $post['number'] = $d['number'];
  6822. $post['features'] = $d['features'];
  6823. $post['enter'] = $time;
  6824. $post['time'] = $time; //操作时间
  6825. for ($i = 0; $i < $num; $i++) {
  6826. $post['label'] = time() . rand(100, 999) . $i;
  6827. $this->whlabel->insert($post);
  6828. }
  6829. }
  6830. sleep(1); //防止入库时间一样,需要延迟1秒
  6831. }
  6832. if ($j > 0) {
  6833. $tt = date('Ymd', time());
  6834. $title = '库存导入错误信息-' . $tt;
  6835. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6836. $tail = "\n";
  6837. $filename = $title . ".xls";
  6838. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6839. $dir = '/data/excel/' . $time . '/';
  6840. $file_name = 'error_' . $time . rand(1000, 9999);
  6841. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6842. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6843. fwrite($myfile, $ecl);
  6844. fclose($myfile);
  6845. $error = $dir . $file_name . '.xls';
  6846. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6847. exit;
  6848. } else {
  6849. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6850. exit;
  6851. }
  6852. }
  6853. }
  6854. public function _fcjxc($arg_array)
  6855. {
  6856. if (isset($_GET['excel'])) {
  6857. $category = $this->input->get('category', true);
  6858. $size = $this->input->get('size', true);
  6859. $grade = $this->input->get('grade', true);
  6860. $color = $this->input->get('color', true);
  6861. $lowe = $this->input->get('lowe', true);
  6862. $sku = $this->input->get('sku');
  6863. $title = $this->input->get('title');
  6864. $warehouse = $arg_array[0];
  6865. $usa = $this->input->get('usa', true);
  6866. $purchase = $this->input->get('purchase', true);
  6867. $lacetype = $this->input->get('lacetype', true);
  6868. $haircap = $this->input->get('haircap', true);
  6869. $density = $this->input->get('density', true);
  6870. $title = $this->input->get('title', true);
  6871. $state = $this->input->get('state', true);
  6872. $ktime = $this->input->get('ktime', true);
  6873. $jtime = $this->input->get('jtime', true);
  6874. $where = "state=11";
  6875. $gj = "";
  6876. $ck = "";
  6877. if ($lacetype) {
  6878. $where .= " and features like '%-$lacetype-%'";
  6879. }
  6880. if ($category) {
  6881. $where .= " and features like '%-$category-%'";
  6882. }
  6883. if ($size) {
  6884. $where .= " and features like '%-$size-%'";
  6885. }
  6886. if ($grade) {
  6887. $where .= " and features like '%-$grade-%'";
  6888. }
  6889. if ($color) {
  6890. $where .= " and features like '%-$color-%'";
  6891. }
  6892. if ($lowe) {
  6893. $where .= " and features like '%-$lowe-%'";
  6894. }
  6895. if ($haircap) {
  6896. $where .= " and features like '%-$haircap-%'";
  6897. }
  6898. if ($density) {
  6899. $where .= " and features like '%-$density-%'";
  6900. }
  6901. if ($usa) {
  6902. if (!$warehouse) {
  6903. $where .= " and (warehouse = '5' or warehouse = '8')";
  6904. }
  6905. }
  6906. if ($warehouse) {
  6907. $where .= " and warehouse = '$warehouse'";
  6908. }
  6909. if ($purchase) {
  6910. $where .= " and purchase = '$purchase'";
  6911. }
  6912. if ($state) {
  6913. $where .= " and state = '$state'";
  6914. }
  6915. $order_str = "id desc";
  6916. if ($sku) {
  6917. $sku = trim($sku, ' ');
  6918. $sku = trim($sku, ' ');
  6919. $where .= " and sku like '%$sku%'";
  6920. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6921. } else if ($title) {
  6922. $title = trim($title, ' ');
  6923. $title = trim($title, ' ');
  6924. $where .= " and title like '%$title%'";
  6925. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6926. } else {
  6927. //$where .= " and time > '$ktime' and time < '$jtime'";
  6928. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6929. }
  6930. //取得信息列表
  6931. $rows = array();
  6932. $list = array();
  6933. foreach ($info_list as $key => $value) {
  6934. $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'] . '"');
  6935. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6936. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6937. $rows[$key] = $value;
  6938. $warehouse = $this->warehouse->read($value['warehouse']);
  6939. $rows[$key]['warehouse'] = $warehouse['title'];
  6940. $rows[$key]['features'] = $g;
  6941. $rows[$key]['a'] = $x;
  6942. $rows[$key]['b'] = $s;
  6943. }
  6944. $title = "总统计表";
  6945. $titlename = "<table border=1>
  6946. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6947. <tr align='center'>
  6948. <td>仓库</td>
  6949. <td>SKU</td>
  6950. <td>产品名称</td>
  6951. <td>录入总量</td>
  6952. <td>取出总量</td>
  6953. <td>剩余总量</td>
  6954. </tr>
  6955. </table>";
  6956. $filename = $title . ".xls";
  6957. $tail = "";
  6958. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6959. }
  6960. $vip = 0;
  6961. if (isset($_SESSION['api'])) {
  6962. $user = $this->user->get_api($_SESSION['api']);
  6963. if ($user['vip'] == 1) {
  6964. $vip = 1;
  6965. }
  6966. } else {
  6967. header('Location: /');
  6968. exit;
  6969. }
  6970. $post = $this->input->post(NULL, TRUE);
  6971. if (isset($post['page'])) {
  6972. $page = $this->input->post('page', true);
  6973. $perpage = $this->input->post('perpage', true);
  6974. $category = $this->input->post('category', true);
  6975. $size = $this->input->post('size', true);
  6976. $grade = $this->input->post('grade', true);
  6977. $color = $this->input->post('color', true);
  6978. $lowe = $this->input->post('lowe', true);
  6979. $sku = $this->input->post('sku');
  6980. $title = $this->input->post('title');
  6981. $warehouse = $arg_array[0];
  6982. $usa = $this->input->post('usa', true);
  6983. $purchase = $this->input->post('purchase', true);
  6984. $lacetype = $this->input->post('lacetype', true);
  6985. $haircap = $this->input->post('haircap', true);
  6986. $density = $this->input->post('density', true);
  6987. $title = $this->input->post('title', true);
  6988. $state = $this->input->post('state', true);
  6989. $ktime = $this->input->post('ktime', true);
  6990. $jtime = $this->input->post('jtime', true);
  6991. $ktime = strtotime($ktime);
  6992. $jtime = strtotime($jtime);
  6993. $where = "state=11";
  6994. $gj = "";
  6995. $ck = "";
  6996. if ($lacetype) {
  6997. $where .= " and features like '%-$lacetype-%'";
  6998. }
  6999. if ($category) {
  7000. $where .= " and features like '%-$category-%'";
  7001. }
  7002. if ($size) {
  7003. $where .= " and features like '%-$size-%'";
  7004. }
  7005. if ($grade) {
  7006. $where .= " and features like '%-$grade-%'";
  7007. }
  7008. if ($color) {
  7009. $where .= " and features like '%-$color-%'";
  7010. }
  7011. if ($lowe) {
  7012. $where .= " and features like '%-$lowe-%'";
  7013. }
  7014. if ($haircap) {
  7015. $where .= " and features like '%-$haircap-%'";
  7016. }
  7017. if ($density) {
  7018. $where .= " and features like '%-$density-%'";
  7019. }
  7020. if ($usa) {
  7021. if (!$warehouse) {
  7022. $where .= " and (warehouse = '5' or warehouse = '8')";
  7023. }
  7024. }
  7025. if ($warehouse) {
  7026. $where .= " and warehouse = '$warehouse'";
  7027. }
  7028. if ($purchase) {
  7029. $where .= " and purchase = '$purchase'";
  7030. }
  7031. if ($state) {
  7032. $where .= " and state = '$state'";
  7033. }
  7034. if ($ktime && $jtime) {
  7035. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7036. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7037. }
  7038. //数据排序
  7039. $order_str = "id desc";
  7040. $xs = 0;
  7041. $rows = array();
  7042. $list = array();
  7043. if (empty($page)) {
  7044. $start = 0;
  7045. $perpage = 1;
  7046. } else {
  7047. $start = ($page - 1) * $perpage;
  7048. }
  7049. if ($sku || $title) {
  7050. if ($title) {
  7051. $title = trim($title, ' ');
  7052. $title = trim($title, ' ');
  7053. $where .= " and title like '%$title%'";
  7054. } else {
  7055. $sku = trim($sku, ' ');
  7056. $sku = trim($sku, ' ');
  7057. $where .= " and sku like '%$sku%'";
  7058. }
  7059. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7060. foreach ($info_list as $key => $value) {
  7061. $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'] . '"');
  7062. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7063. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7064. $rows[$key] = $value;
  7065. $warehouse = $this->warehouse->read($value['warehouse']);
  7066. $rows[$key]['warehouse'] = $warehouse['title'];
  7067. $rows[$key]['features'] = $g;
  7068. $rows[$key]['a'] = $x;
  7069. $rows[$key]['b'] = $s;
  7070. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7071. $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天销量
  7072. $yj = $c / ($xl / 30);
  7073. if ($yj < 7) {
  7074. $rows[$key]['y'] = round($yj) . '天销量';
  7075. } else {
  7076. $rows[$key]['y'] = '正常';
  7077. }
  7078. }
  7079. } else {
  7080. //$where .= " and time > '$ktime' and time < '$jtime'";
  7081. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7082. foreach ($info_list as $key => $value) {
  7083. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  7084. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7085. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7086. $zs[$key] = $value;
  7087. $warehouse = $this->warehouse->read($value['warehouse']);
  7088. $zs[$key]['warehouse'] = $warehouse['title'];
  7089. $zs[$key]['features'] = $g;
  7090. $zs[$key]['a'] = $x;
  7091. $zs[$key]['b'] = $s;
  7092. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7093. $xl = $this->whlabel->find_count($where . " and outk > '" . (time() - 30 * 24 * 3600) . "' and outk < '" . time() . "'" . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"'); //30天销量
  7094. $yj = $c / ($xl / 30);
  7095. if ($yj < 7) {
  7096. $zs[$key]['y'] = round($yj) . '天销量';
  7097. $rows[$key] = $zs[$key];
  7098. }
  7099. }
  7100. }
  7101. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7102. $pagenum = ceil($total / $perpage);
  7103. $over = $total - ($start + $perpage);
  7104. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7105. echo json_encode($rows);
  7106. exit;
  7107. }
  7108. $this->data['arg_array'] = $arg_array[0];
  7109. $this->_Template('whlabel_fcjxc', $this->data);
  7110. }
  7111. public function _0kcdel()
  7112. {
  7113. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7114. $config['upload_path'] = '.' . $dir;
  7115. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7116. $config['allowed_types'] = 'xls|xlsx|csv';
  7117. $config['max_size'] = 10240;
  7118. $this->load->library('upload', $config);
  7119. $this->upload->initialize($config);
  7120. if ($this->upload->do_upload('userfile')) {
  7121. $full_path = $dir . $this->upload->data('file_name');
  7122. $fileName = '.' . $full_path;
  7123. if (!file_exists($fileName)) {
  7124. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7125. exit;
  7126. } else {
  7127. require_once "./data/excel/PHPExcel/IOFactory.php";
  7128. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7129. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7130. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7131. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7132. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7133. ++$column; //如果列数大于26行
  7134. $list = array();
  7135. for ($i = 2; $i <= $row; $i++) // 行数循环
  7136. {
  7137. $data = array();
  7138. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7139. {
  7140. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7141. }
  7142. $list[] = $data;
  7143. }
  7144. }
  7145. $i = 0;
  7146. $j = 0;
  7147. $ed = array();
  7148. foreach ($list as $key => $value) {
  7149. $time = time();
  7150. if ($value['0'] == "" || $value['1'] == "") {
  7151. continue;
  7152. }
  7153. $warehouse = $this->warehouse->get_title($value['0']);
  7154. $sku = $value['1'];
  7155. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7156. if (!$d) //如果没有这个SKU
  7157. {
  7158. $ed[] = array($sku . '-库存中不存在此SKU');
  7159. $j++;
  7160. continue;
  7161. }
  7162. if (!isset($warehouse['id'])) {
  7163. $ed[] = array($sku . '-仓库名错误!');
  7164. $j++;
  7165. continue;
  7166. }
  7167. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7168. if ($z < 1) {
  7169. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7170. foreach ($z as $v) {
  7171. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7172. if (count($zt) > 0) {
  7173. $ed[] = array($sku . '-有在途库存无法删除!');
  7174. $j++;
  7175. continue;
  7176. }
  7177. $this->whlabel->remove($v['id']);
  7178. }
  7179. } else {
  7180. $ed[] = array($sku . '-非0库存!');
  7181. $j++;
  7182. continue;
  7183. }
  7184. }
  7185. if ($j > 0) {
  7186. $tt = date('Ymd', time());
  7187. $title = '删除0库存错误信息-' . $tt;
  7188. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7189. $tail = "\n";
  7190. $filename = $title . ".xls";
  7191. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7192. $dir = '/data/excel/' . $time . '/';
  7193. $file_name = 'error_' . $time . rand(1000, 9999);
  7194. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7195. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7196. fwrite($myfile, $ecl);
  7197. fclose($myfile);
  7198. $error = $dir . $file_name . '.xls';
  7199. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7200. exit;
  7201. } else {
  7202. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7203. exit;
  7204. }
  7205. }
  7206. }
  7207. public function _gbhtype()
  7208. {
  7209. $post = $this->input->post(NULL, TRUE);
  7210. if (isset($post['s'])) {
  7211. $n = $this->input->post('n');
  7212. $d = $this->input->post('s');
  7213. if (!$d) {
  7214. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7215. exit;
  7216. }
  7217. $d = explode(',', trim($d, ','));
  7218. $t = $this->whlabel_type->read($n);
  7219. //循环删除记录
  7220. foreach ($d as $v) {
  7221. $u = $this->whlabel->read($v);
  7222. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7223. foreach ($data as $val) {
  7224. $this->whlabel->save(array('type' => $n), $val['id']);
  7225. }
  7226. }
  7227. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7228. }
  7229. }
  7230. //出库、退库导出
  7231. public function _dccrtype()
  7232. {
  7233. $classid = $this->classid->sku();
  7234. $pm = $classid;
  7235. $typeclass = array();
  7236. $tc = $this->typeclass->find_all();
  7237. foreach ($tc as $v) {
  7238. $typeclass[$v['id']] = $v;
  7239. }
  7240. $prc = array();
  7241. $purchase = $this->purchase->find_all();
  7242. foreach ($purchase as $k => $v) {
  7243. $prc[$v['id']] = $v['title'];
  7244. }
  7245. if (isset($_GET['sid'])) {
  7246. $wh = array();
  7247. $w = $this->warehouse->find_all('1=1', 'id,title');
  7248. foreach ($w as $v) {
  7249. $wh[$v['id']] = $v['title'];
  7250. }
  7251. $type = $this->input->get('excel', true);
  7252. $category = $this->input->get('category', true);
  7253. $size = $this->input->get('size', true);
  7254. $grade = $this->input->get('grade', true);
  7255. $color = $this->input->get('color', true);
  7256. $lowe = $this->input->get('lowe', true);
  7257. $sku = $this->input->get('sku', true);
  7258. $warehouse = $this->input->get('warehouse', true);
  7259. $lacetype = $this->input->get('lacetype', true);
  7260. $lacecolor = $this->input->get('lacecolor', true);
  7261. $density = $this->input->get('density', true);
  7262. $haircap = $this->input->get('haircap', true);
  7263. $purchase = $this->input->get('purchase', true);
  7264. $title = $this->input->get('title', true);
  7265. $state = $this->input->get('state', true);
  7266. $sid = $this->input->get('sid', true);
  7267. $ktime = $this->input->get('ktime', true);
  7268. $jtime = $this->input->get('jtime', true);
  7269. $ktime = strtotime($ktime);
  7270. $jtime = strtotime($jtime);
  7271. $where = "1=1";
  7272. $gj = "";
  7273. $ck = "";
  7274. if ($category) {
  7275. $where .= " and features like '%-$category-%'";
  7276. }
  7277. if ($size) {
  7278. $where .= " and features like '%-$size-%'";
  7279. }
  7280. if ($grade) {
  7281. $where .= " and features like '%-$grade-%'";
  7282. }
  7283. if ($color) {
  7284. $where .= " and features like '%-$color-%'";
  7285. }
  7286. if ($lowe) {
  7287. $where .= " and features like '%-$lowe-%'";
  7288. }
  7289. if ($warehouse) {
  7290. $where .= " and warehouse = '$warehouse'";
  7291. }
  7292. if ($purchase) {
  7293. $where .= " and purchase = '$purchase'";
  7294. }
  7295. if ($state) {
  7296. $where .= " and state = '$state'";
  7297. }
  7298. if ($lacetype) {
  7299. $where .= " and features like '%-$lacetype-%'";
  7300. }
  7301. if ($lacecolor) {
  7302. $where .= " and features like '%-$lacecolor-%'";
  7303. }
  7304. if ($density) {
  7305. $where .= " and features like '%-$density-%'";
  7306. }
  7307. if ($haircap) {
  7308. $where .= " and features like '%-$haircap-%'";
  7309. }
  7310. if ($title) {
  7311. $title = trim($title, ' ');
  7312. $title = trim($title, ' ');
  7313. $where .= " and title like '%$title%'";
  7314. }
  7315. if ($sku) {
  7316. $sku = trim($sku, ' ');
  7317. $sku = trim($sku, ' ');
  7318. $where .= " and sku like '%$sku%'";
  7319. }
  7320. if ($ktime && $jtime) {
  7321. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7322. }
  7323. $sidwhere = '';
  7324. if ($sid) {
  7325. $sd = "";
  7326. $s = explode(',', trim($sid, ','));
  7327. foreach ($s as $value) {
  7328. $sd .= " id = " . $value . " or";
  7329. }
  7330. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7331. }
  7332. //数据排序
  7333. $order_str = "time desc";
  7334. if (empty($page)) {
  7335. $start = 0;
  7336. $perpage = 1;
  7337. } else {
  7338. $start = ($page - 1) * $perpage;
  7339. }
  7340. $wh = array();
  7341. $w = $this->warehouse->find_all('1=1', 'id,title');
  7342. foreach ($w as $v) {
  7343. $wh[$v['id']] = $v['title'];
  7344. }
  7345. $wt = array();
  7346. $whlabel_type = $this->whlabel_type->find_all();
  7347. foreach ($whlabel_type as $v) {
  7348. $wt[$v['id']] = $v['title'];
  7349. }
  7350. $classid = $this->classid->sku();
  7351. $list = array();
  7352. $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');
  7353. foreach ($rows_r as $key => $value) {
  7354. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7355. $pm = $classid;
  7356. $jm = $classid;
  7357. $rows_r[$key]['enter'] = '入库';
  7358. $rows_r[$key]['time'] = $value['enter'];
  7359. if ($value['rktype'] == 1) {
  7360. $rows_r[$key]['rktype'] = '采购入库';
  7361. } else if ($value['rktype'] == 2) {
  7362. $rows_r[$key]['rktype'] = '盘盈调整';
  7363. } else if ($value['rktype'] == 3) {
  7364. $rows_r[$key]['rktype'] = '其他调整入库';
  7365. } else if ($value['rktype'] == 4) {
  7366. $rows_r[$key]['rktype'] = '其他调整入库';
  7367. } else if ($value['rktype'] == 5) {
  7368. $rows_r[$key]['rktype'] = '退库入库';
  7369. } else if ($value['rktype'] == 6) {
  7370. $rows_r[$key]['rktype'] = '退货可用入库';
  7371. } else if ($value['rktype'] == 7) {
  7372. $rows_r[$key]['rktype'] = '形态转换入库';
  7373. } else {
  7374. $rows_r[$key]['rktype'] = '';
  7375. }
  7376. $features = explode('-', trim($value['features'], '-'));
  7377. foreach ($features as $v) {
  7378. if (isset($typeclass[$v])) {
  7379. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7380. $pm[$typeclass[$v]['classid']] = $zh[0];
  7381. }
  7382. if (isset($typeclass[$v])) {
  7383. if (isset($jm[$typeclass[$v]['classid']])) {
  7384. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7385. }
  7386. }
  7387. }
  7388. $zh = implode(" ", $pm);
  7389. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7390. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7391. $rows_r[$key]['zh'] = $zh;
  7392. $jm = array_filter($jm);
  7393. $rows_r[$key]['features'] = implode("-", $jm);
  7394. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7395. }
  7396. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7397. foreach ($rows_c as $key => $value) {
  7398. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7399. $pm = $classid;
  7400. $jm = $classid;
  7401. $rows_c[$key]['time'] = $value['outk'];
  7402. $rows_c[$key]['outk'] = '出库';
  7403. if ($value['cktype'] == 1) {
  7404. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7405. } else if ($value['cktype'] == 2) {
  7406. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7407. } else if ($value['cktype'] == 3) {
  7408. $rows_c[$key]['cktype'] = '盘亏调整';
  7409. } else if ($value['cktype'] == 4) {
  7410. $rows_c[$key]['cktype'] = '其他调整出库';
  7411. } else if ($value['cktype'] == 5) {
  7412. $rows_c[$key]['cktype'] = '形态转换出库';
  7413. } else {
  7414. $rows_c[$key]['cktype'] = '';
  7415. }
  7416. unset($rows_c[$key]['state']);
  7417. $features = explode('-', trim($value['features'], '-'));
  7418. foreach ($features as $v) {
  7419. if (isset($typeclass[$v])) {
  7420. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7421. $pm[$typeclass[$v]['classid']] = $zh[0];
  7422. }
  7423. if (isset($typeclass[$v])) {
  7424. if (isset($jm[$typeclass[$v]['classid']])) {
  7425. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7426. }
  7427. }
  7428. }
  7429. $zh = implode(" ", $pm);
  7430. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7431. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7432. $rows_c[$key]['zh'] = $zh;
  7433. $jm = array_filter($jm);
  7434. $rows_c[$key]['features'] = implode("-", $jm);
  7435. $rows_c[$key]['number'] = 1;
  7436. }
  7437. $merged = $rows_r;
  7438. foreach ($rows_c as $key => $value) {
  7439. if (isset($merged[$key])) {
  7440. $merged[] = $value;
  7441. } else {
  7442. $merged[$key] = $value;
  7443. }
  7444. }
  7445. usort($merged, function ($a, $b) {
  7446. return $a['time'] - $b['time'];
  7447. });
  7448. foreach ($merged as $key => $value) {
  7449. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7450. }
  7451. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7452. $titlename = "<table border=1>
  7453. <tr align='center'>
  7454. <td>仓库</td>
  7455. <td>SKU</td>
  7456. <td>商品名称</td>
  7457. <td>仓库品名</td>
  7458. <td>料号</td>
  7459. <td>时间</td>
  7460. <td>操作</td>
  7461. <td>类型</td>
  7462. <td>数量</td>
  7463. <td>备注</td>
  7464. </tr>
  7465. </table>";
  7466. $filename = $title . ".xlsx";
  7467. $tail = "";
  7468. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7469. }
  7470. }
  7471. /*************************************处理exceljs导出****************************************************/
  7472. public function _excelrjs(){
  7473. if (isset($_GET['excel'])) {
  7474. $category = $this->input->get('category', true);
  7475. $size = $this->input->get('size', true);
  7476. $grade = $this->input->get('grade', true);
  7477. $color = $this->input->get('color', true);
  7478. $lowe = $this->input->get('lowe', true);
  7479. $sku = $this->input->get('sku', true);
  7480. $warehouse = $this->input->get('warehouse', true);
  7481. $purchase = $this->input->get('purchase', true);
  7482. $ktime = $this->input->get('ktime', true);
  7483. $jtime = $this->input->get('jtime', true);
  7484. $ktime = strtotime($ktime);
  7485. $jtime = strtotime($jtime);
  7486. $where = "1=1";
  7487. $gj = "";
  7488. $ck = "";
  7489. if ($category) {
  7490. $where .= " and features like '%-$category-%'";
  7491. }
  7492. if ($size) {
  7493. $where .= " and features like '%-$size-%'";
  7494. }
  7495. if ($grade) {
  7496. $where .= " and features like '%-$grade-%'";
  7497. }
  7498. if ($color) {
  7499. $where .= " and features like '%-$color-%'";
  7500. }
  7501. if ($lowe) {
  7502. $where .= " and features like '%-$lowe-%'";
  7503. }
  7504. if ($warehouse) {
  7505. $where .= " and warehouse = '$warehouse'";
  7506. }
  7507. if ($purchase) {
  7508. $where .= " and purchase = '$purchase'";
  7509. }
  7510. if ($sku) {
  7511. $where .= " and sku = '$sku'";
  7512. }
  7513. if ($ktime && $jtime) {
  7514. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7515. }
  7516. //数据排序
  7517. $order_str = "id desc";
  7518. if (empty($page)) {
  7519. $start = 0;
  7520. $perpage = 1;
  7521. } else {
  7522. $start = ($page - 1) * $perpage;
  7523. }
  7524. $list = array();
  7525. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7526. foreach ($rows as $value) {
  7527. $ck = $this->warehouse->read($value['warehouse']);
  7528. $warehouse = $ck['title'];
  7529. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7530. $retreatwarehouse = $tkck['title'];
  7531. $gy = $this->purchase->read($value['purchase']);
  7532. $purchase = $gy['title'];
  7533. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7534. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7535. }
  7536. // $list = [
  7537. // [
  7538. // 'warehouse'=>"许昌仓",
  7539. // 'sku'=>"123456",
  7540. // 'title'=>"商品名称",
  7541. // 'time'=>"2021-01-01 12:00:00",
  7542. // 'number'=>"121-111121"
  7543. // ],
  7544. // [
  7545. // 'warehouse'=>"美仓",
  7546. // 'sku'=>"353456",
  7547. // 'title'=>"商品名称1",
  7548. // 'time'=>"2021-01-01 12:01:00",
  7549. // 'number'=>"121-1333121"
  7550. // ],
  7551. // ];
  7552. if(empty($list)){
  7553. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7554. }else{
  7555. $final_list = [];
  7556. foreach($list as $v){
  7557. $final_list[] = array_values($v);
  7558. }
  7559. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7560. array_unshift($final_list,[
  7561. "仓库","SKU","商品名称","时间","数量"
  7562. ]);
  7563. array_unshift($final_list,[
  7564. $title,"","","",""
  7565. ]);
  7566. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
  7567. }
  7568. }
  7569. }
  7570. }