Whlabel.php 318 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373
  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. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. } else if ($arg == 'typedy') //进销存浏览店员页面
  62. {
  63. $this->_typedy($arg_array);
  64. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  65. {
  66. $this->_typedy_ck($arg_array);
  67. } else if ($arg == 'typeck') {
  68. $this->_typeck($arg_array);
  69. } else if ($arg == 'whlabeckdc') {
  70. $this->_whlabeckdc($arg_array);
  71. } else if ($arg == 'usatype') //美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  75. {
  76. $this->_usatypeapp();
  77. } else if ($arg == 'enteradd') //入库操作
  78. {
  79. $this->_enteradd();
  80. } else if ($arg == 'enteredit') //修改
  81. {
  82. $this->_enteredit($arg_array);
  83. } else if ($arg == 'enter') //入库浏览
  84. {
  85. $this->_enter();
  86. } else if ($arg == 'out') //出库浏览
  87. {
  88. $this->_out();
  89. } else if ($arg == 'label') //出库标签浏览
  90. {
  91. $this->_label();
  92. } else if ($arg == 'outorder') //独立站出库订单
  93. {
  94. $this->_outorder();
  95. } else if ($arg == 'soutorder') //速卖通出库订单
  96. {
  97. $this->_soutorder();
  98. } else if ($arg == 'toutorder') //TT出库订单
  99. {
  100. $this->_toutorder();
  101. }else if ($arg == 'aoutorder') //amz出库订单
  102. {
  103. $this->_aoutorder();
  104. } else if ($arg == 'retreat') //退库订单
  105. {
  106. $this->_retreat();
  107. } else if ($arg == 'retreatlk') //退库订单
  108. {
  109. $this->_retreatlk();
  110. } else if ($arg == 'change') //更换标签
  111. {
  112. $this->_change();
  113. } else if ($arg == 'del') //删除
  114. {
  115. $this->_del();
  116. } else if ($arg == 'exceljxc') //进销存信息导出
  117. {
  118. $this->_exceljxc();
  119. } else if ($arg == 'excelr') //入库信息导出
  120. {
  121. $this->_excelr();
  122. } else if ($arg == 'excelct') //出库、退库信息导出
  123. {
  124. $this->_excelct();
  125. } else if ($arg == 'dccrtype') //根据出入库类型导出
  126. {
  127. $this->_dccrtype();
  128. } else if ($arg == 'excelcr') //出库、退库信息导出
  129. {
  130. $this->_excelcr();
  131. } else if ($arg == 'kcyz') //库存验证
  132. {
  133. $this->_kcyz();
  134. } else if ($arg == 'kj') //库存扣减
  135. {
  136. $this->_kj($arg_array);
  137. } else if ($arg == 'presetout') //预设库存导入
  138. {
  139. $this->_presetout($arg_array);
  140. } else if ($arg == 'presetedit') //预设库存导入
  141. {
  142. $this->_presetedit($arg_array);
  143. }else if ($arg == 'presetedittwo') //预设库存导入
  144. {
  145. $this->_presetedittwo($arg_array);
  146. } else if ($arg == 'summary') //汇总导出
  147. {
  148. $this->_summary($arg_array);
  149. } else if ($arg == 'manifest') //usps发货清单
  150. {
  151. $this->_manifest();
  152. } else if ($arg == 'abnormal') //占单异常
  153. {
  154. $this->_abnormal();
  155. } else if ($arg == 'error') //0库存SKU
  156. {
  157. $this->_error();
  158. } else if ($arg == 'errorexcel') //0库存SKU导出
  159. {
  160. $this->_errorexcel();
  161. } else if ($arg == 'db') {
  162. $this->_db();
  163. } else if ($arg == 'dbrk') {
  164. $this->_dbrk();
  165. } else if ($arg == 'whlabelczdc') {
  166. $this->_whlabelczdc();
  167. } else if ($arg == 'print') {
  168. $this->_print($arg_array);
  169. } else if ($arg == 'usaprint') {
  170. $this->_usaprint($arg_array);
  171. } else if ($arg == 'printck') {
  172. $this->_printck($arg_array);
  173. } else if ($arg == 'printrk') {
  174. $this->_printrk($arg_array);
  175. } else if ($arg == 'printxzrk') {
  176. $this->_printxzrk($arg_array);
  177. } else if ($arg == 'printexcel') {
  178. $this->_printexcel($arg_array);
  179. } else if ($arg == 'uck') {
  180. $this->_uck();
  181. } else if ($arg == 'whlabelexcelzh') {
  182. $this->_whlabelexcelzh();
  183. } else if ($arg == 'fc') {
  184. $this->_fc();
  185. } else if ($arg == 'fcmb') {
  186. $this->_fcmb();
  187. } else if ($arg == 'fcexcel') {
  188. $this->_fcexcel();
  189. } else if ($arg == 'fcjxc') {
  190. $this->_fcjxc($arg_array);
  191. } else if ($arg == '0kcdel') {
  192. $this->_0kcdel(); //导表删除0库存
  193. } else if ($arg == 'gbhtype') {
  194. $this->_gbhtype(); //更改备货状态
  195. } else if($arg == 'excelrjs'){
  196. $this->_excelrjs();
  197. } else if($arg == 'excelctjs'){
  198. $this->_excelctjs();
  199. }else if ($arg == 'exceljxcjs') //进销存信息导出
  200. {
  201. $this->_exceljxcjs();
  202. } else if ($arg == 'summaryjs') //汇总导出
  203. {
  204. $this->_summaryjs($arg_array);
  205. }else if($arg == 'uckjs'){
  206. $this->_uckjs();
  207. }else if ($arg == 'whlabelexcelzhjs') {
  208. $this->_whlabelexcelzhjs();
  209. }else if($arg == 'dccrtypejs'){
  210. $this->_dccrtypejs();
  211. }else if($arg == 'errorexceljs'){
  212. $this->_errorexceljs();
  213. }else if($arg == "w_t_cs"){
  214. $this->_w_t_cs(); //首页
  215. }else {
  216. $this->_index();
  217. }
  218. }
  219. public function _w_t_cs(){
  220. $vip = 0;
  221. if (isset($_SESSION['api'])) {
  222. $user = $this->user->get_api($_SESSION['api']);
  223. $fgshop = "";
  224. $sid = "";
  225. $usersp = explode('|', trim($user['shop'], '|'));
  226. foreach ($usersp as $value) {
  227. $fgshop .= " shop = " . $value . " or";
  228. $sid .= " id = " . $value . " or";
  229. }
  230. if ($user['vip'] == 1) {
  231. $vip = 1;
  232. }
  233. } else {
  234. header('Location: /');
  235. exit;
  236. }
  237. $prc = array();
  238. $purchase = $this->purchase->find_all();
  239. foreach ($purchase as $k => $v) {
  240. $prc[$v['id']] = $v['title'];
  241. }
  242. $company = array();
  243. $ct = $this->company->find_all();
  244. foreach ($ct as $k => $v) {
  245. $company[$v['id']] = $v['title'];
  246. }
  247. $sp = array();
  248. $s = $this->shop->find_all('1=1', 'id,shopname');
  249. foreach ($s as $v) {
  250. $sp[$v['id']] = $v['shopname'];
  251. }
  252. $wh = array();
  253. $w = $this->warehouse->find_all('1=1', 'id,title');
  254. foreach ($w as $v) {
  255. $wh[$v['id']] = $v['title'];
  256. }
  257. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  258. $this->data['shop'] = $wlshop;
  259. $this->data['vip'] = $vip;
  260. $this->_Template('whlabel_typejs', $this->data);
  261. }
  262. //管理
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if (isset($post['page'])) {
  267. $page = $this->input->post('page', true);
  268. $perpage = $this->input->post('perpage', true);
  269. $sku = $this->input->post('sku', true);
  270. $number = $this->input->post('number', true);
  271. $warehouse = $this->input->post('warehouse', true);
  272. $purchase = $this->input->post('purchase', true);
  273. $orderinfo = $this->input->post('orderinfo', true);
  274. $waybill = $this->input->post('waybill', true);
  275. $category = $this->input->post('category', true);
  276. $size = $this->input->post('size', true);
  277. $grade = $this->input->post('grade', true);
  278. $color = $this->input->post('color', true);
  279. $lowe = $this->input->post('lowe', true);
  280. $state = $this->input->post('state', true);
  281. $label = $this->input->post('label', true);
  282. $timetk = $this->input->post('timetkk', true);
  283. $timetj = $this->input->post('timetjj', true);
  284. $timetk = strtotime($timetk);
  285. $timetj = strtotime($timetj);
  286. $where = "1=1 ";
  287. if ($timetk && $timetj) {
  288. $where .= " and time > '$timetk' and time < '$timetj'";
  289. }
  290. if ($sku) {
  291. $where .= " and sku = '$sku'";
  292. }
  293. if ($number) {
  294. $where .= " and number = '$number'";
  295. }
  296. if ($warehouse) {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if ($purchase) {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if ($orderinfo) {
  303. $where .= " and orderinfo = '$orderinfo'";
  304. }
  305. if ($waybill) {
  306. $where .= " and waybill = '$waybill'";
  307. }
  308. if ($category) {
  309. $where .= " and features like '%-$category-%'";
  310. }
  311. if ($size) {
  312. $where .= " and features like '%-$size-%'";
  313. }
  314. if ($grade) {
  315. $where .= " and features like '%-$grade-%'";
  316. }
  317. if ($color) {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if ($lowe) {
  321. $where .= " and features like '%-$lowe-%'";
  322. }
  323. if ($label) {
  324. $where .= " and label = '$label'";
  325. }
  326. if ($state != '') {
  327. $where .= " and state = '$state'";
  328. }
  329. //数据排序
  330. $order_str = "time desc";
  331. if (empty($page)) {
  332. $start = 0;
  333. $perpage = 1;
  334. } else {
  335. $start = ($page - 1) * $perpage;
  336. }
  337. //取得信息列表
  338. $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);
  339. foreach ($info_list as $key => $value) {
  340. $warehouse = $this->warehouse->read($value['warehouse']);
  341. $info_list[$key]['warehouse'] = $warehouse['title'];
  342. $purchase = $this->purchase->read($value['purchase']);
  343. $info_list[$key]['purchase'] = $purchase['title'];
  344. if ($value['enter'] != 0) {
  345. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  346. } else {
  347. $info_list[$key]['enter'] = "";
  348. }
  349. if ($value['outk'] != 0) {
  350. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  351. } else {
  352. $info_list[$key]['outk'] = "";
  353. }
  354. if ($value['printing'] != 0) {
  355. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  356. } else {
  357. $info_list[$key]['printing'] = "";
  358. }
  359. if ($value['orderinfo'] == 0) {
  360. $info_list[$key]['orderinfo'] = "";
  361. }
  362. if ($value['waybill'] == 0) {
  363. $info_list[$key]['waybill'] = "";
  364. }
  365. if ($value['state'] == 0) {
  366. $info_list[$key]['state'] = "在库";
  367. } else if ($value['state'] == 1) {
  368. $info_list[$key]['state'] = "出库";
  369. } else if ($value['state'] == 2) {
  370. $info_list[$key]['state'] = "退库";
  371. } else if ($value['state'] == 3) {
  372. $info_list[$key]['state'] = "调拨中";
  373. } else if ($value['state'] == 4) {
  374. $info_list[$key]['state'] = "再加工";
  375. } else if ($value['state'] == 5) {
  376. $info_list[$key]['state'] = "维修中";
  377. } else if ($value['state'] == 6) {
  378. $info_list[$key]['state'] = "盘亏";
  379. } else if ($value['state'] == 7) {
  380. $info_list[$key]['state'] = "更换标签";
  381. } else if ($value['state'] == 8) {
  382. $info_list[$key]['state'] = "其它";
  383. } else if ($value['state'] == 9) {
  384. $info_list[$key]['state'] = "预设";
  385. } else if ($value['state'] == 10) {
  386. $info_list[$key]['state'] = "美店零售";
  387. }
  388. if ($value['text'] == "") {
  389. $info_list[$key]['text'] = "";
  390. }
  391. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  392. }
  393. $total = $this->whlabel->find_count($where);
  394. $pagenum = ceil($total / $perpage);
  395. $over = $total - ($start + $perpage);
  396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  397. echo json_encode($rows);
  398. exit;
  399. }
  400. if (isset($post['outsku'])) {
  401. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  402. $cz = $this->input->post('cz', true);
  403. if ($cz == '1') {
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. } else {
  416. $sku = $this->input->post('outsku', true);
  417. if ($sku) {
  418. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  419. if (count($data) < 1) {
  420. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  421. exit;
  422. }
  423. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  424. echo json_encode(array('success' => true));
  425. exit;
  426. }
  427. }
  428. }
  429. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  430. $this->_Template('whlabel', $this->data);
  431. }
  432. //在库标签
  433. public function _existence()
  434. {
  435. $post = $this->input->post(NULL, TRUE);
  436. if (isset($post['s'])) {
  437. $id_arr = $this->input->post('s');
  438. $id_arr = explode(',', $id_arr);
  439. if (!$id_arr) {
  440. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  441. exit;
  442. }
  443. //循环删除记录
  444. foreach ($id_arr as $v) {
  445. $sid = $this->whlabel->read($v);
  446. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  447. if ($count > 0) {
  448. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  449. exit;
  450. }
  451. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  452. if (count($zt) > 0) {
  453. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  454. exit;
  455. }
  456. $this->whlabel->remove($v);
  457. }
  458. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  459. exit;
  460. }
  461. if (isset($post['page'])) {
  462. $page = $this->input->post('page', true);
  463. $perpage = $this->input->post('perpage', true);
  464. $warehouse = $this->input->post('warehouse', true);
  465. $label = $this->input->post('label', true);
  466. $where = "1=1 and state = 0";
  467. if ($warehouse) {
  468. $where .= " and warehouse = '$warehouse'";
  469. }
  470. if ($label) {
  471. $where .= " and label = '$label'";
  472. }
  473. //数据排序
  474. $order_str = "time asc";
  475. if (empty($page)) {
  476. $start = 0;
  477. $perpage = 1;
  478. } else {
  479. $start = ($page - 1) * $perpage;
  480. }
  481. //取得信息列表
  482. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  483. foreach ($info_list as $key => $value) {
  484. if ($value['enter'] != 0) {
  485. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  486. } else {
  487. $info_list[$key]['enter'] = "";
  488. }
  489. if ($value['printing'] != 0) {
  490. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  491. } else {
  492. $info_list[$key]['printing'] = "";
  493. }
  494. }
  495. $total = $this->whlabel->find_count($where);
  496. $pagenum = ceil($total / $perpage);
  497. $over = $total - ($start + $perpage);
  498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  499. echo json_encode($rows);
  500. exit;
  501. }
  502. $this->_Template('whlabel_existence', $this->data);
  503. }
  504. //进销存浏览
  505. public function _typedy($arg_array)
  506. {
  507. $prc = array();
  508. $purchase = $this->purchase->find_all();
  509. foreach ($purchase as $k => $v) {
  510. $prc[$v['id']] = $v['title'];
  511. }
  512. $post = $this->input->post(NULL, TRUE);
  513. if (isset($post['page'])) {
  514. $page = $this->input->post('page', true);
  515. $perpage = $this->input->post('perpage', true);
  516. $category = $this->input->post('category', true);
  517. $size = $this->input->post('size', true);
  518. $grade = $this->input->post('grade', true);
  519. $color = $this->input->post('color', true);
  520. $lowe = $this->input->post('lowe', true);
  521. $sku = $this->input->post('sku');
  522. $title = $this->input->post('title');
  523. $warehouse = $this->input->post('warehouse', true);
  524. $usa = $this->input->post('usa', true);
  525. $purchase = $this->input->post('purchase', true);
  526. $lacetype = $this->input->post('lacetype', true);
  527. $haircap = $this->input->post('haircap', true);
  528. $density = $this->input->post('density', true);
  529. $details = $this->input->post('details', true);
  530. $state = $this->input->post('state', true);
  531. $lacecolor = $this->input->post('lacecolor', true);
  532. $hairnumber = $this->input->post('hairnumber', true);
  533. $cklx = $this->input->post('cklx', true);
  534. $ktime = $this->input->post('ktime', true);
  535. $jtime = $this->input->post('jtime', true);
  536. $sm = $this->input->post('sm', true);
  537. $cpbz = $this->input->post('cpbz', true);
  538. $type = $this->input->post('type', true);
  539. $ktime = strtotime($ktime);
  540. $jtime = strtotime($jtime);
  541. $where = "1=1";
  542. $gj = "";
  543. $ck = "";
  544. if ($usa) {
  545. if (!$warehouse) {
  546. $where .= " and (warehouse = '5' or warehouse = '8')";
  547. }
  548. }
  549. if ($warehouse) {
  550. $where .= " and warehouse = '$warehouse'";
  551. }
  552. if ($details) {
  553. $where .= " and details = '$details'";
  554. }
  555. if ($purchase) {
  556. $where .= " and purchase = '$purchase'";
  557. }
  558. if (isset($state)) {
  559. if($state >-1){
  560. $where .= " and state = '$state'";
  561. }
  562. }
  563. if ($lacetype) {
  564. $where .= " and features like '%-$lacetype-%'";
  565. }
  566. if ($category) {
  567. $where .= " and features like '%-$category-%'";
  568. }
  569. if ($size) {
  570. $where .= " and features like '%-$size-%'";
  571. }
  572. if ($grade) {
  573. $where .= " and features like '%-$grade-%'";
  574. }
  575. if ($color) {
  576. $where .= " and features like '%-$color-%'";
  577. }
  578. if ($lowe) {
  579. $where .= " and features like '%-$lowe-%'";
  580. }
  581. if ($haircap) {
  582. $where .= " and features like '%-$haircap-%'";
  583. }
  584. if ($density) {
  585. $where .= " and features like '%-$density-%'";
  586. }
  587. if ($lacecolor) {
  588. $where .= " and features like '%-$lacecolor-%'";
  589. }
  590. if($sm){
  591. $where .= " and sm like '%".$sm."%'";
  592. }
  593. if($cpbz){
  594. $where .= " and cpbz like '%".$cpbz."%'";
  595. }
  596. if($type){
  597. $where .= " and type = ".$type."";
  598. }
  599. if (!empty($hairnumber)) {
  600. $where .= " and features like '%-128-%' ";
  601. if ($hairnumber < 0) {
  602. $class_list = $this->typeclass->find_all('classid = 43');
  603. foreach ($class_list as $v) {
  604. $where .= " and features not like '%-" . $v['id'] . "-%'";
  605. }
  606. } else {
  607. $where .= " and features like '%-$hairnumber-%'";
  608. }
  609. }
  610. $where_add = '';
  611. if ($cklx) {
  612. $shop = $this->shop->read($cklx);
  613. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  614. }
  615. if ($ktime && $jtime) {
  616. $gj = " and enter > '$ktime' and enter < '$jtime'";
  617. $ck = " and outk > '$ktime' and outk < '$jtime'";
  618. }
  619. //数据排序
  620. $order_str = "id desc";
  621. if (empty($page)) {
  622. $start = 0;
  623. $perpage = 1;
  624. } else {
  625. $start = ($page - 1) * $perpage;
  626. }
  627. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  628. if ($sku) {
  629. $sku = trim($sku, ' ');
  630. $sku = trim($sku, ' ');
  631. $where .= " and sku like '%$sku%'";
  632. $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);
  633. } else if ($title) {
  634. $title = trim($title, ' ');
  635. $title = trim($title, ' ');
  636. $where .= " and title like '%$title%'";
  637. $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);
  638. } else {
  639. //$where .= " and time > '$ktime' and time < '$jtime'";
  640. $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);
  641. }
  642. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  643. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  644. foreach ($info_list as $k => $v) {
  645. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  646. unset($info_list[$k]['pm']);
  647. unset($info_list[$k]['jm']);
  648. unset($info_list[$k]['bm']);
  649. }
  650. //取得信息列表
  651. $rows = array();
  652. $list = array();
  653. foreach ($info_list as $key => $value) {
  654. $warehouse = $this->warehouse->read($value['warehouse']);
  655. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  656. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  657. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  658. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  659. $info_list[$key]['label'] = $value['sm'];
  660. $number = $value['number'];
  661. $ftime = time() - 15 * 24 * 3600;
  662. $info_list[$key]['warehouse'] = $warehouse['title'];
  663. $info_list[$key]['features'] = count($c);
  664. $z = count($z); //查看订单号
  665. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  666. $ztdata = '';
  667. if (count($zt) > 0) {
  668. foreach ($zt as $vv) {
  669. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  670. }
  671. }
  672. $info_list[$key]['number'] = $ztdata;
  673. $info_list[$key]['sm'] = $z;
  674. $details = array();
  675. $cpid = array();
  676. foreach ($c as $k => $v) {
  677. $details[$v['details']] = $v['details'];
  678. if ($v['cpid'] != 0) {
  679. $cpid[$v['cpid']] = $v['cpid'];
  680. }
  681. }
  682. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  683. if ($value['shop'] != '') {
  684. $shop = explode(',', trim($value['shop'], ','));
  685. $shop = $this->shop->read($shop[0]);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. }
  688. }
  689. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  690. $pagenum = ceil($total / $perpage);
  691. $over = $total - ($start + $perpage);
  692. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  693. echo json_encode($rows);
  694. exit;
  695. }
  696. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  697. $this->_Template('whlabel_typedy', $this->data);
  698. }
  699. //进销存浏览
  700. public function _typedy_ck($arg_array)
  701. {
  702. $prc = array();
  703. $purchase = $this->purchase->find_all();
  704. foreach ($purchase as $k => $v) {
  705. $prc[$v['id']] = $v['title'];
  706. }
  707. $post = $this->input->post(NULL, TRUE);
  708. if (isset($post['page'])) {
  709. $page = $this->input->post('page', true);
  710. $perpage = $this->input->post('perpage', true);
  711. $category = $this->input->post('category', true);
  712. $size = $this->input->post('size', true);
  713. $grade = $this->input->post('grade', true);
  714. $color = $this->input->post('color', true);
  715. $lowe = $this->input->post('lowe', true);
  716. $sku = $this->input->post('sku');
  717. $title = $this->input->post('title');
  718. $warehouse = $this->input->post('warehouse', true);
  719. $usa = $this->input->post('usa', true);
  720. $purchase = $this->input->post('purchase', true);
  721. $lacetype = $this->input->post('lacetype', true);
  722. $haircap = $this->input->post('haircap', true);
  723. $density = $this->input->post('density', true);
  724. $details = $this->input->post('details', true);
  725. $state = $this->input->post('state', true);
  726. $lacecolor = $this->input->post('lacecolor', true);
  727. $cklx = $this->input->post('cklx', true);
  728. $ktime = $this->input->post('ktime', true);
  729. $jtime = $this->input->post('jtime', true);
  730. $ktime = strtotime($ktime);
  731. $jtime = strtotime($jtime);
  732. $where = "1=1";
  733. $gj = "";
  734. $ck = "";
  735. if ($lacetype) {
  736. $where .= " and features like '%-$lacetype-%'";
  737. }
  738. if ($category) {
  739. $where .= " and features like '%-$category-%'";
  740. }
  741. if ($size) {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if ($grade) {
  745. $where .= " and features like '%-$grade-%'";
  746. }
  747. if ($color) {
  748. $where .= " and features like '%-$color-%'";
  749. }
  750. if ($lowe) {
  751. $where .= " and features like '%-$lowe-%'";
  752. }
  753. if ($haircap) {
  754. $where .= " and features like '%-$haircap-%'";
  755. }
  756. if ($density) {
  757. $where .= " and features like '%-$density-%'";
  758. }
  759. if ($lacecolor) {
  760. $where .= " and features like '%-$lacecolor-%'";
  761. }
  762. if ($usa) {
  763. if (!$warehouse) {
  764. $where .= " and (warehouse = '5' or warehouse = '8')";
  765. }
  766. }
  767. if ($warehouse) {
  768. $where .= " and warehouse = '$warehouse'";
  769. }
  770. if ($details) {
  771. $where .= " and details = '$details'";
  772. }
  773. if ($purchase) {
  774. $where .= " and purchase = '$purchase'";
  775. }
  776. if ($state) {
  777. $where .= " and state = '$state'";
  778. }
  779. $where_add = '';
  780. if ($cklx) {
  781. $shop = $this->shop->read($cklx);
  782. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  783. }
  784. if ($ktime && $jtime) {
  785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  787. }
  788. //数据排序
  789. $order_str = "id desc";
  790. if (empty($page)) {
  791. $start = 0;
  792. $perpage = 1;
  793. } else {
  794. $start = ($page - 1) * $perpage;
  795. }
  796. if ($sku) {
  797. $sku = trim($sku, ' ');
  798. $sku = trim($sku, ' ');
  799. $where .= " and sku like '%$sku%'";
  800. $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);
  801. } else if ($title) {
  802. $title = trim($title, ' ');
  803. $title = trim($title, ' ');
  804. $where .= " and title like '%$title%'";
  805. $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);
  806. } else {
  807. //$where .= " and time > '$ktime' and time < '$jtime'";
  808. $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);
  809. }
  810. //取得信息列表
  811. $rows = array();
  812. $list = array();
  813. foreach ($info_list as $key => $value) {
  814. $warehouse = $this->warehouse->read($value['warehouse']);
  815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  816. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  817. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  818. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  819. $ftime = time() - 15 * 24 * 3600;
  820. $info_list[$key]['warehouse'] = $warehouse['title'];
  821. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  822. //$z = count($z);//查看订单号
  823. //$info_list[$key]['zd'] = $z;
  824. $details = array();
  825. $cpid = array();
  826. foreach ($c as $k => $v) {
  827. $details[$v['details']] = $v['details'];
  828. if ($v['cpid'] != 0) {
  829. $cpid[$v['cpid']] = $v['cpid'];
  830. }
  831. }
  832. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  833. if ($value['shop'] != '') {
  834. $shop = explode(',', trim($value['shop'], ','));
  835. $shop = $this->shop->read($shop[0]);
  836. $info_list[$key]['shop'] = $shop['shopname'];
  837. }
  838. }
  839. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  840. $pagenum = ceil($total / $perpage);
  841. $over = $total - ($start + $perpage);
  842. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  843. echo json_encode($rows);
  844. exit;
  845. }
  846. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  847. $this->_Template('whlabel_typedy_ck', $this->data);
  848. }
  849. public function _typeck($arg_array)
  850. {
  851. $prc = array();
  852. $purchase = $this->purchase->find_all();
  853. foreach ($purchase as $k => $v) {
  854. $prc[$v['id']] = $v['title'];
  855. }
  856. $post = $this->input->post(NULL, TRUE);
  857. if (isset($post['page'])) {
  858. $page = $this->input->post('page', true);
  859. $perpage = $this->input->post('perpage', true);
  860. $category = $this->input->post('category', true);
  861. $size = $this->input->post('size', true);
  862. $grade = $this->input->post('grade', true);
  863. $color = $this->input->post('color', true);
  864. $lacecolor = $this->input->post('lacecolor', true);
  865. $lowe = $this->input->post('lowe', true);
  866. $sku = $this->input->post('sku');
  867. $title = $this->input->post('title');
  868. $warehouse = 13;
  869. $usa = $this->input->post('usa', true);
  870. $purchase = $this->input->post('purchase', true);
  871. $lacetype = $this->input->post('lacetype', true);
  872. $haircap = $this->input->post('haircap', true);
  873. $density = $this->input->post('density', true);
  874. $details = $this->input->post('details', true);
  875. $state = $this->input->post('state', true);
  876. $ktime = $this->input->post('ktime', true);
  877. $jtime = $this->input->post('jtime', true);
  878. $ktime = strtotime($ktime);
  879. $jtime = strtotime($jtime);
  880. $where = "1=1";
  881. $gj = "";
  882. $ck = "";
  883. if ($lacetype) {
  884. $where .= " and features like '%-$lacetype-%'";
  885. }
  886. if ($category) {
  887. $where .= " and features like '%-$category-%'";
  888. }
  889. if ($size) {
  890. $where .= " and features like '%-$size-%'";
  891. }
  892. if ($grade) {
  893. $where .= " and features like '%-$grade-%'";
  894. }
  895. if ($color) {
  896. $where .= " and features like '%-$color-%'";
  897. }
  898. if ($lacecolor) {
  899. $where .= " and features like '%-$lacecolor-%'";
  900. }
  901. if ($lowe) {
  902. $where .= " and features like '%-$lowe-%'";
  903. }
  904. if ($haircap) {
  905. $where .= " and features like '%-$haircap-%'";
  906. }
  907. if ($density) {
  908. $where .= " and features like '%-$density-%'";
  909. }
  910. if ($warehouse) {
  911. $where .= " and warehouse = '$warehouse'";
  912. }
  913. if ($details) {
  914. $where .= " and details = '$details'";
  915. }
  916. if ($purchase) {
  917. $where .= " and purchase = '$purchase'";
  918. }
  919. if ($state) {
  920. $where .= " and state = '$state'";
  921. }
  922. if ($ktime && $jtime) {
  923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  925. }
  926. //数据排序
  927. $order_str = "id desc";
  928. if (empty($page)) {
  929. $start = 0;
  930. $perpage = 1;
  931. } else {
  932. $start = ($page - 1) * $perpage;
  933. }
  934. if ($sku) {
  935. $sku = trim($sku, ' ');
  936. $sku = trim($sku, ' ');
  937. $where .= " and sku like '%$sku%'";
  938. } else if ($title) {
  939. $title = trim($title, ' ');
  940. $title = trim($title, ' ');
  941. $where .= " and title like '%$title%'";
  942. }
  943. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  944. //取得信息列表
  945. $t = array();
  946. $typeclass = $this->typeclass->find_all();
  947. foreach ($typeclass as $v) {
  948. $t[$v['id']] = $v;
  949. }
  950. $rows = array();
  951. $list = array();
  952. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  953. foreach ($info_list as $key => $value) {
  954. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  955. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  956. $warehouse = $this->warehouse->read($value['warehouse']);
  957. $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');
  958. $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'] . '"');
  959. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  960. $number = $value['number'];
  961. $ftime = time() - 15 * 24 * 3600;
  962. $z = count($z); //查看订单号
  963. $info_list[$key]['warehouse'] = $warehouse['title'];
  964. $info_list[$key]['features'] = count($c);
  965. $info_list[$key]['number'] = $z;
  966. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  967. $details = array();
  968. $cpid = array();
  969. foreach ($c as $k => $v) {
  970. $details[$v['details']] = $v['details'];
  971. if ($v['cpid'] != 0) {
  972. $cpid[$v['cpid']] = $v['cpid'];
  973. }
  974. }
  975. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  976. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  977. unset($info_list[$key]['pm']);
  978. unset($info_list[$key]['jm']);
  979. unset($info_list[$key]['bm']);
  980. }
  981. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  982. $pagenum = ceil($total / $perpage);
  983. $over = $total - ($start + $perpage);
  984. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  985. echo json_encode($rows);
  986. exit;
  987. }
  988. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  989. $this->_Template('whlabel_typeck', $this->data);
  990. }
  991. //进销存导出
  992. public function _whlabeckdc()
  993. {
  994. $prc = array();
  995. $purchase = $this->purchase->find_all();
  996. foreach ($purchase as $k => $v) {
  997. $prc[$v['id']] = $v['title'];
  998. }
  999. if (isset($_GET['excel'])) {
  1000. $where = "sku != 'Preset'";
  1001. //数据排序
  1002. $order_str = "id desc";
  1003. if (empty($page)) {
  1004. $start = 0;
  1005. $perpage = 1;
  1006. } else {
  1007. $start = ($page - 1) * $perpage;
  1008. }
  1009. $category = $this->input->get('category', true);
  1010. $color = $this->input->get('color', true);
  1011. $lowe = $this->input->get('lowe', true);
  1012. $lacetype = $this->input->get('lacetype', true);
  1013. $size = $this->input->get('size', true);
  1014. $density = $this->input->get('density', true);
  1015. $haircap = $this->input->get('haircap', true);
  1016. $sku = $this->input->get('sku', true);
  1017. $details = $this->input->get('details', true);
  1018. $warehouse = 13;
  1019. $excelid = $this->input->get('sid', true);
  1020. if ($category) {
  1021. $where .= " and features like '%-$category-%'";
  1022. }
  1023. if ($color) {
  1024. $where .= " and features like '%-$color-%'";
  1025. }
  1026. if ($lowe) {
  1027. $where .= " and features like '%-$lowe-%'";
  1028. }
  1029. if ($lacetype) {
  1030. $where .= " and features like '%-$lacetype-%'";
  1031. }
  1032. if ($size) {
  1033. $where .= " and features like '%-$size-%'";
  1034. }
  1035. if ($density) {
  1036. $where .= " and features like '%-$density-%'";
  1037. }
  1038. if ($haircap) {
  1039. $where .= " and features like '%-$haircap-%'";
  1040. }
  1041. if ($warehouse) {
  1042. $where .= " and warehouse = '$warehouse'";
  1043. }
  1044. if ($sku) {
  1045. $where .= " and sku like '%$sku%'";
  1046. }
  1047. if ($details) {
  1048. $where .= " and details = '$details'";
  1049. }
  1050. $xzid = '';
  1051. if ($excelid) {
  1052. $excelid = explode(',', trim($excelid, ','));
  1053. foreach ($excelid as $key => $value) {
  1054. $xzid .= " id = " . $value . " or";
  1055. }
  1056. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1057. }
  1058. //取得信息列表
  1059. /**
  1060. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1061. $rows = array();$list = array();
  1062. foreach ($info_list as $key=>$value)
  1063. {
  1064. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1065. }
  1066. **/
  1067. $wh = array();
  1068. $w = $this->warehouse->find_all('1=1', 'id,title');
  1069. foreach ($w as $v) {
  1070. $wh[$v['id']] = $v['title'];
  1071. }
  1072. $tc = array();
  1073. $tcdata = array();
  1074. $list = array();
  1075. $classid = $this->classid->sku();
  1076. $tcall = $this->typeclass->find_all();
  1077. $typeclass = array();
  1078. foreach ($tcall as $v)
  1079. {
  1080. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1081. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1082. }
  1083. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1084. foreach ($rows as $key => $value) {
  1085. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1086. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1087. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1088. $rows[$key]['cpbz'] = $u9_info['bm'];
  1089. $rows[$key]['cs'] = $u9_info['jm'];
  1090. if(empty($value['details'])){
  1091. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1092. }else{
  1093. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1094. }
  1095. $details = array();
  1096. $cpid = array();
  1097. $cpbz = array();
  1098. $c = 0;
  1099. $g = 0;
  1100. $x = 0;
  1101. $t = 0;
  1102. $s = 0;
  1103. $q = 0;
  1104. foreach ($sd as $k => $v) {
  1105. if ($v['state'] == 0) {
  1106. $c++;
  1107. }
  1108. if ($v['state'] != 9) {
  1109. $g++;
  1110. }
  1111. if ($v['state'] == 1) {
  1112. $x++;
  1113. }
  1114. if ($v['state'] == 2) {
  1115. $t++;
  1116. }
  1117. if ($v['state'] == 8) {
  1118. $s++;
  1119. }
  1120. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1121. $q++;
  1122. }
  1123. $details[$v['details']] = $v['details'];
  1124. if ($v['cpid'] != 0) {
  1125. $cpid[$v['cpid']] = $v['cpid'];
  1126. }
  1127. if ($v['cpbz'] != '') {
  1128. $cpbz[$v['cpbz']] = $v['cpbz'];
  1129. }
  1130. }
  1131. $rows[$key]['details'] = implode("、", $details);
  1132. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1133. $number = $value['number'];
  1134. $ftime = time() - 15 * 24 * 3600;
  1135. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1136. $rows[$key]['number'] = $g;
  1137. $rows[$key]['features'] = $c;
  1138. $rows[$key]['x'] = $x;
  1139. $rows[$key]['t'] = $t;
  1140. $rows[$key]['s'] = $s;
  1141. $rows[$key]['q'] = $q;
  1142. $rows[$key]['wzsl'] = count($details);
  1143. //cpbzs
  1144. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1145. $unique_arr = array_unique($tmp_cpbzs);
  1146. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1147. }
  1148. $title = "进销存统计表" . date('Y-m-d', time());
  1149. $titlename = "<table border=1>
  1150. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1151. <tr align='center'>
  1152. <td>仓库</td>
  1153. <td>供应商</td>
  1154. <td>位置</td>
  1155. <td>库存编码</td>
  1156. <td>SKU</td>
  1157. <td>用友编码</td>
  1158. <td>用友料号</td>
  1159. <td>产品英文名</td>
  1160. <td>产品中文名</td>
  1161. <td>备注</td>
  1162. <td>入库总量</td>
  1163. <td>库存数量</td>
  1164. <td>销售数量</td>
  1165. <td>退货数量</td>
  1166. <td>删除数量</td>
  1167. <td>其它操作</td>
  1168. <td>位置数量</td>
  1169. </tr>
  1170. </table>";
  1171. $filename = $title . ".xls";
  1172. $tail = "";
  1173. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1174. }
  1175. }
  1176. public function _type()
  1177. {
  1178. $vip = 0;
  1179. if (isset($_SESSION['api'])) {
  1180. $user = $this->user->get_api($_SESSION['api']);
  1181. $fgshop = "";
  1182. $sid = "";
  1183. $usersp = explode('|', trim($user['shop'], '|'));
  1184. foreach ($usersp as $value) {
  1185. $fgshop .= " shop = " . $value . " or";
  1186. $sid .= " id = " . $value . " or";
  1187. }
  1188. if ($user['vip'] == 1) {
  1189. $vip = 1;
  1190. }
  1191. } else {
  1192. header('Location: /');
  1193. exit;
  1194. }
  1195. $prc = array();
  1196. $purchase = $this->purchase->find_all();
  1197. foreach ($purchase as $k => $v) {
  1198. $prc[$v['id']] = $v['title'];
  1199. }
  1200. $company = array();
  1201. $ct = $this->company->find_all();
  1202. foreach ($ct as $k => $v) {
  1203. $company[$v['id']] = $v['title'];
  1204. }
  1205. $sp = array();
  1206. $s = $this->shop->find_all('1=1', 'id,shopname');
  1207. foreach ($s as $v) {
  1208. $sp[$v['id']] = $v['shopname'];
  1209. }
  1210. $wh = array();
  1211. $w = $this->warehouse->find_all('1=1', 'id,title');
  1212. foreach ($w as $v) {
  1213. $wh[$v['id']] = $v['title'];
  1214. }
  1215. $post = $this->input->post(NULL, TRUE);
  1216. if (isset($post['page'])) {
  1217. $page = $this->input->post('page', true);
  1218. $perpage = $this->input->post('perpage', true);
  1219. $category = $this->input->post('category', true);
  1220. $size = $this->input->post('size', true);
  1221. $grade = $this->input->post('grade', true);
  1222. $color = $this->input->post('color', true);
  1223. $lowe = $this->input->post('lowe', true);
  1224. $sku = $this->input->post('sku');
  1225. $title = $this->input->post('title');
  1226. $warehouse = $this->input->post('warehouse', true);
  1227. $usa = $this->input->post('usa', true);
  1228. $purchase = $this->input->post('purchase', true);
  1229. $lacetype = $this->input->post('lacetype', true);
  1230. $haircap = $this->input->post('haircap', true);
  1231. $density = $this->input->post('density', true);
  1232. $details = $this->input->post('details', true);
  1233. $state = $this->input->post('state', true);
  1234. $shop = $this->input->post('shop', true);
  1235. $lacecolor = $this->input->post('lacecolor', true);
  1236. $hairnumber = $this->input->post('hairnumber', true);
  1237. $type = $this->input->post('type', true);
  1238. $ktime = $this->input->post('ktime', true);
  1239. $jtime = $this->input->post('jtime', true);
  1240. $ktime = strtotime($ktime);
  1241. $jtime = strtotime($jtime);
  1242. $cpbz = $this->input->post('cpbz', true);
  1243. $sm = $this->input->post('sm', true);
  1244. $where = "1=1";
  1245. $gj = "";
  1246. $ck = "";
  1247. if ($usa) {
  1248. if (!$warehouse) {
  1249. $where .= " and (warehouse = '5' or warehouse = '8')";
  1250. }
  1251. }
  1252. if ($warehouse) {
  1253. $where .= " and warehouse = '$warehouse'";
  1254. }
  1255. if ($details) {
  1256. $where .= " and details = '$details'";
  1257. }
  1258. if ($purchase) {
  1259. $where .= " and purchase = '$purchase'";
  1260. }
  1261. if ($state) {
  1262. $where .= " and state = '$state'";
  1263. }
  1264. if ($shop) {
  1265. $where .= " and shop like '%$shop%'";
  1266. }
  1267. if ($type) {
  1268. $where .= " and type = '$type'";
  1269. }
  1270. if ($ktime && $jtime) {
  1271. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1272. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1273. }
  1274. if ($cpbz) {
  1275. $where .= " and cpbz like '%$cpbz%' ";
  1276. }
  1277. if ($sm) {
  1278. $where .= " and sm like '%$sm%' ";
  1279. }
  1280. if ($lacecolor) {
  1281. $where .= " and features like '%-$lacecolor-%'";
  1282. }
  1283. if ($lacetype) {
  1284. $where .= " and features like '%-$lacetype-%'";
  1285. }
  1286. if ($category) {
  1287. $where .= " and features like '%-$category-%'";
  1288. }
  1289. if ($size) {
  1290. $where .= " and features like '%-$size-%'";
  1291. }
  1292. if ($grade) {
  1293. $where .= " and features like '%-$grade-%'";
  1294. }
  1295. if ($color) {
  1296. $where .= " and features like '%-$color-%'";
  1297. }
  1298. if ($lowe) {
  1299. $where .= " and features like '%-$lowe-%'";
  1300. }
  1301. if ($haircap) {
  1302. $where .= " and features like '%-$haircap-%'";
  1303. }
  1304. if ($density) {
  1305. $where .= " and features like '%-$density-%'";
  1306. }
  1307. if (!empty($hairnumber)) {
  1308. $where .= " and features like '%-128-%' ";
  1309. if ($hairnumber < 0) {
  1310. $class_list = $this->typeclass->find_all('classid = 43');
  1311. foreach ($class_list as $v) {
  1312. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1313. }
  1314. } else {
  1315. $where .= " and features like '%-$hairnumber-%'";
  1316. }
  1317. }
  1318. //数据排序
  1319. $order_str = "id desc";
  1320. if (empty($page)) {
  1321. $start = 0;
  1322. $perpage = 1;
  1323. } else {
  1324. $start = ($page - 1) * $perpage;
  1325. }
  1326. $fjnr = '';
  1327. if ($sku) {
  1328. $sku = trim($sku, ' ');
  1329. $sku = trim($sku, ' ');
  1330. $fjnr .= " and sku like '%$sku%'";
  1331. }
  1332. if ($title) {
  1333. $title = trim($title, ' ');
  1334. $title = trim($title, ' ');
  1335. $fjnr .= " and title like '%$title%'";
  1336. }
  1337. $wt = array();
  1338. $whlabel_type = $this->whlabel_type->find_all();
  1339. foreach ($whlabel_type as $v) {
  1340. $wt[$v['id']] = $v['title'];
  1341. }
  1342. //$where .= " and time > '$ktime' and time < '$jtime'";
  1343. $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
  1344. //取得信息列表
  1345. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1346. $rows = array();
  1347. $list = array();
  1348. foreach ($info_list as $key => $value) {
  1349. if (isset($wt[$value['type']])) {
  1350. $info_list[$key]['type'] = $wt[$value['type']];
  1351. } else {
  1352. $info_list[$key]['type'] = '未设置';
  1353. }
  1354. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1355. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1356. $ztdata = '';
  1357. if (count($zt) > 0) {
  1358. foreach ($zt as $vv) {
  1359. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1360. }
  1361. }
  1362. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1363. $cdata = array_filter($qbdata, function ($item) {
  1364. return $item['state'] < 1;
  1365. });
  1366. $c = array_sum(array_column($cdata, 'jnum'));
  1367. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1368. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1369. });
  1370. $g = array_sum(array_column($gdata, 'jnum'));
  1371. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1373. });
  1374. $x = array_sum(array_column($xdata, 'jnum'));
  1375. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $t = array_sum(array_column($tdata, 'jnum'));
  1379. // $zdata = array_filter($qbdata, function ($item) {
  1380. // return $item['zd'] != "" && $item['state'] < 1;
  1381. // });
  1382. // $z = array_sum(array_column($zdata, 'jnum'));
  1383. $zdata = array_filter($qbdata, function ($item) {
  1384. return $item['zd'] != "" && $item['state'] < 1;
  1385. });
  1386. $z = array_sum(array_column($zdata, 'jnum'));
  1387. //$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');
  1388. //$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'].'"');
  1389. //$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'].'"');
  1390. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1391. //$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'].'"');
  1392. $details = array();
  1393. $cpid = array();
  1394. $od = array();
  1395. $odid = '';
  1396. $companytitle = '';
  1397. $shop_list = [];
  1398. foreach ($qbdata as $v) {
  1399. if ($v['zd'] != "" && $v['state'] < 1) {
  1400. if (!isset($od[$v['zd']])) {
  1401. $od[$v['zd']] = 1; //所有数据sku
  1402. } else {
  1403. $od[$v['zd']] = $od[$v['zd']] + 1;
  1404. }
  1405. }
  1406. $details[$v['details']] = $v['details'];
  1407. if ($v['state'] < 1) {
  1408. //$details[$v['details']] = $v['details'];
  1409. if ($v['cpid'] != 0) {
  1410. $cpid[$v['cpid']] = $v['cpid'];
  1411. }
  1412. }
  1413. if($v['state'] == 0){
  1414. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1415. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1416. }
  1417. if ($v['shop'] != '') {
  1418. $shop = explode(',', trim($v['shop'], ','));
  1419. foreach ($shop as $vv) {
  1420. if (!in_array($vv, $shop_list)) {
  1421. $shop_list[] = $vv;
  1422. }
  1423. }
  1424. }
  1425. }
  1426. }
  1427. foreach ($od as $k => $vv) {
  1428. $odid .= $k . '数量' . $vv;
  1429. }
  1430. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1431. $info_list[$key]['label'] = $value['sm'];
  1432. $number = $value['number'];
  1433. $ftime = time() - 15 * 24 * 3600;
  1434. $z = $z . '(' . $odid . ')'; //查看订单号
  1435. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1436. $info_list[$key]['features'] = $c;
  1437. $info_list[$key]['number'] = $ztdata;
  1438. $info_list[$key]['sm'] = $g;
  1439. $info_list[$key]['x'] = $x;
  1440. $info_list[$key]['t'] = $t;
  1441. $info_list[$key]['z'] = $z;
  1442. /**
  1443. foreach ($cdata as $k=>$v)
  1444. {
  1445. $details[$v['details']] = $v['details'];
  1446. if($v['cpid'] != 0)
  1447. {
  1448. $cpid[$v['cpid']] = $v['cpid'];
  1449. }
  1450. }
  1451. **/
  1452. $info_list[$key]['shop'] = '';
  1453. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1454. // if ($value['shop'] != '') {
  1455. // $shop = explode(',', trim($value['shop'], ','));
  1456. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1457. // }
  1458. $shop_list = array_unique($shop_list);
  1459. $shop_str = '';
  1460. foreach ($shop_list as $v) {
  1461. if(isset($sp[$v])){
  1462. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1463. }
  1464. }
  1465. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1466. /**
  1467. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1468. if(isset($companytitle[0]))
  1469. {
  1470. foreach ($companytitle as $k=>$v)
  1471. {
  1472. if($v['companytitle'] != '')
  1473. {
  1474. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1475. }
  1476. }
  1477. }
  1478. **/
  1479. }
  1480. $final_all_list = [];
  1481. foreach ($info_list as $k => $v) {
  1482. $final_all_list[] = [
  1483. 'id' => $v['id'],
  1484. "warehouse" => $v["warehouse"],
  1485. "purchase" => $v["purchase"],
  1486. "sku" => $v["sku"],
  1487. "title" => $v["title"] . "<br/>" . $v["pm"],
  1488. "details" => $v["details"],
  1489. "shop" => $v["shop"],
  1490. "cpbz" => $v["cpbz"],
  1491. 'label' => $v['label'],
  1492. "type" => $v["type"],
  1493. "features" => $v["features"],
  1494. "number" => $v["number"],
  1495. "sm" => $v["sm"],
  1496. "x" => $v["x"],
  1497. "t" => $v["t"],
  1498. "z" => $v["z"]
  1499. ];
  1500. }
  1501. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1502. $pagenum = ceil($total / $perpage);
  1503. $over = $total - ($start + $perpage);
  1504. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1505. echo json_encode($rows);
  1506. exit;
  1507. }
  1508. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1509. $this->data['shop'] = $wlshop;
  1510. $this->data['vip'] = $vip;
  1511. $this->_Template('whlabel_type', $this->data);
  1512. }
  1513. //美仓进销存浏览
  1514. public function _usatype()
  1515. {
  1516. if (isset($_SESSION['api'])) {
  1517. $user = $this->user->get_api($_SESSION['api']);
  1518. $usp = $user;
  1519. $fgshop = "";
  1520. $sid = "";
  1521. $wid = "";
  1522. $wtype = "";
  1523. $userwh = explode('|', trim($user['warehouse'], '|'));
  1524. foreach ($userwh as $value) {
  1525. $wid .= " id = " . $value . " or";
  1526. $wtype .= " type = " . $value . " or";
  1527. }
  1528. }
  1529. $prc = array();
  1530. $purchase = $this->purchase->find_all();
  1531. foreach ($purchase as $k => $v) {
  1532. $prc[$v['id']] = $v['title'];
  1533. }
  1534. $post = $this->input->post(NULL, TRUE);
  1535. if (isset($post['page'])) {
  1536. $page = $this->input->post('page', true);
  1537. $perpage = $this->input->post('perpage', true);
  1538. $category = $this->input->post('category', true);
  1539. $size = $this->input->post('size', true);
  1540. $grade = $this->input->post('grade', true);
  1541. $color = $this->input->post('color', true);
  1542. $lowe = $this->input->post('lowe', true);
  1543. $sku = $this->input->post('sku');
  1544. $title = $this->input->post('title');
  1545. $warehouse = $this->input->post('warehouse', true);
  1546. $usa = $this->input->post('usa', true);
  1547. $purchase = $this->input->post('purchase', true);
  1548. $lacetype = $this->input->post('lacetype', true);
  1549. $haircap = $this->input->post('haircap', true);
  1550. $density = $this->input->post('density', true);
  1551. $details = $this->input->post('details', true);
  1552. $state = $this->input->post('state', true);
  1553. $lacecolor = $this->input->post('lacecolor', true);
  1554. $cklx = $this->input->post('cklx', true);
  1555. $ktime = $this->input->post('ktime', true);
  1556. $jtime = $this->input->post('jtime', true);
  1557. $ktime = strtotime($ktime);
  1558. $jtime = strtotime($jtime);
  1559. $where = "1=1";
  1560. $gj = "";
  1561. $ck = "";
  1562. if ($lacetype) {
  1563. $where .= " and features like '%-$lacetype-%'";
  1564. }
  1565. if ($category) {
  1566. $where .= " and features like '%-$category-%'";
  1567. }
  1568. if ($size) {
  1569. $where .= " and features like '%-$size-%'";
  1570. }
  1571. if ($grade) {
  1572. $where .= " and features like '%-$grade-%'";
  1573. }
  1574. if ($color) {
  1575. $where .= " and features like '%-$color-%'";
  1576. }
  1577. if ($lowe) {
  1578. $where .= " and features like '%-$lowe-%'";
  1579. }
  1580. if ($haircap) {
  1581. $where .= " and features like '%-$haircap-%'";
  1582. }
  1583. if ($density) {
  1584. $where .= " and features like '%-$density-%'";
  1585. }
  1586. if ($lacecolor) {
  1587. $where .= " and features like '%-$lacecolor-%'";
  1588. }
  1589. if ($usa) {
  1590. if (!$warehouse) {
  1591. $where .= " and (warehouse = '5' or warehouse = '8')";
  1592. }
  1593. }
  1594. if ($warehouse) {
  1595. $where .= " and warehouse = '$warehouse'";
  1596. }
  1597. if ($details) {
  1598. $where .= " and details = '$details'";
  1599. }
  1600. if ($purchase) {
  1601. $where .= " and purchase = '$purchase'";
  1602. }
  1603. if ($state) {
  1604. $where .= " and state = '$state'";
  1605. }
  1606. $where_add = '';
  1607. if ($cklx) {
  1608. $shop = $this->shop->read($cklx);
  1609. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1610. }
  1611. if ($ktime && $jtime) {
  1612. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1613. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1614. }
  1615. //数据排序
  1616. $order_str = "id desc";
  1617. if (empty($page)) {
  1618. $start = 0;
  1619. $perpage = 1;
  1620. } else {
  1621. $start = ($page - 1) * $perpage;
  1622. }
  1623. if ($sku) {
  1624. $sku = trim($sku, ' ');
  1625. $sku = trim($sku, ' ');
  1626. $where .= " and sku like '%$sku%'";
  1627. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1628. } else if ($title) {
  1629. $title = trim($title, ' ');
  1630. $title = trim($title, ' ');
  1631. $where .= " and title like '%$title%'";
  1632. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1633. } else {
  1634. //$where .= " and time > '$ktime' and time < '$jtime'";
  1635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1636. }
  1637. //取得信息列表
  1638. $rows = array();
  1639. $list = array();
  1640. foreach ($info_list as $key => $value) {
  1641. $warehouse = $this->warehouse->read($value['warehouse']);
  1642. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1643. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1644. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1645. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1646. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1647. $od = array();
  1648. $odid = '';
  1649. foreach ($z as $v) {
  1650. if (!isset($od[$v['zd']])) {
  1651. $od[$v['zd']] = 1; //所有数据sku
  1652. } else {
  1653. $od[$v['zd']] = $od[$v['zd']] + 1;
  1654. }
  1655. }
  1656. foreach ($od as $k => $vv) {
  1657. $odid .= $k . '数量' . $vv . ' ';
  1658. }
  1659. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1660. $info_list[$key]['features'] = $c;
  1661. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1662. $ztdata = '';
  1663. if (count($zt) > 0) {
  1664. foreach ($zt as $vv) {
  1665. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1666. }
  1667. }
  1668. $info_list[$key]['warehouse'] = $ztdata;
  1669. $info_list[$key]['g'] = $g;
  1670. $info_list[$key]['x'] = $x;
  1671. $info_list[$key]['t'] = $t;
  1672. $info_list[$key]['z'] = $z;
  1673. }
  1674. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1675. $pagenum = ceil($total / $perpage);
  1676. $over = $total - ($start + $perpage);
  1677. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1678. echo json_encode($rows);
  1679. exit;
  1680. }
  1681. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1682. $this->data['warehouse'] = $warehouse;
  1683. $this->_Template('whlabel_typeusa', $this->data);
  1684. }
  1685. //美仓进销存浏览
  1686. public function _usatypeapp()
  1687. {
  1688. $post = $this->input->post(NULL, TRUE);
  1689. if (isset($post['page'])) {
  1690. $page = $this->input->post('page', true);
  1691. $perpage = $this->input->post('perpage', true);
  1692. $sku = $this->input->post('sku', true);
  1693. $warehouse = 5;
  1694. $title = $this->input->post('title', true);
  1695. $state = $this->input->post('state', true);
  1696. $ktime = $this->input->post('ktime', true);
  1697. $jtime = $this->input->post('jtime', true);
  1698. $ktime = strtotime($ktime);
  1699. $jtime = strtotime($jtime);
  1700. $where = "1=1";
  1701. $gj = "";
  1702. $ck = "";
  1703. if ($title) {
  1704. $st = explode(' ', trim($title, ' '));
  1705. foreach ($st as $v) {
  1706. $where .= " and title like '%$v%'";
  1707. }
  1708. }
  1709. if ($warehouse) {
  1710. $where .= " and warehouse = '$warehouse'";
  1711. }
  1712. if ($state) {
  1713. $where .= " and state = '$state'";
  1714. }
  1715. if ($sku) {
  1716. $where .= " and sku like '%$sku%'";
  1717. }
  1718. if ($ktime && $jtime) {
  1719. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1720. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1721. }
  1722. //数据排序
  1723. $order_str = "id desc";
  1724. if (empty($page)) {
  1725. $start = 0;
  1726. $perpage = 1;
  1727. } else {
  1728. $start = ($page - 1) * $perpage;
  1729. }
  1730. //取得信息列表
  1731. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1732. $rows = array();
  1733. $list = array();
  1734. foreach ($info_list as $key => $value) {
  1735. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1736. }
  1737. $rowsdq = array_slice($rows, $start, $perpage);
  1738. foreach ($rowsdq as $value) {
  1739. $warehouse = $this->warehouse->read($value['warehouse']);
  1740. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1741. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1742. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1743. $od = array();
  1744. $odid = '';
  1745. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1746. }
  1747. $total = count($rows);
  1748. $pagenum = ceil($total / $perpage);
  1749. $over = $total - ($start + $perpage);
  1750. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1751. echo json_encode($rows);
  1752. exit;
  1753. }
  1754. $this->_Template('phone/p_usatypeapp', $this->data);
  1755. }
  1756. //入库操作
  1757. public function _enteradd()
  1758. {
  1759. $dt = 0;
  1760. if (isset($_SESSION['api'])) {
  1761. $user = $this->user->get_api($_SESSION['api']);
  1762. $usp = $user;
  1763. $fgshop = "";
  1764. $sid = "";
  1765. $user = explode('|', trim($user['shop'], '|'));
  1766. foreach ($user as $value) {
  1767. $fgshop .= " shop = " . $value . " or";
  1768. $sid .= " id = " . $value . " or";
  1769. }
  1770. }
  1771. $tc = $this->typeclass->find_all();
  1772. $typeclass = array();
  1773. foreach ($tc as $v) {
  1774. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1775. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1776. }
  1777. $post = $this->input->post(NULL, TRUE);
  1778. if (isset($post['sku'])) {
  1779. $list = array();
  1780. $num = "";
  1781. $title = "";
  1782. $features = "";
  1783. $order = $this->input->post('order', true);
  1784. $shop = $this->input->post('shop', true);
  1785. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1786. $sku = $this->input->post('sku', true);
  1787. $post['sm'] = $this->input->post('sm', true);
  1788. $post['warehouse'] = $this->input->post('warehouse', true);
  1789. $post['purchase'] = $this->input->post('purchase', true);
  1790. $post['retreatwarehouse'] = $post['warehouse'];
  1791. $post['state'] = $this->input->post('state', true);
  1792. $post['rktype'] = $this->input->post('rktype', true);
  1793. $post['text'] = $this->input->post('text', true);
  1794. $category = $this->input->post('category', true);
  1795. $list['category'] = $category;
  1796. $list['hairtype'] = $this->input->post('hairtype', true);
  1797. $list['grade'] = $this->input->post('grade', true);
  1798. $size = $this->input->post('size', true);
  1799. $xzsku = $this->input->post('xzsku', true);
  1800. $list['size'] = rtrim($size, ',');
  1801. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1802. $list['extension'] = $this->input->post('extension', true);
  1803. if ($category == 1297) {
  1804. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1805. }
  1806. if ($category == 1702) {
  1807. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1808. $list['syother'] = $this->input->post('syother', true);
  1809. }
  1810. if ($category == 133) {
  1811. $list['fittype'] = $this->input->post('fittype', true);
  1812. $list['acother'] = $this->input->post('acother', true);
  1813. }
  1814. $list['color'] = $this->input->post('color', true);
  1815. $list['lowe'] = $this->input->post('lowe', true);
  1816. if (!$post['purchase']) {
  1817. $post['purchase'] = 1;
  1818. }
  1819. if ($category == 127) {
  1820. $list['type'] = $this->input->post('type', true);
  1821. $list['headroad'] = $this->input->post('headroad', true);
  1822. $list['density'] = $this->input->post('density', true);
  1823. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1824. $list['lacesize'] = $this->input->post('lacesize', true);
  1825. }
  1826. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1827. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1828. }
  1829. if ($category == 128) {
  1830. $list['lacetype'] = $this->input->post('lacetype', true);
  1831. $list['haircap'] = $this->input->post('haircap', true);
  1832. $list['density'] = $this->input->post('density', true);
  1833. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1834. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1835. $list['wigother'] = $this->input->post('wigother', true);
  1836. $list['wigother1'] = $this->input->post('wigother1', true);
  1837. $list['wigother2'] = $this->input->post('wigother2', true);
  1838. }
  1839. if ($category == 129) {
  1840. $list['wide'] = $this->input->post('wide', true);
  1841. }
  1842. if ($category == 131) {
  1843. $list['gifttype'] = $this->input->post('gifttype', true);
  1844. $list['giftother'] = $this->input->post('giftother', true);
  1845. }
  1846. if ($category == 134) {
  1847. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1848. }
  1849. if ($category == 1297) {
  1850. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1851. $list['sywigother'] = $this->input->post('sywigother', true);
  1852. }
  1853. if ($category == 130 || $category == 133 || $category == 1702) {
  1854. $list['items'] = $this->input->post('items', true);
  1855. $list['weight'] = $this->input->post('weight', true);
  1856. }
  1857. if($category == 130){
  1858. $list['jfother'] = $this->input->post('jfother', true);
  1859. }
  1860. if ($category == 1702) {
  1861. $list['syhairther'] = $this->input->post('syhairther', true);
  1862. }
  1863. $classid = $this->classid->sku();
  1864. $scsku = $classid;
  1865. $pm = $classid;
  1866. foreach ($list as $k => $v) {
  1867. if ($v != 0) {
  1868. $num .= $v;
  1869. $features .= $v . '-';
  1870. $post[$k] = $v;
  1871. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1872. if ($k != 'size') {
  1873. $title .= $typeclass[$v]['title'] . " ";
  1874. }
  1875. if (isset($pm[$typeclass[$v]['classid']])) {
  1876. if ($typeclass[$v]['title'] == '9A') {
  1877. $pm[$typeclass[$v]['classid']] = '9A';
  1878. } else if ($typeclass[$v]['title'] == '10A') {
  1879. $pm[$typeclass[$v]['classid']] = '10A';
  1880. } else {
  1881. $clzh = $typeclass[$v]['zh'];
  1882. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1883. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1884. $clzh = $clzh[0];
  1885. }
  1886. $pm[$typeclass[$v]['classid']] = $clzh;
  1887. }
  1888. }
  1889. }
  1890. }
  1891. $zh = implode(" ", $pm);
  1892. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1893. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1894. if ($list['size']) {
  1895. $typeclass = $this->typeclass->read($list['size']);
  1896. $title .= $typeclass['title'];
  1897. }
  1898. $time = time();
  1899. if ($xzsku) {
  1900. $scsku = implode("-", $scsku);
  1901. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1902. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1903. $post['sku'] = trim($scsku, ' ');
  1904. } else {
  1905. $post['sku'] = $sku;
  1906. }
  1907. //$post['sku'] = trim($sku,' ');
  1908. $post['title'] = rtrim($title, ' ');
  1909. $post['number'] = $num;
  1910. $post['features'] = '-' . $features;
  1911. $post['enter'] = $time;
  1912. $post['time'] = $time; //操作时间
  1913. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1914. if ($yza) {
  1915. if ($post['features'] != $yza[0]['features']) {
  1916. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1917. exit;
  1918. }
  1919. }
  1920. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1921. if ($yzb) {
  1922. if ($post['sku'] != $yzb[0]['sku']) {
  1923. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1924. exit;
  1925. }
  1926. }
  1927. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1928. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1929. exit;
  1930. }
  1931. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1932. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1933. exit;
  1934. }
  1935. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1936. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1937. exit;
  1938. }
  1939. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1940. if (isset($yz[0]['type'])) {
  1941. $post['type'] = $yz[0]['type'];
  1942. }
  1943. if ($post['state'] == 9) //如果选择预设库存
  1944. {
  1945. $this->whlabel->insert($post);
  1946. } else {
  1947. /**
  1948. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1949. if($ljg == 1)
  1950. {
  1951. for($i=0;$i<$order;$i++)
  1952. {
  1953. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1954. $this->whlabel->insert($post);
  1955. }
  1956. }
  1957. **/
  1958. //if($post['warehouse'] == '5')
  1959. //{
  1960. //}
  1961. $yydata = $post;
  1962. $yydata['zh'] = $zh;
  1963. /**
  1964. $wl = $this->apiyy->get_cjlp($yydata);
  1965. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1966. {
  1967. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1968. }
  1969. if($wl['Data'][0]['m_isSucess'] != 1)
  1970. {
  1971. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1972. }
  1973. **/
  1974. for ($i = 0; $i < $order; $i++) {
  1975. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1976. $this->whlabel->insert($post);
  1977. }
  1978. }
  1979. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1980. exit;
  1981. }
  1982. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1983. $this->data['wlshop'] = $wlshop;
  1984. $this->_Template('whlabel_enteradd', $this->data);
  1985. }
  1986. //修改产品
  1987. public function _enteredit($arg_array)
  1988. {
  1989. $dt = 0;
  1990. if (isset($_SESSION['api'])) {
  1991. $user = $this->user->get_api($_SESSION['api']);
  1992. $usp = $user;
  1993. $fgshop = "";
  1994. $sid = "";
  1995. $user = explode('|', trim($user['shop'], '|'));
  1996. foreach ($user as $value) {
  1997. $fgshop .= " shop = " . $value . " or";
  1998. $sid .= " id = " . $value . " or";
  1999. }
  2000. }
  2001. $post = $this->input->post(NULL, TRUE);
  2002. if (isset($post['sku'])) {
  2003. $list = array();
  2004. $num = "";
  2005. $title = "";
  2006. $features = "";
  2007. $id = $this->input->post('id', true);
  2008. $order = $this->input->post('order', true);
  2009. $shop = $this->input->post('shop', true);
  2010. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2011. $post['sku'] = $this->input->post('sku', true);
  2012. $post['sm'] = $this->input->post('sm', true);
  2013. $post['warehouse'] = $this->input->post('warehouse', true);
  2014. $post['purchase'] = $this->input->post('purchase', true);
  2015. $post['retreatwarehouse'] = $post['warehouse'];
  2016. $category = $this->input->post('category', true);
  2017. $list['category'] = $category;
  2018. $list['hairtype'] = $this->input->post('hairtype', true);
  2019. $list['grade'] = $this->input->post('grade', true);
  2020. $size = $this->input->post('size', true);
  2021. $list['size'] = rtrim($size, ',');
  2022. $post['rktype'] = $this->input->post('rktype', true);
  2023. $post['text'] = $this->input->post('text', true);
  2024. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2025. $list['extension'] = $this->input->post('extension', true);
  2026. if ($category == 1297) {
  2027. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2028. }
  2029. if ($category == 1702) {
  2030. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2031. $list['syother'] = $this->input->post('syother', true);
  2032. }
  2033. if ($category == 133) {
  2034. $list['fittype'] = $this->input->post('fittype', true);
  2035. $list['acother'] = $this->input->post('acother', true);
  2036. }
  2037. $list['color'] = $this->input->post('color', true);
  2038. $list['lowe'] = $this->input->post('lowe', true);
  2039. if (!$post['purchase']) {
  2040. $post['purchase'] = 1;
  2041. }
  2042. if ($category == 127) {
  2043. $list['type'] = $this->input->post('type', true);
  2044. $list['headroad'] = $this->input->post('headroad', true);
  2045. $list['density'] = $this->input->post('density', true);
  2046. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2047. $list['lacesize'] = $this->input->post('lacesize', true);
  2048. }
  2049. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2050. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2051. }
  2052. if ($category == 128) {
  2053. $list['lacetype'] = $this->input->post('lacetype', true);
  2054. $list['haircap'] = $this->input->post('haircap', true);
  2055. $list['density'] = $this->input->post('density', true);
  2056. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2057. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2058. $list['wigother'] = $this->input->post('wigother', true);
  2059. $list['wigother1'] = $this->input->post('wigother1', true);
  2060. $list['wigother2'] = $this->input->post('wigother2', true);
  2061. }
  2062. if ($category == 129) {
  2063. $list['wide'] = $this->input->post('wide', true);
  2064. }
  2065. if ($category == 131) {
  2066. $list['gifttype'] = $this->input->post('gifttype', true);
  2067. $list['giftother'] = $this->input->post('giftother', true);
  2068. }
  2069. if ($category == 134) {
  2070. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2071. }
  2072. if ($category == 1297) {
  2073. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2074. $list['sywigother'] = $this->input->post('sywigother', true);
  2075. }
  2076. if ($category == 130 || $category == 133 || $category == 1702) {
  2077. $list['items'] = $this->input->post('items', true);
  2078. $list['weight'] = $this->input->post('weight', true);
  2079. }
  2080. if($category == 130){
  2081. $list['jfother'] = $this->input->post('jfother', true);
  2082. }
  2083. if ($category == 1702) {
  2084. $list['syhairther'] = $this->input->post('syhairther', true);
  2085. }
  2086. foreach ($list as $k => $v) {
  2087. if ($v != 0) {
  2088. $num .= $v;
  2089. $features .= $v . '-';
  2090. $typeclass = $this->typeclass->read($v);
  2091. if ($k != 'size') {
  2092. $title .= $typeclass['title'] . " ";
  2093. }
  2094. }
  2095. }
  2096. $typeclass = $this->typeclass->read($list['size']);
  2097. $title .= $typeclass['title'];
  2098. $time = time();
  2099. $post['title'] = rtrim($title, ' ');
  2100. $post['number'] = $num;
  2101. $post['features'] = '-' . $features;
  2102. $post['time'] = $time; //操作时间
  2103. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2104. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2105. exit;
  2106. }
  2107. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2108. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2109. exit;
  2110. }
  2111. $uid = $this->whlabel->read($id);
  2112. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2113. if ($datanum > 0) {
  2114. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2115. exit;
  2116. }
  2117. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2118. {
  2119. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2120. if ($yza) {
  2121. if ($post['features'] != $yza[0]['features']) {
  2122. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2123. exit;
  2124. }
  2125. }
  2126. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2127. if ($yzb) {
  2128. if ($post['sku'] != $yzb[0]['sku']) {
  2129. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2130. exit;
  2131. }
  2132. }
  2133. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2134. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2135. exit;
  2136. }
  2137. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2138. foreach ($data as $v) {
  2139. $post['id'] = $v['id'];
  2140. $this->whlabel->save($post, $v['id']);
  2141. }
  2142. } else {
  2143. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2144. if ($data > 0) {
  2145. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2146. exit;
  2147. } else {
  2148. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2149. foreach ($data as $v) {
  2150. $post['id'] = $v['id'];
  2151. $this->whlabel->save($post, $v['id']);
  2152. }
  2153. }
  2154. }
  2155. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2156. exit;
  2157. }
  2158. $uid = $this->whlabel->read($arg_array[0]);
  2159. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2160. $this->data['enter'] = $uid;
  2161. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2162. $this->data['wlshop'] = $wlshop;
  2163. $this->_Template('whlabel_enteredit', $this->data);
  2164. }
  2165. //入库浏览
  2166. public function _enter()
  2167. {
  2168. $post = $this->input->post(NULL, TRUE);
  2169. if (isset($post['s'])) {
  2170. $id_arr = $this->input->post('s');
  2171. $id_arr = explode(',', $id_arr);
  2172. if (!$id_arr) {
  2173. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2174. exit;
  2175. }
  2176. //循环删除记录
  2177. foreach ($id_arr as $v) {
  2178. $sid = $this->whlabel->read($v);
  2179. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2180. if ($count > 0) {
  2181. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2182. exit;
  2183. }
  2184. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2185. foreach ($info_list as $va) {
  2186. $this->whlabel->remove($va['id']);
  2187. }
  2188. }
  2189. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2190. exit;
  2191. }
  2192. $sp = array();
  2193. $s = $this->shop->find_all('1=1', 'id,shopname');
  2194. foreach ($s as $v) {
  2195. $sp[$v['id']] = $v['shopname'];
  2196. }
  2197. $wh = array();
  2198. $w = $this->warehouse->find_all('1=1', 'id,title');
  2199. foreach ($w as $v) {
  2200. $wh[$v['id']] = $v['title'];
  2201. }
  2202. if (isset($post['page'])) {
  2203. $page = $this->input->post('page', true);
  2204. $perpage = $this->input->post('perpage', true);
  2205. $category = $this->input->post('category', true);
  2206. $size = $this->input->post('size', true);
  2207. $grade = $this->input->post('grade', true);
  2208. $color = $this->input->post('color', true);
  2209. $lowe = $this->input->post('lowe', true);
  2210. $sku = $this->input->post('sku', true);
  2211. $warehouse = $this->input->post('warehouse', true);
  2212. $purchase = $this->input->post('purchase', true);
  2213. $ktime = $this->input->post('ktime', true);
  2214. $jtime = $this->input->post('jtime', true);
  2215. $ktime = strtotime($ktime);
  2216. $jtime = strtotime($jtime);
  2217. $where = "1=1";
  2218. $gj = "";
  2219. $ck = "";
  2220. if ($category) {
  2221. $where .= " and features like '%-$category-%'";
  2222. }
  2223. if ($size) {
  2224. $where .= " and features like '%-$size-%'";
  2225. }
  2226. if ($grade) {
  2227. $where .= " and features like '%-$grade-%'";
  2228. }
  2229. if ($color) {
  2230. $where .= " and features like '%-$color-%'";
  2231. }
  2232. if ($lowe) {
  2233. $where .= " and features like '%-$lowe-%'";
  2234. }
  2235. if ($warehouse) {
  2236. $where .= " and warehouse = '$warehouse'";
  2237. }
  2238. if ($purchase) {
  2239. $where .= " and purchase = '$purchase'";
  2240. }
  2241. if ($sku) {
  2242. $where .= " and sku like '%$sku%'";
  2243. }
  2244. if ($ktime && $jtime) {
  2245. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2246. }
  2247. //数据排序
  2248. $order_str = "enter desc";
  2249. if (empty($page)) {
  2250. $start = 0;
  2251. $perpage = 1;
  2252. } else {
  2253. $start = ($page - 1) * $perpage;
  2254. }
  2255. //取得信息列表
  2256. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2257. foreach ($info_list as $k => $v) {
  2258. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2259. if ($v['shop'] == '') {
  2260. $s = '通用';
  2261. } else {
  2262. $info_list[$k]['shop'] = '';
  2263. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2264. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2265. }
  2266. }
  2267. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2268. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2269. $info_list[$k]['g'] = $g;
  2270. }
  2271. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2272. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2273. $pagenum = ceil($total / $perpage);
  2274. $over = $total - ($start + $perpage);
  2275. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2276. echo json_encode($rows);
  2277. exit;
  2278. }
  2279. $this->_Template('whlabel_enter', $this->data);
  2280. }
  2281. //出库浏览
  2282. public function _out()
  2283. {
  2284. $post = $this->input->post(NULL, TRUE);
  2285. if (isset($post['page'])) {
  2286. $page = $this->input->post('page', true);
  2287. $perpage = $this->input->post('perpage', true);
  2288. $category = $this->input->post('category', true);
  2289. $size = $this->input->post('size', true);
  2290. $grade = $this->input->post('grade', true);
  2291. $color = $this->input->post('color', true);
  2292. $lowe = $this->input->post('lowe', true);
  2293. $sku = $this->input->post('sku', true);
  2294. $warehouse = $this->input->post('warehouse', true);
  2295. $purchase = $this->input->post('purchase', true);
  2296. $state = $this->input->post('state', true);
  2297. $ktime = $this->input->post('ktime', true);
  2298. $jtime = $this->input->post('jtime', true);
  2299. $ktime = strtotime($ktime);
  2300. $jtime = strtotime($jtime);
  2301. $where = "state=3";
  2302. $gj = "";
  2303. $ck = "";
  2304. if ($category) {
  2305. $where .= " and features like '%-$category-%'";
  2306. }
  2307. if ($size) {
  2308. $where .= " and features like '%-$size-%'";
  2309. }
  2310. if ($grade) {
  2311. $where .= " and features like '%-$grade-%'";
  2312. }
  2313. if ($color) {
  2314. $where .= " and features like '%-$color-%'";
  2315. }
  2316. if ($lowe) {
  2317. $where .= " and features like '%-$lowe-%'";
  2318. }
  2319. if ($state) {
  2320. $where .= " and state = '$state'";
  2321. }
  2322. if ($warehouse) {
  2323. $where .= " and warehouse = '$warehouse'";
  2324. }
  2325. if ($purchase) {
  2326. $where .= " and purchase = '$purchase'";
  2327. }
  2328. if ($sku) {
  2329. $where .= " and sku = '$sku'";
  2330. }
  2331. if ($ktime && $jtime) {
  2332. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2333. }
  2334. //数据排序
  2335. $order_str = "id desc";
  2336. if (empty($page)) {
  2337. $start = 0;
  2338. $perpage = 1;
  2339. } else {
  2340. $start = ($page - 1) * $perpage;
  2341. }
  2342. //取得信息列表
  2343. $info_list = $this->whlabel->find_all($where, 'sku');
  2344. $rows = array();
  2345. $list = array();
  2346. foreach ($info_list as $key => $value) {
  2347. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2348. }
  2349. $rows = array_unique($rows); //删除重复记录
  2350. foreach ($rows as $key => $value) {
  2351. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2352. $ck = $this->warehouse->read($data['warehouse']);
  2353. $warehouse = $ck['title'];
  2354. $gy = $this->purchase->read($data['purchase']);
  2355. $purchase = $gy['purchase'];
  2356. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2357. $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);
  2358. }
  2359. $total = count($list);
  2360. $pagenum = ceil($total / $perpage);
  2361. $over = $total - ($start + $perpage);
  2362. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2363. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2364. echo json_encode($rows);
  2365. exit;
  2366. }
  2367. $this->_Template('whlabel_out', $this->data);
  2368. }
  2369. //出库标签浏览
  2370. public function _label()
  2371. {
  2372. $post = $this->input->post(NULL, TRUE);
  2373. if (isset($post['page'])) {
  2374. $page = $this->input->post('page', true);
  2375. $perpage = $this->input->post('perpage', true);
  2376. $sku = $this->input->post('sku', true);
  2377. $warehouse = $this->input->post('warehouse', true);
  2378. $purchase = $this->input->post('purchase', true);
  2379. $orderinfo = $this->input->post('orderinfo', true);
  2380. $waybill = $this->input->post('waybill', true);
  2381. $category = $this->input->post('category', true);
  2382. $size = $this->input->post('size', true);
  2383. $grade = $this->input->post('grade', true);
  2384. $color = $this->input->post('color', true);
  2385. $lowe = $this->input->post('lowe', true);
  2386. $where = "state=1";
  2387. if ($sku) {
  2388. $where .= " and sku = '$sku'";
  2389. }
  2390. if ($warehouse) {
  2391. $where .= " and warehouse = '$warehouse'";
  2392. }
  2393. if ($purchase) {
  2394. $where .= " and purchase = '$purchase'";
  2395. }
  2396. if ($orderinfo) {
  2397. $where .= " and orderinfo = '$orderinfo'";
  2398. }
  2399. if ($waybill) {
  2400. $where .= " and waybill = '$waybill'";
  2401. }
  2402. if ($category) {
  2403. $where .= " and features like '%-$category-%'";
  2404. }
  2405. if ($size) {
  2406. $where .= " and features like '%-$size-%'";
  2407. }
  2408. if ($grade) {
  2409. $where .= " and features like '%-$grade-%'";
  2410. }
  2411. if ($color) {
  2412. $where .= " and features like '%-$color-%'";
  2413. }
  2414. if ($lowe) {
  2415. $where .= " and features like '%-$lowe-%'";
  2416. }
  2417. //数据排序
  2418. $order_str = "outk desc";
  2419. if (empty($page)) {
  2420. $start = 0;
  2421. $perpage = 1;
  2422. } else {
  2423. $start = ($page - 1) * $perpage;
  2424. }
  2425. //取得信息列表
  2426. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2427. foreach ($info_list as $key => $value) {
  2428. $warehouse = $this->warehouse->read($value['warehouse']);
  2429. $info_list[$key]['warehouse'] = $warehouse['title'];
  2430. $purchase = $this->purchase->read($value['purchase']);
  2431. $info_list[$key]['purchase'] = $purchase['title'];
  2432. if ($value['outk'] != 0) {
  2433. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2434. } else {
  2435. $info_list[$key]['outk'] = "";
  2436. }
  2437. if ($value['orderinfo'] == 0) {
  2438. $info_list[$key]['orderinfo'] = "";
  2439. }
  2440. if ($value['waybill'] == 0) {
  2441. $info_list[$key]['waybill'] = "";
  2442. }
  2443. }
  2444. $total = $this->whlabel->find_count($where);
  2445. $pagenum = ceil($total / $perpage);
  2446. $over = $total - ($start + $perpage);
  2447. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2448. echo json_encode($rows);
  2449. exit;
  2450. }
  2451. $this->_Template('whlabel_label', $this->data);
  2452. }
  2453. //独立站出库订单
  2454. public function _outorder()
  2455. {
  2456. if (isset($_SESSION['api'])) {
  2457. $user = $this->user->get_api($_SESSION['api']);
  2458. $usp = $user;
  2459. $fgshop = "";
  2460. $sid = "";
  2461. $user = explode('|', trim($user['shop'], '|'));
  2462. foreach ($user as $value) {
  2463. $fgshop .= " shop = " . $value . " or";
  2464. $sid .= " id = " . $value . " or";
  2465. }
  2466. } else {
  2467. echo "请重新登录";
  2468. }
  2469. $post = $this->input->post(NULL, TRUE);
  2470. if (isset($post['page'])) {
  2471. $page = $this->input->post('page', true);
  2472. $perpage = $this->input->post('perpage', true);
  2473. $warehouse = $this->input->post('warehouse', true);
  2474. $xztime = $this->input->post('xztime', true);
  2475. $timetk = $this->input->post('timetkk', true);
  2476. $timetj = $this->input->post('timetjj', true);
  2477. $shop = $this->input->post('shop', true);
  2478. $source = $this->input->post('source', true);
  2479. $orderinfo = $this->input->post('orderinfo', true);
  2480. $number = $this->input->post('number', true);
  2481. $sfxh = $this->input->post('sfxh', true);
  2482. $express = $this->input->post('express', true);
  2483. $waybill = $this->input->post('waybill', true);
  2484. $library = $this->input->post('library', true);
  2485. $country = $this->input->post('country', true);
  2486. $so = $this->input->post('so', true);
  2487. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2488. $print = $this->input->post('print', true);
  2489. $state = $this->input->post('state', true);
  2490. $orderurl = $this->input->post('orderurl', true);
  2491. $productid = $this->input->post('productid', true);
  2492. $timetk = strtotime($timetk);
  2493. $timetj = strtotime($timetj);
  2494. /**
  2495. $sj = $this->input->post('sj',true);
  2496. if($sj)
  2497. {
  2498. $sj = $this->input->post('sj',true);
  2499. }
  2500. else
  2501. {
  2502. $sj = "fullorder";
  2503. }
  2504. **/
  2505. $sj = "fullorder";
  2506. $where = "1=1";
  2507. if ($warehouse) {
  2508. $where .= " and type = '$warehouse'";
  2509. }
  2510. if ($timetk && $timetj) {
  2511. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2512. }
  2513. if ($orderinfo) {
  2514. $where .= " and orderinfo = '$orderinfo'";
  2515. }
  2516. if ($number) {
  2517. $where .= " and number = '$number'";
  2518. }
  2519. if ($express) {
  2520. $where .= " and express = '$express'";
  2521. }
  2522. if ($waybill) {
  2523. $where .= " and waybill = '$waybill'";
  2524. }
  2525. if ($library) {
  2526. $where .= " and library = '$library'";
  2527. }
  2528. if ($print) {
  2529. $where .= " and print = '$print'";
  2530. }
  2531. if ($libraryconfirm) {
  2532. $where .= " and libraryconfirm = '$libraryconfirm'";
  2533. }
  2534. if ($state) {
  2535. $where .= " and state = '$state'";
  2536. }
  2537. if ($shop) {
  2538. $where .= " and shop = '$shop'";
  2539. }
  2540. if ($country) {
  2541. $where .= " and country = '$country'";
  2542. }
  2543. if ($sfxh != '') {
  2544. $where .= " and sfxh = '$sfxh'";
  2545. }
  2546. if ($so) {
  2547. $where .= " and shipremarks like '%$so%'";
  2548. }
  2549. if ($source) {
  2550. if ($source == '2d') {
  2551. $where .= " and source >= '2'";
  2552. } else {
  2553. $where .= " and source = '$source'";
  2554. }
  2555. }
  2556. if (isset($_SESSION['api'])) {
  2557. foreach ($user as $value) {
  2558. $fgshop .= " shop = " . $value . " or";
  2559. }
  2560. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2561. }
  2562. if ($orderurl) {
  2563. $url = $this->orderurl->read($orderurl);
  2564. $where .= " and link like '%" . $url['url'] . "%'";
  2565. }
  2566. if($productid){
  2567. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2568. }
  2569. //数据排序
  2570. $order_str = "librarytime desc";
  2571. if (empty($page)) {
  2572. $start = 0;
  2573. $perpage = 1;
  2574. } else {
  2575. $start = ($page - 1) * $perpage;
  2576. }
  2577. //取得信息列表
  2578. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2579. //格式化数据
  2580. foreach ($info_list as $key => $value) {
  2581. $shop = $this->shop->read($value['shop']);
  2582. $info_list[$key]['shop'] = $shop['shopname'];
  2583. $express = $this->express->read($value['express']);
  2584. $info_list[$key]['express'] = $express['servicename'];
  2585. $warehouse = $this->warehouse->read($value['type']);
  2586. $info_list[$key]['type'] = $warehouse['title'];
  2587. if ($value['librarytime'] == '0') {
  2588. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2589. } else {
  2590. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2591. }
  2592. }
  2593. $total = $this->$sj->find_count($where);
  2594. $pagenum = ceil($total / $perpage);
  2595. $over = $total - ($start + $perpage);
  2596. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2597. echo json_encode($rows);
  2598. exit;
  2599. }
  2600. $this->data['express'] = $this->express->find_all();
  2601. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2602. $this->data['wlshop'] = $wlshop;
  2603. $user = $this->user->get_api($_SESSION['api']);
  2604. $powerid = $this->power->read($user['power']);
  2605. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2606. $pid = '';
  2607. foreach ($powertext as $v) {
  2608. $pid .= " id = " . $v . " or";
  2609. }
  2610. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2611. $this->data['fullorderexcel'] = $fullorderexcel;
  2612. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2613. $this->data['orderurl'] = $orderurl;
  2614. $this->_Template('whlabel_outorder', $this->data);
  2615. }
  2616. //tt出库
  2617. public function _toutorder()
  2618. {
  2619. $fgshop = "";
  2620. $sid = "";
  2621. if (isset($_SESSION['api'])) {
  2622. $user = $this->user->get_api($_SESSION['api']);
  2623. $usp = $user;
  2624. $user = explode('|', trim($user['shop'], '|'));
  2625. foreach ($user as $value) {
  2626. $fgshop .= " shop = " . $value . " or";
  2627. $sid .= " id = " . $value . " or";
  2628. }
  2629. } else {
  2630. echo "请重新登录";
  2631. die;
  2632. }
  2633. $post = $this->input->post(NULL, TRUE);
  2634. if (isset($post['page'])) {
  2635. $page = $this->input->post('page', true);
  2636. $perpage = $this->input->post('perpage', true);
  2637. $warehouse = $this->input->post('warehouse', true);
  2638. $xztime = $this->input->post('xztime', true);
  2639. $timetk = $this->input->post('timetkk', true);
  2640. $timetj = $this->input->post('timetjj', true);
  2641. $shop = $this->input->post('shop', true);
  2642. $source = $this->input->post('source', true);
  2643. $orderinfo = $this->input->post('orderinfo', true);
  2644. $number = $this->input->post('number', true);
  2645. $sfxh = $this->input->post('sfxh', true);
  2646. $express = $this->input->post('express', true);
  2647. $waybill = $this->input->post('waybill', true);
  2648. $library = $this->input->post('library', true);
  2649. $country = $this->input->post('country', true);
  2650. $so = $this->input->post('so', true);
  2651. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2652. $print = $this->input->post('print', true);
  2653. $state = $this->input->post('state', true);
  2654. $orderurl = $this->input->post('orderurl', true);
  2655. $timetk = strtotime($timetk);
  2656. $timetj = strtotime($timetj);
  2657. /**
  2658. $sj = $this->input->post('sj',true);
  2659. if($sj)
  2660. {
  2661. $sj = $this->input->post('sj',true);
  2662. }
  2663. else
  2664. {
  2665. $sj = "fullorder";
  2666. }
  2667. **/
  2668. $sj = "fullordertt";
  2669. $where = "1=1";
  2670. if ($warehouse) {
  2671. $where .= " and type = '$warehouse'";
  2672. }
  2673. if ($timetk && $timetj) {
  2674. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2675. }
  2676. if ($orderinfo) {
  2677. $where .= " and orderinfo = '$orderinfo'";
  2678. }
  2679. if ($number) {
  2680. $where .= " and number = '$number'";
  2681. }
  2682. if ($express) {
  2683. $where .= " and express = '$express'";
  2684. }
  2685. if ($waybill) {
  2686. $where .= " and waybill = '$waybill'";
  2687. }
  2688. if ($library) {
  2689. $where .= " and library = '$library'";
  2690. }
  2691. if ($print) {
  2692. $where .= " and print = '$print'";
  2693. }
  2694. if ($libraryconfirm) {
  2695. $where .= " and libraryconfirm = '$libraryconfirm'";
  2696. }
  2697. if ($state) {
  2698. $where .= " and state = '$state'";
  2699. }
  2700. if ($shop) {
  2701. $where .= " and shop = '$shop'";
  2702. }
  2703. if ($country) {
  2704. $where .= " and country = '$country'";
  2705. }
  2706. if ($sfxh != '') {
  2707. $where .= " and sfxh = '$sfxh'";
  2708. }
  2709. if ($so) {
  2710. $where .= " and shipremarks like '%$so%'";
  2711. }
  2712. if ($source) {
  2713. if ($source == '2d') {
  2714. $where .= " and source >= '2'";
  2715. } else {
  2716. $where .= " and source = '$source'";
  2717. }
  2718. }
  2719. if (isset($_SESSION['api'])) {
  2720. foreach ($user as $value) {
  2721. $fgshop .= " shop = " . $value . " or";
  2722. }
  2723. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2724. }
  2725. if ($orderurl) {
  2726. $url = $this->orderurl->read($orderurl);
  2727. $where .= " and link like '%" . $url['url'] . "%'";
  2728. }
  2729. //数据排序
  2730. $order_str = "librarytime desc";
  2731. if (empty($page)) {
  2732. $start = 0;
  2733. $perpage = 1;
  2734. } else {
  2735. $start = ($page - 1) * $perpage;
  2736. }
  2737. //取得信息列表
  2738. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2739. //格式化数据
  2740. foreach ($info_list as $key => $value) {
  2741. $shop = $this->shop->read($value['shop']);
  2742. $info_list[$key]['shop'] = $shop['shopname'];
  2743. $express = $this->express->read($value['express']);
  2744. $info_list[$key]['express'] = $express['servicename'];
  2745. $warehouse = $this->warehouse->read($value['type']);
  2746. $info_list[$key]['type'] = $warehouse['title'];
  2747. if ($value['librarytime'] == '0') {
  2748. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2749. } else {
  2750. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2751. }
  2752. }
  2753. $total = $this->$sj->find_count($where);
  2754. $pagenum = ceil($total / $perpage);
  2755. $over = $total - ($start + $perpage);
  2756. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2757. echo json_encode($rows);
  2758. exit;
  2759. }
  2760. $this->data['express'] = $this->express->find_all();
  2761. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2762. $this->data['wlshop'] = $wlshop;
  2763. $user = $this->user->get_api($_SESSION['api']);
  2764. $powerid = $this->power->read($user['power']);
  2765. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2766. $pid = '';
  2767. foreach ($powertext as $v) {
  2768. $pid .= " id = " . $v . " or";
  2769. }
  2770. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2771. $this->data['fullorderexcel'] = $fullorderexcel;
  2772. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2773. $this->data['orderurl'] = $orderurl;
  2774. $this->_Template('whlabel_toutorder', $this->data);
  2775. }
  2776. //tt出库
  2777. public function _aoutorder()
  2778. {
  2779. if (isset($_SESSION['api'])) {
  2780. $user = $this->user->get_api($_SESSION['api']);
  2781. $usp = $user;
  2782. $fgshop = "";
  2783. $sid = "";
  2784. $user = explode('|', trim($user['shop'], '|'));
  2785. foreach ($user as $value) {
  2786. $fgshop .= " shop = " . $value . " or";
  2787. $sid .= " id = " . $value . " or";
  2788. }
  2789. } else {
  2790. echo "请重新登录";
  2791. }
  2792. $post = $this->input->post(NULL, TRUE);
  2793. if (isset($post['page'])) {
  2794. $page = $this->input->post('page', true);
  2795. $perpage = $this->input->post('perpage', true);
  2796. $warehouse = $this->input->post('warehouse', true);
  2797. $xztime = $this->input->post('xztime', true);
  2798. $timetk = $this->input->post('timetkk', true);
  2799. $timetj = $this->input->post('timetjj', true);
  2800. $shop = $this->input->post('shop', true);
  2801. $source = $this->input->post('source', true);
  2802. $orderinfo = $this->input->post('orderinfo', true);
  2803. $number = $this->input->post('number', true);
  2804. $sfxh = $this->input->post('sfxh', true);
  2805. $express = $this->input->post('express', true);
  2806. $waybill = $this->input->post('waybill', true);
  2807. $library = $this->input->post('library', true);
  2808. $country = $this->input->post('country', true);
  2809. $so = $this->input->post('so', true);
  2810. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2811. $print = $this->input->post('print', true);
  2812. $state = $this->input->post('state', true);
  2813. $orderurl = $this->input->post('orderurl', true);
  2814. $timetk = strtotime($timetk);
  2815. $timetj = strtotime($timetj);
  2816. /**
  2817. $sj = $this->input->post('sj',true);
  2818. if($sj)
  2819. {
  2820. $sj = $this->input->post('sj',true);
  2821. }
  2822. else
  2823. {
  2824. $sj = "fullorder";
  2825. }
  2826. **/
  2827. $sj = "fullorderamz";
  2828. $where = "1=1";
  2829. if ($warehouse) {
  2830. $where .= " and type = '$warehouse'";
  2831. }
  2832. if ($timetk && $timetj) {
  2833. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2834. }
  2835. if ($orderinfo) {
  2836. $where .= " and orderinfo = '$orderinfo'";
  2837. }
  2838. if ($number) {
  2839. $where .= " and number = '$number'";
  2840. }
  2841. if ($express) {
  2842. $where .= " and express = '$express'";
  2843. }
  2844. if ($waybill) {
  2845. $where .= " and waybill = '$waybill'";
  2846. }
  2847. if ($library) {
  2848. $where .= " and library = '$library'";
  2849. }
  2850. if ($print) {
  2851. $where .= " and print = '$print'";
  2852. }
  2853. if ($libraryconfirm) {
  2854. $where .= " and libraryconfirm = '$libraryconfirm'";
  2855. }
  2856. if ($state) {
  2857. $where .= " and state = '$state'";
  2858. }
  2859. if ($shop) {
  2860. $where .= " and shop = '$shop'";
  2861. }
  2862. if ($country) {
  2863. $where .= " and country = '$country'";
  2864. }
  2865. if ($sfxh != '') {
  2866. $where .= " and sfxh = '$sfxh'";
  2867. }
  2868. if ($so) {
  2869. $where .= " and shipremarks like '%$so%'";
  2870. }
  2871. if ($source) {
  2872. if ($source == '2d') {
  2873. $where .= " and source >= '2'";
  2874. } else {
  2875. $where .= " and source = '$source'";
  2876. }
  2877. }
  2878. if (isset($_SESSION['api'])) {
  2879. foreach ($user as $value) {
  2880. $fgshop .= " shop = " . $value . " or";
  2881. }
  2882. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2883. }
  2884. if ($orderurl) {
  2885. $url = $this->orderurl->read($orderurl);
  2886. $where .= " and link like '%" . $url['url'] . "%'";
  2887. }
  2888. //数据排序
  2889. $order_str = "librarytime desc";
  2890. if (empty($page)) {
  2891. $start = 0;
  2892. $perpage = 1;
  2893. } else {
  2894. $start = ($page - 1) * $perpage;
  2895. }
  2896. //取得信息列表
  2897. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2898. //格式化数据
  2899. foreach ($info_list as $key => $value) {
  2900. $shop = $this->shop->read($value['shop']);
  2901. $info_list[$key]['shop'] = $shop['shopname'];
  2902. $express = $this->express->read($value['express']);
  2903. $info_list[$key]['express'] = $express['servicename'];
  2904. $warehouse = $this->warehouse->read($value['type']);
  2905. $info_list[$key]['type'] = $warehouse['title'];
  2906. if ($value['librarytime'] == '0') {
  2907. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2908. } else {
  2909. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2910. }
  2911. }
  2912. $total = $this->$sj->find_count($where);
  2913. $pagenum = ceil($total / $perpage);
  2914. $over = $total - ($start + $perpage);
  2915. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2916. echo json_encode($rows);
  2917. exit;
  2918. }
  2919. $this->data['express'] = $this->express->find_all();
  2920. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2921. $this->data['wlshop'] = $wlshop;
  2922. $user = $this->user->get_api($_SESSION['api']);
  2923. $powerid = $this->power->read($user['power']);
  2924. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2925. $pid = '';
  2926. foreach ($powertext as $v) {
  2927. $pid .= " id = " . $v . " or";
  2928. }
  2929. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2930. $this->data['fullorderexcel'] = $fullorderexcel;
  2931. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2932. $this->data['orderurl'] = $orderurl;
  2933. $this->_Template('whlabel_aoutorder', $this->data);
  2934. }
  2935. //速卖通出库订单
  2936. public function _soutorder()
  2937. {
  2938. if (isset($_SESSION['api'])) {
  2939. $user = $this->user->get_api($_SESSION['api']);
  2940. $usp = $user;
  2941. $fgshop = "";
  2942. $sid = "";
  2943. $user = explode('|', trim($user['shop'], '|'));
  2944. foreach ($user as $value) {
  2945. $sid .= " id = " . $value . " or";
  2946. }
  2947. }
  2948. $post = $this->input->post(NULL, TRUE);
  2949. if (isset($post['page'])) {
  2950. $page = $this->input->post('page', true);
  2951. $perpage = $this->input->post('perpage', true);
  2952. $warehouse = $this->input->post('warehouse', true);
  2953. $xztime = $this->input->post('xztime', true);
  2954. $timetk = $this->input->post('timetkk', true);
  2955. $timetj = $this->input->post('timetjj', true);
  2956. $shop = $this->input->post('shop', true);
  2957. $source = $this->input->post('source', true);
  2958. $orderinfo = $this->input->post('orderinfo', true);
  2959. $number = $this->input->post('number', true);
  2960. $express = $this->input->post('express', true);
  2961. $waybill = $this->input->post('waybill', true);
  2962. $library = $this->input->post('library', true);
  2963. $country = $this->input->post('country', true);
  2964. $sfxh = $this->input->post('sfxh', true);
  2965. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2966. $print = $this->input->post('print', true);
  2967. $state = $this->input->post('state', true);
  2968. $so = $this->input->post('so', true);
  2969. $timetk = strtotime($timetk);
  2970. $timetj = strtotime($timetj);
  2971. /**
  2972. $sj = $this->input->post('sj',true);
  2973. if($sj)
  2974. {
  2975. $sj = $this->input->post('sj',true);
  2976. }
  2977. else
  2978. {
  2979. $sj = "fullorder";
  2980. }
  2981. **/
  2982. $sj = "fullordersmt";
  2983. $where = "1=1";
  2984. if ($warehouse) {
  2985. $where .= " and type = '$warehouse'";
  2986. }
  2987. if ($timetk && $timetj) {
  2988. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2989. }
  2990. if ($orderinfo) {
  2991. $where .= " and orderinfo = '$orderinfo'";
  2992. }
  2993. if ($number) {
  2994. $where .= " and number = '$number'";
  2995. }
  2996. if ($express) {
  2997. $where .= " and express = '$express'";
  2998. }
  2999. if ($waybill) {
  3000. $where .= " and waybill = '$waybill'";
  3001. }
  3002. if ($library) {
  3003. $where .= " and library = '$library'";
  3004. }
  3005. if ($print) {
  3006. $where .= " and print = '$print'";
  3007. }
  3008. if ($libraryconfirm) {
  3009. $where .= " and libraryconfirm = '$libraryconfirm'";
  3010. }
  3011. if ($state) {
  3012. $where .= " and state = '$state'";
  3013. }
  3014. if ($shop) {
  3015. $where .= " and shop = '$shop'";
  3016. }
  3017. if ($sfxh != '') {
  3018. $where .= " and sfxh = '$sfxh'";
  3019. }
  3020. if ($so) {
  3021. $where .= " and shipremarks like '%$so%'";
  3022. }
  3023. if ($source) {
  3024. $where .= " and source = '$source'";
  3025. }
  3026. if ($country) {
  3027. $where .= " and country = '$country'";
  3028. } else {
  3029. if (isset($_SESSION['api'])) {
  3030. foreach ($user as $value) {
  3031. $fgshop .= " shop = " . $value . " or";
  3032. }
  3033. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3034. }
  3035. }
  3036. //数据排序
  3037. $order_str = "librarytime desc";
  3038. if (empty($page)) {
  3039. $start = 0;
  3040. $perpage = 1;
  3041. } else {
  3042. $start = ($page - 1) * $perpage;
  3043. }
  3044. //取得信息列表
  3045. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3046. //格式化数据
  3047. foreach ($info_list as $key => $value) {
  3048. $shop = $this->shop->read($value['shop']);
  3049. $info_list[$key]['shop'] = $shop['shopname'];
  3050. $express = $this->express->read($value['express']);
  3051. $info_list[$key]['express'] = $express['servicename'];
  3052. $warehouse = $this->warehouse->read($value['type']);
  3053. $info_list[$key]['type'] = $warehouse['title'];
  3054. if ($value['librarytime'] == '0') {
  3055. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3056. } else {
  3057. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3058. }
  3059. }
  3060. $total = $this->$sj->find_count($where);
  3061. $pagenum = ceil($total / $perpage);
  3062. $over = $total - ($start + $perpage);
  3063. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3064. echo json_encode($rows);
  3065. exit;
  3066. }
  3067. $this->data['express'] = $this->express->find_all();
  3068. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3069. $this->data['wlshop'] = $wlshop;
  3070. $user = $this->user->get_api($_SESSION['api']);
  3071. $powerid = $this->power->read($user['power']);
  3072. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3073. $pid = '';
  3074. foreach ($powertext as $v) {
  3075. $pid .= " id = " . $v . " or";
  3076. }
  3077. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3078. $this->data['fullorderexcel'] = $fullorderexcel;
  3079. $this->_Template('whlabel_soutorder', $this->data);
  3080. }
  3081. //订单退库
  3082. public function _retreat()
  3083. {
  3084. $post = $this->input->post(NULL, TRUE);
  3085. if (isset($post['page'])) {
  3086. $page = $this->input->post('page', true);
  3087. $perpage = $this->input->post('perpage', true);
  3088. $warehouse = $this->input->post('warehouse', true);
  3089. $timetk = $this->input->post('timetk', true);
  3090. $timetj = $this->input->post('timetj', true);
  3091. $shop = $this->input->post('shop', true);
  3092. $source = $this->input->post('source', true);
  3093. $state = $this->input->post('state', true);
  3094. $review = $this->input->post('review', true);
  3095. $state = $this->input->post('state', true);
  3096. $express = $this->input->post('express', true);
  3097. $orderinfo = $this->input->post('orderinfo', true);
  3098. $user = $this->input->post('user', true);
  3099. $name = $this->input->post('name', true);
  3100. $waybill = $this->input->post('waybill', true);
  3101. $timetk = strtotime($timetk);
  3102. $timetj = strtotime($timetj);
  3103. $where = "(state=206 or state=210) and mergeid = 0";
  3104. if ($warehouse) {
  3105. $where .= " and state = '$warehouse'";
  3106. }
  3107. if ($timetk && $timetj) {
  3108. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3109. }
  3110. if ($shop) {
  3111. $where .= " and shop = '$shop'";
  3112. }
  3113. if ($source) {
  3114. $where .= " and source = '$source'";
  3115. }
  3116. if ($state) {
  3117. $where .= " and state = '$state'";
  3118. }
  3119. if ($review) {
  3120. $where .= " and review = '$review'";
  3121. }
  3122. if ($state) {
  3123. $where .= " and state = '$state'";
  3124. }
  3125. if ($express) {
  3126. $where .= " and express = '$express'";
  3127. }
  3128. if ($orderinfo) {
  3129. $where .= " and orderinfo = '$orderinfo'";
  3130. }
  3131. if ($user) {
  3132. $where .= " and user = '$user'";
  3133. }
  3134. if ($name) {
  3135. $where .= " and name = '$name'";
  3136. }
  3137. if ($waybill) {
  3138. $where .= " and waybill = '$waybill'";
  3139. }
  3140. //数据排序
  3141. $order_str = "id desc";
  3142. if (empty($page)) {
  3143. $start = 0;
  3144. $perpage = 1;
  3145. } else {
  3146. $start = ($page - 1) * $perpage;
  3147. }
  3148. //取得信息列表
  3149. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3150. //格式化数据
  3151. foreach ($info_list as $key => $value) {
  3152. $shop = $this->shop->read($value['shop']);
  3153. $info_list[$key]['shop'] = $shop['shopname'];
  3154. $warehouse = $this->warehouse->read($value['warehouse']);
  3155. $info_list[$key]['warehouse'] = $warehouse['title'];
  3156. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3157. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3158. if ($value['waybill'] == 0) {
  3159. $info_list[$key]['waybill'] = "";
  3160. }
  3161. $express = $this->express->read($value['express']);
  3162. $info_list[$key]['express'] = $express['title'];
  3163. $typeclass = $this->typeclass->read($value['state']);
  3164. $info_list[$key]['state'] = $typeclass['title'];
  3165. }
  3166. $total = $this->fullorder->find_count($where);
  3167. $pagenum = ceil($total / $perpage);
  3168. $over = $total - ($start + $perpage);
  3169. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3170. echo json_encode($rows);
  3171. exit;
  3172. }
  3173. $this->data['express'] = $this->express->find_all();
  3174. $this->_Template('whlabel_retreat', $this->data);
  3175. }
  3176. //退库标签浏览
  3177. public function _retreatlk()
  3178. {
  3179. $post = $this->input->post(NULL, TRUE);
  3180. if (isset($post['page'])) {
  3181. $page = $this->input->post('page', true);
  3182. $perpage = $this->input->post('perpage', true);
  3183. $timetk = $this->input->post('timetk', true);
  3184. $timetj = $this->input->post('timetj', true);
  3185. $sku = $this->input->post('sku', true);
  3186. $warehouse = $this->input->post('warehouse', true);
  3187. $purchase = $this->input->post('purchase', true);
  3188. $orderinfo = $this->input->post('orderinfo', true);
  3189. $waybill = $this->input->post('waybill', true);
  3190. $category = $this->input->post('category', true);
  3191. $size = $this->input->post('size', true);
  3192. $grade = $this->input->post('grade', true);
  3193. $color = $this->input->post('color', true);
  3194. $lowe = $this->input->post('lowe', true);
  3195. $state = $this->input->post('state', true);
  3196. $timetk = strtotime($timetk);
  3197. $timetj = strtotime($timetj);
  3198. $where = "state=2";
  3199. if ($timetk && $timetj) {
  3200. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3201. }
  3202. if ($sku) {
  3203. $where .= " and sku = '$sku'";
  3204. }
  3205. if ($warehouse) {
  3206. $where .= " and warehouse = '$warehouse'";
  3207. }
  3208. if ($purchase) {
  3209. $where .= " and purchase = '$purchase'";
  3210. }
  3211. if ($orderinfo) {
  3212. $where .= " and orderinfo = '$orderinfo'";
  3213. }
  3214. if ($waybill) {
  3215. $where .= " and waybill = '$waybill'";
  3216. }
  3217. if ($category) {
  3218. $where .= " and features like '%-$category-%'";
  3219. }
  3220. if ($size) {
  3221. $where .= " and features like '%-$size-%'";
  3222. }
  3223. if ($grade) {
  3224. $where .= " and features like '%-$grade-%'";
  3225. }
  3226. if ($color) {
  3227. $where .= " and features like '%-$color-%'";
  3228. }
  3229. if ($lowe) {
  3230. $where .= " and features like '%-$lowe-%'";
  3231. }
  3232. //数据排序
  3233. $order_str = "time desc";
  3234. if (empty($page)) {
  3235. $start = 0;
  3236. $perpage = 1;
  3237. } else {
  3238. $start = ($page - 1) * $perpage;
  3239. }
  3240. //取得信息列表
  3241. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3242. foreach ($info_list as $key => $value) {
  3243. $warehouse = $this->warehouse->read($value['warehouse']);
  3244. $info_list[$key]['warehouse'] = $warehouse['title'];
  3245. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3246. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3247. $purchase = $this->purchase->read($value['purchase']);
  3248. $info_list[$key]['purchase'] = $purchase['title'];
  3249. if ($value['outk'] != 0) {
  3250. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3251. } else {
  3252. $info_list[$key]['outk'] = "";
  3253. }
  3254. if ($value['retreat'] != 0) {
  3255. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3256. } else {
  3257. $info_list[$key]['retreat'] = "";
  3258. }
  3259. if ($value['orderinfo'] == 0) {
  3260. $info_list[$key]['orderinfo'] = "";
  3261. }
  3262. if ($value['waybill'] == 0) {
  3263. $info_list[$key]['waybill'] = "";
  3264. }
  3265. }
  3266. $total = $this->whlabel->find_count($where);
  3267. $pagenum = ceil($total / $perpage);
  3268. $over = $total - ($start + $perpage);
  3269. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3270. echo json_encode($rows);
  3271. exit;
  3272. }
  3273. $this->_Template('whlabel_retreatlk', $this->data);
  3274. }
  3275. //更换标签及浏览
  3276. public function _change()
  3277. {
  3278. $post = $this->input->post(NULL, TRUE);
  3279. if (isset($post['page'])) {
  3280. $page = $this->input->post('page', true);
  3281. $perpage = $this->input->post('perpage', true);
  3282. $timetk = $this->input->post('timetk', true);
  3283. $timetj = $this->input->post('timetj', true);
  3284. $label = $this->input->post('label', true);
  3285. $oldlabel = $this->input->post('oldlabel', true);
  3286. $timetk = strtotime($timetk);
  3287. $timetj = strtotime($timetj);
  3288. $where = "state=10 ";
  3289. if ($timetk && $timetj) {
  3290. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3291. }
  3292. if ($label) {
  3293. $where .= " and label = '$label'";
  3294. }
  3295. if ($oldlabel) {
  3296. $where .= " and oldlabel = '$oldlabel'";
  3297. }
  3298. //数据排序
  3299. $order_str = "time asc";
  3300. if (empty($page)) {
  3301. $start = 0;
  3302. $perpage = 1;
  3303. } else {
  3304. $start = ($page - 1) * $perpage;
  3305. }
  3306. //取得信息列表
  3307. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3308. foreach ($info_list as $key => $value) {
  3309. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3310. }
  3311. $total = $this->whlabel->find_count($where);
  3312. $pagenum = ceil($total / $perpage);
  3313. $over = $total - ($start + $perpage);
  3314. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3315. echo json_encode($rows);
  3316. exit;
  3317. }
  3318. $this->_Template('whlabel_change', $this->data);
  3319. }
  3320. //产品标签
  3321. public function _cpbqdc()
  3322. {
  3323. if (isset($_GET['excel'])) {
  3324. $where = "1=1";
  3325. //数据排序
  3326. $order_str = "id desc";
  3327. if (empty($page)) {
  3328. $start = 0;
  3329. $perpage = 1;
  3330. } else {
  3331. $start = ($page - 1) * $perpage;
  3332. }
  3333. $warehouse = $this->input->get('warehouse', true);
  3334. $state = $this->input->get('state', true);
  3335. $timetk = $this->input->get('timetkk', true);
  3336. $timetj = $this->input->get('timetjj', true);
  3337. $timetk = strtotime($timetk);
  3338. $timetj = strtotime($timetj);
  3339. if ($warehouse) {
  3340. $where .= " and warehouse = '$warehouse'";
  3341. }
  3342. if ($state || $state == 0) {
  3343. $where .= " and state = '$state'";
  3344. }
  3345. if ($timetk && $timetj) {
  3346. $where .= " and time > '$timetk' and time < '$timetj'";
  3347. }
  3348. //取得信息列表
  3349. $info_list = $this->whlabel->find_all($where, '*');
  3350. $rows = array();
  3351. $list = array();
  3352. foreach ($info_list as $key => $value) {
  3353. $rows[$value['time']] = $value; //所有数据sku
  3354. }
  3355. foreach ($rows as $value) {
  3356. $warehouse = $this->warehouse->read($value['warehouse']);
  3357. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3358. $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);
  3359. }
  3360. $title = "产品标签统计表";
  3361. $titlename = "<table border=1>
  3362. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3363. <tr align='center'>
  3364. <td>仓库</td>
  3365. <td>SKU</td>
  3366. <td>产品</td>
  3367. <td>入库时间</td>
  3368. <td>操作时间</td>
  3369. <td>备注</td>
  3370. <td>数量</td>
  3371. </tr>
  3372. </table>";
  3373. $filename = $title . ".xls";
  3374. $tail = "";
  3375. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3376. }
  3377. }
  3378. //进销存导出
  3379. public function _exceljxc()
  3380. {
  3381. $classid = $this->classid->sku();
  3382. $pm = $classid;
  3383. $typeclass = array();
  3384. $tc = $this->typeclass->find_all();
  3385. foreach ($tc as $v) {
  3386. $typeclass[$v['id']] = $v;
  3387. }
  3388. $prc = array();
  3389. $purchase = $this->purchase->find_all();
  3390. foreach ($purchase as $k => $v) {
  3391. $prc[$v['id']] = $v['title'];
  3392. }
  3393. if (isset($_GET['excel'])) {
  3394. $where = "sku != 'Preset'";
  3395. //数据排序
  3396. $order_str = "id desc";
  3397. if (empty($page)) {
  3398. $start = 0;
  3399. $perpage = 1;
  3400. } else {
  3401. $start = ($page - 1) * $perpage;
  3402. }
  3403. $category = $this->input->get('category', true);
  3404. $warehouse = $this->input->get('warehouse', true);
  3405. $excelid = $this->input->get('sid', true);
  3406. if ($category) {
  3407. $where .= " and features like '%-$category-%'";
  3408. }
  3409. if ($warehouse) {
  3410. $where .= " and warehouse = '$warehouse'";
  3411. }
  3412. $xzid = '';
  3413. if ($excelid) {
  3414. $excelid = explode(',', trim($excelid, ','));
  3415. foreach ($excelid as $key => $value) {
  3416. $xzid .= " id = " . $value . " or";
  3417. }
  3418. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3419. }
  3420. //取得信息列表
  3421. /**
  3422. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3423. $rows = array();$list = array();
  3424. foreach ($info_list as $key=>$value)
  3425. {
  3426. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3427. }
  3428. **/
  3429. $wt = array();
  3430. $whlabel_type = $this->whlabel_type->find_all();
  3431. foreach ($whlabel_type as $v) {
  3432. $wt[$v['id']] = $v['title'];
  3433. }
  3434. $wh = array();
  3435. $w = $this->warehouse->find_all('1=1', 'id,title');
  3436. foreach ($w as $v) {
  3437. $wh[$v['id']] = $v['title'];
  3438. }
  3439. $list = array();
  3440. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3441. foreach ($rows as $key => $value) {
  3442. if (isset($wt[$value['type']])) {
  3443. $rows[$key]['type'] = $wt[$value['type']];
  3444. } else {
  3445. $rows[$key]['type'] = '未设置';
  3446. }
  3447. $bm = '03';
  3448. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3449. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3450. $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');
  3451. $details = array();
  3452. $cpid = array();
  3453. $cpbz = array();
  3454. $c = 0;
  3455. $g = 0;
  3456. $x = 0;
  3457. $t = 0;
  3458. $s = 0;
  3459. $q = 0;
  3460. foreach ($sd as $k => $v) {
  3461. if ($v['state'] == 0) {
  3462. $c++;
  3463. if ($v['cpid'] != 0) {
  3464. $cpid[$v['cpid']] = $v['cpid'];
  3465. }
  3466. if ($v['cpbz'] != '') {
  3467. $cpbz[$v['cpbz']] = $v['cpbz'];
  3468. }
  3469. }
  3470. if ($v['state'] != 9) {
  3471. $g++;
  3472. }
  3473. if ($v['state'] == 1) {
  3474. $x++;
  3475. }
  3476. if ($v['state'] == 2) {
  3477. $t++;
  3478. }
  3479. if ($v['state'] == 8) {
  3480. $s++;
  3481. }
  3482. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3483. $q++;
  3484. }
  3485. $details[$v['details']] = $v['details'];
  3486. }
  3487. $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'] . '"');
  3488. $rows[$key]['details'] = implode("、", $details);
  3489. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3490. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3491. $number = $value['number'];
  3492. $ftime = time() - 15 * 24 * 3600;
  3493. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3494. $rows[$key]['number'] = $g;
  3495. $rows[$key]['c'] = $c;
  3496. $rows[$key]['x'] = $x;
  3497. $rows[$key]['t'] = $t;
  3498. $rows[$key]['s'] = $s;
  3499. $rows[$key]['q'] = $q;
  3500. $rows[$key]['z'] = $z;
  3501. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3502. $features = explode('-', trim($features, '-'));
  3503. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3504. // $pm = $classid;
  3505. // $jm = $classid;
  3506. // foreach($features as $k=>$v)
  3507. // {
  3508. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3509. // {
  3510. // if($typeclass[$v]['bm'] != '')
  3511. // {
  3512. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3513. // }
  3514. // }
  3515. // if($v != 0)
  3516. // {
  3517. // if(!isset($typeclass[$v]))
  3518. // {
  3519. // continue;
  3520. // }
  3521. // if(isset($pm[$typeclass[$v]['classid']]))
  3522. // {
  3523. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3524. // {
  3525. // $tz = explode('|',$typeclass[$v]['zh']);
  3526. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3527. // }
  3528. // else
  3529. // {
  3530. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3531. // }
  3532. // }
  3533. // if(isset($jm[$typeclass[$v]['classid']]))
  3534. // {
  3535. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3536. // }
  3537. // }
  3538. // }
  3539. // $jm = array_filter($jm);
  3540. // $rows[$key]['bs'] = implode("-",$jm);
  3541. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3542. // $zh = implode(" ",$pm);
  3543. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3544. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3545. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3546. // $rows[$key]['features'] = $zh;
  3547. }
  3548. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3549. $final_list = [];
  3550. foreach ($list as $k => $v) {
  3551. if (empty($v['sku'])) {
  3552. continue;
  3553. }
  3554. $final_list[] = [
  3555. "warehouse" => $v["warehouse"],
  3556. "purchase" => $v["purchase"],
  3557. "details" => $v["details"],
  3558. "cpid" => $v["cpid"],
  3559. "dbcontent" => $v["dbcontent"],
  3560. "sku" => $v["sku"],
  3561. "cs" => $v["bm"],
  3562. "bs" => $v["jm"],
  3563. "title" => $v["title"],
  3564. "features" => $v["pm"],
  3565. "cpbz" => $v["cpbz"],
  3566. "sm" => $v["sm"],
  3567. "type" => $v["type"],
  3568. "number" => $v["number"],
  3569. "c" => $v["c"],
  3570. "x" => $v["x"],
  3571. "t" => $v["t"],
  3572. "s" => $v["s"],
  3573. "q" => $v["q"],
  3574. "z" => $v["z"],
  3575. "weight" => $v['weight'],
  3576. ];
  3577. }
  3578. $title = "总进销存统计表";
  3579. $titlename = "<table border=1>
  3580. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3581. <tr align='center'>
  3582. <td>仓库</td>
  3583. <td>供应商</td>
  3584. <td>位置</td>
  3585. <td>库存编码</td>
  3586. <td>类目</td>
  3587. <td>SKU</td>
  3588. <td>用友编码</td>
  3589. <td>用友料号</td>
  3590. <td>商品名称</td>
  3591. <td>商品中文</td>
  3592. <td>产品备注</td>
  3593. <td>库位负责人</td>
  3594. <td>类型</td>
  3595. <td>入库总量</td>
  3596. <td>库存数量</td>
  3597. <td>销售数量</td>
  3598. <td>退货数量</td>
  3599. <td>删除数量</td>
  3600. <td>其它操作</td>
  3601. <td>占单数量</td>
  3602. <td>重量(g)</td>
  3603. </tr>
  3604. </table>";
  3605. $filename = $title . ".xls";
  3606. $tail = "";
  3607. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3608. }
  3609. }
  3610. //入库导出
  3611. public function _excelr()
  3612. {
  3613. if (isset($_GET['excel'])) {
  3614. $category = $this->input->get('category', true);
  3615. $size = $this->input->get('size', true);
  3616. $grade = $this->input->get('grade', true);
  3617. $color = $this->input->get('color', true);
  3618. $lowe = $this->input->get('lowe', true);
  3619. $sku = $this->input->get('sku', true);
  3620. $warehouse = $this->input->get('warehouse', true);
  3621. $purchase = $this->input->get('purchase', true);
  3622. $ktime = $this->input->get('ktime', true);
  3623. $jtime = $this->input->get('jtime', true);
  3624. $ktime = strtotime($ktime);
  3625. $jtime = strtotime($jtime);
  3626. $where = "1=1";
  3627. $gj = "";
  3628. $ck = "";
  3629. if ($category) {
  3630. $where .= " and features like '%-$category-%'";
  3631. }
  3632. if ($size) {
  3633. $where .= " and features like '%-$size-%'";
  3634. }
  3635. if ($grade) {
  3636. $where .= " and features like '%-$grade-%'";
  3637. }
  3638. if ($color) {
  3639. $where .= " and features like '%-$color-%'";
  3640. }
  3641. if ($lowe) {
  3642. $where .= " and features like '%-$lowe-%'";
  3643. }
  3644. if ($warehouse) {
  3645. $where .= " and warehouse = '$warehouse'";
  3646. }
  3647. if ($purchase) {
  3648. $where .= " and purchase = '$purchase'";
  3649. }
  3650. if ($sku) {
  3651. $where .= " and sku = '$sku'";
  3652. }
  3653. if ($ktime && $jtime) {
  3654. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3655. }
  3656. //数据排序
  3657. $order_str = "id desc";
  3658. if (empty($page)) {
  3659. $start = 0;
  3660. $perpage = 1;
  3661. } else {
  3662. $start = ($page - 1) * $perpage;
  3663. }
  3664. $list = array();
  3665. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3666. foreach ($rows as $value) {
  3667. $ck = $this->warehouse->read($value['warehouse']);
  3668. $warehouse = $ck['title'];
  3669. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3670. $retreatwarehouse = $tkck['title'];
  3671. $gy = $this->purchase->read($value['purchase']);
  3672. $purchase = $gy['title'];
  3673. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3674. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3675. }
  3676. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3677. $titlename = "<table border=1>
  3678. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3679. <tr align='center'>
  3680. <td>仓库</td>
  3681. <td>SKU</td>
  3682. <td>产品</td>
  3683. <td>时间</td>
  3684. <td>数量</td>
  3685. </tr>
  3686. </table>";
  3687. $filename = $title . ".xls";
  3688. $tail = "";
  3689. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3690. }
  3691. }
  3692. //出库、退库导出
  3693. public function _excelct()
  3694. {
  3695. $classid = $this->classid->sku();
  3696. $pm = $classid;
  3697. $typeclass = array();
  3698. $tc = $this->typeclass->find_all();
  3699. foreach ($tc as $v) {
  3700. $typeclass[$v['id']] = $v;
  3701. }
  3702. $prc = array();
  3703. $purchase = $this->purchase->find_all();
  3704. foreach ($purchase as $k => $v) {
  3705. $prc[$v['id']] = $v['title'];
  3706. }
  3707. if (isset($_GET['excel'])) {
  3708. $wh = array();
  3709. $w = $this->warehouse->find_all('1=1', 'id,title');
  3710. foreach ($w as $v) {
  3711. $wh[$v['id']] = $v['title'];
  3712. }
  3713. $type = $this->input->get('excel', true);
  3714. $category = $this->input->get('category', true);
  3715. $size = $this->input->get('size', true);
  3716. $grade = $this->input->get('grade', true);
  3717. $color = $this->input->get('color', true);
  3718. $lowe = $this->input->get('lowe', true);
  3719. $sku = $this->input->get('sku', true);
  3720. $title = $this->input->get('title', true);
  3721. $warehouse = $this->input->get('warehouse', true);
  3722. $purchase = $this->input->get('purchase', true);
  3723. $lacetype = $this->input->get('lacetype', true);
  3724. $haircap = $this->input->get('haircap', true);
  3725. $lacecolor = $this->input->get('lacecolor', true);
  3726. $density = $this->input->get('density', true);
  3727. $details = $this->input->get('details', true);
  3728. $state = $this->input->get('state', true);
  3729. $shop = $this->input->get('shop', true);
  3730. $hairnumber = $this->input->get('hairnumber', true);
  3731. $type_leixi = $this->input->get('type', true);
  3732. $cpbz = $this->input->get('cpbz', true);
  3733. $sm = $this->input->get('sm', true);
  3734. $sid = $this->input->get('sid', true);
  3735. $ktime = $this->input->get('ktime', true);
  3736. $jtime = $this->input->get('jtime', true);
  3737. $ktime = strtotime($ktime);
  3738. $jtime = strtotime($jtime);
  3739. //$where = " 1=1 ";
  3740. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3741. $where = " sku != '' ";
  3742. $gj = "";
  3743. $ck = "";
  3744. if ($category) {
  3745. $where .= " and features like '%-$category-%'";
  3746. }
  3747. if ($size) {
  3748. $where .= " and features like '%-$size-%'";
  3749. }
  3750. if ($grade) {
  3751. $where .= " and features like '%-$grade-%'";
  3752. }
  3753. if ($color) {
  3754. $where .= " and features like '%-$color-%'";
  3755. }
  3756. if ($lowe) {
  3757. $where .= " and features like '%-$lowe-%'";
  3758. }
  3759. if ($warehouse) {
  3760. $where .= " and warehouse = '$warehouse'";
  3761. }
  3762. if ($purchase) {
  3763. $where .= " and purchase = '$purchase'";
  3764. }
  3765. if ($state) {
  3766. $where .= " and state = '$state'";
  3767. }
  3768. if ($lacetype) {
  3769. $where .= " and features like '%-$lacetype-%'";
  3770. }
  3771. if ($lacecolor) {
  3772. $where .= " and features like '%-$lacecolor-%'";
  3773. }
  3774. if ($density) {
  3775. $where .= " and features like '%-$density-%'";
  3776. }
  3777. if ($haircap) {
  3778. $where .= " and features like '%-$haircap-%'";
  3779. }
  3780. if ($details) {
  3781. $where .= " and details = '$details'";
  3782. }
  3783. if ($shop) {
  3784. $where .= " and shop like '%$shop%'";
  3785. }
  3786. if ($title) {
  3787. $title = trim($title, ' ');
  3788. $title = trim($title, ' ');
  3789. $where .= " and title like '%$title%'";
  3790. }
  3791. if (!empty($hairnumber)) {
  3792. $where .= " and features like '%-128-%' ";
  3793. if ($hairnumber < 0) {
  3794. $class_list = $this->typeclass->find_all('classid = 43');
  3795. foreach ($class_list as $v) {
  3796. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3797. }
  3798. } else {
  3799. $where .= " and features like '%-$hairnumber-%'";
  3800. }
  3801. }
  3802. if ($type_leixi) {
  3803. $where .= " and type = '$type_leixi'";
  3804. }
  3805. if ($cpbz) {
  3806. $where .= " and cpbz like '%$cpbz%' ";
  3807. }
  3808. if ($sm) {
  3809. $where .= " and sm like '%$sm%' ";
  3810. }
  3811. if ($sku) {
  3812. $sku = trim($sku, ' ');
  3813. $sku = trim($sku, ' ');
  3814. $where .= " and sku like '%$sku%'";
  3815. }
  3816. if ($ktime && $jtime) {
  3817. if ($type == 1) {
  3818. $tl = '出库';
  3819. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3820. } else if ($type == 2) {
  3821. $tl = '退库';
  3822. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3823. } else if ($type == 3) {
  3824. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3825. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3826. } else if ($type == 4) {
  3827. $tl = '出库+零售';
  3828. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3829. } else if ($type == 5) {
  3830. $tl = '零售';
  3831. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3832. }
  3833. }
  3834. $sidwhere = '';
  3835. if ($sid) {
  3836. $sd = "";
  3837. $s = explode(',', trim($sid, ','));
  3838. foreach ($s as $value) {
  3839. $sd .= " id = " . $value . " or";
  3840. }
  3841. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3842. }
  3843. //数据排序
  3844. $order_str = "time desc";
  3845. if (empty($page)) {
  3846. $start = 0;
  3847. $perpage = 1;
  3848. } else {
  3849. $start = ($page - 1) * $perpage;
  3850. }
  3851. //取得信息列表
  3852. if ($type != 3 && $type != 5) {
  3853. if ($type == 1 || $type == 4) {
  3854. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3855. foreach ($info_list as $key => $value) {
  3856. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3857. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3858. $warehouse = $this->warehouse->read($value['warehouse']);
  3859. $info_list[$key]['warehouse'] = $warehouse['title'];
  3860. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3861. $features = explode('-', trim($features, '-'));
  3862. $pm = $classid;
  3863. foreach ($features as $k => $v) {
  3864. if ($v != 0) {
  3865. if (!isset($typeclass[$v])) {
  3866. continue;
  3867. }
  3868. if (isset($pm[$typeclass[$v]['classid']])) {
  3869. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3870. $tz = explode('|', $typeclass[$v]['zh']);
  3871. $pm[$typeclass[$v]['classid']] = $tz[0];
  3872. } else {
  3873. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3874. }
  3875. }
  3876. }
  3877. }
  3878. $zh = implode(" ", $pm);
  3879. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3880. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3881. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3882. $info_list[$key]['features'] = $zh;
  3883. }
  3884. $final_list = [];
  3885. foreach($info_list as $k=>$v){
  3886. $number = "";
  3887. if(!empty($v['orderinfo'])){
  3888. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3889. if(!empty($tmp_info['number'])){
  3890. $number = $tmp_info['number'];
  3891. }
  3892. }
  3893. $final_list[] = [
  3894. 'warehouse'=>$v['warehouse'],
  3895. 'purchase'=>$v['purchase'],
  3896. 'sku'=>$v['sku'],
  3897. 'title'=>$v['title'],
  3898. 'features'=>$v['features'],
  3899. 'label'=>$v['label'],
  3900. 'orderinfo'=>$v['orderinfo'],
  3901. 'number'=>$number,
  3902. 'waybill'=>$v['waybill'],
  3903. 'outk'=>$v['outk'],
  3904. ];
  3905. }
  3906. } else {
  3907. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3908. foreach ($info_list as $key => $value) {
  3909. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3910. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3911. $warehouse = $this->warehouse->read($value['warehouse']);
  3912. $info_list[$key]['warehouse'] = $warehouse['title'];
  3913. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3914. $features = explode('-', trim($features, '-'));
  3915. $pm = $classid;
  3916. foreach ($features as $k => $v) {
  3917. if ($v != 0) {
  3918. if (!isset($typeclass[$v])) {
  3919. continue;
  3920. }
  3921. if (isset($pm[$typeclass[$v]['classid']])) {
  3922. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3923. $tz = explode('|', $typeclass[$v]['zh']);
  3924. $pm[$typeclass[$v]['classid']] = $tz[0];
  3925. } else {
  3926. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3927. }
  3928. }
  3929. }
  3930. }
  3931. $zh = implode(" ", $pm);
  3932. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3933. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3934. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3935. $info_list[$key]['features'] = $zh;
  3936. }
  3937. $final_list = [];
  3938. foreach($info_list as $k=>$v){
  3939. $number = "";
  3940. if(!empty($v['orderinfo'])){
  3941. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3942. if(!empty($tmp_info['number'])){
  3943. $number = $tmp_info['number'];
  3944. }
  3945. }
  3946. $final_list[] = [
  3947. 'warehouse'=>$v['warehouse'],
  3948. 'purchase'=>$v['purchase'],
  3949. 'sku'=>$v['sku'],
  3950. 'title'=>$v['title'],
  3951. 'features'=>$v['features'],
  3952. 'label'=>$v['label'],
  3953. 'orderinfo'=>$v['orderinfo'],
  3954. 'number'=>$number,
  3955. 'waybill'=>$v['waybill'],
  3956. 'retreat'=>$v['retreat'],
  3957. ];
  3958. }
  3959. }
  3960. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3961. $titlename = "<table border=1>
  3962. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3963. <tr align='center'>
  3964. <td>仓库</td>
  3965. <td>供应商</td>
  3966. <td>SKU</td>
  3967. <td>商品名称</td>
  3968. <td>商品中文</td>
  3969. <td>标签</td>
  3970. <td>订单号</td>
  3971. <td>订单编码</td>
  3972. <td>运单号</td>
  3973. <td>" . $tl . "时间(中国时间)</td>
  3974. </tr>
  3975. </table>";
  3976. $filename = $title . ".xls";
  3977. $tail = "";
  3978. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3979. } else if ($type == 5) {
  3980. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3981. foreach ($info_list as $key => $value) {
  3982. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3983. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3984. $warehouse = $this->warehouse->read($value['warehouse']);
  3985. $info_list[$key]['warehouse'] = $warehouse['title'];
  3986. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3987. $features = explode('-', trim($features, '-'));
  3988. $pm = $classid;
  3989. foreach ($features as $k => $v) {
  3990. if ($v != 0) {
  3991. if (!isset($typeclass[$v])) {
  3992. continue;
  3993. }
  3994. if (isset($pm[$typeclass[$v]['classid']])) {
  3995. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3996. $tz = explode('|', $typeclass[$v]['zh']);
  3997. $pm[$typeclass[$v]['classid']] = $tz[0];
  3998. } else {
  3999. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4000. }
  4001. }
  4002. }
  4003. }
  4004. $zh = implode(" ", $pm);
  4005. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4006. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4007. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4008. $info_list[$key]['features'] = $zh;
  4009. }
  4010. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4011. $titlename = "<table border=1>
  4012. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4013. <tr align='center'>
  4014. <td>仓库</td>
  4015. <td>供应商</td>
  4016. <td>SKU</td>
  4017. <td>商品名称</td>
  4018. <td>商品中文</td>
  4019. <td>标签</td>
  4020. <td>" . $tl . "时间(中国时间)</td>
  4021. </tr>
  4022. </table>";
  4023. $filename = $title . ".xls";
  4024. $tail = "";
  4025. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4026. } else {
  4027. /**
  4028. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4029. $rows = array();$list = array();
  4030. foreach ($info_list as $key=>$value)
  4031. {
  4032. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4033. }
  4034. **/
  4035. $wh = array();
  4036. $w = $this->warehouse->find_all('1=1', 'id,title');
  4037. foreach ($w as $v) {
  4038. $wh[$v['id']] = $v['title'];
  4039. }
  4040. $wt = array();
  4041. $whlabel_type = $this->whlabel_type->find_all();
  4042. foreach ($whlabel_type as $v) {
  4043. $wt[$v['id']] = $v['title'];
  4044. }
  4045. $classid = $this->classid->sku();
  4046. $list = array();
  4047. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4048. foreach ($rows as $key => $value) {
  4049. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4050. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4051. $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');
  4052. $details = array();
  4053. $cpid = array();
  4054. $cpbz = array();
  4055. $c = 0;
  4056. $g = 0;
  4057. $x = 0;
  4058. $t = 0;
  4059. $s = 0;
  4060. $q = 0;
  4061. foreach ($sd as $k => $v) {
  4062. if ($v['state'] == 0) {
  4063. $c++;
  4064. }
  4065. if ($v['state'] != 9) {
  4066. $g++;
  4067. }
  4068. if ($v['outk'] > 1) {
  4069. $x++;
  4070. }
  4071. if ($v['retreat'] > 0) {
  4072. $t++;
  4073. }
  4074. if ($v['state'] == 8) {
  4075. $s++;
  4076. }
  4077. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4078. $q++;
  4079. }
  4080. $details[$v['details']] = $v['details'];
  4081. if ($v['cpid'] != 0) {
  4082. $cpid[$v['cpid']] = $v['cpid'];
  4083. }
  4084. if ($v['cpbz'] != '') {
  4085. $cpbz[$v['cpbz']] = $v['cpbz'];
  4086. }
  4087. }
  4088. if (isset($wt[$value['type']])) {
  4089. $rows[$key]['type'] = $wt[$value['type']];
  4090. } else {
  4091. $rows[$key]['type'] = '未设置';
  4092. }
  4093. $rows[$key]['details'] = implode("、", $details);
  4094. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4095. $ftime = time() - 15 * 24 * 3600;
  4096. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4097. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4098. $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);
  4099. $rows[$key]['c'] = $c;
  4100. $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);
  4101. $rows[$key]['t'] = $t;
  4102. $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'] . '"');
  4103. $rows[$key]['z'] = $z;
  4104. // $jm = $classid;
  4105. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4106. $features = explode('-', trim($features, '-'));
  4107. // $pm = $classid;
  4108. // foreach ($features as $k => $v) {
  4109. // if ($v != 0) {
  4110. // if (!isset($typeclass[$v])) {
  4111. // continue;
  4112. // }
  4113. // if (isset($pm[$typeclass[$v]['classid']])) {
  4114. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4115. // $tz = explode('|', $typeclass[$v]['zh']);
  4116. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4117. // } else {
  4118. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4119. // }
  4120. // if (isset($jm[$typeclass[$v]['classid']])) {
  4121. // if ($typeclass[$v]['jm']) {
  4122. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4123. // }
  4124. // }
  4125. // }
  4126. // }
  4127. // }
  4128. // $zh = implode(" ", $pm);
  4129. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4130. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4131. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4132. // $rows[$key]['features'] = $zh;
  4133. // $jm = array_filter($jm); //去除空值
  4134. // $jm = implode("-", $jm);
  4135. // $rows[$key]['jm'] = $jm;
  4136. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4137. }
  4138. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4139. // echo "<pre>";
  4140. // print_r($tmp_list);
  4141. // die;
  4142. $final_list =[];
  4143. foreach($tmp_list as $k=>$v){
  4144. $final_list[] = [
  4145. "warehouse"=>$v['warehouse'],
  4146. "purchase"=>$v['purchase'],
  4147. "details"=>trim($v['details'],'、'),
  4148. "cpid"=>$v['cpid'],
  4149. "sku"=>$v['sku'],
  4150. "title"=>$v['title'],
  4151. "features"=>$v['pm'],
  4152. "cpbz"=>$v['cpbz'],
  4153. "sm"=>$v['sm'],
  4154. "type"=>$v['type'],
  4155. "g"=>$v["g"],
  4156. "c"=>$v["c"],
  4157. "x"=>$v["x"],
  4158. "t"=>$v["t"],
  4159. "z"=>$v["z"],
  4160. "jm"=>$v["jm"],
  4161. "weight"=>$v["weight"],
  4162. "asd"=>$v["asd"],
  4163. ];
  4164. }
  4165. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4166. $titlename = "<table border=1>
  4167. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4168. <tr align='center'>
  4169. <td>仓库</td>
  4170. <td>供应商</td>
  4171. <td>位置</td>
  4172. <td>库存编码</td>
  4173. <td>SKU</td>
  4174. <td>商品名称</td>
  4175. <td>商品中文</td>
  4176. <td>产品备注</td>
  4177. <td>说明</td>
  4178. <td>类型</td>
  4179. <td>入库总量</td>
  4180. <td>库存数量</td>
  4181. <td>销售数量</td>
  4182. <td>退货数量</td>
  4183. <td>占单数量</td>
  4184. <td>料号</td>
  4185. <td>重量</td>
  4186. <td>类目</td>
  4187. </tr>
  4188. </table>";
  4189. $filename = $title . ".xls";
  4190. $tail = "";
  4191. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4192. }
  4193. }
  4194. }
  4195. //出库+入库数据整合
  4196. public function _excelcr()
  4197. {
  4198. if (isset($_GET['excel'])) {
  4199. $type = $this->input->get('excel', true);
  4200. $category = $this->input->get('category', true);
  4201. $size = $this->input->get('size', true);
  4202. $grade = $this->input->get('grade', true);
  4203. $color = $this->input->get('color', true);
  4204. $lowe = $this->input->get('lowe', true);
  4205. $sku = $this->input->get('sku', true);
  4206. $warehouse = $this->input->get('warehouse', true);
  4207. $purchase = $this->input->get('purchase', true);
  4208. $state = $this->input->get('state', true);
  4209. $sid = $this->input->get('sid', true);
  4210. $ktime = $this->input->get('ktime', true);
  4211. $jtime = $this->input->get('jtime', true);
  4212. $ktime = strtotime($ktime);
  4213. $jtime = strtotime($jtime);
  4214. $where = "1=1";
  4215. $gj = "";
  4216. $ck = "";
  4217. if ($category) {
  4218. $where .= " and features like '%-$category-%'";
  4219. }
  4220. if ($size) {
  4221. $where .= " and features like '%-$size-%'";
  4222. }
  4223. if ($grade) {
  4224. $where .= " and features like '%-$grade-%'";
  4225. }
  4226. if ($color) {
  4227. $where .= " and features like '%-$color-%'";
  4228. }
  4229. if ($lowe) {
  4230. $where .= " and features like '%-$lowe-%'";
  4231. }
  4232. if ($warehouse) {
  4233. $where .= " and warehouse = '$warehouse'";
  4234. }
  4235. if ($purchase) {
  4236. $where .= " and purchase = '$purchase'";
  4237. }
  4238. if ($state) {
  4239. $where .= " and state = '$state'";
  4240. }
  4241. if ($sku) {
  4242. $where .= " and sku like '%$sku%'";
  4243. }
  4244. if ($ktime && $jtime) {
  4245. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4246. }
  4247. $sidwhere = '';
  4248. if ($sid) {
  4249. $sd = "";
  4250. $s = explode(',', trim($sid, ','));
  4251. foreach ($s as $value) {
  4252. $sd .= " id = " . $value . " or";
  4253. }
  4254. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4255. }
  4256. //取得信息列表
  4257. $timeread = $ktime;
  4258. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4259. $timelist = array();
  4260. for ($i = 0; $i < $timenum; $i++) {
  4261. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4262. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4263. }
  4264. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4265. //echo "<pre>";
  4266. //print_r($info_list);
  4267. //exit();
  4268. $rows = array();
  4269. $list = array();
  4270. foreach ($info_list as $key => $value) {
  4271. $thistime = $timelist;
  4272. if (isset($rows[strtolower($value['sku'])])) {
  4273. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4274. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4275. }
  4276. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4277. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4278. }
  4279. } else {
  4280. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4281. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4282. }
  4283. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4284. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4285. }
  4286. $rows[strtolower($value['sku'])] = $thistime;
  4287. }
  4288. }
  4289. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4290. <head>
  4291. <!--[if gte mso 9]><xml>
  4292. <x:ExcelWorkbook>
  4293. <x:ExcelWorksheets>
  4294. <x:ExcelWorksheet>
  4295. <x:Name>EXCEL</x:Name>
  4296. <x:WorksheetOptions>
  4297. <x:Print>
  4298. <x:ValidPrinterInfo />
  4299. </x:Print>
  4300. </x:WorksheetOptions>
  4301. </x:ExcelWorksheet>
  4302. </x:ExcelWorksheets>
  4303. </x:ExcelWorkbook>
  4304. </xml>
  4305. <![endif]-->
  4306. </head><body>";
  4307. $str .= "<table border=1><tr><td>SKU</td>";
  4308. foreach ($timelist as $k => $v) {
  4309. $str .= "<td>" . $k . "出库</td>";
  4310. $str .= "<td>" . $k . "入库</td>";
  4311. }
  4312. $str .= "</tr></table>";
  4313. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4314. foreach ($rows as $key => $val) {
  4315. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4316. foreach ($val as $k => $v) {
  4317. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4318. if ($val[$k]['r'] > 0) {
  4319. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4320. } else {
  4321. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4322. }
  4323. }
  4324. $str .= "</tr>";
  4325. }
  4326. $str .= "</table>";
  4327. $str .= "</body></html>";
  4328. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4329. header("Content-type: application/octet-stream");
  4330. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4331. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4332. header("Pragma: no-cache");
  4333. header("Expires: 0");
  4334. exit($str);
  4335. }
  4336. }
  4337. //数量调整模板导出
  4338. public function _presetout()
  4339. {
  4340. if (isset($_GET['excel'])) {
  4341. $where = "sku != 'Preset' and purchase != 0";
  4342. //数据排序
  4343. $order_str = "id desc";
  4344. if (empty($page)) {
  4345. $start = 0;
  4346. $perpage = 1;
  4347. } else {
  4348. $start = ($page - 1) * $perpage;
  4349. }
  4350. //取得信息列表
  4351. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4352. $rows = array();
  4353. $list = array();
  4354. foreach ($info_list as $value) {
  4355. $warehouse = $this->warehouse->read($value['warehouse']);
  4356. $number = $value['number'];
  4357. $ftime = time() - 15 * 24 * 3600;
  4358. $purchase = $this->purchase->read($value['purchase']);
  4359. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4360. }
  4361. $title = "库存模板";
  4362. $titlename = "<table border=1>
  4363. <tr align='center'>
  4364. <td>仓库</td>
  4365. <td>供应商编码</td>
  4366. <td>SKU</td>
  4367. <td>增减数量(正数或负数)</td>
  4368. <td>增减备注</td>
  4369. <td>扣减方式:0减少库存1删除库存</td>
  4370. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4371. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4372. </tr>
  4373. </table>";
  4374. $filename = $title . ".xls";
  4375. $tail = "";
  4376. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4377. }
  4378. }
  4379. //数量调整模板导入
  4380. public function _presetedit()
  4381. {
  4382. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4383. $config['upload_path'] = '.' . $dir;
  4384. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4385. $config['allowed_types'] = 'xls|xlsx|csv';
  4386. $config['max_size'] = 10240;
  4387. $this->load->library('upload', $config);
  4388. $this->upload->initialize($config);
  4389. if ($this->upload->do_upload('userfile')) {
  4390. $full_path = $dir . $this->upload->data('file_name');
  4391. $fileName = '.' . $full_path;
  4392. if (!file_exists($fileName)) {
  4393. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4394. exit;
  4395. } else {
  4396. require_once "./data/excel/PHPExcel/IOFactory.php";
  4397. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4398. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4399. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4400. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4401. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4402. ++$column; //如果列数大于26行
  4403. $list = array();
  4404. for ($i = 2; $i <= $row; $i++) // 行数循环
  4405. {
  4406. $data = array();
  4407. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4408. {
  4409. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4410. }
  4411. $list[] = $data;
  4412. }
  4413. }
  4414. $i = 0;
  4415. $j = 0;
  4416. $ed = array();
  4417. foreach ($list as $key => $value) {
  4418. $time = time();
  4419. if ($value['0'] == "") {
  4420. continue;
  4421. }
  4422. $warehouse = $this->warehouse->get_title($value['0']);
  4423. $purchase = $this->purchase->get_bm($value['1']);
  4424. $sku = $value['2'];
  4425. $num = $value['3']; //调整数量
  4426. $text = $value['4']; //扣减说明
  4427. $type = $value['5']; //调整方式0扣减1删除
  4428. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4429. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4430. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4431. if (!$purchase) //如果没有这个SKU
  4432. {
  4433. $ed[] = array($purchase . '-不存在此供应商编码');
  4434. $j++;
  4435. continue;
  4436. }
  4437. if (!$d) //如果没有这个SKU
  4438. {
  4439. $ed[] = array($sku . '-库存中不存在此SKU');
  4440. $j++;
  4441. continue;
  4442. }
  4443. if (!isset($warehouse['id'])) {
  4444. $ed[] = array($sku . '-仓库名错误!');
  4445. $j++;
  4446. continue;
  4447. }
  4448. if ($type != '0' && $type != '1') {
  4449. $ed[] = array($sku . '-扣减方式填写错误!');
  4450. $j++;
  4451. continue;
  4452. }
  4453. if ($num < 0) //扣减库存
  4454. {
  4455. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4456. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4457. $j++;
  4458. continue;
  4459. }
  4460. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4461. if (count($data) < abs($num)) {
  4462. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4463. $j++;
  4464. continue;
  4465. }
  4466. if ($type == 0) //如果扣减方式为 扣减库存
  4467. {
  4468. for ($i = 0; $i < abs($num); $i++) {
  4469. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4470. }
  4471. } else if ($type == 1) {
  4472. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4473. if (count($zt) > 0) {
  4474. $ed[] = array($sku . '-有在途库存无法删除!');
  4475. $j++;
  4476. continue;
  4477. }
  4478. for ($i = 0; $i < abs($num); $i++) {
  4479. $this->whlabel->remove($data[$i]['id']);
  4480. }
  4481. }
  4482. } else if ($num > 0) //增加库存
  4483. {
  4484. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4485. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4486. $j++;
  4487. continue;
  4488. }
  4489. $post['sku'] = $d['sku'];
  4490. $post['shop'] = $d['shop'];
  4491. $post['warehouse'] = $warehouse['id'];
  4492. $post['purchase'] = $purchase['id'];
  4493. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4494. $post['state'] = 0;
  4495. $post['title'] = $d['title'];
  4496. $post['number'] = $d['number'];
  4497. $post['features'] = $d['features'];
  4498. $post['enter'] = $time;
  4499. $post['time'] = $time; //操作时间
  4500. $post['rktype'] = $rktype;
  4501. for ($i = 0; $i < $num; $i++) {
  4502. $post['label'] = time() . rand(100, 999) . $i;
  4503. $this->whlabel->insert($post);
  4504. }
  4505. }
  4506. sleep(1); //防止入库时间一样,需要延迟1秒
  4507. }
  4508. if ($j > 0) {
  4509. $tt = date('Ymd', time());
  4510. $title = '库存导入错误信息-' . $tt;
  4511. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4512. $tail = "\n";
  4513. $filename = $title . ".xls";
  4514. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4515. $dir = '/data/excel/' . $time . '/';
  4516. $file_name = 'error_' . $time . rand(1000, 9999);
  4517. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4518. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4519. fwrite($myfile, $ecl);
  4520. fclose($myfile);
  4521. $error = $dir . $file_name . '.xls';
  4522. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4523. exit;
  4524. } else {
  4525. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4526. exit;
  4527. }
  4528. }
  4529. }
  4530. public function _presetedittwo(){
  4531. $data = $this->input->post(NULL, TRUE);
  4532. if(empty($list)){
  4533. $raw_data = $this->input->raw_input_stream;
  4534. // 解码 JSON
  4535. $data = json_decode($raw_data, true);
  4536. }
  4537. if(empty($data)){
  4538. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4539. }
  4540. $list = [];
  4541. if(isset($data['list'])){
  4542. $list = $data['list'];
  4543. }
  4544. $i = 0;
  4545. $j = 0;
  4546. $ed = array();
  4547. foreach ($list as $key => $value) {
  4548. $time = time();
  4549. if ($value['0'] == "") {
  4550. continue;
  4551. }
  4552. $warehouse = $this->warehouse->get_title($value['0']);
  4553. $purchase = $this->purchase->get_bm($value['1']);
  4554. $sku = $value['2'];
  4555. $num = $value['3']; //调整数量
  4556. $text = $value['4']; //扣减说明
  4557. $type = $value['5']; //调整方式0扣减1删除
  4558. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4559. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4560. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4561. if (!$purchase) //如果没有这个SKU
  4562. {
  4563. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4564. $j++;
  4565. continue;
  4566. }
  4567. if (!$d) //如果没有这个SKU
  4568. {
  4569. $ed[] = array($sku . '-库存中不存在此SKU');
  4570. $j++;
  4571. continue;
  4572. }
  4573. if (!isset($warehouse['id'])) {
  4574. $ed[] = array($sku . '-仓库名错误!');
  4575. $j++;
  4576. continue;
  4577. }
  4578. if ($type != '0' && $type != '1') {
  4579. $ed[] = array($sku . '-扣减方式填写错误!');
  4580. $j++;
  4581. continue;
  4582. }
  4583. if ($num < 0) //扣减库存
  4584. {
  4585. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4586. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4587. $j++;
  4588. continue;
  4589. }
  4590. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4591. if (count($data) < abs($num)) {
  4592. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4593. $j++;
  4594. continue;
  4595. }
  4596. if ($type == 0) //如果扣减方式为 扣减库存
  4597. {
  4598. for ($i = 0; $i < abs($num); $i++) {
  4599. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4600. }
  4601. } else if ($type == 1) {
  4602. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4603. if (count($zt) > 0) {
  4604. $ed[] = array($sku . '-有在途库存无法删除!');
  4605. $j++;
  4606. continue;
  4607. }
  4608. for ($i = 0; $i < abs($num); $i++) {
  4609. $this->whlabel->remove($data[$i]['id']);
  4610. }
  4611. }
  4612. } else if ($num > 0) //增加库存
  4613. {
  4614. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4615. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4616. $j++;
  4617. continue;
  4618. }
  4619. $post['sku'] = $d['sku'];
  4620. $post['shop'] = $d['shop'];
  4621. $post['warehouse'] = $warehouse['id'];
  4622. $post['purchase'] = $purchase['id'];
  4623. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4624. $post['state'] = 0;
  4625. $post['title'] = $d['title'];
  4626. $post['number'] = $d['number'];
  4627. $post['features'] = $d['features'];
  4628. $post['enter'] = $time;
  4629. $post['time'] = $time; //操作时间
  4630. $post['rktype'] = $rktype;
  4631. $post['sku_master_id'] = $d['sku_master_id'];
  4632. $post['sku_shop_id'] = $d['sku_shop_id'];
  4633. for ($i = 0; $i < $num; $i++) {
  4634. $post['label'] = time() . rand(100, 999) . $i;
  4635. $this->whlabel->insert($post);
  4636. }
  4637. }
  4638. sleep(1); //防止入库时间一样,需要延迟1秒
  4639. }
  4640. if ($j > 0) {
  4641. $tt = date('Ymd', time());
  4642. $title = '库存导入错误信息-' . $tt;
  4643. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4644. $tail = "\n";
  4645. $filename = $title . ".xls";
  4646. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4647. $dir = '/data/excel/' . $time . '/';
  4648. $file_name = 'error_' . $time . rand(1000, 9999);
  4649. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4650. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4651. fwrite($myfile, $ecl);
  4652. fclose($myfile);
  4653. $error = $dir . $file_name . '.xls';
  4654. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4655. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4656. exit;
  4657. } else {
  4658. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4659. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4660. exit;
  4661. }
  4662. }
  4663. //笛卡儿积
  4664. function cp($ps, $sets, $list)
  4665. {
  4666. $result = array();
  4667. $j = 0;
  4668. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4669. if ($i == 0) {
  4670. $result = $sets[$i];
  4671. }
  4672. $tmp = array();
  4673. foreach ($result as $res) {
  4674. foreach ($sets[$i + 1] as $set) {
  4675. $tmp[] = $res . ',' . $set;
  4676. }
  4677. }
  4678. $result = $tmp;
  4679. }
  4680. $this->db->trans_begin();
  4681. foreach ($result as $v) {
  4682. $post = array();
  4683. $title = "";
  4684. $num = "";
  4685. $data = explode(',', $v);
  4686. for ($i = 0; $i < count($list); $i++) {
  4687. $post[$list[$i]] = $data[$i];
  4688. $typeclass = $this->typeclass->read($data[$i]);
  4689. $title = $title . $typeclass['title'] . " ";
  4690. if ($data[$i] != 0) {
  4691. $num .= $data[$i]; //所有数据ID拼接
  4692. }
  4693. }
  4694. foreach ($ps as $kp => $vp) {
  4695. $post[$kp] = $vp;
  4696. }
  4697. $post['number'] = $num;
  4698. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4699. if ($info_list) {
  4700. $j++;
  4701. } else {
  4702. $skunum = $this->whlabel->find_count();
  4703. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4704. $post['title'] = rtrim($title, ' ');
  4705. $this->whlabel->insert($post);
  4706. }
  4707. }
  4708. if ($this->db->trans_status() === FALSE) {
  4709. $this->db->trans_commit();
  4710. return NULL;
  4711. } else {
  4712. $this->db->trans_commit();
  4713. return $j;
  4714. }
  4715. }
  4716. public function _kj($arg_array)
  4717. {
  4718. if (isset($_POST['sku'])) {
  4719. $time = time();
  4720. $sku = $this->input->post('sku', true);
  4721. $warehouse = $this->input->post('warehouse', true);
  4722. $num = $this->input->post('num', true);
  4723. $text = $this->input->post('text', true);
  4724. $purchase = $this->input->post('purchase', true);
  4725. $cktype = $this->input->post('cktype', true);
  4726. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4727. if ($cktype != 1 && $text == '') {
  4728. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4729. exit;
  4730. }
  4731. if ($num > count($order)) {
  4732. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4733. exit;
  4734. } else {
  4735. for ($i = 0; $i < $num; $i++) {
  4736. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4737. }
  4738. }
  4739. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4740. exit;
  4741. }
  4742. $uid = $this->whlabel->read($arg_array[0]);
  4743. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4744. $this->data['data'] = $uid;
  4745. $this->_Template('whlabel_kj', $this->data);
  4746. }
  4747. public function _summary($arg_array)
  4748. {
  4749. $prc = array();
  4750. $purchase = $this->purchase->find_all();
  4751. foreach ($purchase as $k => $v) {
  4752. $prc[$v['id']] = $v['title'];
  4753. }
  4754. if (isset($_GET['excel'])) {
  4755. $ktime = $this->input->get('ktime', true);
  4756. $jtime = $this->input->get('jtime', true);
  4757. $ktime = strtotime($ktime);
  4758. $jtime = strtotime($jtime);
  4759. $where = "1=1";
  4760. if ($ktime && $jtime) {
  4761. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4762. }
  4763. //数据排序
  4764. $order_str = "time desc";
  4765. if (empty($page)) {
  4766. $start = 0;
  4767. $perpage = 1;
  4768. } else {
  4769. $start = ($page - 1) * $perpage;
  4770. }
  4771. //取得信息列表
  4772. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4773. foreach ($info_list as $key => $value) {
  4774. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4775. $warehouse = $this->warehouse->read($value['warehouse']);
  4776. $info_list[$key]['warehouse'] = $warehouse['title'];
  4777. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4778. $details = array();
  4779. $cpid = array();
  4780. foreach ($x as $k => $v) {
  4781. if ($v['details'] != '') {
  4782. $details[$v['details']] = $v['details'];
  4783. }
  4784. if ($v['cpid'] != 0) {
  4785. $cpid[$v['cpid']] = $v['cpid'];
  4786. }
  4787. }
  4788. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4789. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4790. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4791. $info_list[$key]['s'] = $s;
  4792. $info_list[$key]['x'] = count($x);
  4793. }
  4794. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4795. $titlename = "<table border=1>
  4796. <tr align='center'>
  4797. <td>仓库</td>
  4798. <td>供应商</td>
  4799. <td>出库位置</td>
  4800. <td>出库编码</td>
  4801. <td>SKU</td>
  4802. <td>产品名</td>
  4803. <td>总剩余库存</td>
  4804. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4805. </tr>
  4806. </table>";
  4807. $filename = $title . ".xls";
  4808. $tail = "";
  4809. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4810. }
  4811. }
  4812. //usps发货清单
  4813. public function _manifest()
  4814. {
  4815. if (isset($_POST['manifest'])) {
  4816. $wltext = $this->input->post('wltext', true);
  4817. $time = time() - 16 * 3600;
  4818. $ptime = strtotime(date('Y-m-d', $time));
  4819. $waybill = array();
  4820. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4821. foreach ($fullorder as $v) {
  4822. $waybill[$v['waybill']] = $v['waybill'];
  4823. }
  4824. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4825. foreach ($fullordersmt as $v) {
  4826. $waybill[$v['waybill']] = $v['waybill'];
  4827. }
  4828. $wltext = explode(';', $wltext);
  4829. foreach ($wltext as $v) {
  4830. if (isset($waybill[$v])) {
  4831. unset($waybill[$v]);
  4832. }
  4833. }
  4834. $data = $this->usps->get_manifest($waybill);
  4835. if (isset($data['Description'])) {
  4836. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4837. exit;
  4838. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4839. $bctime = date('Ymd', time());
  4840. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4841. echo json_encode(array('msg' => $pdf, 'success' => true));
  4842. exit;
  4843. } else {
  4844. echo json_encode(array('msg' => $data, 'success' => false));
  4845. exit;
  4846. }
  4847. }
  4848. }
  4849. public function _pdf($pdf, $title, $bctime)
  4850. {
  4851. $pdf_path = './data/pdf/' . $bctime . '/';
  4852. $file_base64 = $pdf;
  4853. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4854. $file_base64 = base64_decode($file_base64);
  4855. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4856. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4857. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4858. }
  4859. /**
  4860. *
  4861. *
  4862. *
  4863. 进销存占单异常索引
  4864. *
  4865. *
  4866. *
  4867. **/
  4868. public function _abnormal()
  4869. {
  4870. $post = $this->input->post(NULL, TRUE);
  4871. if (isset($post['page'])) {
  4872. $page = $this->input->post('page', true);
  4873. $perpage = $this->input->post('perpage', true);
  4874. $sku = $this->input->post('sku', true);
  4875. $where = "1=1";
  4876. //数据排序
  4877. $order_str = "id desc";
  4878. if (empty($page)) {
  4879. $start = 0;
  4880. $perpage = 1;
  4881. } else {
  4882. $start = ($page - 1) * $perpage;
  4883. }
  4884. //取得信息列表
  4885. $info_list = $this->whlabel->find_all($where, '*');
  4886. $rows = array();
  4887. $list = array();
  4888. foreach ($info_list as $key => $value) {
  4889. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4890. }
  4891. foreach ($rows as $value) {
  4892. $warehouse = $this->warehouse->read($value['warehouse']);
  4893. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4894. $number = $value['number'];
  4895. $ftime = time() - 15 * 24 * 3600;
  4896. if ($value['shop'] != '') {
  4897. $shop = $value['shop'];
  4898. $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');
  4899. $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');
  4900. $order = array_merge($orderdlz, $ordersmt);
  4901. $od = 0;
  4902. $a = '';
  4903. $orid = '';
  4904. foreach ($order as $v) {
  4905. $or = explode('|', ltrim($v['whlabel'], '|'));
  4906. for ($i = 0; $i < count($or); $i++) {
  4907. $orod = explode('-', $or[$i]);
  4908. if ($orod[0] == $number) {
  4909. $od += $orod[1];
  4910. }
  4911. }
  4912. $orid .= $v['number'] . '-';
  4913. }
  4914. } else {
  4915. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4916. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4917. $order = array_merge($orderdlz, $ordersmt);
  4918. $od = 0;
  4919. $a = '';
  4920. $orid = '';
  4921. $qt = array();
  4922. foreach ($order as $v) {
  4923. $or = explode('|', ltrim($v['whlabel'], '|'));
  4924. for ($i = 0; $i < count($or); $i++) {
  4925. $orod = explode('-', $or[$i]);
  4926. if ($orod[0] == $number) {
  4927. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4928. if ($czzs > 0) {
  4929. if (isset($qt[$v['shop']])) {
  4930. if ($qt[$v['shop']] < $orod[1]) {
  4931. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4932. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4933. } else {
  4934. $qt[$v['shop']] -= $orod[1];
  4935. }
  4936. } else {
  4937. $qt[$v['shop']] = $czzs;
  4938. }
  4939. } else {
  4940. $od += $orod[1];
  4941. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4942. }
  4943. }
  4944. }
  4945. }
  4946. }
  4947. $z = $od . '(' . $orid . ')'; //查看订单号
  4948. //$z = $od;
  4949. if ($od > $c) {
  4950. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4951. }
  4952. }
  4953. $listdata = array_slice($list, $start, $perpage);
  4954. $total = count($list);
  4955. $pagenum = ceil($total / $perpage);
  4956. $over = $total - ($start + $perpage);
  4957. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4958. echo json_encode($rows);
  4959. exit;
  4960. }
  4961. $this->_Template('whlabel_abnormal', $this->data);
  4962. }
  4963. /**
  4964. *
  4965. *
  4966. *
  4967. 进销存占单异常索引
  4968. *
  4969. *
  4970. *
  4971. **/
  4972. public function _error()
  4973. {
  4974. $post = $this->input->post(NULL, TRUE);
  4975. if (isset($post['page'])) {
  4976. $page = $this->input->post('page', true);
  4977. $perpage = $this->input->post('perpage', true);
  4978. $sku = $this->input->post('sku', true);
  4979. $warehouse = $this->input->post('warehouse', true);
  4980. $ktime = $this->input->post('ktime', true);
  4981. $jtime = $this->input->post('jtime', true);
  4982. $ktime = strtotime($ktime);
  4983. $jtime = strtotime($jtime);
  4984. $where = "sku != 'Preset'";
  4985. $gj = '';
  4986. if ($sku) {
  4987. $where .= " and sku like '%$sku%'";
  4988. } else {
  4989. if ($ktime && $jtime) {
  4990. $gj = " and time > '$ktime' and time < '$jtime'";
  4991. }
  4992. }
  4993. if ($warehouse) {
  4994. $where .= " and warehouse = '$warehouse'";
  4995. }
  4996. //数据排序
  4997. $order_str = "id desc";
  4998. if (empty($page)) {
  4999. $start = 0;
  5000. $perpage = 1;
  5001. } else {
  5002. $start = ($page - 1) * $perpage;
  5003. }
  5004. //取得信息列表
  5005. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5006. $rows = array();
  5007. $list = array();
  5008. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5009. // foreach ($info_list as $value)
  5010. // {
  5011. // $warehouse = $this->warehouse->read($value['warehouse']);
  5012. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5013. // $number = $value['number'];$ftime = time()-15*24*3600;
  5014. // if($c < 1)
  5015. // {
  5016. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5017. // }
  5018. // }
  5019. $warehouse_list = $this->warehouse->find_all();
  5020. $warehouse_list = array_column($warehouse_list, null, 'id');
  5021. foreach ($info_list as $value) {
  5022. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5023. 'title' => "",
  5024. ];
  5025. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5026. $number = $value['number'];
  5027. $ftime = time() - 15 * 24 * 3600;
  5028. if ($c < 1) {
  5029. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5030. }
  5031. }
  5032. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5033. // $query = $this->db->query($sql);
  5034. // $info_list = $query->result_array();
  5035. // $sql_two = "select title,id from crowd_warehouse";
  5036. // $query_two = $this->db->query($sql_two);
  5037. // $warehouse_list = $query_two->result_array();
  5038. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5039. // foreach ($info_list as $value)
  5040. // {
  5041. // if(isset($warehouse_arr[$value['warehouse']])){
  5042. // $warehouse = $warehouse_arr[$value['warehouse']];
  5043. // }else{
  5044. // $warehouse = [
  5045. // 'id'=>0,
  5046. // 'title'=>"异常",
  5047. // ];
  5048. // }
  5049. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5050. // $number = $value['number'];$ftime = time()-15*24*3600;
  5051. // if($c < 1)
  5052. // {
  5053. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5054. // }
  5055. // }
  5056. $listdata = array_slice($list, $start, $perpage);
  5057. $total = count($list);
  5058. $pagenum = ceil($total / $perpage);
  5059. $over = $total - ($start + $perpage);
  5060. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5061. echo json_encode($rows);
  5062. exit;
  5063. }
  5064. if (isset($post['s'])) {
  5065. $id_arr = $this->input->post('s');
  5066. $id_arr = explode(',', trim($id_arr, ','));
  5067. if (!$id_arr) {
  5068. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5069. exit;
  5070. }
  5071. //循环删除记录
  5072. foreach ($id_arr as $v) {
  5073. $dd = $this->whlabel->read($v);
  5074. if (!isset($dd['id'])) {
  5075. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5076. exit;
  5077. }
  5078. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5079. if (isset($zt[0])) {
  5080. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5081. exit;
  5082. }
  5083. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5084. foreach ($deldd as $vv) {
  5085. $this->whlabel->remove($vv['id']);
  5086. }
  5087. }
  5088. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5089. exit;
  5090. }
  5091. $this->_Template('whlabel_error', $this->data);
  5092. }
  5093. public function _errorexcel()
  5094. {
  5095. $post = $this->input->post(NULL, TRUE);
  5096. if (isset($_GET['page'])) {
  5097. $page = $this->input->get('page', true);
  5098. $perpage = $this->input->get('perpage', true);
  5099. $sku = $this->input->get('sku', true);
  5100. $warehouse = $this->input->get('warehouse', true);
  5101. $ktime = $this->input->get('ktime', true);
  5102. $jtime = $this->input->get('jtime', true);
  5103. $ktime = strtotime($ktime);
  5104. $jtime = strtotime($jtime);
  5105. $where = "sku != 'Preset'";
  5106. $gj = '';
  5107. if ($sku) {
  5108. $where .= " and sku like '%$sku%'";
  5109. } else {
  5110. if ($ktime && $jtime) {
  5111. $gj = " and time > '$ktime' and time < '$jtime'";
  5112. }
  5113. }
  5114. if ($warehouse) {
  5115. $where .= " and warehouse = '$warehouse'";
  5116. }
  5117. //数据排序
  5118. $order_str = "id desc";
  5119. if (empty($page)) {
  5120. $start = 0;
  5121. $perpage = 1;
  5122. } else {
  5123. $start = ($page - 1) * $perpage;
  5124. }
  5125. //取得信息列表
  5126. $rows = array();
  5127. $list = array();
  5128. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5129. foreach ($info_list as $value) {
  5130. $warehouse = $this->warehouse->read($value['warehouse']);
  5131. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5132. $number = $value['number'];
  5133. $ftime = time() - 15 * 24 * 3600;
  5134. if ($c < 1) {
  5135. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5136. }
  5137. }
  5138. $title = "0库存汇总";
  5139. $titlename = "<table border=1>
  5140. <tr align='center'>
  5141. <td>仓库</td>
  5142. <td>SKU</td>
  5143. <td>产品</td>
  5144. <td>当前库存</td>
  5145. </tr>
  5146. </table>";
  5147. $filename = $title . ".xls";
  5148. $tail = "";
  5149. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5150. }
  5151. }
  5152. /**
  5153. *
  5154. *
  5155. * 占单
  5156. *
  5157. *
  5158. **/
  5159. public function _kcyz()
  5160. {
  5161. $post = $this->input->post(NULL, TRUE);
  5162. if (isset($post['warehouse'])) {
  5163. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5164. exit; //不再使用
  5165. $warehouse = $this->input->post('warehouse', true);
  5166. $whlabel = $this->input->post('whlabel', true);
  5167. $id = $this->input->post('id', true);
  5168. $shop = $this->input->post('shop', true);
  5169. $number = $this->input->post('number', true);
  5170. if (!$whlabel || $whlabel == '|') {
  5171. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5172. exit;
  5173. }
  5174. $pp = explode('|', trim($whlabel, '|'));
  5175. $x = 0;
  5176. $save = array();
  5177. foreach ($pp as $va) {
  5178. $num = explode('-', $va);
  5179. if ($number) {
  5180. $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 = '')"); //通用
  5181. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5182. } else {
  5183. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5184. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5185. }
  5186. $x++;
  5187. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5188. $save[] = $x - 1;
  5189. continue; //提前先加X不然出错,所以要减1
  5190. }
  5191. }
  5192. if (isset($save[0])) {
  5193. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5194. exit;
  5195. } else {
  5196. echo json_encode(array('success' => true));
  5197. exit;
  5198. }
  5199. }
  5200. }
  5201. public function _db()
  5202. {
  5203. $post = $this->input->post(NULL, TRUE);
  5204. if (isset($post['page'])) {
  5205. $page = $this->input->post('page', true);
  5206. $perpage = $this->input->post('perpage', true);
  5207. $sku = $this->input->post('sku', true);
  5208. $number = $this->input->post('number', true);
  5209. $warehouse = $this->input->post('warehouse', true);
  5210. $purchase = $this->input->post('purchase', true);
  5211. $orderinfo = $this->input->post('orderinfo', true);
  5212. $waybill = $this->input->post('waybill', true);
  5213. $category = $this->input->post('category', true);
  5214. $size = $this->input->post('size', true);
  5215. $grade = $this->input->post('grade', true);
  5216. $color = $this->input->post('color', true);
  5217. $lowe = $this->input->post('lowe', true);
  5218. $state = $this->input->post('state', true);
  5219. $label = $this->input->post('label', true);
  5220. $timetk = $this->input->post('timetkk', true);
  5221. $timetj = $this->input->post('timetjj', true);
  5222. $timetk = strtotime($timetk);
  5223. $timetj = strtotime($timetj);
  5224. $where = "dbtime > 0";
  5225. if ($timetk && $timetj) {
  5226. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5227. }
  5228. if ($sku) {
  5229. $where .= " and sku = '$sku'";
  5230. }
  5231. if ($warehouse) {
  5232. $where .= " and warehouse = '$warehouse'";
  5233. if ($warehouse == 12) {
  5234. $w = 'specialstock';
  5235. } else {
  5236. $w = 'whlabel';
  5237. }
  5238. }
  5239. if ($purchase) {
  5240. $where .= " and purchase = '$purchase'";
  5241. }
  5242. if ($category) {
  5243. $where .= " and features like '%-$category-%'";
  5244. }
  5245. if ($size) {
  5246. $where .= " and features like '%-$size-%'";
  5247. }
  5248. if ($grade) {
  5249. $where .= " and features like '%-$grade-%'";
  5250. }
  5251. if ($color) {
  5252. $where .= " and features like '%-$color-%'";
  5253. }
  5254. if ($lowe) {
  5255. $where .= " and features like '%-$lowe-%'";
  5256. }
  5257. if ($state != '') {
  5258. $where .= " and state = '$state'";
  5259. }
  5260. //数据排序
  5261. $order_str = "dbtime desc";
  5262. if (empty($page)) {
  5263. $start = 0;
  5264. $perpage = 1;
  5265. } else {
  5266. $start = ($page - 1) * $perpage;
  5267. }
  5268. //取得信息列表
  5269. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5270. foreach ($info_list as $key => $value) {
  5271. $warehouse = $this->$w->read($value['warehouse']);
  5272. $info_list[$key]['warehouse'] = $warehouse['title'];
  5273. $purchase = $this->purchase->read($value['purchase']);
  5274. $info_list[$key]['purchase'] = $purchase['title'];
  5275. if ($value['enter'] != 0) {
  5276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5277. } else {
  5278. $info_list[$key]['enter'] = "";
  5279. }
  5280. if ($value['dbtime'] != 0) {
  5281. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5282. } else {
  5283. $info_list[$key]['dbtime'] = "";
  5284. }
  5285. if ($value['state'] == 0) {
  5286. $info_list[$key]['state'] = "在库";
  5287. } else if ($value['state'] == 1) {
  5288. $info_list[$key]['state'] = "出库";
  5289. } else if ($value['state'] == 2) {
  5290. $info_list[$key]['state'] = "退库";
  5291. } else if ($value['state'] == 3) {
  5292. $info_list[$key]['state'] = "调拨中";
  5293. } else if ($value['state'] == 4) {
  5294. $info_list[$key]['state'] = "再加工";
  5295. } else if ($value['state'] == 5) {
  5296. $info_list[$key]['state'] = "维修中";
  5297. } else if ($value['state'] == 6) {
  5298. $info_list[$key]['state'] = "盘亏";
  5299. } else if ($value['state'] == 7) {
  5300. $info_list[$key]['state'] = "更换标签";
  5301. } else if ($value['state'] == 8) {
  5302. $info_list[$key]['state'] = "其它";
  5303. } else if ($value['state'] == 9) {
  5304. $info_list[$key]['state'] = "预设";
  5305. }
  5306. }
  5307. $total = $this->whlabel->find_count($where);
  5308. $pagenum = ceil($total / $perpage);
  5309. $over = $total - ($start + $perpage);
  5310. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5311. echo json_encode($rows);
  5312. exit;
  5313. }
  5314. if (isset($post['outsku'])) {
  5315. $time = time();
  5316. $cz = $this->input->post('cz', true);
  5317. $label = $this->input->post('outsku', true);
  5318. $sl = $this->input->post('sl', true);
  5319. $num = $this->input->post('num', true);
  5320. //$warehouse = $this->input->post('warehouse',true);
  5321. if (!$sl) {
  5322. $sl = 1;
  5323. }
  5324. if (!$warehouse) {
  5325. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5326. exit;
  5327. }
  5328. $dblabel = $this->whlabellabel->get_label($label);
  5329. if ($dblabel) {
  5330. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5331. if (count($data) < 1) {
  5332. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5333. exit;
  5334. }
  5335. if (count($data) < $num) {
  5336. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5337. exit;
  5338. }
  5339. for ($i = 0; $i < $sl; $i++) {
  5340. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5341. }
  5342. echo json_encode(array('success' => true));
  5343. exit;
  5344. } else {
  5345. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5346. exit;
  5347. }
  5348. }
  5349. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5350. $this->_Template('whlabel_db', $this->data);
  5351. }
  5352. public function _dbrk()
  5353. {
  5354. $post = $this->input->post(NULL, TRUE);
  5355. if (isset($post['page'])) {
  5356. $page = $this->input->post('page', true);
  5357. $perpage = $this->input->post('perpage', true);
  5358. $sku = $this->input->post('sku', true);
  5359. $number = $this->input->post('number', true);
  5360. $warehouse = $this->input->post('warehouse', true);
  5361. $purchase = $this->input->post('purchase', true);
  5362. $orderinfo = $this->input->post('orderinfo', true);
  5363. $waybill = $this->input->post('waybill', true);
  5364. $category = $this->input->post('category', true);
  5365. $size = $this->input->post('size', true);
  5366. $grade = $this->input->post('grade', true);
  5367. $color = $this->input->post('color', true);
  5368. $lowe = $this->input->post('lowe', true);
  5369. $state = $this->input->post('state', true);
  5370. $label = $this->input->post('label', true);
  5371. $ctime = $this->input->post('ctime', true);
  5372. $timetk = $this->input->post('timetkk', true);
  5373. $timetj = $this->input->post('timetjj', true);
  5374. $timetk = strtotime($timetk);
  5375. $timetj = strtotime($timetj);
  5376. $where = "dbtime > 0";
  5377. if ($timetk && $timetj) {
  5378. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5379. }
  5380. if ($sku) {
  5381. $where .= " and sku = '$sku'";
  5382. }
  5383. if ($warehouse) {
  5384. $where .= " and warehouse = '$warehouse'";
  5385. }
  5386. if ($purchase) {
  5387. $where .= " and purchase = '$purchase'";
  5388. }
  5389. if ($category) {
  5390. $where .= " and features like '%-$category-%'";
  5391. }
  5392. if ($size) {
  5393. $where .= " and features like '%-$size-%'";
  5394. }
  5395. if ($grade) {
  5396. $where .= " and features like '%-$grade-%'";
  5397. }
  5398. if ($color) {
  5399. $where .= " and features like '%-$color-%'";
  5400. }
  5401. if ($lowe) {
  5402. $where .= " and features like '%-$lowe-%'";
  5403. }
  5404. if ($state != '') {
  5405. $where .= " and state = '$state'";
  5406. }
  5407. //数据排序
  5408. $order_str = "dbtime desc";
  5409. if (empty($page)) {
  5410. $start = 0;
  5411. $perpage = 1;
  5412. } else {
  5413. $start = ($page - 1) * $perpage;
  5414. }
  5415. //取得信息列表
  5416. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5417. foreach ($info_list as $key => $value) {
  5418. $warehouse = $this->warehouse->read($value['warehouse']);
  5419. $info_list[$key]['warehouse'] = $warehouse['title'];
  5420. $purchase = $this->purchase->read($value['purchase']);
  5421. $info_list[$key]['purchase'] = $purchase['title'];
  5422. if ($value['enter'] != 0) {
  5423. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5424. } else {
  5425. $info_list[$key]['enter'] = "";
  5426. }
  5427. if ($value['dbtime'] != 0) {
  5428. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5429. } else {
  5430. $info_list[$key]['dbtime'] = "";
  5431. }
  5432. if ($value['state'] == 0) {
  5433. $info_list[$key]['state'] = "在库";
  5434. } else if ($value['state'] == 1) {
  5435. $info_list[$key]['state'] = "出库";
  5436. } else if ($value['state'] == 2) {
  5437. $info_list[$key]['state'] = "退库";
  5438. } else if ($value['state'] == 3) {
  5439. $info_list[$key]['state'] = "调拨中";
  5440. } else if ($value['state'] == 4) {
  5441. $info_list[$key]['state'] = "再加工";
  5442. } else if ($value['state'] == 5) {
  5443. $info_list[$key]['state'] = "维修中";
  5444. } else if ($value['state'] == 6) {
  5445. $info_list[$key]['state'] = "盘亏";
  5446. } else if ($value['state'] == 7) {
  5447. $info_list[$key]['state'] = "更换标签";
  5448. } else if ($value['state'] == 8) {
  5449. $info_list[$key]['state'] = "其它";
  5450. } else if ($value['state'] == 9) {
  5451. $info_list[$key]['state'] = "预设";
  5452. }
  5453. }
  5454. $total = $this->whlabel->find_count($where);
  5455. $pagenum = ceil($total / $perpage);
  5456. $over = $total - ($start + $perpage);
  5457. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5458. echo json_encode($rows);
  5459. exit;
  5460. }
  5461. if (isset($post['rsku'])) {
  5462. $cz = $this->input->post('cz', true);
  5463. $label = $this->input->post('rsku', true);
  5464. $sl = $this->input->post('sl', true);
  5465. $warehouse = $this->input->post('warehouse', true);
  5466. if (!$sl) {
  5467. $sl = 1;
  5468. }
  5469. if (!$warehouse) {
  5470. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5471. exit;
  5472. }
  5473. $dblabel = $this->whlabellabel->get_label($label);
  5474. if ($dblabel) {
  5475. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5476. if (count($data) < 1) {
  5477. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5478. exit;
  5479. }
  5480. if ($sl > count($data)) {
  5481. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5482. exit;
  5483. }
  5484. $time = time();
  5485. for ($i = 0; $i < $sl; $i++) {
  5486. $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']);
  5487. }
  5488. echo json_encode(array('success' => true));
  5489. exit;
  5490. } else {
  5491. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5492. exit;
  5493. }
  5494. }
  5495. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5496. $this->_Template('whlabel_dbrk', $this->data);
  5497. }
  5498. public function _whlabelczdc()
  5499. {
  5500. if (isset($_GET['excel'])) {
  5501. //数据排序
  5502. $order_str = "id desc";
  5503. if (empty($page)) {
  5504. $start = 0;
  5505. $perpage = 1;
  5506. } else {
  5507. $start = ($page - 1) * $perpage;
  5508. }
  5509. $state = $this->input->get('state', true);
  5510. $sku = $this->input->get('sku', true);
  5511. $ctime = $this->input->get('ctime', true);
  5512. $category = $this->input->get('category', true);
  5513. $size = $this->input->get('size', true);
  5514. $grade = $this->input->get('grade', true);
  5515. $color = $this->input->get('color', true);
  5516. $lowe = $this->input->get('lowe', true);
  5517. $timetk = $this->input->get('timetkk', true);
  5518. $timetj = $this->input->get('timetjj', true);
  5519. $timetk = strtotime($timetk);
  5520. $timetj = strtotime($timetj);
  5521. $where = "dbtime > 0";
  5522. if ($timetk && $timetj) {
  5523. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5524. }
  5525. if ($category) {
  5526. $where .= " and features like '%-$category-%'";
  5527. }
  5528. if ($size) {
  5529. $where .= " and features like '%-$size-%'";
  5530. }
  5531. if ($grade) {
  5532. $where .= " and features like '%-$grade-%'";
  5533. }
  5534. if ($color) {
  5535. $where .= " and features like '%-$color-%'";
  5536. }
  5537. if ($lowe) {
  5538. $where .= " and features like '%-$lowe-%'";
  5539. }
  5540. //取得信息列表
  5541. $info_list = $this->whlabel->find_all($where, '*');
  5542. $rows = array();
  5543. $list = array();
  5544. foreach ($info_list as $key => $value) {
  5545. $rows[$value['sku']] = $value; //所有数据sku
  5546. }
  5547. foreach ($rows as $value) {
  5548. $warehouse = $this->warehouse->read($value['warehouse']);
  5549. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5550. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5551. if ($value['orderinfo'] == 0) {
  5552. $info_list[$key]['orderinfo'] = "";
  5553. }
  5554. if ($value['waybill'] == 0) {
  5555. $info_list[$key]['waybill'] = "";
  5556. }
  5557. if ($value['state'] == 0) {
  5558. $value['state'] = "在库";
  5559. } else if ($value['state'] == 3) {
  5560. $value['state'] = "调拨中";
  5561. }
  5562. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5563. }
  5564. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5565. $titlename = "<table border=1>
  5566. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5567. <tr align='center'>
  5568. <td>SKU</td>
  5569. <td>产品</td>
  5570. <td>调拨数量</td>
  5571. <td>入库数量</td>
  5572. </tr>
  5573. </table>";
  5574. $filename = $title . ".xls";
  5575. $tail = "";
  5576. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5577. }
  5578. }
  5579. public function _print($arg_array)
  5580. {
  5581. if (isset($_SESSION['api'])) {
  5582. $user = $this->user->get_api($_SESSION['api']);
  5583. $usp = $user;
  5584. $fgshop = "";
  5585. $sid = "";
  5586. $wid = "";
  5587. $wtype = "";
  5588. $usersp = explode('|', trim($user['shop'], '|'));
  5589. $userwh = explode('|', trim($user['warehouse'], '|'));
  5590. foreach ($usersp as $value) {
  5591. $fgshop .= " shop = " . $value . " or";
  5592. $sid .= " id = " . $value . " or";
  5593. }
  5594. foreach ($userwh as $value) {
  5595. $wid .= " id = " . $value . " or";
  5596. $wtype .= " type = " . $value . " or";
  5597. }
  5598. }
  5599. $post = $this->input->post(NULL, TRUE);
  5600. if (isset($post['tmsku'])) {
  5601. $tmsku = $this->input->post('tmsku', true);
  5602. if (is_numeric($tmsku)) {
  5603. $yyh = $this->whlabellabel->get_label($tmsku);
  5604. } else {
  5605. $yyh = $this->whlabellabel->get_sku($tmsku);
  5606. if(empty($yyh)){
  5607. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5608. if($r['code'] == -1 ){
  5609. echo json_encode(array('success' => false));
  5610. exit;
  5611. }else{
  5612. echo json_encode(array('features' => $r['data'], 'success' => true));
  5613. exit;
  5614. }
  5615. }
  5616. }
  5617. if ($yyh) {
  5618. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5619. exit;
  5620. } else {
  5621. echo json_encode(array('success' => false));
  5622. exit;
  5623. }
  5624. }
  5625. $classid = $this->classid->sku();
  5626. $pm = $classid;
  5627. $scsku = $classid;
  5628. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5629. if (isset($post['warehouse'])) {
  5630. if ($post['warehouse']) {
  5631. $list = array();
  5632. $num = "";
  5633. $title = "";
  5634. $features = "";
  5635. $order = 0;
  5636. $post['shop'] = '';
  5637. $brand = $this->input->post('brand', true);
  5638. if ($brand != '0,') {
  5639. $b = $this->brand->read(rtrim($brand, ','));
  5640. if ($b) {
  5641. $post['shop'] = str_replace('|', ',', $b['shop']);
  5642. }
  5643. }
  5644. $post['details'] = $this->input->post('details', true); //打印数量
  5645. $xbqnum = $this->input->post('xbqnum', true);
  5646. $post['purchase'] = $this->input->post('purchase', true);
  5647. $post['warehouse'] = $this->input->post('warehouse', true);
  5648. $post['purchase'] = $this->input->post('purchase', true);
  5649. $post['retreatwarehouse'] = $post['warehouse'];
  5650. $post['cpbz'] = $this->input->post('cpbz', true);
  5651. $post['state'] = 9;
  5652. $category = $this->input->post('category', true);
  5653. $list['category'] = $category;
  5654. $list['hairtype'] = $this->input->post('hairtype', true);
  5655. $list['grade'] = $this->input->post('grade', true);
  5656. $size = $this->input->post('size', true);
  5657. $list['size'] = rtrim($size, ',');
  5658. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5659. $list['extension'] = $this->input->post('extension', true);
  5660. if ($category == 1297) {
  5661. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5662. }
  5663. if ($category == 1702) {
  5664. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5665. $list['syother'] = $this->input->post('syother', true);
  5666. }
  5667. if ($category == 133) {
  5668. $list['fittype'] = $this->input->post('fittype', true);
  5669. $list['acother'] = $this->input->post('acother', true);
  5670. }
  5671. $list['color'] = $this->input->post('color', true);
  5672. $list['lowe'] = $this->input->post('lowe', true);
  5673. if ($category == 127) {
  5674. $list['type'] = $this->input->post('type', true);
  5675. $list['headroad'] = $this->input->post('headroad', true);
  5676. $list['density'] = $this->input->post('density', true);
  5677. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5678. $list['lacesize'] = $this->input->post('lacesize', true);
  5679. }
  5680. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5681. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5682. }
  5683. if ($category == 128) {
  5684. $list['lacetype'] = $this->input->post('lacetype', true);
  5685. $list['haircap'] = $this->input->post('haircap', true);
  5686. $list['density'] = $this->input->post('density', true);
  5687. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5688. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5689. $list['wigother'] = $this->input->post('wigother', true);
  5690. $list['wigother1'] = $this->input->post('wigother1', true);
  5691. $list['wigother2'] = $this->input->post('wigother2', true);
  5692. }
  5693. if ($category == 129) {
  5694. $list['wide'] = $this->input->post('wide', true);
  5695. }
  5696. if ($category == 131) {
  5697. $list['gifttype'] = $this->input->post('gifttype', true);
  5698. $list['giftother'] = $this->input->post('giftother', true);
  5699. }
  5700. if ($category == 134) {
  5701. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5702. }
  5703. if ($category == 1297) {
  5704. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5705. $list['sywigother'] = $this->input->post('sywigother', true);
  5706. }
  5707. if ($category == 130 || $category == 133 || $category == 1702) {
  5708. $list['items'] = $this->input->post('items', true);
  5709. $list['weight'] = $this->input->post('weight', true);
  5710. }
  5711. if ($category == 1702) {
  5712. $list['syhairther'] = $this->input->post('syhairther', true);
  5713. }
  5714. if($category == 130){
  5715. $list['jfother'] = $this->input->post('jfother', true);
  5716. }
  5717. foreach ($list as $k => $v) {
  5718. if ($v != 0) {
  5719. $num .= $v;
  5720. $features .= $v . '-';
  5721. $post[$k] = $v;
  5722. $typeclass = $this->typeclass->read($v);
  5723. if (isset($pm[$typeclass['classid']])) {
  5724. if (stripos($typeclass['zh'], '|') !== false) {
  5725. $exzh = explode('|', $typeclass['zh']);
  5726. $pm[$typeclass['classid']] = $exzh[0];
  5727. } else {
  5728. $pm[$typeclass['classid']] = $typeclass['zh'];
  5729. }
  5730. }
  5731. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5732. if ($k != 'size') {
  5733. $title .= $typeclass['title'] . " ";
  5734. }
  5735. }
  5736. }
  5737. $typeclass = $this->typeclass->read($list['size']);
  5738. $title .= $typeclass['title'];
  5739. $time = time();
  5740. $post['title'] = rtrim($title, ' ');
  5741. $post['number'] = $num;
  5742. $post['features'] = '-' . $features;
  5743. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5744. $featurespp = explode('-', trim($featurespp, '-'));
  5745. if (isset($featurespp[5])) {
  5746. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5747. } else {
  5748. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5749. }
  5750. $post['enter'] = $time;
  5751. $post['time'] = $time; //操作时间
  5752. $scsku = implode("-", $scsku);
  5753. $zh = implode(" ", $pm);
  5754. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5755. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5756. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5757. $post['sku'] = $bqsku;
  5758. $label = time() . rand(0, 9);
  5759. $post['label'] = $label;
  5760. $cpid = $this->whlabellabel->find_count();
  5761. $post['cpid'] = $cpid + 1;
  5762. $cpid = $post['cpid'];
  5763. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5764. //if($whlabelbarcode)
  5765. //{
  5766. //$post['label'] = $whlabelbarcode['label'];
  5767. //if(!$this->whlabellabel->insert($post))
  5768. //{
  5769. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5770. //}
  5771. //}
  5772. //else
  5773. //{
  5774. $this->db->trans_begin();
  5775. $this->whlabellabel->insert($post);
  5776. //$this->whlabelbarcode->insert($post);
  5777. if ($this->db->trans_status() === TRUE) {
  5778. $this->db->trans_commit();
  5779. } else {
  5780. $this->db->trans_rollback();
  5781. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5782. exit;
  5783. }
  5784. //}
  5785. $warehouse_name = "";
  5786. $warehouse = $post['warehouse'];
  5787. if($warehouse == 12){
  5788. $warehouse_name = "特殊库存库";
  5789. }
  5790. // if($warehouse == 13){
  5791. // $warehouse_name = "许昌仓";
  5792. // }
  5793. // if($warehouse == 5){
  5794. // $warehouse_name = "美国店";
  5795. // }
  5796. // if($warehouse == 16){
  5797. // $warehouse_name = "定制头套仓";
  5798. // }
  5799. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5800. if(!empty($warehouse_name)){
  5801. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5802. }
  5803. $purchase = $this->purchase->read($post['purchase']);
  5804. 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));
  5805. exit; //特殊仓目前不需要仓库选项
  5806. }
  5807. }
  5808. if (isset($_SESSION['api'])) {
  5809. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5810. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5811. $this->data['wlshop'] = $wlshop;
  5812. $this->data['warehouse'] = $warehouse;
  5813. }
  5814. $whlabelwz = $this->whlabelwz->find_all();
  5815. $this->data['whlabelwz'] = $whlabelwz;
  5816. $this->_Template('whlabel_print', $this->data);
  5817. }
  5818. public function _usaprint($arg_array)
  5819. {
  5820. if (isset($_SESSION['api'])) {
  5821. $user = $this->user->get_api($_SESSION['api']);
  5822. $usp = $user;
  5823. $fgshop = "";
  5824. $sid = "";
  5825. $wid = "";
  5826. $wtype = "";
  5827. $usersp = explode('|', trim($user['shop'], '|'));
  5828. $userwh = explode('|', trim($user['warehouse'], '|'));
  5829. foreach ($usersp as $value) {
  5830. $fgshop .= " shop = " . $value . " or";
  5831. $sid .= " id = " . $value . " or";
  5832. }
  5833. foreach ($userwh as $value) {
  5834. $wid .= " id = " . $value . " or";
  5835. $wtype .= " type = " . $value . " or";
  5836. }
  5837. }
  5838. $post = $this->input->post(NULL, TRUE);
  5839. if (isset($post['tmsku'])) {
  5840. $tmsku = $this->input->post('tmsku', true);
  5841. if (is_numeric($tmsku)) {
  5842. $yyh = $this->whlabellabel->get_label($tmsku);
  5843. } else {
  5844. $yyh = $this->whlabellabel->get_sku($tmsku);
  5845. }
  5846. if ($yyh) {
  5847. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5848. exit;
  5849. } else {
  5850. echo json_encode(array('success' => false));
  5851. exit;
  5852. }
  5853. }
  5854. $classid = $this->classid->sku();
  5855. $pm = $classid;
  5856. $scsku = $classid;
  5857. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5858. if (isset($post['warehouse'])) {
  5859. if ($post['warehouse']) {
  5860. $list = array();
  5861. $num = "";
  5862. $title = "";
  5863. $features = "";
  5864. $order = 0;
  5865. $post['shop'] = '';
  5866. $brand = $this->input->post('brand', true);
  5867. if ($brand != '0,') {
  5868. $b = $this->brand->read(rtrim($brand, ','));
  5869. if ($b) {
  5870. $post['shop'] = str_replace('|', ',', $b['shop']);
  5871. }
  5872. }
  5873. $post['details'] = $this->input->post('details', true); //打印数量
  5874. $xbqnum = $this->input->post('xbqnum', true);
  5875. $post['purchase'] = $this->input->post('purchase', true);
  5876. $post['warehouse'] = $this->input->post('warehouse', true);
  5877. $post['purchase'] = $this->input->post('purchase', true);
  5878. $post['retreatwarehouse'] = $post['warehouse'];
  5879. $post['cpbz'] = $this->input->post('cpbz', true);
  5880. $post['state'] = 9;
  5881. $category = $this->input->post('category', true);
  5882. $list['category'] = $category;
  5883. $list['hairtype'] = $this->input->post('hairtype', true);
  5884. $list['grade'] = $this->input->post('grade', true);
  5885. $size = $this->input->post('size', true);
  5886. $list['size'] = rtrim($size, ',');
  5887. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5888. $list['extension'] = $this->input->post('extension', true);
  5889. if ($category == 1297) {
  5890. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5891. }
  5892. if ($category == 1702) {
  5893. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5894. $list['syother'] = $this->input->post('syother', true);
  5895. }
  5896. if ($category == 133) {
  5897. $list['fittype'] = $this->input->post('fittype', true);
  5898. $list['acother'] = $this->input->post('acother', true);
  5899. }
  5900. $list['color'] = $this->input->post('color', true);
  5901. $list['lowe'] = $this->input->post('lowe', true);
  5902. if ($category == 127) {
  5903. $list['type'] = $this->input->post('type', true);
  5904. $list['headroad'] = $this->input->post('headroad', true);
  5905. $list['density'] = $this->input->post('density', true);
  5906. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5907. $list['lacesize'] = $this->input->post('lacesize', true);
  5908. }
  5909. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5910. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5911. }
  5912. if ($category == 128) {
  5913. $list['lacetype'] = $this->input->post('lacetype', true);
  5914. $list['haircap'] = $this->input->post('haircap', true);
  5915. $list['density'] = $this->input->post('density', true);
  5916. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5917. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5918. $list['wigother'] = $this->input->post('wigother', true);
  5919. $list['wigother1'] = $this->input->post('wigother1', true);
  5920. $list['wigother2'] = $this->input->post('wigother2', true);
  5921. }
  5922. if ($category == 129) {
  5923. $list['wide'] = $this->input->post('wide', true);
  5924. }
  5925. if ($category == 131) {
  5926. $list['gifttype'] = $this->input->post('gifttype', true);
  5927. $list['giftother'] = $this->input->post('giftother', true);
  5928. }
  5929. if ($category == 134) {
  5930. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5931. }
  5932. if ($category == 1297) {
  5933. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5934. $list['sywigother'] = $this->input->post('sywigother', true);
  5935. }
  5936. if ($category == 130 || $category == 133 || $category == 1702) {
  5937. $list['items'] = $this->input->post('items', true);
  5938. $list['weight'] = $this->input->post('weight', true);
  5939. }
  5940. if ($category == 1702) {
  5941. $list['syhairther'] = $this->input->post('syhairther', true);
  5942. }
  5943. foreach ($list as $k => $v) {
  5944. if ($v != 0) {
  5945. $num .= $v;
  5946. $features .= $v . '-';
  5947. $post[$k] = $v;
  5948. $typeclass = $this->typeclass->read($v);
  5949. if (isset($pm[$typeclass['classid']])) {
  5950. if (stripos($typeclass['zh'], '|') !== false) {
  5951. $exzh = explode('|', $typeclass['zh']);
  5952. $pm[$typeclass['classid']] = $exzh[0];
  5953. } else {
  5954. $pm[$typeclass['classid']] = $typeclass['zh'];
  5955. }
  5956. }
  5957. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5958. if ($k != 'size') {
  5959. $title .= $typeclass['title'] . " ";
  5960. }
  5961. }
  5962. }
  5963. $typeclass = $this->typeclass->read($list['size']);
  5964. $title .= $typeclass['title'];
  5965. $time = time();
  5966. $post['title'] = rtrim($title, ' ');
  5967. $post['number'] = $num;
  5968. $post['features'] = '-' . $features;
  5969. $fp = $this->whlabel->get_features($post['features']);
  5970. if (!$fp) {
  5971. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5972. exit;
  5973. }
  5974. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5975. $featurespp = explode('-', trim($featurespp, '-'));
  5976. if (isset($featurespp[5])) {
  5977. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5978. } else {
  5979. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5980. }
  5981. $post['enter'] = $time;
  5982. $post['time'] = $time; //操作时间
  5983. $scsku = implode("-", $scsku);
  5984. $zh = implode(" ", $pm);
  5985. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5986. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5987. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5988. $post['sku'] = $fp['sku'];
  5989. $post['label'] = $fp['sku'];
  5990. $cpid = $this->whlabellabel->find_count();
  5991. $post['cpid'] = $cpid + 1;
  5992. $cpid = $post['cpid'];
  5993. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5994. //if($whlabelbarcode)
  5995. //{
  5996. //$post['label'] = $whlabelbarcode['label'];
  5997. //if(!$this->whlabellabel->insert($post))
  5998. //{
  5999. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6000. //}
  6001. //}
  6002. //else
  6003. //{
  6004. $this->db->trans_begin();
  6005. $this->whlabellabel->insert($post);
  6006. //$this->whlabelbarcode->insert($post);
  6007. if ($this->db->trans_status() === TRUE) {
  6008. $this->db->trans_commit();
  6009. } else {
  6010. $this->db->trans_rollback();
  6011. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6012. exit;
  6013. }
  6014. //}
  6015. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6016. $purchase = $this->purchase->read($post['purchase']);
  6017. 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));
  6018. exit; //特殊仓目前不需要仓库选项
  6019. }
  6020. }
  6021. if (isset($_SESSION['api'])) {
  6022. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6023. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6024. $this->data['wlshop'] = $wlshop;
  6025. $this->data['warehouse'] = $warehouse;
  6026. }
  6027. $whlabelwz = $this->whlabelwz->find_all();
  6028. $this->data['whlabelwz'] = $whlabelwz;
  6029. $this->_Template('whlabel_usaprint', $this->data);
  6030. }
  6031. public function _printrk($arg_array)
  6032. {
  6033. $prc = array();
  6034. $purchase = $this->purchase->find_all();
  6035. foreach ($purchase as $k => $v) {
  6036. $prc[$v['id']] = $v['title'];
  6037. }
  6038. $post = $this->input->post(NULL, TRUE);
  6039. if (isset($post['page'])) {
  6040. $page = $this->input->post('page', true);
  6041. $perpage = $this->input->post('perpage', true);
  6042. $sku = $this->input->post('sku', true);
  6043. $bs = $this->input->post('bs', true);
  6044. $number = $this->input->post('number', true);
  6045. $warehouse = $this->input->post('warehouse', true);
  6046. $purchase = $this->input->post('purchase', true);
  6047. $orderinfo = $this->input->post('orderinfo', true);
  6048. $waybill = $this->input->post('waybill', true);
  6049. $category = $this->input->post('category', true);
  6050. $size = $this->input->post('size', true);
  6051. $grade = $this->input->post('grade', true);
  6052. $color = $this->input->post('color', true);
  6053. $lowe = $this->input->post('lowe', true);
  6054. $state = $this->input->post('state', true);
  6055. $label = $this->input->post('label', true);
  6056. $timetk = $this->input->post('ktime', true);
  6057. $timetj = $this->input->post('jtime', true);
  6058. $timetk = strtotime($timetk);
  6059. $timetj = strtotime($timetj);
  6060. $where = "1=1 ";
  6061. if ($timetk && $timetj) {
  6062. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6063. }
  6064. if ($sku) {
  6065. $where .= " and sku = '$sku'";
  6066. }
  6067. if ($bs != '') {
  6068. $where .= " and bs = '$bs'";
  6069. }
  6070. if ($number) {
  6071. $where .= " and number = '$number'";
  6072. }
  6073. if ($warehouse) {
  6074. $where .= " and warehouse = '$warehouse'";
  6075. }
  6076. if ($purchase) {
  6077. $where .= " and purchase = '$purchase'";
  6078. }
  6079. if ($orderinfo) {
  6080. $where .= " and orderinfo = '$orderinfo'";
  6081. }
  6082. if ($waybill) {
  6083. $where .= " and waybill = '$waybill'";
  6084. }
  6085. if ($category) {
  6086. $where .= " and features like '%-$category-%'";
  6087. }
  6088. if ($size) {
  6089. $where .= " and features like '%-$size-%'";
  6090. }
  6091. if ($grade) {
  6092. $where .= " and features like '%-$grade-%'";
  6093. }
  6094. if ($color) {
  6095. $where .= " and features like '%-$color-%'";
  6096. }
  6097. if ($lowe) {
  6098. $where .= " and features like '%-$lowe-%'";
  6099. }
  6100. if ($label) {
  6101. $where .= " and label = '$label'";
  6102. }
  6103. if ($state || $state == 0) {
  6104. $where .= " and state = '$state'";
  6105. }
  6106. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6107. //数据排序
  6108. $order_str = "enter desc";
  6109. if (empty($page)) {
  6110. $start = 0;
  6111. $perpage = 1;
  6112. } else {
  6113. $start = ($page - 1) * $perpage;
  6114. }
  6115. //取得信息列表
  6116. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6117. foreach ($info_list as $key => $value) {
  6118. $warehouse = $this->warehouse->read($value['warehouse']);
  6119. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6120. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6121. if ($value['state'] == 0) {
  6122. $info_list[$key]['state'] = "在库";
  6123. } else if ($value['state'] == 1) {
  6124. $info_list[$key]['state'] = "出库";
  6125. } else if ($value['state'] == 2) {
  6126. $info_list[$key]['state'] = "退库";
  6127. } else if ($value['state'] == 3) {
  6128. $info_list[$key]['state'] = "调拨中";
  6129. } else if ($value['state'] == 4) {
  6130. $info_list[$key]['state'] = "再加工";
  6131. } else if ($value['state'] == 5) {
  6132. $info_list[$key]['state'] = "维修中";
  6133. } else if ($value['state'] == 6) {
  6134. $info_list[$key]['state'] = "盘亏";
  6135. } else if ($value['state'] == 7) {
  6136. $info_list[$key]['state'] = "更换标签";
  6137. } else if ($value['state'] == 8) {
  6138. $info_list[$key]['state'] = "其它";
  6139. } else if ($value['state'] == 9) {
  6140. $info_list[$key]['state'] = "预设";
  6141. } else if ($value['state'] == 10) {
  6142. $info_list[$key]['state'] = "美店零售";
  6143. }
  6144. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6145. }
  6146. $total = $this->$ck->find_count($where);
  6147. $pagenum = ceil($total / $perpage);
  6148. $over = $total - ($start + $perpage);
  6149. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6150. echo json_encode($rows);
  6151. exit;
  6152. }
  6153. if (isset($post['tmsku'])) {
  6154. $time = time();
  6155. $tmsku = $this->input->post('tmsku', true);
  6156. //$post['shop'] = $this->input->post('shop',true);
  6157. $num = $this->input->post('num', true);
  6158. $rktype = $this->input->post('rktype', true);
  6159. if ($num > 200) {
  6160. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6161. exit;
  6162. }
  6163. if (!$rktype) {
  6164. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6165. }
  6166. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6167. /**
  6168. $wz = array();
  6169. foreach ($rk as $key=>$value)
  6170. {
  6171. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6172. }
  6173. if(count($wz) > 1)
  6174. {
  6175. $wz = array_values($wz);
  6176. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6177. }
  6178. **/
  6179. if (isset($rk[0]['purchase'])) {
  6180. $rk = $rk[0];
  6181. $j = 0;
  6182. $post['purchase'] = $rk['purchase'];
  6183. $post['warehouse'] = $rk['warehouse'];
  6184. $post['retreatwarehouse'] = $rk['warehouse'];
  6185. $post['sku'] = $rk['sku'];
  6186. $post['number'] = $rk['number'];
  6187. $post['features'] = $rk['features'];
  6188. $post['title'] = $rk['title'];
  6189. $post['enter'] = $time;
  6190. $post['time'] = $time;
  6191. $post['bs'] = 1;
  6192. $post['shop'] = $rk['shop'];
  6193. $post['details'] = $rk['details'];
  6194. $post['cpid'] = $rk['cpid'];
  6195. $post['cpbz'] = $rk['cpbz'];
  6196. $post['rktype'] = $rktype;
  6197. $warehouse = $this->warehouse->read($rk['warehouse']);
  6198. if ($warehouse['bdck'] == '') {
  6199. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6200. exit;
  6201. } else {
  6202. $bdck = $warehouse['bdck'];
  6203. }
  6204. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6205. if (isset($pdwz['details'])) {
  6206. if ($pdwz['details'] != $post['details']) {
  6207. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6208. }else{
  6209. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6210. exit;
  6211. }
  6212. }
  6213. }
  6214. $post['featurespp'] = $rk['featurespp'];
  6215. if ($post['warehouse'] == '5') {
  6216. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6217. if ($yza) {
  6218. if ($post['features'] != $yza[0]['features']) {
  6219. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6220. exit;
  6221. }
  6222. }
  6223. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6224. if ($yzb) {
  6225. if ($post['sku'] != $yzb[0]['sku']) {
  6226. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6227. exit;
  6228. }
  6229. }
  6230. }
  6231. for ($i = 0; $i < $num; $i++) {
  6232. $post['label'] = time() . rand(100, 999) . $i;
  6233. if ($this->$bdck->insert($post)) {
  6234. $j++;
  6235. }
  6236. }
  6237. /**
  6238. if($post['warehouse'] != 12)
  6239. {
  6240. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6241. }
  6242. **/
  6243. $this->whlabelscanlog->insert([
  6244. 'shop'=>$rk['shop'],
  6245. 'type'=>1,
  6246. 'purchase'=>$rk['purchase'],
  6247. 'sku'=>$rk['sku'],
  6248. 'features'=>$rk['features'],
  6249. 'title'=>$rk['title'],
  6250. 'label'=>$rk['label'],
  6251. 'warehouse'=>$rk['warehouse'],
  6252. 'wlid'=>$rk['id'],
  6253. 'num'=>$num,
  6254. 'addtime'=>time()
  6255. ]);
  6256. if ($j == $num) {
  6257. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6258. exit;
  6259. } else {
  6260. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6261. exit;
  6262. }
  6263. } else {
  6264. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6265. exit;
  6266. }
  6267. }
  6268. $this->_Template('whlabel_printrk', $this->data);
  6269. }
  6270. public function _printxzrk($arg_array)
  6271. {
  6272. $post = $this->input->post(NULL, TRUE);
  6273. if (isset($post['wzid'])) {
  6274. $time = time();
  6275. $id = $this->input->post('wzid', true);
  6276. //$post['shop'] = $this->input->post('shop',true);
  6277. $num = 1;
  6278. $rk = $this->whlabellabel->read($id);
  6279. if (isset($rk['purchase'])) {
  6280. $x = 0;
  6281. $post['purchase'] = $rk['purchase'];
  6282. $post['warehouse'] = $rk['warehouse'];
  6283. $post['retreatwarehouse'] = $rk['warehouse'];
  6284. $post['sku'] = $rk['sku'];
  6285. $post['number'] = $rk['number'];
  6286. $post['features'] = $rk['features'];
  6287. $post['title'] = $rk['title'];
  6288. $post['enter'] = $time;
  6289. $post['time'] = $time;
  6290. $post['bs'] = 1;
  6291. $post['shop'] = $rk['shop'];
  6292. $post['details'] = $rk['details'];
  6293. $post['cpid'] = $rk['cpid'];
  6294. $post['cpbz'] = $rk['cpbz'];
  6295. $warehouse = $this->warehouse->read($rk['warehouse']);
  6296. if ($warehouse['bdck'] == '') {
  6297. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6298. exit;
  6299. } else {
  6300. $bdck = $warehouse['bdck'];
  6301. }
  6302. $post['featurespp'] = $rk['featurespp'];
  6303. $this->db->trans_begin();
  6304. for ($i = 0; $i < $num; $i++) {
  6305. $post['label'] = time() . rand(100, 999) . $i;
  6306. $this->$bdck->insert($post);
  6307. }
  6308. /**
  6309. if($post['warehouse'] != 12)
  6310. {
  6311. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6312. }
  6313. **/
  6314. if ($this->db->trans_status() === TRUE) {
  6315. $this->db->trans_commit();
  6316. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6317. exit;
  6318. } else {
  6319. $this->db->trans_rollback();
  6320. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6321. exit;
  6322. }
  6323. } else {
  6324. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6325. exit;
  6326. }
  6327. }
  6328. }
  6329. public function _printck($arg_array)
  6330. {
  6331. $prc = array();
  6332. $purchase = $this->purchase->find_all();
  6333. foreach ($purchase as $k => $v) {
  6334. $prc[$v['id']] = $v['title'];
  6335. }
  6336. $post = $this->input->post(NULL, TRUE);
  6337. if (isset($post['page'])) {
  6338. $page = $this->input->post('page', true);
  6339. $perpage = $this->input->post('perpage', true);
  6340. $sku = $this->input->post('sku', true);
  6341. $bs = $this->input->post('bs', true);
  6342. $number = $this->input->post('number', true);
  6343. $warehouse = $this->input->post('warehouse', true);
  6344. $purchase = $this->input->post('purchase', true);
  6345. $orderinfo = $this->input->post('orderinfo', true);
  6346. $waybill = $this->input->post('waybill', true);
  6347. $category = $this->input->post('category', true);
  6348. $size = $this->input->post('size', true);
  6349. $grade = $this->input->post('grade', true);
  6350. $color = $this->input->post('color', true);
  6351. $lowe = $this->input->post('lowe', true);
  6352. $state = $this->input->post('state', true);
  6353. $label = $this->input->post('label', true);
  6354. $timetk = $this->input->post('ktime', true);
  6355. $timetj = $this->input->post('jtime', true);
  6356. $timetk = strtotime($timetk);
  6357. $timetj = strtotime($timetj);
  6358. $where = "state=1 ";
  6359. if ($timetk && $timetj) {
  6360. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6361. }
  6362. if ($sku) {
  6363. $where .= " and sku = '$sku'";
  6364. }
  6365. if ($bs != '') {
  6366. $where .= " and bs = '$bs'";
  6367. }
  6368. if ($number) {
  6369. $where .= " and number = '$number'";
  6370. }
  6371. if ($warehouse) {
  6372. $where .= " and warehouse = '$warehouse'";
  6373. }
  6374. if ($purchase) {
  6375. $where .= " and purchase = '$purchase'";
  6376. }
  6377. if ($orderinfo) {
  6378. $where .= " and orderinfo = '$orderinfo'";
  6379. }
  6380. if ($waybill) {
  6381. $where .= " and waybill = '$waybill'";
  6382. }
  6383. if ($category) {
  6384. $where .= " and features like '%-$category-%'";
  6385. }
  6386. if ($size) {
  6387. $where .= " and features like '%-$size-%'";
  6388. }
  6389. if ($grade) {
  6390. $where .= " and features like '%-$grade-%'";
  6391. }
  6392. if ($color) {
  6393. $where .= " and features like '%-$color-%'";
  6394. }
  6395. if ($lowe) {
  6396. $where .= " and features like '%-$lowe-%'";
  6397. }
  6398. if ($label) {
  6399. $where .= " and label = '$label'";
  6400. }
  6401. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6402. //数据排序
  6403. $order_str = "outk desc";
  6404. if (empty($page)) {
  6405. $start = 0;
  6406. $perpage = 1;
  6407. } else {
  6408. $start = ($page - 1) * $perpage;
  6409. }
  6410. //取得信息列表
  6411. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6412. foreach ($info_list as $key => $value) {
  6413. $warehouse = $this->warehouse->read($value['warehouse']);
  6414. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6415. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6416. if ($value['state'] == 0) {
  6417. $info_list[$key]['state'] = "在库";
  6418. } else if ($value['state'] == 1) {
  6419. $info_list[$key]['state'] = "出库";
  6420. } else if ($value['state'] == 2) {
  6421. $info_list[$key]['state'] = "退库";
  6422. } else if ($value['state'] == 3) {
  6423. $info_list[$key]['state'] = "调拨中";
  6424. } else if ($value['state'] == 4) {
  6425. $info_list[$key]['state'] = "再加工";
  6426. } else if ($value['state'] == 5) {
  6427. $info_list[$key]['state'] = "维修中";
  6428. } else if ($value['state'] == 6) {
  6429. $info_list[$key]['state'] = "盘亏";
  6430. } else if ($value['state'] == 7) {
  6431. $info_list[$key]['state'] = "更换标签";
  6432. } else if ($value['state'] == 8) {
  6433. $info_list[$key]['state'] = "其它";
  6434. } else if ($value['state'] == 9) {
  6435. $info_list[$key]['state'] = "预设";
  6436. } else if ($value['state'] == 10) {
  6437. $info_list[$key]['state'] = "美店零售";
  6438. }
  6439. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6440. }
  6441. $total = $this->$ck->find_count($where);
  6442. $pagenum = ceil($total / $perpage);
  6443. $over = $total - ($start + $perpage);
  6444. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6445. echo json_encode($rows);
  6446. exit;
  6447. }
  6448. if (isset($post['tmsku'])) {
  6449. $time = time();
  6450. $tmsku = $this->input->post('tmsku', true);
  6451. //$post['shop'] = $this->input->post('shop',true);
  6452. $num = $this->input->post('num', true);
  6453. $cktype = $this->input->post('cktype', true);
  6454. $label = $this->whlabellabel->get_label($tmsku);
  6455. if (!$cktype) {
  6456. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6457. }
  6458. if (!isset($label['warehouse'])) {
  6459. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6460. exit;
  6461. }
  6462. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6463. $extra_where = "";
  6464. if(!empty($label['details'])){
  6465. $extra_where .= " and details = '" . $label['details'] . "'";
  6466. }
  6467. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6468. if (stripos($label['features'], '-126-') !== false) {
  6469. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6470. } else {
  6471. $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 = '' or zd is null ) ".$extra_where);
  6472. }
  6473. $j = 0;
  6474. if (count($ck) >= $num) {
  6475. for ($i = 0; $i < $num; $i++) {
  6476. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6477. {
  6478. $j++;
  6479. }
  6480. }
  6481. $this->whlabelscanlog->insert([
  6482. 'shop'=>$label['shop'],
  6483. 'type'=>2,
  6484. 'purchase'=>$label['purchase'],
  6485. 'sku'=>$label['sku'],
  6486. 'features'=>$label['features'],
  6487. 'title'=>$label['title'],
  6488. 'label'=>$label['label'],
  6489. 'warehouse'=>$label['warehouse'],
  6490. 'wlid'=>$label['id'],
  6491. 'num'=>$num,
  6492. 'addtime'=>time()
  6493. ]);
  6494. if ($j == $num) {
  6495. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6496. exit;
  6497. } else {
  6498. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6499. exit;
  6500. }
  6501. } else {
  6502. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6503. exit;
  6504. }
  6505. }
  6506. if(isset($_SESSION['api']))
  6507. {
  6508. $user = $this->user->get_api($_SESSION['api']);
  6509. if(in_array($user['power'],[1,27])){
  6510. $vip = 1;
  6511. }
  6512. }
  6513. else
  6514. {
  6515. $vip = 0;
  6516. header('Location: /');exit;
  6517. }
  6518. $this->data['vip'] = $vip;
  6519. $this->_Template('whlabel_printck', $this->data);
  6520. }
  6521. public function _printexcel()
  6522. {
  6523. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6524. $config['upload_path'] = '.' . $dir;
  6525. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6526. $config['allowed_types'] = 'xls|xlsx|csv';
  6527. $config['max_size'] = 10240;
  6528. $this->load->library('upload', $config);
  6529. $this->upload->initialize($config);
  6530. if ($this->upload->do_upload('userfile')) {
  6531. $full_path = $dir . $this->upload->data('file_name');
  6532. $fileName = '.' . $full_path;
  6533. if (!file_exists($fileName)) {
  6534. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6535. exit;
  6536. } else {
  6537. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6538. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6539. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6540. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6541. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6542. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6543. ++$column; //如果列数大于26行
  6544. $list = array();
  6545. for ($i = 2; $i <= $row; $i++) // 行数循环
  6546. {
  6547. $data = array();
  6548. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6549. {
  6550. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6551. }
  6552. $list[] = $data;
  6553. }
  6554. }
  6555. $ed = array();
  6556. $i = 0;
  6557. $j = 0;
  6558. $dcdata = array();
  6559. $yc = '';
  6560. $cmf_arr = array_column($list, '1');
  6561. array_multisort($cmf_arr, SORT_ASC, $list);
  6562. foreach ($list as $key => $value) {
  6563. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6564. if ($typeclass) {
  6565. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6566. } else {
  6567. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6568. $i++;
  6569. continue;
  6570. }
  6571. }
  6572. if ($i > 0) {
  6573. $yc = $i . '条异常';
  6574. }
  6575. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6576. exit;
  6577. }
  6578. }
  6579. public function _uck()
  6580. {
  6581. if (isset($_GET['excel'])) {
  6582. $tc = array();
  6583. $typeclass = $this->typeclass->find_all();
  6584. foreach ($typeclass as $v) {
  6585. $tc[$v['id']] = $v['zh'];
  6586. }
  6587. $data = array();
  6588. $t = array();
  6589. $rq = '';
  6590. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6591. $ts = $ts / (24 * 3600);
  6592. for ($i = 0; $i < $ts; $i++) {
  6593. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6594. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6595. }
  6596. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6597. foreach ($info_list as $k => $v) {
  6598. $features = explode('-', trim($v['features'], '-'));
  6599. if (!isset($features[3]) || !isset($features[4])) {
  6600. continue;
  6601. }
  6602. $data[$k][0] = $tc[$features[0]]; //类型
  6603. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6604. $data[$k][2] = $tc[$features[4]]; //曲度
  6605. $data[$k][3] = '';
  6606. if (isset($data[$k][1])) {
  6607. $data[$k][3] .= $data[$k][1];
  6608. }
  6609. if (isset($data[$k][2])) {
  6610. $data[$k][3] .= $data[$k][2];
  6611. }
  6612. if (isset($features[5])) {
  6613. $data[$k][3] .= $tc[$features[5]];
  6614. }
  6615. if (isset($features[2])) {
  6616. $data[$k][3] .= $tc[$features[2]];
  6617. }
  6618. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6619. $data[$k][4] = $v['sku'];
  6620. $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())) . '))'); //月初库存
  6621. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6622. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6623. $ztrq = '';
  6624. $ztsl = '';
  6625. if (count($zt) > 0) {
  6626. foreach ($zt as $vv) {
  6627. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6628. $ztsl .= $vv['num'] . '<br>';
  6629. }
  6630. }
  6631. $data[$k][] = trim($ztsl, '<br>');
  6632. $data[$k][] = trim($ztrq, '<br>');
  6633. $byck = 0;
  6634. foreach ($t as $vv) {
  6635. $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));
  6636. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6637. $byck += $sl;
  6638. }
  6639. $data[$k][] = ($byck > 0) ? $byck : '';
  6640. }
  6641. $title = "详情 " . date("Y-m-d", time());
  6642. $titlename = "<table border=1>
  6643. <tr align='center'>
  6644. <td>类别</td>
  6645. <td>颜色</td>
  6646. <td>曲度</td>
  6647. <td>名称</td>
  6648. <td>SKU</td>
  6649. <td>月初库存</td>
  6650. <td>剩余库存</td>
  6651. <td>在途数量</td>
  6652. <td>预达日期</td>" .
  6653. $rq
  6654. . "<td>本月出库</td></tr>
  6655. </table>";
  6656. $filename = $title . ".xls";
  6657. $tail = "";
  6658. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6659. }
  6660. }
  6661. public function _whlabelexcelzh()
  6662. {
  6663. if (isset($_GET['excel'])) {
  6664. $where = "sku != 'Preset'";
  6665. //数据排序
  6666. $order_str = "id desc";
  6667. if (empty($page)) {
  6668. $start = 0;
  6669. $perpage = 1;
  6670. } else {
  6671. $start = ($page - 1) * $perpage;
  6672. }
  6673. $category = $this->input->get('category', true);
  6674. $warehouse = $this->input->get('warehouse', true);
  6675. $excelid = $this->input->get('sid', true);
  6676. if ($category) {
  6677. $where .= " and features like '%-$category-%'";
  6678. }
  6679. if ($warehouse) {
  6680. $where .= " and warehouse = '$warehouse'";
  6681. }
  6682. $xzid = '';
  6683. if ($excelid) {
  6684. $excelid = explode(',', trim($excelid, ','));
  6685. foreach ($excelid as $key => $value) {
  6686. $xzid .= " id = " . $value . " or";
  6687. }
  6688. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6689. }
  6690. //取得信息列表
  6691. /**
  6692. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6693. $rows = array();$list = array();
  6694. foreach ($info_list as $key=>$value)
  6695. {
  6696. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6697. }
  6698. **/
  6699. $list = array();
  6700. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6701. foreach ($rows as $key => $value) {
  6702. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6703. $zh = '';
  6704. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6705. foreach ($zt as $v) {
  6706. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6707. }
  6708. $zt = array_sum(array_column($zt, 'num'));
  6709. $number = $value['number'];
  6710. $ftime = time() - 15 * 24 * 3600;
  6711. $warehouse = $this->warehouse->read($value['warehouse']);
  6712. $rows[$key]['warehouse'] = $warehouse['title'];
  6713. $rows[$key]['number'] = $c;
  6714. $rows[$key]['features'] = $zh;
  6715. $rows[$key]['hb'] = $c + $zt;
  6716. }
  6717. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6718. $titlename = "<table border=1>
  6719. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6720. <tr align='center'>
  6721. <td>仓库</td>
  6722. <td>SKU</td>
  6723. <td>产品</td>
  6724. <td>库存数量</td>
  6725. <td>在途数量及预达日期</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. if (isset($_GET['excel'])) {
  6734. $warehouse = $this->input->get('warehouse', true);
  6735. $sku = $this->input->get('sku', true);
  6736. $cz = $this->input->get('cz', true);
  6737. $text = $this->input->post('text', true);
  6738. $xztime = $this->input->get('xztime', true);
  6739. $timetk = $this->input->get('timetk', true);
  6740. $timetj = $this->input->get('timetj', true);
  6741. $timetk = strtotime($timetk);
  6742. $timetj = strtotime($timetj);
  6743. $where = "time = '0' ";
  6744. if ($warehouse) {
  6745. $where .= " and warehouse = '$warehouse'";
  6746. }
  6747. if ($sku) {
  6748. $where .= " and sku = '$sku'";
  6749. }
  6750. if ($text) {
  6751. $where .= " and text like '%$text%'";
  6752. }
  6753. if ($cz != '') {
  6754. $where .= " and cz = '$cz'";
  6755. }
  6756. if ($timetk && $timetj) {
  6757. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6758. }
  6759. //数据排序
  6760. $order_str = $xztime . " desc";
  6761. //取得信息列表
  6762. $zh = array();
  6763. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6764. foreach ($info_list as $v) {
  6765. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6766. $warehouse = $this->warehouse->read($v['warehouse']);
  6767. $v['warehouse'] = $warehouse['title'];
  6768. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6769. $v['stime'] = date('Y-m-d', $v['stime']);
  6770. if (isset($zh[$v['features']])) {
  6771. $zh[$v['features']]['num'] += $v['num'];
  6772. } else {
  6773. $zh[$v['features']] = $v;
  6774. }
  6775. $zh[$v['features']]['features'] = $c;
  6776. }
  6777. $title = "在途数据" . date('Y-m-d', time());
  6778. $titlename = "<table border=1>
  6779. <tr align='center'>
  6780. <td>仓库</td>
  6781. <td>SKU</td>
  6782. <td>名称</td>
  6783. <td>在途数量</td>
  6784. <td>库存数量</td>
  6785. <td>添加在途日期</td>
  6786. <td>预达日期</td>
  6787. <td>备注</td>
  6788. </tr>
  6789. </table>";
  6790. $filename = $title . ".xls";
  6791. $tail = "";
  6792. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6793. }
  6794. }
  6795. public function _fc()
  6796. {
  6797. $vip = 0;
  6798. if (isset($_SESSION['api'])) {
  6799. $user = $this->user->get_api($_SESSION['api']);
  6800. if ($user['vip'] == 1) {
  6801. $vip = 1;
  6802. }
  6803. } else {
  6804. header('Location: /');
  6805. exit;
  6806. }
  6807. $post = $this->input->post(NULL, TRUE);
  6808. if (isset($post['page'])) {
  6809. $page = $this->input->post('page', true);
  6810. $perpage = $this->input->post('perpage', true);
  6811. $category = $this->input->post('category', true);
  6812. $size = $this->input->post('size', true);
  6813. $grade = $this->input->post('grade', true);
  6814. $color = $this->input->post('color', true);
  6815. $lowe = $this->input->post('lowe', true);
  6816. $sku = $this->input->post('sku');
  6817. $title = $this->input->post('title');
  6818. $warehouse = $this->input->post('warehouse', true);
  6819. $usa = $this->input->post('usa', true);
  6820. $purchase = $this->input->post('purchase', true);
  6821. $lacetype = $this->input->post('lacetype', true);
  6822. $haircap = $this->input->post('haircap', true);
  6823. $density = $this->input->post('density', true);
  6824. $details = $this->input->post('details', true);
  6825. $state = $this->input->post('state', true);
  6826. $ktime = $this->input->post('ktime', true);
  6827. $jtime = $this->input->post('jtime', true);
  6828. $ktime = strtotime($ktime);
  6829. $jtime = strtotime($jtime);
  6830. $where = "state = '11'";
  6831. $gj = "";
  6832. $ck = "";
  6833. if ($lacetype) {
  6834. $where .= " and features like '%-$lacetype-%'";
  6835. }
  6836. if ($category) {
  6837. $where .= " and features like '%-$category-%'";
  6838. }
  6839. if ($size) {
  6840. $where .= " and features like '%-$size-%'";
  6841. }
  6842. if ($grade) {
  6843. $where .= " and features like '%-$grade-%'";
  6844. }
  6845. if ($color) {
  6846. $where .= " and features like '%-$color-%'";
  6847. }
  6848. if ($lowe) {
  6849. $where .= " and features like '%-$lowe-%'";
  6850. }
  6851. if ($haircap) {
  6852. $where .= " and features like '%-$haircap-%'";
  6853. }
  6854. if ($density) {
  6855. $where .= " and features like '%-$density-%'";
  6856. }
  6857. if ($usa) {
  6858. if (!$warehouse) {
  6859. $where .= " and (warehouse = '5' or warehouse = '8')";
  6860. }
  6861. }
  6862. if ($warehouse) {
  6863. $where .= " and warehouse = '$warehouse'";
  6864. }
  6865. if ($details) {
  6866. $where .= " and details = '$details'";
  6867. }
  6868. if ($purchase) {
  6869. $where .= " and purchase = '$purchase'";
  6870. }
  6871. if ($state) {
  6872. $where .= " and state = '$state'";
  6873. }
  6874. if ($ktime && $jtime) {
  6875. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6876. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6877. }
  6878. //数据排序
  6879. $order_str = "id desc";
  6880. if (empty($page)) {
  6881. $start = 0;
  6882. $perpage = 1;
  6883. } else {
  6884. $start = ($page - 1) * $perpage;
  6885. }
  6886. if ($sku) {
  6887. $sku = trim($sku, ' ');
  6888. $sku = trim($sku, ' ');
  6889. $where .= " and sku like '%$sku%'";
  6890. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6891. } else if ($title) {
  6892. $title = trim($title, ' ');
  6893. $title = trim($title, ' ');
  6894. $where .= " and title like '%$title%'";
  6895. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6896. } else {
  6897. //$where .= " and time > '$ktime' and time < '$jtime'";
  6898. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6899. }
  6900. //取得信息列表
  6901. $rows = array();
  6902. $list = array();
  6903. foreach ($info_list as $key => $value) {
  6904. $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'] . '"');
  6905. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6906. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6907. $warehouse = $this->warehouse->read($value['warehouse']);
  6908. $info_list[$key]['warehouse'] = $warehouse['title'];
  6909. $info_list[$key]['number'] = $g;
  6910. $info_list[$key]['features'] = $x;
  6911. $info_list[$key]['x'] = $s;
  6912. }
  6913. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6914. $pagenum = ceil($total / $perpage);
  6915. $over = $total - ($start + $perpage);
  6916. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6917. echo json_encode($rows);
  6918. exit;
  6919. }
  6920. $this->data['vip'] = $vip;
  6921. $this->_Template('whlabel_fc', $this->data);
  6922. }
  6923. public function _fcmb()
  6924. {
  6925. $where = "sku != 'Preset'";
  6926. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6927. foreach ($rows as $k => $v) {
  6928. $warehouse = $this->warehouse->read($v['warehouse']);
  6929. $rows[$k]['warehouse'] = $warehouse['title'];
  6930. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6931. $rows[$k]['t'] = '';
  6932. $rows[$k]['n'] = '';
  6933. }
  6934. $title = "封货产品数据导入模板";
  6935. $titlename = "<table border=1>
  6936. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6937. <tr align='center'>
  6938. <td>仓库</td>
  6939. <td>SKU</td>
  6940. <td>产品</td>
  6941. <td>封存产品总数量</td>
  6942. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6943. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6944. </tr>
  6945. </table>";
  6946. $filename = $title . ".xls";
  6947. $tail = "";
  6948. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6949. }
  6950. public function _fcexcel()
  6951. {
  6952. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6953. $config['upload_path'] = '.' . $dir;
  6954. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6955. $config['allowed_types'] = 'xls|xlsx|csv';
  6956. $config['max_size'] = 10240;
  6957. $this->load->library('upload', $config);
  6958. $this->upload->initialize($config);
  6959. if ($this->upload->do_upload('userfile')) {
  6960. $full_path = $dir . $this->upload->data('file_name');
  6961. $fileName = '.' . $full_path;
  6962. if (!file_exists($fileName)) {
  6963. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6964. exit;
  6965. } else {
  6966. libxml_use_internal_errors(true);
  6967. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6968. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6969. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6970. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6971. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6972. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6973. ++$column; //如果列数大于26行
  6974. $list = array();
  6975. for ($i = 2; $i <= $row; $i++) // 行数循环
  6976. {
  6977. $data = array();
  6978. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6979. {
  6980. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6981. }
  6982. $list[] = $data;
  6983. }
  6984. }
  6985. $i = 0;
  6986. $j = 0;
  6987. $ed = array();
  6988. foreach ($list as $key => $value) {
  6989. $time = time();
  6990. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6991. continue;
  6992. }
  6993. $warehouse = $this->warehouse->get_title($value['0']);
  6994. $sku = $value['1'];
  6995. $type = $value['4']; //调整方式0扣减1删除
  6996. $num = $value['5']; //调整数量
  6997. //$text = $value['4'];//扣减说明
  6998. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6999. if (!$d) //如果没有这个SKU
  7000. {
  7001. $ed[] = array($sku . '-库存中不存在此SKU');
  7002. $j++;
  7003. continue;
  7004. }
  7005. if (!isset($warehouse['id'])) {
  7006. $ed[] = array($sku . '-仓库名错误!');
  7007. $j++;
  7008. continue;
  7009. }
  7010. if ($type == 1 || $type == 2) //扣减库存
  7011. {
  7012. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7013. if (count($data) < abs($num)) {
  7014. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7015. $j++;
  7016. continue;
  7017. }
  7018. if ($type == 1) //转入库存
  7019. {
  7020. for ($i = 0; $i < abs($num); $i++) {
  7021. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7022. }
  7023. } else if ($type == 2) //删除
  7024. {
  7025. for ($i = 0; $i < abs($num); $i++) {
  7026. $this->whlabel->remove($data[$i]['id']);
  7027. }
  7028. }
  7029. } else if ($type == 0) //增加库存
  7030. {
  7031. $post['sku'] = $d['sku'];
  7032. $post['shop'] = '';
  7033. $post['warehouse'] = $warehouse['id'];
  7034. $post['purchase'] = $d['purchase'];
  7035. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7036. $post['state'] = 11;
  7037. $post['title'] = $d['title'];
  7038. $post['number'] = $d['number'];
  7039. $post['features'] = $d['features'];
  7040. $post['enter'] = $time;
  7041. $post['time'] = $time; //操作时间
  7042. for ($i = 0; $i < $num; $i++) {
  7043. $post['label'] = time() . rand(100, 999) . $i;
  7044. $this->whlabel->insert($post);
  7045. }
  7046. }
  7047. sleep(1); //防止入库时间一样,需要延迟1秒
  7048. }
  7049. if ($j > 0) {
  7050. $tt = date('Ymd', time());
  7051. $title = '库存导入错误信息-' . $tt;
  7052. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7053. $tail = "\n";
  7054. $filename = $title . ".xls";
  7055. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7056. $dir = '/data/excel/' . $time . '/';
  7057. $file_name = 'error_' . $time . rand(1000, 9999);
  7058. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7059. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7060. fwrite($myfile, $ecl);
  7061. fclose($myfile);
  7062. $error = $dir . $file_name . '.xls';
  7063. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7064. exit;
  7065. } else {
  7066. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7067. exit;
  7068. }
  7069. }
  7070. }
  7071. public function _fcjxc($arg_array)
  7072. {
  7073. if (isset($_GET['excel'])) {
  7074. $category = $this->input->get('category', true);
  7075. $size = $this->input->get('size', true);
  7076. $grade = $this->input->get('grade', true);
  7077. $color = $this->input->get('color', true);
  7078. $lowe = $this->input->get('lowe', true);
  7079. $sku = $this->input->get('sku');
  7080. $title = $this->input->get('title');
  7081. $warehouse = $arg_array[0];
  7082. $usa = $this->input->get('usa', true);
  7083. $purchase = $this->input->get('purchase', true);
  7084. $lacetype = $this->input->get('lacetype', true);
  7085. $haircap = $this->input->get('haircap', true);
  7086. $density = $this->input->get('density', true);
  7087. $title = $this->input->get('title', true);
  7088. $state = $this->input->get('state', true);
  7089. $ktime = $this->input->get('ktime', true);
  7090. $jtime = $this->input->get('jtime', true);
  7091. $where = "state=11";
  7092. $gj = "";
  7093. $ck = "";
  7094. if ($lacetype) {
  7095. $where .= " and features like '%-$lacetype-%'";
  7096. }
  7097. if ($category) {
  7098. $where .= " and features like '%-$category-%'";
  7099. }
  7100. if ($size) {
  7101. $where .= " and features like '%-$size-%'";
  7102. }
  7103. if ($grade) {
  7104. $where .= " and features like '%-$grade-%'";
  7105. }
  7106. if ($color) {
  7107. $where .= " and features like '%-$color-%'";
  7108. }
  7109. if ($lowe) {
  7110. $where .= " and features like '%-$lowe-%'";
  7111. }
  7112. if ($haircap) {
  7113. $where .= " and features like '%-$haircap-%'";
  7114. }
  7115. if ($density) {
  7116. $where .= " and features like '%-$density-%'";
  7117. }
  7118. if ($usa) {
  7119. if (!$warehouse) {
  7120. $where .= " and (warehouse = '5' or warehouse = '8')";
  7121. }
  7122. }
  7123. if ($warehouse) {
  7124. $where .= " and warehouse = '$warehouse'";
  7125. }
  7126. if ($purchase) {
  7127. $where .= " and purchase = '$purchase'";
  7128. }
  7129. if ($state) {
  7130. $where .= " and state = '$state'";
  7131. }
  7132. $order_str = "id desc";
  7133. if ($sku) {
  7134. $sku = trim($sku, ' ');
  7135. $sku = trim($sku, ' ');
  7136. $where .= " and sku like '%$sku%'";
  7137. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7138. } else if ($title) {
  7139. $title = trim($title, ' ');
  7140. $title = trim($title, ' ');
  7141. $where .= " and title like '%$title%'";
  7142. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7143. } else {
  7144. //$where .= " and time > '$ktime' and time < '$jtime'";
  7145. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7146. }
  7147. //取得信息列表
  7148. $rows = array();
  7149. $list = array();
  7150. foreach ($info_list as $key => $value) {
  7151. $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'] . '"');
  7152. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7153. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7154. $rows[$key] = $value;
  7155. $warehouse = $this->warehouse->read($value['warehouse']);
  7156. $rows[$key]['warehouse'] = $warehouse['title'];
  7157. $rows[$key]['features'] = $g;
  7158. $rows[$key]['a'] = $x;
  7159. $rows[$key]['b'] = $s;
  7160. }
  7161. $title = "总统计表";
  7162. $titlename = "<table border=1>
  7163. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7164. <tr align='center'>
  7165. <td>仓库</td>
  7166. <td>SKU</td>
  7167. <td>产品名称</td>
  7168. <td>录入总量</td>
  7169. <td>取出总量</td>
  7170. <td>剩余总量</td>
  7171. </tr>
  7172. </table>";
  7173. $filename = $title . ".xls";
  7174. $tail = "";
  7175. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7176. }
  7177. $vip = 0;
  7178. if (isset($_SESSION['api'])) {
  7179. $user = $this->user->get_api($_SESSION['api']);
  7180. if ($user['vip'] == 1) {
  7181. $vip = 1;
  7182. }
  7183. } else {
  7184. header('Location: /');
  7185. exit;
  7186. }
  7187. $post = $this->input->post(NULL, TRUE);
  7188. if (isset($post['page'])) {
  7189. $page = $this->input->post('page', true);
  7190. $perpage = $this->input->post('perpage', true);
  7191. $category = $this->input->post('category', true);
  7192. $size = $this->input->post('size', true);
  7193. $grade = $this->input->post('grade', true);
  7194. $color = $this->input->post('color', true);
  7195. $lowe = $this->input->post('lowe', true);
  7196. $sku = $this->input->post('sku');
  7197. $title = $this->input->post('title');
  7198. $warehouse = $arg_array[0];
  7199. $usa = $this->input->post('usa', true);
  7200. $purchase = $this->input->post('purchase', true);
  7201. $lacetype = $this->input->post('lacetype', true);
  7202. $haircap = $this->input->post('haircap', true);
  7203. $density = $this->input->post('density', true);
  7204. $title = $this->input->post('title', true);
  7205. $state = $this->input->post('state', true);
  7206. $ktime = $this->input->post('ktime', true);
  7207. $jtime = $this->input->post('jtime', true);
  7208. $ktime = strtotime($ktime);
  7209. $jtime = strtotime($jtime);
  7210. $where = "state=11";
  7211. $gj = "";
  7212. $ck = "";
  7213. if ($lacetype) {
  7214. $where .= " and features like '%-$lacetype-%'";
  7215. }
  7216. if ($category) {
  7217. $where .= " and features like '%-$category-%'";
  7218. }
  7219. if ($size) {
  7220. $where .= " and features like '%-$size-%'";
  7221. }
  7222. if ($grade) {
  7223. $where .= " and features like '%-$grade-%'";
  7224. }
  7225. if ($color) {
  7226. $where .= " and features like '%-$color-%'";
  7227. }
  7228. if ($lowe) {
  7229. $where .= " and features like '%-$lowe-%'";
  7230. }
  7231. if ($haircap) {
  7232. $where .= " and features like '%-$haircap-%'";
  7233. }
  7234. if ($density) {
  7235. $where .= " and features like '%-$density-%'";
  7236. }
  7237. if ($usa) {
  7238. if (!$warehouse) {
  7239. $where .= " and (warehouse = '5' or warehouse = '8')";
  7240. }
  7241. }
  7242. if ($warehouse) {
  7243. $where .= " and warehouse = '$warehouse'";
  7244. }
  7245. if ($purchase) {
  7246. $where .= " and purchase = '$purchase'";
  7247. }
  7248. if ($state) {
  7249. $where .= " and state = '$state'";
  7250. }
  7251. if ($ktime && $jtime) {
  7252. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7253. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7254. }
  7255. //数据排序
  7256. $order_str = "id desc";
  7257. $xs = 0;
  7258. $rows = array();
  7259. $list = array();
  7260. if (empty($page)) {
  7261. $start = 0;
  7262. $perpage = 1;
  7263. } else {
  7264. $start = ($page - 1) * $perpage;
  7265. }
  7266. if ($sku || $title) {
  7267. if ($title) {
  7268. $title = trim($title, ' ');
  7269. $title = trim($title, ' ');
  7270. $where .= " and title like '%$title%'";
  7271. } else {
  7272. $sku = trim($sku, ' ');
  7273. $sku = trim($sku, ' ');
  7274. $where .= " and sku like '%$sku%'";
  7275. }
  7276. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7277. foreach ($info_list as $key => $value) {
  7278. $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'] . '"');
  7279. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7280. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7281. $rows[$key] = $value;
  7282. $warehouse = $this->warehouse->read($value['warehouse']);
  7283. $rows[$key]['warehouse'] = $warehouse['title'];
  7284. $rows[$key]['features'] = $g;
  7285. $rows[$key]['a'] = $x;
  7286. $rows[$key]['b'] = $s;
  7287. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7288. $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天销量
  7289. $yj = $c / ($xl / 30);
  7290. if ($yj < 7) {
  7291. $rows[$key]['y'] = round($yj) . '天销量';
  7292. } else {
  7293. $rows[$key]['y'] = '正常';
  7294. }
  7295. }
  7296. } else {
  7297. //$where .= " and time > '$ktime' and time < '$jtime'";
  7298. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7299. foreach ($info_list as $key => $value) {
  7300. $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'] . '"');
  7301. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7302. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7303. $zs[$key] = $value;
  7304. $warehouse = $this->warehouse->read($value['warehouse']);
  7305. $zs[$key]['warehouse'] = $warehouse['title'];
  7306. $zs[$key]['features'] = $g;
  7307. $zs[$key]['a'] = $x;
  7308. $zs[$key]['b'] = $s;
  7309. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7310. $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天销量
  7311. $yj = $c / ($xl / 30);
  7312. if ($yj < 7) {
  7313. $zs[$key]['y'] = round($yj) . '天销量';
  7314. $rows[$key] = $zs[$key];
  7315. }
  7316. }
  7317. }
  7318. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7319. $pagenum = ceil($total / $perpage);
  7320. $over = $total - ($start + $perpage);
  7321. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7322. echo json_encode($rows);
  7323. exit;
  7324. }
  7325. $this->data['arg_array'] = $arg_array[0];
  7326. $this->_Template('whlabel_fcjxc', $this->data);
  7327. }
  7328. public function _0kcdel()
  7329. {
  7330. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7331. $config['upload_path'] = '.' . $dir;
  7332. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7333. $config['allowed_types'] = 'xls|xlsx|csv';
  7334. $config['max_size'] = 10240;
  7335. $this->load->library('upload', $config);
  7336. $this->upload->initialize($config);
  7337. if ($this->upload->do_upload('userfile')) {
  7338. $full_path = $dir . $this->upload->data('file_name');
  7339. $fileName = '.' . $full_path;
  7340. if (!file_exists($fileName)) {
  7341. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7342. exit;
  7343. } else {
  7344. require_once "./data/excel/PHPExcel/IOFactory.php";
  7345. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7346. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7347. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7348. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7349. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7350. ++$column; //如果列数大于26行
  7351. $list = array();
  7352. for ($i = 2; $i <= $row; $i++) // 行数循环
  7353. {
  7354. $data = array();
  7355. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7356. {
  7357. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7358. }
  7359. $list[] = $data;
  7360. }
  7361. }
  7362. $i = 0;
  7363. $j = 0;
  7364. $ed = array();
  7365. foreach ($list as $key => $value) {
  7366. $time = time();
  7367. if ($value['0'] == "" || $value['1'] == "") {
  7368. continue;
  7369. }
  7370. $warehouse = $this->warehouse->get_title($value['0']);
  7371. $sku = $value['1'];
  7372. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7373. if (!$d) //如果没有这个SKU
  7374. {
  7375. $ed[] = array($sku . '-库存中不存在此SKU');
  7376. $j++;
  7377. continue;
  7378. }
  7379. if (!isset($warehouse['id'])) {
  7380. $ed[] = array($sku . '-仓库名错误!');
  7381. $j++;
  7382. continue;
  7383. }
  7384. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7385. if ($z < 1) {
  7386. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7387. foreach ($z as $v) {
  7388. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7389. if (count($zt) > 0) {
  7390. $ed[] = array($sku . '-有在途库存无法删除!');
  7391. $j++;
  7392. continue;
  7393. }
  7394. $this->whlabel->remove($v['id']);
  7395. }
  7396. } else {
  7397. $ed[] = array($sku . '-非0库存!');
  7398. $j++;
  7399. continue;
  7400. }
  7401. }
  7402. if ($j > 0) {
  7403. $tt = date('Ymd', time());
  7404. $title = '删除0库存错误信息-' . $tt;
  7405. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7406. $tail = "\n";
  7407. $filename = $title . ".xls";
  7408. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7409. $dir = '/data/excel/' . $time . '/';
  7410. $file_name = 'error_' . $time . rand(1000, 9999);
  7411. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7412. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7413. fwrite($myfile, $ecl);
  7414. fclose($myfile);
  7415. $error = $dir . $file_name . '.xls';
  7416. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7417. exit;
  7418. } else {
  7419. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7420. exit;
  7421. }
  7422. }
  7423. }
  7424. public function _gbhtype()
  7425. {
  7426. $post = $this->input->post(NULL, TRUE);
  7427. if (isset($post['s'])) {
  7428. $n = $this->input->post('n');
  7429. $d = $this->input->post('s');
  7430. if (!$d) {
  7431. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7432. exit;
  7433. }
  7434. $d = explode(',', trim($d, ','));
  7435. $t = $this->whlabel_type->read($n);
  7436. //循环删除记录
  7437. foreach ($d as $v) {
  7438. $u = $this->whlabel->read($v);
  7439. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7440. foreach ($data as $val) {
  7441. $this->whlabel->save(array('type' => $n), $val['id']);
  7442. }
  7443. }
  7444. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7445. }
  7446. }
  7447. //出库、退库导出
  7448. public function _dccrtype()
  7449. {
  7450. $classid = $this->classid->sku();
  7451. $pm = $classid;
  7452. $typeclass = array();
  7453. $tc = $this->typeclass->find_all();
  7454. foreach ($tc as $v) {
  7455. $typeclass[$v['id']] = $v;
  7456. }
  7457. $prc = array();
  7458. $purchase = $this->purchase->find_all();
  7459. foreach ($purchase as $k => $v) {
  7460. $prc[$v['id']] = $v['title'];
  7461. }
  7462. if (isset($_GET['sid'])) {
  7463. $wh = array();
  7464. $w = $this->warehouse->find_all('1=1', 'id,title');
  7465. foreach ($w as $v) {
  7466. $wh[$v['id']] = $v['title'];
  7467. }
  7468. $type = $this->input->get('excel', true);
  7469. $category = $this->input->get('category', true);
  7470. $size = $this->input->get('size', true);
  7471. $grade = $this->input->get('grade', true);
  7472. $color = $this->input->get('color', true);
  7473. $lowe = $this->input->get('lowe', true);
  7474. $sku = $this->input->get('sku', true);
  7475. $warehouse = $this->input->get('warehouse', true);
  7476. $lacetype = $this->input->get('lacetype', true);
  7477. $lacecolor = $this->input->get('lacecolor', true);
  7478. $density = $this->input->get('density', true);
  7479. $haircap = $this->input->get('haircap', true);
  7480. $purchase = $this->input->get('purchase', true);
  7481. $title = $this->input->get('title', true);
  7482. $state = $this->input->get('state', true);
  7483. $sid = $this->input->get('sid', true);
  7484. $ktime = $this->input->get('ktime', true);
  7485. $jtime = $this->input->get('jtime', true);
  7486. $ktime = strtotime($ktime);
  7487. $jtime = strtotime($jtime);
  7488. $where = "1=1";
  7489. $gj = "";
  7490. $ck = "";
  7491. if ($category) {
  7492. $where .= " and features like '%-$category-%'";
  7493. }
  7494. if ($size) {
  7495. $where .= " and features like '%-$size-%'";
  7496. }
  7497. if ($grade) {
  7498. $where .= " and features like '%-$grade-%'";
  7499. }
  7500. if ($color) {
  7501. $where .= " and features like '%-$color-%'";
  7502. }
  7503. if ($lowe) {
  7504. $where .= " and features like '%-$lowe-%'";
  7505. }
  7506. if ($warehouse) {
  7507. $where .= " and warehouse = '$warehouse'";
  7508. }
  7509. if ($purchase) {
  7510. $where .= " and purchase = '$purchase'";
  7511. }
  7512. if ($state) {
  7513. $where .= " and state = '$state'";
  7514. }
  7515. if ($lacetype) {
  7516. $where .= " and features like '%-$lacetype-%'";
  7517. }
  7518. if ($lacecolor) {
  7519. $where .= " and features like '%-$lacecolor-%'";
  7520. }
  7521. if ($density) {
  7522. $where .= " and features like '%-$density-%'";
  7523. }
  7524. if ($haircap) {
  7525. $where .= " and features like '%-$haircap-%'";
  7526. }
  7527. if ($title) {
  7528. $title = trim($title, ' ');
  7529. $title = trim($title, ' ');
  7530. $where .= " and title like '%$title%'";
  7531. }
  7532. if ($sku) {
  7533. $sku = trim($sku, ' ');
  7534. $sku = trim($sku, ' ');
  7535. $where .= " and sku like '%$sku%'";
  7536. }
  7537. if ($ktime && $jtime) {
  7538. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7539. }
  7540. $sidwhere = '';
  7541. if ($sid) {
  7542. $sd = "";
  7543. $s = explode(',', trim($sid, ','));
  7544. foreach ($s as $value) {
  7545. $sd .= " id = " . $value . " or";
  7546. }
  7547. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7548. }
  7549. //数据排序
  7550. $order_str = "time desc";
  7551. if (empty($page)) {
  7552. $start = 0;
  7553. $perpage = 1;
  7554. } else {
  7555. $start = ($page - 1) * $perpage;
  7556. }
  7557. $wh = array();
  7558. $w = $this->warehouse->find_all('1=1', 'id,title');
  7559. foreach ($w as $v) {
  7560. $wh[$v['id']] = $v['title'];
  7561. }
  7562. $wt = array();
  7563. $whlabel_type = $this->whlabel_type->find_all();
  7564. foreach ($whlabel_type as $v) {
  7565. $wt[$v['id']] = $v['title'];
  7566. }
  7567. $classid = $this->classid->sku();
  7568. $list = array();
  7569. $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');
  7570. foreach ($rows_r as $key => $value) {
  7571. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7572. $pm = $classid;
  7573. $jm = $classid;
  7574. $rows_r[$key]['enter'] = '入库';
  7575. $rows_r[$key]['time'] = $value['enter'];
  7576. if ($value['rktype'] == 1) {
  7577. $rows_r[$key]['rktype'] = '采购入库';
  7578. } else if ($value['rktype'] == 2) {
  7579. $rows_r[$key]['rktype'] = '盘盈调整';
  7580. } else if ($value['rktype'] == 3) {
  7581. $rows_r[$key]['rktype'] = '其他调整入库';
  7582. } else if ($value['rktype'] == 4) {
  7583. $rows_r[$key]['rktype'] = '其他调整入库';
  7584. } else if ($value['rktype'] == 5) {
  7585. $rows_r[$key]['rktype'] = '退库入库';
  7586. } else if ($value['rktype'] == 6) {
  7587. $rows_r[$key]['rktype'] = '退货可用入库';
  7588. } else if ($value['rktype'] == 7) {
  7589. $rows_r[$key]['rktype'] = '形态转换入库';
  7590. } else {
  7591. $rows_r[$key]['rktype'] = '';
  7592. }
  7593. $features = explode('-', trim($value['features'], '-'));
  7594. foreach ($features as $v) {
  7595. if (isset($typeclass[$v])) {
  7596. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7597. $pm[$typeclass[$v]['classid']] = $zh[0];
  7598. }
  7599. if (isset($typeclass[$v])) {
  7600. if (isset($jm[$typeclass[$v]['classid']])) {
  7601. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7602. }
  7603. }
  7604. }
  7605. $zh = implode(" ", $pm);
  7606. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7607. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7608. $rows_r[$key]['zh'] = $zh;
  7609. $jm = array_filter($jm);
  7610. $rows_r[$key]['features'] = implode("-", $jm);
  7611. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7612. }
  7613. $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');
  7614. foreach ($rows_c as $key => $value) {
  7615. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7616. $pm = $classid;
  7617. $jm = $classid;
  7618. $rows_c[$key]['time'] = $value['outk'];
  7619. $rows_c[$key]['outk'] = '出库';
  7620. if ($value['cktype'] == 1) {
  7621. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7622. } else if ($value['cktype'] == 2) {
  7623. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7624. } else if ($value['cktype'] == 3) {
  7625. $rows_c[$key]['cktype'] = '盘亏调整';
  7626. } else if ($value['cktype'] == 4) {
  7627. $rows_c[$key]['cktype'] = '其他调整出库';
  7628. } else if ($value['cktype'] == 5) {
  7629. $rows_c[$key]['cktype'] = '形态转换出库';
  7630. } else {
  7631. $rows_c[$key]['cktype'] = '';
  7632. }
  7633. unset($rows_c[$key]['state']);
  7634. $features = explode('-', trim($value['features'], '-'));
  7635. foreach ($features as $v) {
  7636. if (isset($typeclass[$v])) {
  7637. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7638. $pm[$typeclass[$v]['classid']] = $zh[0];
  7639. }
  7640. if (isset($typeclass[$v])) {
  7641. if (isset($jm[$typeclass[$v]['classid']])) {
  7642. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7643. }
  7644. }
  7645. }
  7646. $zh = implode(" ", $pm);
  7647. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7648. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7649. $rows_c[$key]['zh'] = $zh;
  7650. $jm = array_filter($jm);
  7651. $rows_c[$key]['features'] = implode("-", $jm);
  7652. $rows_c[$key]['number'] = 1;
  7653. }
  7654. $merged = $rows_r;
  7655. foreach ($rows_c as $key => $value) {
  7656. if (isset($merged[$key])) {
  7657. $merged[] = $value;
  7658. } else {
  7659. $merged[$key] = $value;
  7660. }
  7661. }
  7662. usort($merged, function ($a, $b) {
  7663. return $a['time'] - $b['time'];
  7664. });
  7665. foreach ($merged as $key => $value) {
  7666. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7667. }
  7668. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7669. $titlename = "<table border=1>
  7670. <tr align='center'>
  7671. <td>仓库</td>
  7672. <td>SKU</td>
  7673. <td>商品名称</td>
  7674. <td>仓库品名</td>
  7675. <td>料号</td>
  7676. <td>时间</td>
  7677. <td>操作</td>
  7678. <td>类型</td>
  7679. <td>数量</td>
  7680. <td>备注</td>
  7681. </tr>
  7682. </table>";
  7683. $filename = $title . ".xlsx";
  7684. $tail = "";
  7685. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7686. }
  7687. }
  7688. /*************************************处理exceljs导出****************************************************/
  7689. public function _excelrjs(){
  7690. if (isset($_GET['excel'])) {
  7691. $category = $this->input->get('category', true);
  7692. $size = $this->input->get('size', true);
  7693. $grade = $this->input->get('grade', true);
  7694. $color = $this->input->get('color', true);
  7695. $lowe = $this->input->get('lowe', true);
  7696. $sku = $this->input->get('sku', true);
  7697. $warehouse = $this->input->get('warehouse', true);
  7698. $purchase = $this->input->get('purchase', true);
  7699. $ktime = $this->input->get('ktime', true);
  7700. $jtime = $this->input->get('jtime', true);
  7701. $ktime = strtotime($ktime);
  7702. $jtime = strtotime($jtime);
  7703. $where = "1=1";
  7704. $gj = "";
  7705. $ck = "";
  7706. if ($category) {
  7707. $where .= " and features like '%-$category-%'";
  7708. }
  7709. if ($size) {
  7710. $where .= " and features like '%-$size-%'";
  7711. }
  7712. if ($grade) {
  7713. $where .= " and features like '%-$grade-%'";
  7714. }
  7715. if ($color) {
  7716. $where .= " and features like '%-$color-%'";
  7717. }
  7718. if ($lowe) {
  7719. $where .= " and features like '%-$lowe-%'";
  7720. }
  7721. if ($warehouse) {
  7722. $where .= " and warehouse = '$warehouse'";
  7723. }
  7724. if ($purchase) {
  7725. $where .= " and purchase = '$purchase'";
  7726. }
  7727. if ($sku) {
  7728. $where .= " and sku = '$sku'";
  7729. }
  7730. if ($ktime && $jtime) {
  7731. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7732. }
  7733. //数据排序
  7734. $order_str = "id desc";
  7735. if (empty($page)) {
  7736. $start = 0;
  7737. $perpage = 1;
  7738. } else {
  7739. $start = ($page - 1) * $perpage;
  7740. }
  7741. $list = array();
  7742. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7743. foreach ($rows as $value) {
  7744. $ck = $this->warehouse->read($value['warehouse']);
  7745. $warehouse = $ck['title'];
  7746. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7747. $retreatwarehouse = $tkck['title'];
  7748. $gy = $this->purchase->read($value['purchase']);
  7749. $purchase = $gy['title'];
  7750. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7751. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7752. }
  7753. if(empty($list)){
  7754. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7755. }else{
  7756. $final_list = [];
  7757. foreach($list as $v){
  7758. $final_list[] = array_values($v);
  7759. }
  7760. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7761. array_unshift($final_list,[
  7762. "仓库","SKU","商品名称","时间","数量"
  7763. ]);
  7764. array_unshift($final_list,[
  7765. $title,"","","",""
  7766. ]);
  7767. $merges = [
  7768. [
  7769. "s"=>["r"=>0,"c"=>0],
  7770. "e"=>["r"=>0,"c"=>4]
  7771. ]
  7772. ];
  7773. $cols = [
  7774. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7775. ];
  7776. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7777. }
  7778. }
  7779. }
  7780. //出库、退库导出
  7781. public function _excelctjs()
  7782. {
  7783. $classid = $this->classid->sku();
  7784. $pm = $classid;
  7785. $typeclass = array();
  7786. $tc = $this->typeclass->find_all();
  7787. foreach ($tc as $v) {
  7788. $typeclass[$v['id']] = $v;
  7789. }
  7790. $prc = array();
  7791. $purchase = $this->purchase->find_all();
  7792. foreach ($purchase as $k => $v) {
  7793. $prc[$v['id']] = $v['title'];
  7794. }
  7795. if (isset($_GET['excel'])) {
  7796. $wh = array();
  7797. $w = $this->warehouse->find_all('1=1', 'id,title');
  7798. foreach ($w as $v) {
  7799. $wh[$v['id']] = $v['title'];
  7800. }
  7801. $type = $this->input->get('excel', true);
  7802. $category = $this->input->get('category', true);
  7803. $size = $this->input->get('size', true);
  7804. $grade = $this->input->get('grade', true);
  7805. $color = $this->input->get('color', true);
  7806. $lowe = $this->input->get('lowe', true);
  7807. $sku = $this->input->get('sku', true);
  7808. $title = $this->input->get('title', true);
  7809. $warehouse = $this->input->get('warehouse', true);
  7810. $purchase = $this->input->get('purchase', true);
  7811. $lacetype = $this->input->get('lacetype', true);
  7812. $haircap = $this->input->get('haircap', true);
  7813. $lacecolor = $this->input->get('lacecolor', true);
  7814. $density = $this->input->get('density', true);
  7815. $details = $this->input->get('details', true);
  7816. $state = $this->input->get('state', true);
  7817. $shop = $this->input->get('shop', true);
  7818. $hairnumber = $this->input->get('hairnumber', true);
  7819. $type_leixi = $this->input->get('type', true);
  7820. $cpbz = $this->input->get('cpbz', true);
  7821. $sm = $this->input->get('sm', true);
  7822. $sid = $this->input->get('sid', true);
  7823. $ktime = $this->input->get('ktime', true);
  7824. $jtime = $this->input->get('jtime', true);
  7825. $ktime = strtotime($ktime);
  7826. $jtime = strtotime($jtime);
  7827. //$where = " 1=1 ";
  7828. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7829. $where = " sku != '' ";
  7830. $gj = "";
  7831. $ck = "";
  7832. if ($category) {
  7833. $where .= " and features like '%-$category-%'";
  7834. }
  7835. if ($size) {
  7836. $where .= " and features like '%-$size-%'";
  7837. }
  7838. if ($grade) {
  7839. $where .= " and features like '%-$grade-%'";
  7840. }
  7841. if ($color) {
  7842. $where .= " and features like '%-$color-%'";
  7843. }
  7844. if ($lowe) {
  7845. $where .= " and features like '%-$lowe-%'";
  7846. }
  7847. if ($warehouse) {
  7848. $where .= " and warehouse = '$warehouse'";
  7849. }
  7850. if ($purchase) {
  7851. $where .= " and purchase = '$purchase'";
  7852. }
  7853. if ($state) {
  7854. $where .= " and state = '$state'";
  7855. }
  7856. if ($lacetype) {
  7857. $where .= " and features like '%-$lacetype-%'";
  7858. }
  7859. if ($lacecolor) {
  7860. $where .= " and features like '%-$lacecolor-%'";
  7861. }
  7862. if ($density) {
  7863. $where .= " and features like '%-$density-%'";
  7864. }
  7865. if ($haircap) {
  7866. $where .= " and features like '%-$haircap-%'";
  7867. }
  7868. if ($details) {
  7869. $where .= " and details = '$details'";
  7870. }
  7871. if ($shop) {
  7872. $where .= " and shop like '%$shop%'";
  7873. }
  7874. if ($title) {
  7875. $title = trim($title, ' ');
  7876. $title = trim($title, ' ');
  7877. $where .= " and title like '%$title%'";
  7878. }
  7879. if (!empty($hairnumber)) {
  7880. $where .= " and features like '%-128-%' ";
  7881. if ($hairnumber < 0) {
  7882. $class_list = $this->typeclass->find_all('classid = 43');
  7883. foreach ($class_list as $v) {
  7884. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7885. }
  7886. } else {
  7887. $where .= " and features like '%-$hairnumber-%'";
  7888. }
  7889. }
  7890. if ($type_leixi) {
  7891. $where .= " and type = '$type_leixi'";
  7892. }
  7893. if ($cpbz) {
  7894. $where .= " and cpbz like '%$cpbz%' ";
  7895. }
  7896. if ($sm) {
  7897. $where .= " and sm like '%$sm%' ";
  7898. }
  7899. if ($sku) {
  7900. $sku = trim($sku, ' ');
  7901. $sku = trim($sku, ' ');
  7902. $where .= " and sku like '%$sku%'";
  7903. }
  7904. if ($ktime && $jtime) {
  7905. if ($type == 1) {
  7906. $tl = '出库';
  7907. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7908. } else if ($type == 2) {
  7909. $tl = '退库';
  7910. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7911. } else if ($type == 3) {
  7912. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7913. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7914. } else if ($type == 4) {
  7915. $tl = '出库+零售';
  7916. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7917. } else if ($type == 5) {
  7918. $tl = '零售';
  7919. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7920. }
  7921. }
  7922. $sidwhere = '';
  7923. if ($sid) {
  7924. $sd = "";
  7925. $s = explode(',', trim($sid, ','));
  7926. foreach ($s as $value) {
  7927. $sd .= " id = " . $value . " or";
  7928. }
  7929. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7930. }
  7931. //数据排序
  7932. $order_str = "time desc";
  7933. if (empty($page)) {
  7934. $start = 0;
  7935. $perpage = 1;
  7936. } else {
  7937. $start = ($page - 1) * $perpage;
  7938. }
  7939. //取得信息列表
  7940. if ($type != 3 && $type != 5) {
  7941. if ($type == 1 || $type == 4) {
  7942. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7943. foreach ($info_list as $key => $value) {
  7944. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7945. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7946. $warehouse = $this->warehouse->read($value['warehouse']);
  7947. $info_list[$key]['warehouse'] = $warehouse['title'];
  7948. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7949. $features = explode('-', trim($features, '-'));
  7950. $pm = $classid;
  7951. foreach ($features as $k => $v) {
  7952. if ($v != 0) {
  7953. if (!isset($typeclass[$v])) {
  7954. continue;
  7955. }
  7956. if (isset($pm[$typeclass[$v]['classid']])) {
  7957. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7958. $tz = explode('|', $typeclass[$v]['zh']);
  7959. $pm[$typeclass[$v]['classid']] = $tz[0];
  7960. } else {
  7961. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7962. }
  7963. }
  7964. }
  7965. }
  7966. $zh = implode(" ", $pm);
  7967. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7968. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7969. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7970. $info_list[$key]['features'] = $zh;
  7971. }
  7972. $final_list = [];
  7973. foreach($info_list as $k=>$v){
  7974. $number = "";
  7975. if(!empty($v['orderinfo'])){
  7976. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7977. if(!empty($tmp_info['number'])){
  7978. $number = $tmp_info['number'];
  7979. }
  7980. }
  7981. $final_list[] = [
  7982. 'warehouse'=>$v['warehouse'],
  7983. 'purchase'=>$v['purchase'],
  7984. 'sku'=>$v['sku'],
  7985. 'title'=>$v['title'],
  7986. 'features'=>$v['features'],
  7987. 'label'=>$v['label'],
  7988. 'orderinfo'=>$v['orderinfo'],
  7989. 'number'=>$number,
  7990. 'waybill'=>$v['waybill'],
  7991. 'outk'=>$v['outk'],
  7992. ];
  7993. }
  7994. } else {
  7995. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7996. foreach ($info_list as $key => $value) {
  7997. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7998. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7999. $warehouse = $this->warehouse->read($value['warehouse']);
  8000. $info_list[$key]['warehouse'] = $warehouse['title'];
  8001. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8002. $features = explode('-', trim($features, '-'));
  8003. $pm = $classid;
  8004. foreach ($features as $k => $v) {
  8005. if ($v != 0) {
  8006. if (!isset($typeclass[$v])) {
  8007. continue;
  8008. }
  8009. if (isset($pm[$typeclass[$v]['classid']])) {
  8010. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8011. $tz = explode('|', $typeclass[$v]['zh']);
  8012. $pm[$typeclass[$v]['classid']] = $tz[0];
  8013. } else {
  8014. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8015. }
  8016. }
  8017. }
  8018. }
  8019. $zh = implode(" ", $pm);
  8020. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8021. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8022. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8023. $info_list[$key]['features'] = $zh;
  8024. }
  8025. $final_list = [];
  8026. foreach($info_list as $k=>$v){
  8027. $number = "";
  8028. if(!empty($v['orderinfo'])){
  8029. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8030. if(!empty($tmp_info['number'])){
  8031. $number = $tmp_info['number'];
  8032. }
  8033. }
  8034. $final_list[] = [
  8035. 'warehouse'=>$v['warehouse'],
  8036. 'purchase'=>$v['purchase'],
  8037. 'sku'=>$v['sku'],
  8038. 'title'=>$v['title'],
  8039. 'features'=>$v['features'],
  8040. 'label'=>$v['label'],
  8041. 'orderinfo'=>$v['orderinfo'],
  8042. 'number'=>$number,
  8043. 'waybill'=>$v['waybill'],
  8044. 'retreat'=>$v['retreat'],
  8045. ];
  8046. }
  8047. }
  8048. if(empty($final_list)){
  8049. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8050. }else{
  8051. $end_list = [];
  8052. foreach($final_list as $v){
  8053. $end_list[] = array_values($v);
  8054. }
  8055. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8056. array_unshift($end_list,[
  8057. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8058. ]);
  8059. array_unshift($end_list,[
  8060. $title,"","","","","","","","",""
  8061. ]);
  8062. $merges = [
  8063. [
  8064. "s"=>["r"=>0,"c"=>0],
  8065. "e"=>["r"=>0,"c"=>9]
  8066. ]
  8067. ];
  8068. $cols = [
  8069. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8070. ];
  8071. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8072. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8073. ] )));
  8074. }
  8075. } else if ($type == 5) {
  8076. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8077. foreach ($info_list as $key => $value) {
  8078. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8079. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8080. $warehouse = $this->warehouse->read($value['warehouse']);
  8081. $info_list[$key]['warehouse'] = $warehouse['title'];
  8082. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8083. $features = explode('-', trim($features, '-'));
  8084. $pm = $classid;
  8085. foreach ($features as $k => $v) {
  8086. if ($v != 0) {
  8087. if (!isset($typeclass[$v])) {
  8088. continue;
  8089. }
  8090. if (isset($pm[$typeclass[$v]['classid']])) {
  8091. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8092. $tz = explode('|', $typeclass[$v]['zh']);
  8093. $pm[$typeclass[$v]['classid']] = $tz[0];
  8094. } else {
  8095. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8096. }
  8097. }
  8098. }
  8099. }
  8100. $zh = implode(" ", $pm);
  8101. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8102. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8103. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8104. $info_list[$key]['features'] = $zh;
  8105. }
  8106. if(empty($info_list)){
  8107. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8108. }else{
  8109. $final_list = [];
  8110. foreach($info_list as $v){
  8111. $final_list[] = array_values($v);
  8112. }
  8113. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8114. array_unshift($final_list,[
  8115. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8116. ]);
  8117. array_unshift($final_list,[
  8118. $title,"","","","","","",
  8119. ]);
  8120. $merges = [
  8121. [
  8122. "s"=>["r"=>0,"c"=>0],
  8123. "e"=>["r"=>0,"c"=>6]
  8124. ]
  8125. ];
  8126. $cols = [
  8127. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8128. ];
  8129. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8130. }
  8131. } else {
  8132. $wh = array();
  8133. $w = $this->warehouse->find_all('1=1', 'id,title');
  8134. foreach ($w as $v) {
  8135. $wh[$v['id']] = $v['title'];
  8136. }
  8137. $wt = array();
  8138. $whlabel_type = $this->whlabel_type->find_all();
  8139. foreach ($whlabel_type as $v) {
  8140. $wt[$v['id']] = $v['title'];
  8141. }
  8142. $classid = $this->classid->sku();
  8143. $list = array();
  8144. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8145. foreach ($rows as $key => $value) {
  8146. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8147. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8148. $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');
  8149. $details = array();
  8150. $cpid = array();
  8151. $cpbz = array();
  8152. $c = 0;
  8153. $g = 0;
  8154. $x = 0;
  8155. $t = 0;
  8156. $s = 0;
  8157. $q = 0;
  8158. foreach ($sd as $k => $v) {
  8159. if ($v['state'] == 0) {
  8160. $c++;
  8161. }
  8162. if ($v['state'] != 9) {
  8163. $g++;
  8164. }
  8165. if ($v['outk'] > 1) {
  8166. $x++;
  8167. }
  8168. if ($v['retreat'] > 0) {
  8169. $t++;
  8170. }
  8171. if ($v['state'] == 8) {
  8172. $s++;
  8173. }
  8174. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8175. $q++;
  8176. }
  8177. $details[$v['details']] = $v['details'];
  8178. if ($v['cpid'] != 0) {
  8179. $cpid[$v['cpid']] = $v['cpid'];
  8180. }
  8181. if ($v['cpbz'] != '') {
  8182. $cpbz[$v['cpbz']] = $v['cpbz'];
  8183. }
  8184. }
  8185. if (isset($wt[$value['type']])) {
  8186. $rows[$key]['type'] = $wt[$value['type']];
  8187. } else {
  8188. $rows[$key]['type'] = '未设置';
  8189. }
  8190. $rows[$key]['details'] = implode("、", $details);
  8191. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8192. $ftime = time() - 15 * 24 * 3600;
  8193. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8194. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8195. $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);
  8196. $rows[$key]['c'] = $c;
  8197. $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);
  8198. $rows[$key]['t'] = $t;
  8199. $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'] . '"');
  8200. $rows[$key]['z'] = $z;
  8201. // $jm = $classid;
  8202. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8203. $features = explode('-', trim($features, '-'));
  8204. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8205. }
  8206. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8207. $final_list =[];
  8208. foreach($tmp_list as $k=>$v){
  8209. $final_list[] = [
  8210. "warehouse"=>$v['warehouse'],
  8211. "purchase"=>$v['purchase'],
  8212. "details"=>$v['details'],
  8213. "cpid"=>$v['cpid'],
  8214. "sku"=>$v['sku'],
  8215. "title"=>$v['title'],
  8216. "features"=>$v['pm'],
  8217. "cpbz"=>$v['cpbz'],
  8218. "sm"=>$v['sm'],
  8219. "type"=>$v['type'],
  8220. "g"=>$v["g"],
  8221. "c"=>$v["c"],
  8222. "x"=>$v["x"],
  8223. "t"=>$v["t"],
  8224. "z"=>$v["z"],
  8225. "jm"=>$v["jm"],
  8226. "weight"=>$v["weight"],
  8227. "asd"=>$v["asd"],
  8228. ];
  8229. }
  8230. if(empty($final_list)){
  8231. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8232. }else{
  8233. $end_list = [];
  8234. foreach($final_list as $v){
  8235. $end_list[] = array_values($v);
  8236. }
  8237. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8238. array_unshift($end_list,[
  8239. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8240. ]);
  8241. array_unshift($end_list,[
  8242. $title,"","","","","","","","","","","","","","","","","",""
  8243. ]);
  8244. $merges = [
  8245. [
  8246. "s"=>["r"=>0,"c"=>0],
  8247. "e"=>["r"=>0,"c"=>6]
  8248. ]
  8249. ];
  8250. $cols = [
  8251. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8252. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8253. ];
  8254. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8255. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8256. ])));
  8257. }
  8258. }
  8259. }
  8260. }
  8261. public function _exceljxcjs(){
  8262. $classid = $this->classid->sku();
  8263. $pm = $classid;
  8264. $typeclass = array();
  8265. $tc = $this->typeclass->find_all();
  8266. foreach ($tc as $v) {
  8267. $typeclass[$v['id']] = $v;
  8268. }
  8269. $prc = array();
  8270. $purchase = $this->purchase->find_all();
  8271. foreach ($purchase as $k => $v) {
  8272. $prc[$v['id']] = $v['title'];
  8273. }
  8274. if(!isset($_GET['excel'])){
  8275. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8276. }
  8277. $where = "sku != 'Preset'";
  8278. //数据排序
  8279. $order_str = "id desc";
  8280. if (empty($page)) {
  8281. $start = 0;
  8282. $perpage = 1;
  8283. } else {
  8284. $start = ($page - 1) * $perpage;
  8285. }
  8286. $category = $this->input->get('category', true);
  8287. $warehouse = $this->input->get('warehouse', true);
  8288. $excelid = $this->input->get('sid', true);
  8289. if ($category) {
  8290. $where .= " and features like '%-$category-%'";
  8291. }
  8292. if ($warehouse) {
  8293. $where .= " and warehouse = '$warehouse'";
  8294. }
  8295. $xzid = '';
  8296. if ($excelid) {
  8297. $excelid = explode(',', trim($excelid, ','));
  8298. foreach ($excelid as $key => $value) {
  8299. $xzid .= " id = " . $value . " or";
  8300. }
  8301. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8302. }
  8303. $wt = array();
  8304. $whlabel_type = $this->whlabel_type->find_all();
  8305. foreach ($whlabel_type as $v) {
  8306. $wt[$v['id']] = $v['title'];
  8307. }
  8308. $wh = array();
  8309. $w = $this->warehouse->find_all('1=1', 'id,title');
  8310. foreach ($w as $v) {
  8311. $wh[$v['id']] = $v['title'];
  8312. }
  8313. $list = array();
  8314. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8315. foreach ($rows as $key => $value) {
  8316. if (isset($wt[$value['type']])) {
  8317. $rows[$key]['type'] = $wt[$value['type']];
  8318. } else {
  8319. $rows[$key]['type'] = '未设置';
  8320. }
  8321. $bm = '03';
  8322. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8323. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8324. $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');
  8325. $details = array();
  8326. $cpid = array();
  8327. $cpbz = array();
  8328. $c = 0;
  8329. $g = 0;
  8330. $x = 0;
  8331. $t = 0;
  8332. $s = 0;
  8333. $q = 0;
  8334. foreach ($sd as $k => $v) {
  8335. if ($v['state'] == 0) {
  8336. $c++;
  8337. if ($v['cpid'] != 0) {
  8338. $cpid[$v['cpid']] = $v['cpid'];
  8339. }
  8340. if ($v['cpbz'] != '') {
  8341. $cpbz[$v['cpbz']] = $v['cpbz'];
  8342. }
  8343. }
  8344. if ($v['state'] != 9) {
  8345. $g++;
  8346. }
  8347. if ($v['state'] == 1) {
  8348. $x++;
  8349. }
  8350. if ($v['state'] == 2) {
  8351. $t++;
  8352. }
  8353. if ($v['state'] == 8) {
  8354. $s++;
  8355. }
  8356. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8357. $q++;
  8358. }
  8359. $details[$v['details']] = $v['details'];
  8360. }
  8361. $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'] . '"');
  8362. $rows[$key]['details'] = implode("、", $details);
  8363. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8364. $number = $value['number'];
  8365. $ftime = time() - 15 * 24 * 3600;
  8366. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8367. $rows[$key]['number'] = $g;
  8368. $rows[$key]['c'] = $c;
  8369. $rows[$key]['x'] = $x;
  8370. $rows[$key]['t'] = $t;
  8371. $rows[$key]['s'] = $s;
  8372. $rows[$key]['q'] = $q;
  8373. $rows[$key]['z'] = $z;
  8374. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8375. $features = explode('-', trim($features, '-'));
  8376. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8377. }
  8378. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8379. $final_list = [];
  8380. foreach ($list as $k => $v) {
  8381. if (empty($v['sku'])) {
  8382. continue;
  8383. }
  8384. $final_list[] = [
  8385. $v["warehouse"],
  8386. $v["purchase"],
  8387. $v["details"],
  8388. $v["cpid"],
  8389. $v["dbcontent"],
  8390. $v["sku"],
  8391. $v["bm"],
  8392. $v["jm"],
  8393. $v["title"],
  8394. $v["pm"],
  8395. $v["cpbz"],
  8396. $v["sm"],
  8397. $v["type"],
  8398. $v["number"],
  8399. $v["c"],
  8400. $v["x"],
  8401. $v["t"],
  8402. $v["s"],
  8403. $v["q"],
  8404. $v["z"],
  8405. $v['weight'],
  8406. ];
  8407. }
  8408. if(empty($final_list)){
  8409. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8410. }
  8411. $title = "总进销存统计表";
  8412. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8413. $merges = [
  8414. [
  8415. "s"=>["r"=>0,"c"=>0],
  8416. "e"=>["r"=>0,"c"=>21]
  8417. ]
  8418. ];
  8419. $cols = [
  8420. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8421. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8422. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8423. ];
  8424. array_unshift($final_list, $first_row);
  8425. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8426. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8427. }
  8428. public function _summaryjs($arg_array)
  8429. {
  8430. $prc = array();
  8431. $purchase = $this->purchase->find_all();
  8432. foreach ($purchase as $k => $v) {
  8433. $prc[$v['id']] = $v['title'];
  8434. }
  8435. if (isset($_GET['excel'])) {
  8436. $ktime = $this->input->get('ktime', true);
  8437. $jtime = $this->input->get('jtime', true);
  8438. $ktime = strtotime($ktime);
  8439. $jtime = strtotime($jtime);
  8440. $where = "1=1";
  8441. if ($ktime && $jtime) {
  8442. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8443. }
  8444. //数据排序
  8445. $order_str = "time desc";
  8446. if (empty($page)) {
  8447. $start = 0;
  8448. $perpage = 1;
  8449. } else {
  8450. $start = ($page - 1) * $perpage;
  8451. }
  8452. //取得信息列表
  8453. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8454. foreach ($info_list as $key => $value) {
  8455. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8456. $warehouse = $this->warehouse->read($value['warehouse']);
  8457. $info_list[$key]['warehouse'] = $warehouse['title'];
  8458. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8459. $details = array();
  8460. $cpid = array();
  8461. foreach ($x as $k => $v) {
  8462. if ($v['details'] != '') {
  8463. $details[$v['details']] = $v['details'];
  8464. }
  8465. if ($v['cpid'] != 0) {
  8466. $cpid[$v['cpid']] = $v['cpid'];
  8467. }
  8468. }
  8469. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8470. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8471. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8472. $info_list[$key]['s'] = $s;
  8473. $info_list[$key]['x'] = count($x);
  8474. }
  8475. if(empty($info_list)){
  8476. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8477. }
  8478. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8479. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8480. $merges = [
  8481. [
  8482. "s"=>["r"=>0,"c"=>0],
  8483. "e"=>["r"=>0,"c"=>7]
  8484. ]
  8485. ];
  8486. $cols = [
  8487. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8488. ];
  8489. $final_list = [];
  8490. foreach($info_list as $k => $v){
  8491. $final_list[] = array_values($v);
  8492. }
  8493. array_unshift($final_list, $first_row);
  8494. array_unshift($final_list,[
  8495. $title,"","","","","","","","",
  8496. ]);
  8497. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8498. $titlename = "<table border=1>
  8499. <tr align='center'>
  8500. <td>仓库</td>
  8501. <td>供应商</td>
  8502. <td>出库位置</td>
  8503. <td>出库编码</td>
  8504. <td>SKU</td>
  8505. <td>产品名</td>
  8506. <td>总剩余库存</td>
  8507. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8508. </tr>
  8509. </table>";
  8510. $filename = $title . ".xls";
  8511. $tail = "";
  8512. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8513. }
  8514. }
  8515. public function _uckjs()
  8516. {
  8517. if (isset($_GET['excel'])) {
  8518. $tc = array();
  8519. $typeclass = $this->typeclass->find_all();
  8520. foreach ($typeclass as $v) {
  8521. $tc[$v['id']] = $v['zh'];
  8522. }
  8523. $first_row = [
  8524. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8525. ];
  8526. $t = array();
  8527. $rq = '';
  8528. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8529. $ts = $ts / (24 * 3600);
  8530. for ($i = 0; $i < $ts; $i++) {
  8531. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8532. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8533. }
  8534. $day_len = count($t);
  8535. $first_row[] = "本月出库";
  8536. $merges = [
  8537. ];
  8538. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8539. $excel_key = 1;
  8540. $final_list = [];
  8541. foreach ($info_list as $k => $v) {
  8542. $features = explode('-', trim($v['features'], '-'));
  8543. if (!isset($features[3]) || !isset($features[4])) {
  8544. continue;
  8545. }
  8546. $tmp = [];
  8547. $tmp[0] = $tc[$features[0]]; //类型
  8548. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8549. $tmp[2] = $tc[$features[4]]; //曲度
  8550. $tmp[3] = '';
  8551. if (isset($data[$k][1])) {
  8552. $tmp[3] .=$tmp[1];
  8553. }
  8554. if (isset($data[$k][2])) {
  8555. $tmp[3] .= $tmp[2];
  8556. }
  8557. if (isset($features[5])) {
  8558. $tmp[3] .= $tc[$features[5]];
  8559. }
  8560. if (isset($features[2])) {
  8561. $tmp[3] .= $tc[$features[2]];
  8562. }
  8563. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8564. $tmp[4] = $v['sku'];
  8565. $tmp[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())) . '))'); //月初库存
  8566. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8567. $tmp[7] ="";
  8568. $tmp[8] ="";
  8569. $byck = 0;
  8570. foreach ($t as $vv) {
  8571. $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));
  8572. $tmp[] = ($sl > 0) ? $sl : '';
  8573. $byck += $sl;
  8574. }
  8575. $tmp[] = ($byck > 0) ? $byck : '';
  8576. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8577. // $ztrq = '';
  8578. // $ztsl = '';
  8579. // if (count($zt) > 0) {
  8580. // foreach ($zt as $vv) {
  8581. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8582. // $ztsl .= $vv['num'] . '<br>';
  8583. // }
  8584. // }
  8585. if(empty($zt)){
  8586. $final_list[] = $tmp;
  8587. $excel_key = $excel_key + 1;
  8588. }else{
  8589. $len = count($zt);
  8590. if($len == 1){
  8591. $tmp[7] = $zt[0]['num'] ;
  8592. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8593. $final_list[] = $tmp;
  8594. $excel_key = $excel_key + 1;
  8595. }else{
  8596. foreach($zt as $vv){
  8597. $tmp[7] = "";
  8598. $tmp[8] = "";
  8599. $tmp[7] = $vv['num'];
  8600. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8601. $final_list[] = $tmp;
  8602. }
  8603. $merges[] = [
  8604. "s"=>["r"=>$excel_key,"c"=>0],
  8605. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8606. ];
  8607. $merges[] = [
  8608. "s"=>["r"=>$excel_key,"c"=>1],
  8609. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8610. ];
  8611. $merges[] = [
  8612. "s"=>["r"=>$excel_key,"c"=>2],
  8613. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8614. ];
  8615. $merges[] = [
  8616. "s"=>["r"=>$excel_key,"c"=>3],
  8617. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8618. ];
  8619. $merges[] = [
  8620. "s"=>["r"=>$excel_key,"c"=>4],
  8621. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8622. ];
  8623. $merges[] = [
  8624. "s"=>["r"=>$excel_key,"c"=>5],
  8625. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8626. ];
  8627. $merges[] = [
  8628. "s"=>["r"=>$excel_key,"c"=>6],
  8629. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8630. ];
  8631. for($i=1;$i<=$day_len;$i++){
  8632. $merges[] = [
  8633. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8634. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8635. ];
  8636. }
  8637. $merges[] = [
  8638. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8639. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8640. ];
  8641. $excel_key = $excel_key + $len;
  8642. }
  8643. }
  8644. }
  8645. $title = "详情 " . date("Y-m-d", time());
  8646. if(empty($final_list)){
  8647. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8648. }
  8649. $cols = [
  8650. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8651. ];
  8652. array_unshift($final_list, $first_row);
  8653. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8654. }
  8655. }
  8656. public function _whlabelexcelzhjs(){
  8657. if(empty($_GET['excel'])){
  8658. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8659. }
  8660. $where = "sku != 'Preset' and sku != '' ";
  8661. //数据排序
  8662. $order_str = "id desc";
  8663. if (empty($page)) {
  8664. $start = 0;
  8665. $perpage = 1;
  8666. } else {
  8667. $start = ($page - 1) * $perpage;
  8668. }
  8669. $category = $this->input->get('category', true);
  8670. $warehouse = $this->input->get('warehouse', true);
  8671. $excelid = $this->input->get('sid', true);
  8672. if ($category) {
  8673. $where .= " and features like '%-$category-%'";
  8674. }
  8675. if ($warehouse) {
  8676. $where .= " and warehouse = '$warehouse'";
  8677. }
  8678. $xzid = '';
  8679. if ($excelid) {
  8680. $excelid = explode(',', trim($excelid, ','));
  8681. foreach ($excelid as $key => $value) {
  8682. $xzid .= " id = " . $value . " or";
  8683. }
  8684. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8685. }
  8686. $merges = [
  8687. [
  8688. "s"=>["r"=>0,"c"=>0],
  8689. "e"=>["r"=>0,"c"=>6]
  8690. ]
  8691. ];
  8692. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8693. $excel_index = 2;
  8694. $final_list = [];
  8695. foreach ($rows as $key => $value) {
  8696. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8697. $zh = '';
  8698. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8699. // foreach ($zt_list as $v) {
  8700. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8701. // }
  8702. $zt = array_sum(array_column($zt_list, 'num'));
  8703. $number = $value['number'];
  8704. $ftime = time() - 15 * 24 * 3600;
  8705. $warehouse = $this->warehouse->read($value['warehouse']);
  8706. // $rows[$key]['warehouse'] = $warehouse['title'];
  8707. // $rows[$key]['number'] = $c;
  8708. // $rows[$key]['features'] = $zh;
  8709. //$rows[$key]['hb'] = $c + $zt;
  8710. $tmp = [];
  8711. $tmp[0] = $warehouse['title'];
  8712. $tmp[1] = $value['sku'];
  8713. $tmp[2] = $value['title'];
  8714. $tmp[3] = $c;
  8715. $tmp[4] = "";
  8716. $tmp[5] = $c + $zt;
  8717. if(empty($zt_list)){
  8718. $tmp[4] = "";
  8719. $final_list[] = $tmp;
  8720. $excel_index = $excel_index + 1;
  8721. }else{
  8722. if(count($zt_list) == 1){
  8723. $tmp[4] = "";
  8724. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8725. $final_list[] = $tmp;
  8726. $excel_index = $excel_index + 1;
  8727. }else{
  8728. $len = count($zt_list);
  8729. foreach ($zt_list as $v){
  8730. $tmp[4] = "";
  8731. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8732. $final_list[] = $tmp;
  8733. }
  8734. $merges[] = [
  8735. "s"=>["r"=>$excel_index,"c"=>0],
  8736. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8737. ];
  8738. $merges[] = [
  8739. "s"=>["r"=>$excel_index,"c"=>1],
  8740. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8741. ];
  8742. $merges[] = [
  8743. "s"=>["r"=>$excel_index,"c"=>2],
  8744. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8745. ];
  8746. $merges[] = [
  8747. "s"=>["r"=>$excel_index,"c"=>3],
  8748. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8749. ];
  8750. $merges[] = [
  8751. "s"=>["r"=>$excel_index,"c"=>5],
  8752. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8753. ];
  8754. $excel_index = $excel_index + $len;
  8755. }
  8756. }
  8757. }
  8758. $first_row = [
  8759. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8760. ];
  8761. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8762. if(empty($final_list)){
  8763. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8764. }
  8765. $cols = [
  8766. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8767. ];
  8768. array_unshift($final_list, $first_row);
  8769. array_unshift($final_list, [
  8770. $title,"","","","",""
  8771. ]);
  8772. $end_list = [];
  8773. foreach ($final_list as $key => $value) {
  8774. $end_list[] = array_values($value);
  8775. }
  8776. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8777. }
  8778. //出库、退库导出
  8779. public function _dccrtypejs()
  8780. {
  8781. $classid = $this->classid->sku();
  8782. $pm = $classid;
  8783. $typeclass = array();
  8784. $tc = $this->typeclass->find_all();
  8785. foreach ($tc as $v) {
  8786. $typeclass[$v['id']] = $v;
  8787. }
  8788. $prc = array();
  8789. $purchase = $this->purchase->find_all();
  8790. foreach ($purchase as $k => $v) {
  8791. $prc[$v['id']] = $v['title'];
  8792. }
  8793. if (isset($_GET['sid'])) {
  8794. $wh = array();
  8795. $w = $this->warehouse->find_all('1=1', 'id,title');
  8796. foreach ($w as $v) {
  8797. $wh[$v['id']] = $v['title'];
  8798. }
  8799. $type = $this->input->get('excel', true);
  8800. $category = $this->input->get('category', true);
  8801. $size = $this->input->get('size', true);
  8802. $grade = $this->input->get('grade', true);
  8803. $color = $this->input->get('color', true);
  8804. $lowe = $this->input->get('lowe', true);
  8805. $sku = $this->input->get('sku', true);
  8806. $warehouse = $this->input->get('warehouse', true);
  8807. $lacetype = $this->input->get('lacetype', true);
  8808. $lacecolor = $this->input->get('lacecolor', true);
  8809. $density = $this->input->get('density', true);
  8810. $haircap = $this->input->get('haircap', true);
  8811. $purchase = $this->input->get('purchase', true);
  8812. $title = $this->input->get('title', true);
  8813. $state = $this->input->get('state', true);
  8814. $sid = $this->input->get('sid', true);
  8815. $ktime = $this->input->get('ktime', true);
  8816. $jtime = $this->input->get('jtime', true);
  8817. $ktime = strtotime($ktime);
  8818. $jtime = strtotime($jtime);
  8819. $where = "1=1";
  8820. $gj = "";
  8821. $ck = "";
  8822. if ($category) {
  8823. $where .= " and features like '%-$category-%'";
  8824. }
  8825. if ($size) {
  8826. $where .= " and features like '%-$size-%'";
  8827. }
  8828. if ($grade) {
  8829. $where .= " and features like '%-$grade-%'";
  8830. }
  8831. if ($color) {
  8832. $where .= " and features like '%-$color-%'";
  8833. }
  8834. if ($lowe) {
  8835. $where .= " and features like '%-$lowe-%'";
  8836. }
  8837. if ($warehouse) {
  8838. $where .= " and warehouse = '$warehouse'";
  8839. }
  8840. if ($purchase) {
  8841. $where .= " and purchase = '$purchase'";
  8842. }
  8843. if ($state) {
  8844. $where .= " and state = '$state'";
  8845. }
  8846. if ($lacetype) {
  8847. $where .= " and features like '%-$lacetype-%'";
  8848. }
  8849. if ($lacecolor) {
  8850. $where .= " and features like '%-$lacecolor-%'";
  8851. }
  8852. if ($density) {
  8853. $where .= " and features like '%-$density-%'";
  8854. }
  8855. if ($haircap) {
  8856. $where .= " and features like '%-$haircap-%'";
  8857. }
  8858. if ($title) {
  8859. $title = trim($title, ' ');
  8860. $title = trim($title, ' ');
  8861. $where .= " and title like '%$title%'";
  8862. }
  8863. if ($sku) {
  8864. $sku = trim($sku, ' ');
  8865. $sku = trim($sku, ' ');
  8866. $where .= " and sku like '%$sku%'";
  8867. }
  8868. if ($ktime && $jtime) {
  8869. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8870. }
  8871. $sidwhere = '';
  8872. if ($sid) {
  8873. $sd = "";
  8874. $s = explode(',', trim($sid, ','));
  8875. foreach ($s as $value) {
  8876. $sd .= " id = " . $value . " or";
  8877. }
  8878. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8879. }
  8880. //数据排序
  8881. $order_str = "time desc";
  8882. if (empty($page)) {
  8883. $start = 0;
  8884. $perpage = 1;
  8885. } else {
  8886. $start = ($page - 1) * $perpage;
  8887. }
  8888. $wh = array();
  8889. $w = $this->warehouse->find_all('1=1', 'id,title');
  8890. foreach ($w as $v) {
  8891. $wh[$v['id']] = $v['title'];
  8892. }
  8893. $wt = array();
  8894. $whlabel_type = $this->whlabel_type->find_all();
  8895. foreach ($whlabel_type as $v) {
  8896. $wt[$v['id']] = $v['title'];
  8897. }
  8898. $classid = $this->classid->sku();
  8899. $list = array();
  8900. $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');
  8901. foreach ($rows_r as $key => $value) {
  8902. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8903. $pm = $classid;
  8904. $jm = $classid;
  8905. $rows_r[$key]['enter'] = '入库';
  8906. $rows_r[$key]['time'] = $value['enter'];
  8907. if ($value['rktype'] == 1) {
  8908. $rows_r[$key]['rktype'] = '采购入库';
  8909. } else if ($value['rktype'] == 2) {
  8910. $rows_r[$key]['rktype'] = '盘盈调整';
  8911. } else if ($value['rktype'] == 3) {
  8912. $rows_r[$key]['rktype'] = '其他调整入库';
  8913. } else if ($value['rktype'] == 4) {
  8914. $rows_r[$key]['rktype'] = '其他调整入库';
  8915. } else if ($value['rktype'] == 5) {
  8916. $rows_r[$key]['rktype'] = '退库入库';
  8917. } else if ($value['rktype'] == 6) {
  8918. $rows_r[$key]['rktype'] = '退货可用入库';
  8919. } else if ($value['rktype'] == 7) {
  8920. $rows_r[$key]['rktype'] = '形态转换入库';
  8921. } else {
  8922. $rows_r[$key]['rktype'] = '';
  8923. }
  8924. $features = explode('-', trim($value['features'], '-'));
  8925. foreach ($features as $v) {
  8926. if (isset($typeclass[$v])) {
  8927. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8928. $pm[$typeclass[$v]['classid']] = $zh[0];
  8929. }
  8930. if (isset($typeclass[$v])) {
  8931. if (isset($jm[$typeclass[$v]['classid']])) {
  8932. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8933. }
  8934. }
  8935. }
  8936. $zh = implode(" ", $pm);
  8937. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8938. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8939. $rows_r[$key]['zh'] = $zh;
  8940. $jm = array_filter($jm);
  8941. $rows_r[$key]['features'] = implode("-", $jm);
  8942. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8943. }
  8944. $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');
  8945. foreach ($rows_c as $key => $value) {
  8946. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8947. $pm = $classid;
  8948. $jm = $classid;
  8949. $rows_c[$key]['time'] = $value['outk'];
  8950. $rows_c[$key]['outk'] = '出库';
  8951. if ($value['cktype'] == 1) {
  8952. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8953. } else if ($value['cktype'] == 2) {
  8954. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8955. } else if ($value['cktype'] == 3) {
  8956. $rows_c[$key]['cktype'] = '盘亏调整';
  8957. } else if ($value['cktype'] == 4) {
  8958. $rows_c[$key]['cktype'] = '其他调整出库';
  8959. } else if ($value['cktype'] == 5) {
  8960. $rows_c[$key]['cktype'] = '形态转换出库';
  8961. } else {
  8962. $rows_c[$key]['cktype'] = '';
  8963. }
  8964. unset($rows_c[$key]['state']);
  8965. $features = explode('-', trim($value['features'], '-'));
  8966. foreach ($features as $v) {
  8967. if (isset($typeclass[$v])) {
  8968. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8969. $pm[$typeclass[$v]['classid']] = $zh[0];
  8970. }
  8971. if (isset($typeclass[$v])) {
  8972. if (isset($jm[$typeclass[$v]['classid']])) {
  8973. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8974. }
  8975. }
  8976. }
  8977. $zh = implode(" ", $pm);
  8978. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8979. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8980. $rows_c[$key]['zh'] = $zh;
  8981. $jm = array_filter($jm);
  8982. $rows_c[$key]['features'] = implode("-", $jm);
  8983. $rows_c[$key]['number'] = 1;
  8984. }
  8985. $merged = $rows_r;
  8986. foreach ($rows_c as $key => $value) {
  8987. if (isset($merged[$key])) {
  8988. $merged[] = $value;
  8989. } else {
  8990. $merged[$key] = $value;
  8991. }
  8992. }
  8993. usort($merged, function ($a, $b) {
  8994. return $a['time'] - $b['time'];
  8995. });
  8996. foreach ($merged as $key => $value) {
  8997. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8998. }
  8999. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9000. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9001. $cols = [
  9002. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9003. ];
  9004. $final_list= [];
  9005. foreach($merged as $key => $value){
  9006. $final_list[] = array_values($value) ;
  9007. }
  9008. if(empty($merged)){
  9009. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9010. }
  9011. array_unshift($final_list, $first_row);
  9012. $end_list = [];
  9013. foreach ($final_list as $key => $value) {
  9014. $end_list[] = array_values($value);
  9015. }
  9016. $merges = [];
  9017. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9018. }
  9019. }
  9020. public function _errorexceljs()
  9021. {
  9022. $post = $this->input->post(NULL, TRUE);
  9023. if (isset($_GET['page'])) {
  9024. $page = $this->input->get('page', true);
  9025. $perpage = $this->input->get('perpage', true);
  9026. $sku = $this->input->get('sku', true);
  9027. $warehouse = $this->input->get('warehouse', true);
  9028. $ktime = $this->input->get('ktime', true);
  9029. $jtime = $this->input->get('jtime', true);
  9030. $ktime = strtotime($ktime);
  9031. $jtime = strtotime($jtime);
  9032. $where = "sku != 'Preset'";
  9033. $gj = '';
  9034. if ($sku) {
  9035. $where .= " and sku like '%$sku%'";
  9036. } else {
  9037. if ($ktime && $jtime) {
  9038. $gj = " and time > '$ktime' and time < '$jtime'";
  9039. }
  9040. }
  9041. if ($warehouse) {
  9042. $where .= " and warehouse = '$warehouse'";
  9043. }
  9044. //数据排序
  9045. $order_str = "id desc";
  9046. if (empty($page)) {
  9047. $start = 0;
  9048. $perpage = 1;
  9049. } else {
  9050. $start = ($page - 1) * $perpage;
  9051. }
  9052. //取得信息列表
  9053. $rows = array();
  9054. $list = array();
  9055. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9056. foreach ($info_list as $value) {
  9057. $warehouse = $this->warehouse->read($value['warehouse']);
  9058. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9059. $number = $value['number'];
  9060. $ftime = time() - 15 * 24 * 3600;
  9061. if ($c < 1) {
  9062. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9063. }
  9064. }
  9065. $title = "0库存汇总";
  9066. $first_row = ["仓库","SKU","产品","当前库存"];
  9067. $cols = [
  9068. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9069. ];
  9070. $final_list= [];
  9071. foreach($list as $key => $value){
  9072. $final_list[] = array_values($value) ;
  9073. }
  9074. if(empty($final_list)){
  9075. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9076. }
  9077. array_unshift($final_list, $first_row);
  9078. $merges = [];
  9079. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9080. }
  9081. }
  9082. }