Whlabel.php 316 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313
  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. }
  47. //定义方法的调用规则 获取URI第二段值
  48. public function _remap($arg, $arg_array)
  49. {
  50. if ($arg == 'existence') //在库标签
  51. {
  52. $this->_existence();
  53. } else if ($arg == 'cpbqdc') //在库标签
  54. {
  55. $this->_cpbqdc();
  56. } else if ($arg == 'type') //进销存浏览
  57. {
  58. $this->_type();
  59. } else if ($arg == 'typedy') //进销存浏览店员页面
  60. {
  61. $this->_typedy($arg_array);
  62. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  63. {
  64. $this->_typedy_ck($arg_array);
  65. } else if ($arg == 'typeck') {
  66. $this->_typeck($arg_array);
  67. } else if ($arg == 'whlabeckdc') {
  68. $this->_whlabeckdc($arg_array);
  69. } else if ($arg == 'usatype') //美仓进销存浏览
  70. {
  71. $this->_usatype();
  72. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  73. {
  74. $this->_usatypeapp();
  75. } else if ($arg == 'enteradd') //入库操作
  76. {
  77. $this->_enteradd();
  78. } else if ($arg == 'enteredit') //修改
  79. {
  80. $this->_enteredit($arg_array);
  81. } else if ($arg == 'enter') //入库浏览
  82. {
  83. $this->_enter();
  84. } else if ($arg == 'out') //出库浏览
  85. {
  86. $this->_out();
  87. } else if ($arg == 'label') //出库标签浏览
  88. {
  89. $this->_label();
  90. } else if ($arg == 'outorder') //独立站出库订单
  91. {
  92. $this->_outorder();
  93. } else if ($arg == 'soutorder') //速卖通出库订单
  94. {
  95. $this->_soutorder();
  96. } else if ($arg == 'toutorder') //TT出库订单
  97. {
  98. $this->_toutorder();
  99. }else if ($arg == 'aoutorder') //amz出库订单
  100. {
  101. $this->_aoutorder();
  102. } else if ($arg == 'retreat') //退库订单
  103. {
  104. $this->_retreat();
  105. } else if ($arg == 'retreatlk') //退库订单
  106. {
  107. $this->_retreatlk();
  108. } else if ($arg == 'change') //更换标签
  109. {
  110. $this->_change();
  111. } else if ($arg == 'del') //删除
  112. {
  113. $this->_del();
  114. } else if ($arg == 'exceljxc') //进销存信息导出
  115. {
  116. $this->_exceljxc();
  117. } else if ($arg == 'excelr') //入库信息导出
  118. {
  119. $this->_excelr();
  120. } else if ($arg == 'excelct') //出库、退库信息导出
  121. {
  122. $this->_excelct();
  123. } else if ($arg == 'dccrtype') //根据出入库类型导出
  124. {
  125. $this->_dccrtype();
  126. } else if ($arg == 'excelcr') //出库、退库信息导出
  127. {
  128. $this->_excelcr();
  129. } else if ($arg == 'kcyz') //库存验证
  130. {
  131. $this->_kcyz();
  132. } else if ($arg == 'kj') //库存扣减
  133. {
  134. $this->_kj($arg_array);
  135. } else if ($arg == 'presetout') //预设库存导入
  136. {
  137. $this->_presetout($arg_array);
  138. } else if ($arg == 'presetedit') //预设库存导入
  139. {
  140. $this->_presetedit($arg_array);
  141. }else if ($arg == 'presetedittwo') //预设库存导入
  142. {
  143. $this->_presetedittwo($arg_array);
  144. } else if ($arg == 'summary') //汇总导出
  145. {
  146. $this->_summary($arg_array);
  147. } else if ($arg == 'manifest') //usps发货清单
  148. {
  149. $this->_manifest();
  150. } else if ($arg == 'abnormal') //占单异常
  151. {
  152. $this->_abnormal();
  153. } else if ($arg == 'error') //0库存SKU
  154. {
  155. $this->_error();
  156. } else if ($arg == 'errorexcel') //0库存SKU导出
  157. {
  158. $this->_errorexcel();
  159. } else if ($arg == 'db') {
  160. $this->_db();
  161. } else if ($arg == 'dbrk') {
  162. $this->_dbrk();
  163. } else if ($arg == 'whlabelczdc') {
  164. $this->_whlabelczdc();
  165. } else if ($arg == 'print') {
  166. $this->_print($arg_array);
  167. } else if ($arg == 'usaprint') {
  168. $this->_usaprint($arg_array);
  169. } else if ($arg == 'printck') {
  170. $this->_printck($arg_array);
  171. } else if ($arg == 'printrk') {
  172. $this->_printrk($arg_array);
  173. } else if ($arg == 'printxzrk') {
  174. $this->_printxzrk($arg_array);
  175. } else if ($arg == 'printexcel') {
  176. $this->_printexcel($arg_array);
  177. } else if ($arg == 'uck') {
  178. $this->_uck();
  179. } else if ($arg == 'whlabelexcelzh') {
  180. $this->_whlabelexcelzh();
  181. } else if ($arg == 'fc') {
  182. $this->_fc();
  183. } else if ($arg == 'fcmb') {
  184. $this->_fcmb();
  185. } else if ($arg == 'fcexcel') {
  186. $this->_fcexcel();
  187. } else if ($arg == 'fcjxc') {
  188. $this->_fcjxc($arg_array);
  189. } else if ($arg == '0kcdel') {
  190. $this->_0kcdel(); //导表删除0库存
  191. } else if ($arg == 'gbhtype') {
  192. $this->_gbhtype(); //更改备货状态
  193. } else if($arg == 'excelrjs'){
  194. $this->_excelrjs();
  195. } else if($arg == 'excelctjs'){
  196. $this->_excelctjs();
  197. }else if ($arg == 'exceljxcjs') //进销存信息导出
  198. {
  199. $this->_exceljxcjs();
  200. } else if ($arg == 'summaryjs') //汇总导出
  201. {
  202. $this->_summaryjs($arg_array);
  203. }else if($arg == 'uckjs'){
  204. $this->_uckjs();
  205. }else if ($arg == 'whlabelexcelzhjs') {
  206. $this->_whlabelexcelzhjs();
  207. }else if($arg == 'dccrtypejs'){
  208. $this->_dccrtypejs();
  209. }else if($arg == 'errorexceljs'){
  210. $this->_errorexceljs();
  211. }else if($arg == "w_t_cs"){
  212. $this->_w_t_cs(); //首页
  213. }else {
  214. $this->_index();
  215. }
  216. }
  217. public function _w_t_cs(){
  218. $vip = 0;
  219. if (isset($_SESSION['api'])) {
  220. $user = $this->user->get_api($_SESSION['api']);
  221. $fgshop = "";
  222. $sid = "";
  223. $usersp = explode('|', trim($user['shop'], '|'));
  224. foreach ($usersp as $value) {
  225. $fgshop .= " shop = " . $value . " or";
  226. $sid .= " id = " . $value . " or";
  227. }
  228. if ($user['vip'] == 1) {
  229. $vip = 1;
  230. }
  231. } else {
  232. header('Location: /');
  233. exit;
  234. }
  235. $prc = array();
  236. $purchase = $this->purchase->find_all();
  237. foreach ($purchase as $k => $v) {
  238. $prc[$v['id']] = $v['title'];
  239. }
  240. $company = array();
  241. $ct = $this->company->find_all();
  242. foreach ($ct as $k => $v) {
  243. $company[$v['id']] = $v['title'];
  244. }
  245. $sp = array();
  246. $s = $this->shop->find_all('1=1', 'id,shopname');
  247. foreach ($s as $v) {
  248. $sp[$v['id']] = $v['shopname'];
  249. }
  250. $wh = array();
  251. $w = $this->warehouse->find_all('1=1', 'id,title');
  252. foreach ($w as $v) {
  253. $wh[$v['id']] = $v['title'];
  254. }
  255. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  256. $this->data['shop'] = $wlshop;
  257. $this->data['vip'] = $vip;
  258. $this->_Template('whlabel_typejs', $this->data);
  259. }
  260. //管理
  261. public function _index()
  262. {
  263. $post = $this->input->post(NULL, TRUE);
  264. if (isset($post['page'])) {
  265. $page = $this->input->post('page', true);
  266. $perpage = $this->input->post('perpage', true);
  267. $sku = $this->input->post('sku', true);
  268. $number = $this->input->post('number', true);
  269. $warehouse = $this->input->post('warehouse', true);
  270. $purchase = $this->input->post('purchase', true);
  271. $orderinfo = $this->input->post('orderinfo', true);
  272. $waybill = $this->input->post('waybill', true);
  273. $category = $this->input->post('category', true);
  274. $size = $this->input->post('size', true);
  275. $grade = $this->input->post('grade', true);
  276. $color = $this->input->post('color', true);
  277. $lowe = $this->input->post('lowe', true);
  278. $state = $this->input->post('state', true);
  279. $label = $this->input->post('label', true);
  280. $timetk = $this->input->post('timetkk', true);
  281. $timetj = $this->input->post('timetjj', true);
  282. $timetk = strtotime($timetk);
  283. $timetj = strtotime($timetj);
  284. $where = "1=1 ";
  285. if ($timetk && $timetj) {
  286. $where .= " and time > '$timetk' and time < '$timetj'";
  287. }
  288. if ($sku) {
  289. $where .= " and sku = '$sku'";
  290. }
  291. if ($number) {
  292. $where .= " and number = '$number'";
  293. }
  294. if ($warehouse) {
  295. $where .= " and warehouse = '$warehouse'";
  296. }
  297. if ($purchase) {
  298. $where .= " and purchase = '$purchase'";
  299. }
  300. if ($orderinfo) {
  301. $where .= " and orderinfo = '$orderinfo'";
  302. }
  303. if ($waybill) {
  304. $where .= " and waybill = '$waybill'";
  305. }
  306. if ($category) {
  307. $where .= " and features like '%-$category-%'";
  308. }
  309. if ($size) {
  310. $where .= " and features like '%-$size-%'";
  311. }
  312. if ($grade) {
  313. $where .= " and features like '%-$grade-%'";
  314. }
  315. if ($color) {
  316. $where .= " and features like '%-$color-%'";
  317. }
  318. if ($lowe) {
  319. $where .= " and features like '%-$lowe-%'";
  320. }
  321. if ($label) {
  322. $where .= " and label = '$label'";
  323. }
  324. if ($state != '') {
  325. $where .= " and state = '$state'";
  326. }
  327. //数据排序
  328. $order_str = "time desc";
  329. if (empty($page)) {
  330. $start = 0;
  331. $perpage = 1;
  332. } else {
  333. $start = ($page - 1) * $perpage;
  334. }
  335. //取得信息列表
  336. $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);
  337. foreach ($info_list as $key => $value) {
  338. $warehouse = $this->warehouse->read($value['warehouse']);
  339. $info_list[$key]['warehouse'] = $warehouse['title'];
  340. $purchase = $this->purchase->read($value['purchase']);
  341. $info_list[$key]['purchase'] = $purchase['title'];
  342. if ($value['enter'] != 0) {
  343. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  344. } else {
  345. $info_list[$key]['enter'] = "";
  346. }
  347. if ($value['outk'] != 0) {
  348. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  349. } else {
  350. $info_list[$key]['outk'] = "";
  351. }
  352. if ($value['printing'] != 0) {
  353. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  354. } else {
  355. $info_list[$key]['printing'] = "";
  356. }
  357. if ($value['orderinfo'] == 0) {
  358. $info_list[$key]['orderinfo'] = "";
  359. }
  360. if ($value['waybill'] == 0) {
  361. $info_list[$key]['waybill'] = "";
  362. }
  363. if ($value['state'] == 0) {
  364. $info_list[$key]['state'] = "在库";
  365. } else if ($value['state'] == 1) {
  366. $info_list[$key]['state'] = "出库";
  367. } else if ($value['state'] == 2) {
  368. $info_list[$key]['state'] = "退库";
  369. } else if ($value['state'] == 3) {
  370. $info_list[$key]['state'] = "调拨中";
  371. } else if ($value['state'] == 4) {
  372. $info_list[$key]['state'] = "再加工";
  373. } else if ($value['state'] == 5) {
  374. $info_list[$key]['state'] = "维修中";
  375. } else if ($value['state'] == 6) {
  376. $info_list[$key]['state'] = "盘亏";
  377. } else if ($value['state'] == 7) {
  378. $info_list[$key]['state'] = "更换标签";
  379. } else if ($value['state'] == 8) {
  380. $info_list[$key]['state'] = "其它";
  381. } else if ($value['state'] == 9) {
  382. $info_list[$key]['state'] = "预设";
  383. } else if ($value['state'] == 10) {
  384. $info_list[$key]['state'] = "美店零售";
  385. }
  386. if ($value['text'] == "") {
  387. $info_list[$key]['text'] = "";
  388. }
  389. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  390. }
  391. $total = $this->whlabel->find_count($where);
  392. $pagenum = ceil($total / $perpage);
  393. $over = $total - ($start + $perpage);
  394. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  395. echo json_encode($rows);
  396. exit;
  397. }
  398. if (isset($post['outsku'])) {
  399. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  400. $cz = $this->input->post('cz', true);
  401. if ($cz == '1') {
  402. $sku = $this->input->post('outsku', true);
  403. if ($sku) {
  404. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  405. if (count($data) < 1) {
  406. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  407. exit;
  408. }
  409. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  410. echo json_encode(array('success' => true));
  411. exit;
  412. }
  413. } else {
  414. $sku = $this->input->post('outsku', true);
  415. if ($sku) {
  416. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  417. if (count($data) < 1) {
  418. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  419. exit;
  420. }
  421. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  422. echo json_encode(array('success' => true));
  423. exit;
  424. }
  425. }
  426. }
  427. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  428. $this->_Template('whlabel', $this->data);
  429. }
  430. //在库标签
  431. public function _existence()
  432. {
  433. $post = $this->input->post(NULL, TRUE);
  434. if (isset($post['s'])) {
  435. $id_arr = $this->input->post('s');
  436. $id_arr = explode(',', $id_arr);
  437. if (!$id_arr) {
  438. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  439. exit;
  440. }
  441. //循环删除记录
  442. foreach ($id_arr as $v) {
  443. $sid = $this->whlabel->read($v);
  444. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  445. if ($count > 0) {
  446. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  447. exit;
  448. }
  449. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  450. if (count($zt) > 0) {
  451. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  452. exit;
  453. }
  454. $this->whlabel->remove($v);
  455. }
  456. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  457. exit;
  458. }
  459. if (isset($post['page'])) {
  460. $page = $this->input->post('page', true);
  461. $perpage = $this->input->post('perpage', true);
  462. $warehouse = $this->input->post('warehouse', true);
  463. $label = $this->input->post('label', true);
  464. $where = "1=1 and state = 0";
  465. if ($warehouse) {
  466. $where .= " and warehouse = '$warehouse'";
  467. }
  468. if ($label) {
  469. $where .= " and label = '$label'";
  470. }
  471. //数据排序
  472. $order_str = "time asc";
  473. if (empty($page)) {
  474. $start = 0;
  475. $perpage = 1;
  476. } else {
  477. $start = ($page - 1) * $perpage;
  478. }
  479. //取得信息列表
  480. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  481. foreach ($info_list as $key => $value) {
  482. if ($value['enter'] != 0) {
  483. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  484. } else {
  485. $info_list[$key]['enter'] = "";
  486. }
  487. if ($value['printing'] != 0) {
  488. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  489. } else {
  490. $info_list[$key]['printing'] = "";
  491. }
  492. }
  493. $total = $this->whlabel->find_count($where);
  494. $pagenum = ceil($total / $perpage);
  495. $over = $total - ($start + $perpage);
  496. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  497. echo json_encode($rows);
  498. exit;
  499. }
  500. $this->_Template('whlabel_existence', $this->data);
  501. }
  502. //进销存浏览
  503. public function _typedy($arg_array)
  504. {
  505. $prc = array();
  506. $purchase = $this->purchase->find_all();
  507. foreach ($purchase as $k => $v) {
  508. $prc[$v['id']] = $v['title'];
  509. }
  510. $post = $this->input->post(NULL, TRUE);
  511. if (isset($post['page'])) {
  512. $page = $this->input->post('page', true);
  513. $perpage = $this->input->post('perpage', true);
  514. $category = $this->input->post('category', true);
  515. $size = $this->input->post('size', true);
  516. $grade = $this->input->post('grade', true);
  517. $color = $this->input->post('color', true);
  518. $lowe = $this->input->post('lowe', true);
  519. $sku = $this->input->post('sku');
  520. $title = $this->input->post('title');
  521. $warehouse = $this->input->post('warehouse', true);
  522. $usa = $this->input->post('usa', true);
  523. $purchase = $this->input->post('purchase', true);
  524. $lacetype = $this->input->post('lacetype', true);
  525. $haircap = $this->input->post('haircap', true);
  526. $density = $this->input->post('density', true);
  527. $details = $this->input->post('details', true);
  528. $state = $this->input->post('state', true);
  529. $lacecolor = $this->input->post('lacecolor', true);
  530. $hairnumber = $this->input->post('hairnumber', true);
  531. $cklx = $this->input->post('cklx', true);
  532. $ktime = $this->input->post('ktime', true);
  533. $jtime = $this->input->post('jtime', true);
  534. $sm = $this->input->post('sm', true);
  535. $cpbz = $this->input->post('cpbz', true);
  536. $type = $this->input->post('type', true);
  537. $ktime = strtotime($ktime);
  538. $jtime = strtotime($jtime);
  539. $where = "1=1";
  540. $gj = "";
  541. $ck = "";
  542. if ($usa) {
  543. if (!$warehouse) {
  544. $where .= " and (warehouse = '5' or warehouse = '8')";
  545. }
  546. }
  547. if ($warehouse) {
  548. $where .= " and warehouse = '$warehouse'";
  549. }
  550. if ($details) {
  551. $where .= " and details = '$details'";
  552. }
  553. if ($purchase) {
  554. $where .= " and purchase = '$purchase'";
  555. }
  556. if (isset($state)) {
  557. if($state >-1){
  558. $where .= " and state = '$state'";
  559. }
  560. }
  561. if ($lacetype) {
  562. $where .= " and features like '%-$lacetype-%'";
  563. }
  564. if ($category) {
  565. $where .= " and features like '%-$category-%'";
  566. }
  567. if ($size) {
  568. $where .= " and features like '%-$size-%'";
  569. }
  570. if ($grade) {
  571. $where .= " and features like '%-$grade-%'";
  572. }
  573. if ($color) {
  574. $where .= " and features like '%-$color-%'";
  575. }
  576. if ($lowe) {
  577. $where .= " and features like '%-$lowe-%'";
  578. }
  579. if ($haircap) {
  580. $where .= " and features like '%-$haircap-%'";
  581. }
  582. if ($density) {
  583. $where .= " and features like '%-$density-%'";
  584. }
  585. if ($lacecolor) {
  586. $where .= " and features like '%-$lacecolor-%'";
  587. }
  588. if($sm){
  589. $where .= " and sm like '%".$sm."%'";
  590. }
  591. if($cpbz){
  592. $where .= " and cpbz like '%".$cpbz."%'";
  593. }
  594. if($type){
  595. $where .= " and type = ".$type."";
  596. }
  597. if (!empty($hairnumber)) {
  598. $where .= " and features like '%-128-%' ";
  599. if ($hairnumber < 0) {
  600. $class_list = $this->typeclass->find_all('classid = 43');
  601. foreach ($class_list as $v) {
  602. $where .= " and features not like '%-" . $v['id'] . "-%'";
  603. }
  604. } else {
  605. $where .= " and features like '%-$hairnumber-%'";
  606. }
  607. }
  608. $where_add = '';
  609. if ($cklx) {
  610. $shop = $this->shop->read($cklx);
  611. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  612. }
  613. if ($ktime && $jtime) {
  614. $gj = " and enter > '$ktime' and enter < '$jtime'";
  615. $ck = " and outk > '$ktime' and outk < '$jtime'";
  616. }
  617. //数据排序
  618. $order_str = "id desc";
  619. if (empty($page)) {
  620. $start = 0;
  621. $perpage = 1;
  622. } else {
  623. $start = ($page - 1) * $perpage;
  624. }
  625. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  626. if ($sku) {
  627. $sku = trim($sku, ' ');
  628. $sku = trim($sku, ' ');
  629. $where .= " and sku like '%$sku%'";
  630. $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);
  631. } else if ($title) {
  632. $title = trim($title, ' ');
  633. $title = trim($title, ' ');
  634. $where .= " and title like '%$title%'";
  635. $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);
  636. } else {
  637. //$where .= " and time > '$ktime' and time < '$jtime'";
  638. $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);
  639. }
  640. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  641. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  642. foreach ($info_list as $k => $v) {
  643. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  644. unset($info_list[$k]['pm']);
  645. unset($info_list[$k]['jm']);
  646. unset($info_list[$k]['bm']);
  647. }
  648. //取得信息列表
  649. $rows = array();
  650. $list = array();
  651. foreach ($info_list as $key => $value) {
  652. $warehouse = $this->warehouse->read($value['warehouse']);
  653. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  654. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  655. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  656. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  657. $info_list[$key]['label'] = $value['sm'];
  658. $number = $value['number'];
  659. $ftime = time() - 15 * 24 * 3600;
  660. $info_list[$key]['warehouse'] = $warehouse['title'];
  661. $info_list[$key]['features'] = count($c);
  662. $z = count($z); //查看订单号
  663. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  664. $ztdata = '';
  665. if (count($zt) > 0) {
  666. foreach ($zt as $vv) {
  667. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  668. }
  669. }
  670. $info_list[$key]['number'] = $ztdata;
  671. $info_list[$key]['sm'] = $z;
  672. $details = array();
  673. $cpid = array();
  674. foreach ($c as $k => $v) {
  675. $details[$v['details']] = $v['details'];
  676. if ($v['cpid'] != 0) {
  677. $cpid[$v['cpid']] = $v['cpid'];
  678. }
  679. }
  680. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  681. if ($value['shop'] != '') {
  682. $shop = explode(',', trim($value['shop'], ','));
  683. $shop = $this->shop->read($shop[0]);
  684. $info_list[$key]['shop'] = $shop['shopname'];
  685. }
  686. }
  687. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  688. $pagenum = ceil($total / $perpage);
  689. $over = $total - ($start + $perpage);
  690. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  691. echo json_encode($rows);
  692. exit;
  693. }
  694. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  695. $this->_Template('whlabel_typedy', $this->data);
  696. }
  697. //进销存浏览
  698. public function _typedy_ck($arg_array)
  699. {
  700. $prc = array();
  701. $purchase = $this->purchase->find_all();
  702. foreach ($purchase as $k => $v) {
  703. $prc[$v['id']] = $v['title'];
  704. }
  705. $post = $this->input->post(NULL, TRUE);
  706. if (isset($post['page'])) {
  707. $page = $this->input->post('page', true);
  708. $perpage = $this->input->post('perpage', true);
  709. $category = $this->input->post('category', true);
  710. $size = $this->input->post('size', true);
  711. $grade = $this->input->post('grade', true);
  712. $color = $this->input->post('color', true);
  713. $lowe = $this->input->post('lowe', true);
  714. $sku = $this->input->post('sku');
  715. $title = $this->input->post('title');
  716. $warehouse = $this->input->post('warehouse', true);
  717. $usa = $this->input->post('usa', true);
  718. $purchase = $this->input->post('purchase', true);
  719. $lacetype = $this->input->post('lacetype', true);
  720. $haircap = $this->input->post('haircap', true);
  721. $density = $this->input->post('density', true);
  722. $details = $this->input->post('details', true);
  723. $state = $this->input->post('state', true);
  724. $lacecolor = $this->input->post('lacecolor', true);
  725. $cklx = $this->input->post('cklx', true);
  726. $ktime = $this->input->post('ktime', true);
  727. $jtime = $this->input->post('jtime', true);
  728. $ktime = strtotime($ktime);
  729. $jtime = strtotime($jtime);
  730. $where = "1=1";
  731. $gj = "";
  732. $ck = "";
  733. if ($lacetype) {
  734. $where .= " and features like '%-$lacetype-%'";
  735. }
  736. if ($category) {
  737. $where .= " and features like '%-$category-%'";
  738. }
  739. if ($size) {
  740. $where .= " and features like '%-$size-%'";
  741. }
  742. if ($grade) {
  743. $where .= " and features like '%-$grade-%'";
  744. }
  745. if ($color) {
  746. $where .= " and features like '%-$color-%'";
  747. }
  748. if ($lowe) {
  749. $where .= " and features like '%-$lowe-%'";
  750. }
  751. if ($haircap) {
  752. $where .= " and features like '%-$haircap-%'";
  753. }
  754. if ($density) {
  755. $where .= " and features like '%-$density-%'";
  756. }
  757. if ($lacecolor) {
  758. $where .= " and features like '%-$lacecolor-%'";
  759. }
  760. if ($usa) {
  761. if (!$warehouse) {
  762. $where .= " and (warehouse = '5' or warehouse = '8')";
  763. }
  764. }
  765. if ($warehouse) {
  766. $where .= " and warehouse = '$warehouse'";
  767. }
  768. if ($details) {
  769. $where .= " and details = '$details'";
  770. }
  771. if ($purchase) {
  772. $where .= " and purchase = '$purchase'";
  773. }
  774. if ($state) {
  775. $where .= " and state = '$state'";
  776. }
  777. $where_add = '';
  778. if ($cklx) {
  779. $shop = $this->shop->read($cklx);
  780. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  781. }
  782. if ($ktime && $jtime) {
  783. $gj = " and enter > '$ktime' and enter < '$jtime'";
  784. $ck = " and outk > '$ktime' and outk < '$jtime'";
  785. }
  786. //数据排序
  787. $order_str = "id desc";
  788. if (empty($page)) {
  789. $start = 0;
  790. $perpage = 1;
  791. } else {
  792. $start = ($page - 1) * $perpage;
  793. }
  794. if ($sku) {
  795. $sku = trim($sku, ' ');
  796. $sku = trim($sku, ' ');
  797. $where .= " and sku like '%$sku%'";
  798. $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);
  799. } else if ($title) {
  800. $title = trim($title, ' ');
  801. $title = trim($title, ' ');
  802. $where .= " and title like '%$title%'";
  803. $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);
  804. } else {
  805. //$where .= " and time > '$ktime' and time < '$jtime'";
  806. $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);
  807. }
  808. //取得信息列表
  809. $rows = array();
  810. $list = array();
  811. foreach ($info_list as $key => $value) {
  812. $warehouse = $this->warehouse->read($value['warehouse']);
  813. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  814. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  815. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  816. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  817. $ftime = time() - 15 * 24 * 3600;
  818. $info_list[$key]['warehouse'] = $warehouse['title'];
  819. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  820. //$z = count($z);//查看订单号
  821. //$info_list[$key]['zd'] = $z;
  822. $details = array();
  823. $cpid = array();
  824. foreach ($c as $k => $v) {
  825. $details[$v['details']] = $v['details'];
  826. if ($v['cpid'] != 0) {
  827. $cpid[$v['cpid']] = $v['cpid'];
  828. }
  829. }
  830. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  831. if ($value['shop'] != '') {
  832. $shop = explode(',', trim($value['shop'], ','));
  833. $shop = $this->shop->read($shop[0]);
  834. $info_list[$key]['shop'] = $shop['shopname'];
  835. }
  836. }
  837. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  838. $pagenum = ceil($total / $perpage);
  839. $over = $total - ($start + $perpage);
  840. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  841. echo json_encode($rows);
  842. exit;
  843. }
  844. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  845. $this->_Template('whlabel_typedy_ck', $this->data);
  846. }
  847. public function _typeck($arg_array)
  848. {
  849. $prc = array();
  850. $purchase = $this->purchase->find_all();
  851. foreach ($purchase as $k => $v) {
  852. $prc[$v['id']] = $v['title'];
  853. }
  854. $post = $this->input->post(NULL, TRUE);
  855. if (isset($post['page'])) {
  856. $page = $this->input->post('page', true);
  857. $perpage = $this->input->post('perpage', true);
  858. $category = $this->input->post('category', true);
  859. $size = $this->input->post('size', true);
  860. $grade = $this->input->post('grade', true);
  861. $color = $this->input->post('color', true);
  862. $lacecolor = $this->input->post('lacecolor', true);
  863. $lowe = $this->input->post('lowe', true);
  864. $sku = $this->input->post('sku');
  865. $title = $this->input->post('title');
  866. $warehouse = 13;
  867. $usa = $this->input->post('usa', true);
  868. $purchase = $this->input->post('purchase', true);
  869. $lacetype = $this->input->post('lacetype', true);
  870. $haircap = $this->input->post('haircap', true);
  871. $density = $this->input->post('density', true);
  872. $details = $this->input->post('details', true);
  873. $state = $this->input->post('state', true);
  874. $ktime = $this->input->post('ktime', true);
  875. $jtime = $this->input->post('jtime', true);
  876. $ktime = strtotime($ktime);
  877. $jtime = strtotime($jtime);
  878. $where = "1=1";
  879. $gj = "";
  880. $ck = "";
  881. if ($lacetype) {
  882. $where .= " and features like '%-$lacetype-%'";
  883. }
  884. if ($category) {
  885. $where .= " and features like '%-$category-%'";
  886. }
  887. if ($size) {
  888. $where .= " and features like '%-$size-%'";
  889. }
  890. if ($grade) {
  891. $where .= " and features like '%-$grade-%'";
  892. }
  893. if ($color) {
  894. $where .= " and features like '%-$color-%'";
  895. }
  896. if ($lacecolor) {
  897. $where .= " and features like '%-$lacecolor-%'";
  898. }
  899. if ($lowe) {
  900. $where .= " and features like '%-$lowe-%'";
  901. }
  902. if ($haircap) {
  903. $where .= " and features like '%-$haircap-%'";
  904. }
  905. if ($density) {
  906. $where .= " and features like '%-$density-%'";
  907. }
  908. if ($warehouse) {
  909. $where .= " and warehouse = '$warehouse'";
  910. }
  911. if ($details) {
  912. $where .= " and details = '$details'";
  913. }
  914. if ($purchase) {
  915. $where .= " and purchase = '$purchase'";
  916. }
  917. if ($state) {
  918. $where .= " and state = '$state'";
  919. }
  920. if ($ktime && $jtime) {
  921. $gj = " and enter > '$ktime' and enter < '$jtime'";
  922. $ck = " and outk > '$ktime' and outk < '$jtime'";
  923. }
  924. //数据排序
  925. $order_str = "id desc";
  926. if (empty($page)) {
  927. $start = 0;
  928. $perpage = 1;
  929. } else {
  930. $start = ($page - 1) * $perpage;
  931. }
  932. if ($sku) {
  933. $sku = trim($sku, ' ');
  934. $sku = trim($sku, ' ');
  935. $where .= " and sku like '%$sku%'";
  936. } else if ($title) {
  937. $title = trim($title, ' ');
  938. $title = trim($title, ' ');
  939. $where .= " and title like '%$title%'";
  940. }
  941. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  942. //取得信息列表
  943. $t = array();
  944. $typeclass = $this->typeclass->find_all();
  945. foreach ($typeclass as $v) {
  946. $t[$v['id']] = $v;
  947. }
  948. $rows = array();
  949. $list = array();
  950. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  951. foreach ($info_list as $key => $value) {
  952. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  953. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  954. $warehouse = $this->warehouse->read($value['warehouse']);
  955. $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');
  956. $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'] . '"');
  957. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  958. $number = $value['number'];
  959. $ftime = time() - 15 * 24 * 3600;
  960. $z = count($z); //查看订单号
  961. $info_list[$key]['warehouse'] = $warehouse['title'];
  962. $info_list[$key]['features'] = count($c);
  963. $info_list[$key]['number'] = $z;
  964. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  965. $details = array();
  966. $cpid = array();
  967. foreach ($c as $k => $v) {
  968. $details[$v['details']] = $v['details'];
  969. if ($v['cpid'] != 0) {
  970. $cpid[$v['cpid']] = $v['cpid'];
  971. }
  972. }
  973. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  974. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  975. unset($info_list[$key]['pm']);
  976. unset($info_list[$key]['jm']);
  977. unset($info_list[$key]['bm']);
  978. }
  979. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  980. $pagenum = ceil($total / $perpage);
  981. $over = $total - ($start + $perpage);
  982. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  983. echo json_encode($rows);
  984. exit;
  985. }
  986. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  987. $this->_Template('whlabel_typeck', $this->data);
  988. }
  989. //进销存导出
  990. public function _whlabeckdc()
  991. {
  992. $prc = array();
  993. $purchase = $this->purchase->find_all();
  994. foreach ($purchase as $k => $v) {
  995. $prc[$v['id']] = $v['title'];
  996. }
  997. if (isset($_GET['excel'])) {
  998. $where = "sku != 'Preset'";
  999. //数据排序
  1000. $order_str = "id desc";
  1001. if (empty($page)) {
  1002. $start = 0;
  1003. $perpage = 1;
  1004. } else {
  1005. $start = ($page - 1) * $perpage;
  1006. }
  1007. $category = $this->input->get('category', true);
  1008. $color = $this->input->get('color', true);
  1009. $lowe = $this->input->get('lowe', true);
  1010. $lacetype = $this->input->get('lacetype', true);
  1011. $size = $this->input->get('size', true);
  1012. $density = $this->input->get('density', true);
  1013. $haircap = $this->input->get('haircap', true);
  1014. $sku = $this->input->get('sku', true);
  1015. $details = $this->input->get('details', true);
  1016. $warehouse = 13;
  1017. $excelid = $this->input->get('sid', true);
  1018. if ($category) {
  1019. $where .= " and features like '%-$category-%'";
  1020. }
  1021. if ($color) {
  1022. $where .= " and features like '%-$color-%'";
  1023. }
  1024. if ($lowe) {
  1025. $where .= " and features like '%-$lowe-%'";
  1026. }
  1027. if ($lacetype) {
  1028. $where .= " and features like '%-$lacetype-%'";
  1029. }
  1030. if ($size) {
  1031. $where .= " and features like '%-$size-%'";
  1032. }
  1033. if ($density) {
  1034. $where .= " and features like '%-$density-%'";
  1035. }
  1036. if ($haircap) {
  1037. $where .= " and features like '%-$haircap-%'";
  1038. }
  1039. if ($warehouse) {
  1040. $where .= " and warehouse = '$warehouse'";
  1041. }
  1042. if ($sku) {
  1043. $where .= " and sku like '%$sku%'";
  1044. }
  1045. if ($details) {
  1046. $where .= " and details = '$details'";
  1047. }
  1048. $xzid = '';
  1049. if ($excelid) {
  1050. $excelid = explode(',', trim($excelid, ','));
  1051. foreach ($excelid as $key => $value) {
  1052. $xzid .= " id = " . $value . " or";
  1053. }
  1054. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1055. }
  1056. //取得信息列表
  1057. /**
  1058. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1059. $rows = array();$list = array();
  1060. foreach ($info_list as $key=>$value)
  1061. {
  1062. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1063. }
  1064. **/
  1065. $wh = array();
  1066. $w = $this->warehouse->find_all('1=1', 'id,title');
  1067. foreach ($w as $v) {
  1068. $wh[$v['id']] = $v['title'];
  1069. }
  1070. $tc = array();
  1071. $tcdata = array();
  1072. $list = array();
  1073. $classid = $this->classid->sku();
  1074. $tcall = $this->typeclass->find_all();
  1075. $typeclass = array();
  1076. foreach ($tcall as $v)
  1077. {
  1078. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1079. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1080. }
  1081. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1082. foreach ($rows as $key => $value) {
  1083. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1084. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1085. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1086. $rows[$key]['cpbz'] = $u9_info['bm'];
  1087. $rows[$key]['cs'] = $u9_info['jm'];
  1088. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1089. $details = array();
  1090. $cpid = array();
  1091. $cpbz = array();
  1092. $c = 0;
  1093. $g = 0;
  1094. $x = 0;
  1095. $t = 0;
  1096. $s = 0;
  1097. $q = 0;
  1098. foreach ($sd as $k => $v) {
  1099. if ($v['state'] == 0) {
  1100. $c++;
  1101. }
  1102. if ($v['state'] != 9) {
  1103. $g++;
  1104. }
  1105. if ($v['state'] == 1) {
  1106. $x++;
  1107. }
  1108. if ($v['state'] == 2) {
  1109. $t++;
  1110. }
  1111. if ($v['state'] == 8) {
  1112. $s++;
  1113. }
  1114. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1115. $q++;
  1116. }
  1117. $details[$v['details']] = $v['details'];
  1118. if ($v['cpid'] != 0) {
  1119. $cpid[$v['cpid']] = $v['cpid'];
  1120. }
  1121. if ($v['cpbz'] != '') {
  1122. $cpbz[$v['cpbz']] = $v['cpbz'];
  1123. }
  1124. }
  1125. $rows[$key]['details'] = implode("、", $details);
  1126. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1127. $number = $value['number'];
  1128. $ftime = time() - 15 * 24 * 3600;
  1129. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1130. $rows[$key]['number'] = $g;
  1131. $rows[$key]['features'] = $c;
  1132. $rows[$key]['x'] = $x;
  1133. $rows[$key]['t'] = $t;
  1134. $rows[$key]['s'] = $s;
  1135. $rows[$key]['q'] = $q;
  1136. $rows[$key]['wzsl'] = count($details);
  1137. }
  1138. $title = "进销存统计表" . date('Y-m-d', time());
  1139. $titlename = "<table border=1>
  1140. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1141. <tr align='center'>
  1142. <td>仓库</td>
  1143. <td>供应商</td>
  1144. <td>位置</td>
  1145. <td>库存编码</td>
  1146. <td>SKU</td>
  1147. <td>用友编码</td>
  1148. <td>用友料号</td>
  1149. <td>产品英文名</td>
  1150. <td>产品中文名</td>
  1151. <td>入库总量</td>
  1152. <td>库存数量</td>
  1153. <td>销售数量</td>
  1154. <td>退货数量</td>
  1155. <td>删除数量</td>
  1156. <td>其它操作</td>
  1157. <td>位置数量</td>
  1158. </tr>
  1159. </table>";
  1160. $filename = $title . ".xls";
  1161. $tail = "";
  1162. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1163. }
  1164. }
  1165. public function _type()
  1166. {
  1167. $vip = 0;
  1168. if (isset($_SESSION['api'])) {
  1169. $user = $this->user->get_api($_SESSION['api']);
  1170. $fgshop = "";
  1171. $sid = "";
  1172. $usersp = explode('|', trim($user['shop'], '|'));
  1173. foreach ($usersp as $value) {
  1174. $fgshop .= " shop = " . $value . " or";
  1175. $sid .= " id = " . $value . " or";
  1176. }
  1177. if ($user['vip'] == 1) {
  1178. $vip = 1;
  1179. }
  1180. } else {
  1181. header('Location: /');
  1182. exit;
  1183. }
  1184. $prc = array();
  1185. $purchase = $this->purchase->find_all();
  1186. foreach ($purchase as $k => $v) {
  1187. $prc[$v['id']] = $v['title'];
  1188. }
  1189. $company = array();
  1190. $ct = $this->company->find_all();
  1191. foreach ($ct as $k => $v) {
  1192. $company[$v['id']] = $v['title'];
  1193. }
  1194. $sp = array();
  1195. $s = $this->shop->find_all('1=1', 'id,shopname');
  1196. foreach ($s as $v) {
  1197. $sp[$v['id']] = $v['shopname'];
  1198. }
  1199. $wh = array();
  1200. $w = $this->warehouse->find_all('1=1', 'id,title');
  1201. foreach ($w as $v) {
  1202. $wh[$v['id']] = $v['title'];
  1203. }
  1204. $post = $this->input->post(NULL, TRUE);
  1205. if (isset($post['page'])) {
  1206. $page = $this->input->post('page', true);
  1207. $perpage = $this->input->post('perpage', true);
  1208. $category = $this->input->post('category', true);
  1209. $size = $this->input->post('size', true);
  1210. $grade = $this->input->post('grade', true);
  1211. $color = $this->input->post('color', true);
  1212. $lowe = $this->input->post('lowe', true);
  1213. $sku = $this->input->post('sku');
  1214. $title = $this->input->post('title');
  1215. $warehouse = $this->input->post('warehouse', true);
  1216. $usa = $this->input->post('usa', true);
  1217. $purchase = $this->input->post('purchase', true);
  1218. $lacetype = $this->input->post('lacetype', true);
  1219. $haircap = $this->input->post('haircap', true);
  1220. $density = $this->input->post('density', true);
  1221. $details = $this->input->post('details', true);
  1222. $state = $this->input->post('state', true);
  1223. $shop = $this->input->post('shop', true);
  1224. $lacecolor = $this->input->post('lacecolor', true);
  1225. $hairnumber = $this->input->post('hairnumber', true);
  1226. $type = $this->input->post('type', true);
  1227. $ktime = $this->input->post('ktime', true);
  1228. $jtime = $this->input->post('jtime', true);
  1229. $ktime = strtotime($ktime);
  1230. $jtime = strtotime($jtime);
  1231. $cpbz = $this->input->post('cpbz', true);
  1232. $sm = $this->input->post('sm', true);
  1233. $where = "1=1";
  1234. $gj = "";
  1235. $ck = "";
  1236. if ($usa) {
  1237. if (!$warehouse) {
  1238. $where .= " and (warehouse = '5' or warehouse = '8')";
  1239. }
  1240. }
  1241. if ($warehouse) {
  1242. $where .= " and warehouse = '$warehouse'";
  1243. }
  1244. if ($details) {
  1245. $where .= " and details = '$details'";
  1246. }
  1247. if ($purchase) {
  1248. $where .= " and purchase = '$purchase'";
  1249. }
  1250. if ($state) {
  1251. $where .= " and state = '$state'";
  1252. }
  1253. if ($shop) {
  1254. $where .= " and shop like '%$shop%'";
  1255. }
  1256. if ($type) {
  1257. $where .= " and type = '$type'";
  1258. }
  1259. if ($ktime && $jtime) {
  1260. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1261. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1262. }
  1263. if ($cpbz) {
  1264. $where .= " and cpbz like '%$cpbz%' ";
  1265. }
  1266. if ($sm) {
  1267. $where .= " and sm like '%$sm%' ";
  1268. }
  1269. if ($lacecolor) {
  1270. $where .= " and features like '%-$lacecolor-%'";
  1271. }
  1272. if ($lacetype) {
  1273. $where .= " and features like '%-$lacetype-%'";
  1274. }
  1275. if ($category) {
  1276. $where .= " and features like '%-$category-%'";
  1277. }
  1278. if ($size) {
  1279. $where .= " and features like '%-$size-%'";
  1280. }
  1281. if ($grade) {
  1282. $where .= " and features like '%-$grade-%'";
  1283. }
  1284. if ($color) {
  1285. $where .= " and features like '%-$color-%'";
  1286. }
  1287. if ($lowe) {
  1288. $where .= " and features like '%-$lowe-%'";
  1289. }
  1290. if ($haircap) {
  1291. $where .= " and features like '%-$haircap-%'";
  1292. }
  1293. if ($density) {
  1294. $where .= " and features like '%-$density-%'";
  1295. }
  1296. if (!empty($hairnumber)) {
  1297. $where .= " and features like '%-128-%' ";
  1298. if ($hairnumber < 0) {
  1299. $class_list = $this->typeclass->find_all('classid = 43');
  1300. foreach ($class_list as $v) {
  1301. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1302. }
  1303. } else {
  1304. $where .= " and features like '%-$hairnumber-%'";
  1305. }
  1306. }
  1307. //数据排序
  1308. $order_str = "id desc";
  1309. if (empty($page)) {
  1310. $start = 0;
  1311. $perpage = 1;
  1312. } else {
  1313. $start = ($page - 1) * $perpage;
  1314. }
  1315. $fjnr = '';
  1316. if ($sku) {
  1317. $sku = trim($sku, ' ');
  1318. $sku = trim($sku, ' ');
  1319. $fjnr .= " and sku like '%$sku%'";
  1320. }
  1321. if ($title) {
  1322. $title = trim($title, ' ');
  1323. $title = trim($title, ' ');
  1324. $fjnr .= " and title like '%$title%'";
  1325. }
  1326. $wt = array();
  1327. $whlabel_type = $this->whlabel_type->find_all();
  1328. foreach ($whlabel_type as $v) {
  1329. $wt[$v['id']] = $v['title'];
  1330. }
  1331. //$where .= " and time > '$ktime' and time < '$jtime'";
  1332. $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
  1333. //取得信息列表
  1334. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1335. $rows = array();
  1336. $list = array();
  1337. foreach ($info_list as $key => $value) {
  1338. if (isset($wt[$value['type']])) {
  1339. $info_list[$key]['type'] = $wt[$value['type']];
  1340. } else {
  1341. $info_list[$key]['type'] = '未设置';
  1342. }
  1343. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1344. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1345. $ztdata = '';
  1346. if (count($zt) > 0) {
  1347. foreach ($zt as $vv) {
  1348. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1349. }
  1350. }
  1351. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1352. $cdata = array_filter($qbdata, function ($item) {
  1353. return $item['state'] < 1;
  1354. });
  1355. $c = array_sum(array_column($cdata, 'jnum'));
  1356. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1357. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1358. });
  1359. $g = array_sum(array_column($gdata, 'jnum'));
  1360. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1361. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1362. });
  1363. $x = array_sum(array_column($xdata, 'jnum'));
  1364. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1365. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1366. });
  1367. $t = array_sum(array_column($tdata, 'jnum'));
  1368. // $zdata = array_filter($qbdata, function ($item) {
  1369. // return $item['zd'] != "" && $item['state'] < 1;
  1370. // });
  1371. // $z = array_sum(array_column($zdata, 'jnum'));
  1372. $zdata = array_filter($qbdata, function ($item) {
  1373. return $item['zd'] != "" && $item['state'] < 1;
  1374. });
  1375. $z = array_sum(array_column($zdata, 'jnum'));
  1376. //$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');
  1377. //$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'].'"');
  1378. //$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'].'"');
  1379. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1380. //$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'].'"');
  1381. $details = array();
  1382. $cpid = array();
  1383. $od = array();
  1384. $odid = '';
  1385. $companytitle = '';
  1386. $shop_list = [];
  1387. foreach ($qbdata as $v) {
  1388. if ($v['zd'] != "" && $v['state'] < 1) {
  1389. if (!isset($od[$v['zd']])) {
  1390. $od[$v['zd']] = 1; //所有数据sku
  1391. } else {
  1392. $od[$v['zd']] = $od[$v['zd']] + 1;
  1393. }
  1394. }
  1395. $details[$v['details']] = $v['details'];
  1396. if ($v['state'] < 1) {
  1397. //$details[$v['details']] = $v['details'];
  1398. if ($v['cpid'] != 0) {
  1399. $cpid[$v['cpid']] = $v['cpid'];
  1400. }
  1401. }
  1402. if($v['state'] == 0){
  1403. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1404. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1405. }
  1406. if ($v['shop'] != '') {
  1407. $shop = explode(',', trim($v['shop'], ','));
  1408. foreach ($shop as $vv) {
  1409. if (!in_array($vv, $shop_list)) {
  1410. $shop_list[] = $vv;
  1411. }
  1412. }
  1413. }
  1414. }
  1415. }
  1416. foreach ($od as $k => $vv) {
  1417. $odid .= $k . '数量' . $vv;
  1418. }
  1419. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1420. $info_list[$key]['label'] = $value['sm'];
  1421. $number = $value['number'];
  1422. $ftime = time() - 15 * 24 * 3600;
  1423. $z = $z . '(' . $odid . ')'; //查看订单号
  1424. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1425. $info_list[$key]['features'] = $c;
  1426. $info_list[$key]['number'] = $ztdata;
  1427. $info_list[$key]['sm'] = $g;
  1428. $info_list[$key]['x'] = $x;
  1429. $info_list[$key]['t'] = $t;
  1430. $info_list[$key]['z'] = $z;
  1431. /**
  1432. foreach ($cdata as $k=>$v)
  1433. {
  1434. $details[$v['details']] = $v['details'];
  1435. if($v['cpid'] != 0)
  1436. {
  1437. $cpid[$v['cpid']] = $v['cpid'];
  1438. }
  1439. }
  1440. **/
  1441. $info_list[$key]['shop'] = '';
  1442. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1443. // if ($value['shop'] != '') {
  1444. // $shop = explode(',', trim($value['shop'], ','));
  1445. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1446. // }
  1447. $shop_list = array_unique($shop_list);
  1448. $shop_str = '';
  1449. foreach ($shop_list as $v) {
  1450. if(isset($sp[$v])){
  1451. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1452. }
  1453. }
  1454. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1455. /**
  1456. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1457. if(isset($companytitle[0]))
  1458. {
  1459. foreach ($companytitle as $k=>$v)
  1460. {
  1461. if($v['companytitle'] != '')
  1462. {
  1463. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1464. }
  1465. }
  1466. }
  1467. **/
  1468. }
  1469. $final_all_list = [];
  1470. foreach ($info_list as $k => $v) {
  1471. $final_all_list[] = [
  1472. 'id' => $v['id'],
  1473. "warehouse" => $v["warehouse"],
  1474. "purchase" => $v["purchase"],
  1475. "sku" => $v["sku"],
  1476. "title" => $v["title"] . "<br/>" . $v["pm"],
  1477. "details" => $v["details"],
  1478. "shop" => $v["shop"],
  1479. "cpbz" => $v["cpbz"],
  1480. 'label' => $v['label'],
  1481. "type" => $v["type"],
  1482. "features" => $v["features"],
  1483. "number" => $v["number"],
  1484. "sm" => $v["sm"],
  1485. "x" => $v["x"],
  1486. "t" => $v["t"],
  1487. "z" => $v["z"]
  1488. ];
  1489. }
  1490. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1491. $pagenum = ceil($total / $perpage);
  1492. $over = $total - ($start + $perpage);
  1493. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1494. echo json_encode($rows);
  1495. exit;
  1496. }
  1497. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1498. $this->data['shop'] = $wlshop;
  1499. $this->data['vip'] = $vip;
  1500. $this->_Template('whlabel_type', $this->data);
  1501. }
  1502. //美仓进销存浏览
  1503. public function _usatype()
  1504. {
  1505. if (isset($_SESSION['api'])) {
  1506. $user = $this->user->get_api($_SESSION['api']);
  1507. $usp = $user;
  1508. $fgshop = "";
  1509. $sid = "";
  1510. $wid = "";
  1511. $wtype = "";
  1512. $userwh = explode('|', trim($user['warehouse'], '|'));
  1513. foreach ($userwh as $value) {
  1514. $wid .= " id = " . $value . " or";
  1515. $wtype .= " type = " . $value . " or";
  1516. }
  1517. }
  1518. $prc = array();
  1519. $purchase = $this->purchase->find_all();
  1520. foreach ($purchase as $k => $v) {
  1521. $prc[$v['id']] = $v['title'];
  1522. }
  1523. $post = $this->input->post(NULL, TRUE);
  1524. if (isset($post['page'])) {
  1525. $page = $this->input->post('page', true);
  1526. $perpage = $this->input->post('perpage', true);
  1527. $category = $this->input->post('category', true);
  1528. $size = $this->input->post('size', true);
  1529. $grade = $this->input->post('grade', true);
  1530. $color = $this->input->post('color', true);
  1531. $lowe = $this->input->post('lowe', true);
  1532. $sku = $this->input->post('sku');
  1533. $title = $this->input->post('title');
  1534. $warehouse = $this->input->post('warehouse', true);
  1535. $usa = $this->input->post('usa', true);
  1536. $purchase = $this->input->post('purchase', true);
  1537. $lacetype = $this->input->post('lacetype', true);
  1538. $haircap = $this->input->post('haircap', true);
  1539. $density = $this->input->post('density', true);
  1540. $details = $this->input->post('details', true);
  1541. $state = $this->input->post('state', true);
  1542. $lacecolor = $this->input->post('lacecolor', true);
  1543. $cklx = $this->input->post('cklx', true);
  1544. $ktime = $this->input->post('ktime', true);
  1545. $jtime = $this->input->post('jtime', true);
  1546. $ktime = strtotime($ktime);
  1547. $jtime = strtotime($jtime);
  1548. $where = "1=1";
  1549. $gj = "";
  1550. $ck = "";
  1551. if ($lacetype) {
  1552. $where .= " and features like '%-$lacetype-%'";
  1553. }
  1554. if ($category) {
  1555. $where .= " and features like '%-$category-%'";
  1556. }
  1557. if ($size) {
  1558. $where .= " and features like '%-$size-%'";
  1559. }
  1560. if ($grade) {
  1561. $where .= " and features like '%-$grade-%'";
  1562. }
  1563. if ($color) {
  1564. $where .= " and features like '%-$color-%'";
  1565. }
  1566. if ($lowe) {
  1567. $where .= " and features like '%-$lowe-%'";
  1568. }
  1569. if ($haircap) {
  1570. $where .= " and features like '%-$haircap-%'";
  1571. }
  1572. if ($density) {
  1573. $where .= " and features like '%-$density-%'";
  1574. }
  1575. if ($lacecolor) {
  1576. $where .= " and features like '%-$lacecolor-%'";
  1577. }
  1578. if ($usa) {
  1579. if (!$warehouse) {
  1580. $where .= " and (warehouse = '5' or warehouse = '8')";
  1581. }
  1582. }
  1583. if ($warehouse) {
  1584. $where .= " and warehouse = '$warehouse'";
  1585. }
  1586. if ($details) {
  1587. $where .= " and details = '$details'";
  1588. }
  1589. if ($purchase) {
  1590. $where .= " and purchase = '$purchase'";
  1591. }
  1592. if ($state) {
  1593. $where .= " and state = '$state'";
  1594. }
  1595. $where_add = '';
  1596. if ($cklx) {
  1597. $shop = $this->shop->read($cklx);
  1598. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1599. }
  1600. if ($ktime && $jtime) {
  1601. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1602. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1603. }
  1604. //数据排序
  1605. $order_str = "id desc";
  1606. if (empty($page)) {
  1607. $start = 0;
  1608. $perpage = 1;
  1609. } else {
  1610. $start = ($page - 1) * $perpage;
  1611. }
  1612. if ($sku) {
  1613. $sku = trim($sku, ' ');
  1614. $sku = trim($sku, ' ');
  1615. $where .= " and sku like '%$sku%'";
  1616. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1617. } else if ($title) {
  1618. $title = trim($title, ' ');
  1619. $title = trim($title, ' ');
  1620. $where .= " and title like '%$title%'";
  1621. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1622. } else {
  1623. //$where .= " and time > '$ktime' and time < '$jtime'";
  1624. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1625. }
  1626. //取得信息列表
  1627. $rows = array();
  1628. $list = array();
  1629. foreach ($info_list as $key => $value) {
  1630. $warehouse = $this->warehouse->read($value['warehouse']);
  1631. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1632. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1633. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1635. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1636. $od = array();
  1637. $odid = '';
  1638. foreach ($z as $v) {
  1639. if (!isset($od[$v['zd']])) {
  1640. $od[$v['zd']] = 1; //所有数据sku
  1641. } else {
  1642. $od[$v['zd']] = $od[$v['zd']] + 1;
  1643. }
  1644. }
  1645. foreach ($od as $k => $vv) {
  1646. $odid .= $k . '数量' . $vv . ' ';
  1647. }
  1648. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1649. $info_list[$key]['features'] = $c;
  1650. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1651. $ztdata = '';
  1652. if (count($zt) > 0) {
  1653. foreach ($zt as $vv) {
  1654. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1655. }
  1656. }
  1657. $info_list[$key]['warehouse'] = $ztdata;
  1658. $info_list[$key]['g'] = $g;
  1659. $info_list[$key]['x'] = $x;
  1660. $info_list[$key]['t'] = $t;
  1661. $info_list[$key]['z'] = $z;
  1662. }
  1663. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1664. $pagenum = ceil($total / $perpage);
  1665. $over = $total - ($start + $perpage);
  1666. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1667. echo json_encode($rows);
  1668. exit;
  1669. }
  1670. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1671. $this->data['warehouse'] = $warehouse;
  1672. $this->_Template('whlabel_typeusa', $this->data);
  1673. }
  1674. //美仓进销存浏览
  1675. public function _usatypeapp()
  1676. {
  1677. $post = $this->input->post(NULL, TRUE);
  1678. if (isset($post['page'])) {
  1679. $page = $this->input->post('page', true);
  1680. $perpage = $this->input->post('perpage', true);
  1681. $sku = $this->input->post('sku', true);
  1682. $warehouse = 5;
  1683. $title = $this->input->post('title', true);
  1684. $state = $this->input->post('state', true);
  1685. $ktime = $this->input->post('ktime', true);
  1686. $jtime = $this->input->post('jtime', true);
  1687. $ktime = strtotime($ktime);
  1688. $jtime = strtotime($jtime);
  1689. $where = "1=1";
  1690. $gj = "";
  1691. $ck = "";
  1692. if ($title) {
  1693. $st = explode(' ', trim($title, ' '));
  1694. foreach ($st as $v) {
  1695. $where .= " and title like '%$v%'";
  1696. }
  1697. }
  1698. if ($warehouse) {
  1699. $where .= " and warehouse = '$warehouse'";
  1700. }
  1701. if ($state) {
  1702. $where .= " and state = '$state'";
  1703. }
  1704. if ($sku) {
  1705. $where .= " and sku like '%$sku%'";
  1706. }
  1707. if ($ktime && $jtime) {
  1708. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1709. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1710. }
  1711. //数据排序
  1712. $order_str = "id desc";
  1713. if (empty($page)) {
  1714. $start = 0;
  1715. $perpage = 1;
  1716. } else {
  1717. $start = ($page - 1) * $perpage;
  1718. }
  1719. //取得信息列表
  1720. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1721. $rows = array();
  1722. $list = array();
  1723. foreach ($info_list as $key => $value) {
  1724. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1725. }
  1726. $rowsdq = array_slice($rows, $start, $perpage);
  1727. foreach ($rowsdq as $value) {
  1728. $warehouse = $this->warehouse->read($value['warehouse']);
  1729. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1730. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1731. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1732. $od = array();
  1733. $odid = '';
  1734. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1735. }
  1736. $total = count($rows);
  1737. $pagenum = ceil($total / $perpage);
  1738. $over = $total - ($start + $perpage);
  1739. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1740. echo json_encode($rows);
  1741. exit;
  1742. }
  1743. $this->_Template('phone/p_usatypeapp', $this->data);
  1744. }
  1745. //入库操作
  1746. public function _enteradd()
  1747. {
  1748. $dt = 0;
  1749. if (isset($_SESSION['api'])) {
  1750. $user = $this->user->get_api($_SESSION['api']);
  1751. $usp = $user;
  1752. $fgshop = "";
  1753. $sid = "";
  1754. $user = explode('|', trim($user['shop'], '|'));
  1755. foreach ($user as $value) {
  1756. $fgshop .= " shop = " . $value . " or";
  1757. $sid .= " id = " . $value . " or";
  1758. }
  1759. }
  1760. $tc = $this->typeclass->find_all();
  1761. $typeclass = array();
  1762. foreach ($tc as $v) {
  1763. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1764. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1765. }
  1766. $post = $this->input->post(NULL, TRUE);
  1767. if (isset($post['sku'])) {
  1768. $list = array();
  1769. $num = "";
  1770. $title = "";
  1771. $features = "";
  1772. $order = $this->input->post('order', true);
  1773. $shop = $this->input->post('shop', true);
  1774. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1775. $sku = $this->input->post('sku', true);
  1776. $post['sm'] = $this->input->post('sm', true);
  1777. $post['warehouse'] = $this->input->post('warehouse', true);
  1778. $post['purchase'] = $this->input->post('purchase', true);
  1779. $post['retreatwarehouse'] = $post['warehouse'];
  1780. $post['state'] = $this->input->post('state', true);
  1781. $post['rktype'] = $this->input->post('rktype', true);
  1782. $post['text'] = $this->input->post('text', true);
  1783. $category = $this->input->post('category', true);
  1784. $list['category'] = $category;
  1785. $list['hairtype'] = $this->input->post('hairtype', true);
  1786. $list['grade'] = $this->input->post('grade', true);
  1787. $size = $this->input->post('size', true);
  1788. $xzsku = $this->input->post('xzsku', true);
  1789. $list['size'] = rtrim($size, ',');
  1790. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1791. $list['extension'] = $this->input->post('extension', true);
  1792. if ($category == 1297) {
  1793. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1794. }
  1795. if ($category == 1702) {
  1796. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1797. $list['syother'] = $this->input->post('syother', true);
  1798. }
  1799. if ($category == 133) {
  1800. $list['fittype'] = $this->input->post('fittype', true);
  1801. $list['acother'] = $this->input->post('acother', true);
  1802. }
  1803. $list['color'] = $this->input->post('color', true);
  1804. $list['lowe'] = $this->input->post('lowe', true);
  1805. if (!$post['purchase']) {
  1806. $post['purchase'] = 1;
  1807. }
  1808. if ($category == 127) {
  1809. $list['type'] = $this->input->post('type', true);
  1810. $list['headroad'] = $this->input->post('headroad', true);
  1811. $list['density'] = $this->input->post('density', true);
  1812. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1813. $list['lacesize'] = $this->input->post('lacesize', true);
  1814. }
  1815. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1816. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1817. }
  1818. if ($category == 128) {
  1819. $list['lacetype'] = $this->input->post('lacetype', true);
  1820. $list['haircap'] = $this->input->post('haircap', true);
  1821. $list['density'] = $this->input->post('density', true);
  1822. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1823. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1824. $list['wigother'] = $this->input->post('wigother', true);
  1825. $list['wigother1'] = $this->input->post('wigother1', true);
  1826. $list['wigother2'] = $this->input->post('wigother2', true);
  1827. }
  1828. if ($category == 129) {
  1829. $list['wide'] = $this->input->post('wide', true);
  1830. }
  1831. if ($category == 131) {
  1832. $list['gifttype'] = $this->input->post('gifttype', true);
  1833. $list['giftother'] = $this->input->post('giftother', true);
  1834. }
  1835. if ($category == 134) {
  1836. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1837. }
  1838. if ($category == 1297) {
  1839. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1840. $list['sywigother'] = $this->input->post('sywigother', true);
  1841. }
  1842. if ($category == 130 || $category == 133 || $category == 1702) {
  1843. $list['items'] = $this->input->post('items', true);
  1844. $list['weight'] = $this->input->post('weight', true);
  1845. }
  1846. if ($category == 1702) {
  1847. $list['syhairther'] = $this->input->post('syhairther', true);
  1848. }
  1849. $classid = $this->classid->sku();
  1850. $scsku = $classid;
  1851. $pm = $classid;
  1852. foreach ($list as $k => $v) {
  1853. if ($v != 0) {
  1854. $num .= $v;
  1855. $features .= $v . '-';
  1856. $post[$k] = $v;
  1857. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1858. if ($k != 'size') {
  1859. $title .= $typeclass[$v]['title'] . " ";
  1860. }
  1861. if (isset($pm[$typeclass[$v]['classid']])) {
  1862. if ($typeclass[$v]['title'] == '9A') {
  1863. $pm[$typeclass[$v]['classid']] = '9A';
  1864. } else if ($typeclass[$v]['title'] == '10A') {
  1865. $pm[$typeclass[$v]['classid']] = '10A';
  1866. } else {
  1867. $clzh = $typeclass[$v]['zh'];
  1868. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1869. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1870. $clzh = $clzh[0];
  1871. }
  1872. $pm[$typeclass[$v]['classid']] = $clzh;
  1873. }
  1874. }
  1875. }
  1876. }
  1877. $zh = implode(" ", $pm);
  1878. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1879. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1880. if ($list['size']) {
  1881. $typeclass = $this->typeclass->read($list['size']);
  1882. $title .= $typeclass['title'];
  1883. }
  1884. $time = time();
  1885. if ($xzsku) {
  1886. $scsku = implode("-", $scsku);
  1887. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1888. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1889. $post['sku'] = trim($scsku, ' ');
  1890. } else {
  1891. $post['sku'] = $sku;
  1892. }
  1893. //$post['sku'] = trim($sku,' ');
  1894. $post['title'] = rtrim($title, ' ');
  1895. $post['number'] = $num;
  1896. $post['features'] = '-' . $features;
  1897. $post['enter'] = $time;
  1898. $post['time'] = $time; //操作时间
  1899. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1900. if ($yza) {
  1901. if ($post['features'] != $yza[0]['features']) {
  1902. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1903. exit;
  1904. }
  1905. }
  1906. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1907. if ($yzb) {
  1908. if ($post['sku'] != $yzb[0]['sku']) {
  1909. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1910. exit;
  1911. }
  1912. }
  1913. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1914. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1915. exit;
  1916. }
  1917. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1918. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1919. exit;
  1920. }
  1921. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1922. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1923. exit;
  1924. }
  1925. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1926. if (isset($yz[0]['type'])) {
  1927. $post['type'] = $yz[0]['type'];
  1928. }
  1929. if ($post['state'] == 9) //如果选择预设库存
  1930. {
  1931. $this->whlabel->insert($post);
  1932. } else {
  1933. /**
  1934. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1935. if($ljg == 1)
  1936. {
  1937. for($i=0;$i<$order;$i++)
  1938. {
  1939. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1940. $this->whlabel->insert($post);
  1941. }
  1942. }
  1943. **/
  1944. //if($post['warehouse'] == '5')
  1945. //{
  1946. //}
  1947. $yydata = $post;
  1948. $yydata['zh'] = $zh;
  1949. /**
  1950. $wl = $this->apiyy->get_cjlp($yydata);
  1951. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1952. {
  1953. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1954. }
  1955. if($wl['Data'][0]['m_isSucess'] != 1)
  1956. {
  1957. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1958. }
  1959. **/
  1960. for ($i = 0; $i < $order; $i++) {
  1961. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1962. $this->whlabel->insert($post);
  1963. }
  1964. }
  1965. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1966. exit;
  1967. }
  1968. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1969. $this->data['wlshop'] = $wlshop;
  1970. $this->_Template('whlabel_enteradd', $this->data);
  1971. }
  1972. //修改产品
  1973. public function _enteredit($arg_array)
  1974. {
  1975. $dt = 0;
  1976. if (isset($_SESSION['api'])) {
  1977. $user = $this->user->get_api($_SESSION['api']);
  1978. $usp = $user;
  1979. $fgshop = "";
  1980. $sid = "";
  1981. $user = explode('|', trim($user['shop'], '|'));
  1982. foreach ($user as $value) {
  1983. $fgshop .= " shop = " . $value . " or";
  1984. $sid .= " id = " . $value . " or";
  1985. }
  1986. }
  1987. $post = $this->input->post(NULL, TRUE);
  1988. if (isset($post['sku'])) {
  1989. $list = array();
  1990. $num = "";
  1991. $title = "";
  1992. $features = "";
  1993. $id = $this->input->post('id', true);
  1994. $order = $this->input->post('order', true);
  1995. $shop = $this->input->post('shop', true);
  1996. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1997. $post['sku'] = $this->input->post('sku', true);
  1998. $post['sm'] = $this->input->post('sm', true);
  1999. $post['warehouse'] = $this->input->post('warehouse', true);
  2000. $post['purchase'] = $this->input->post('purchase', true);
  2001. $post['retreatwarehouse'] = $post['warehouse'];
  2002. $category = $this->input->post('category', true);
  2003. $list['category'] = $category;
  2004. $list['hairtype'] = $this->input->post('hairtype', true);
  2005. $list['grade'] = $this->input->post('grade', true);
  2006. $size = $this->input->post('size', true);
  2007. $list['size'] = rtrim($size, ',');
  2008. $post['rktype'] = $this->input->post('rktype', true);
  2009. $post['text'] = $this->input->post('text', true);
  2010. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2011. $list['extension'] = $this->input->post('extension', true);
  2012. if ($category == 1297) {
  2013. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2014. }
  2015. if ($category == 1702) {
  2016. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2017. $list['syother'] = $this->input->post('syother', true);
  2018. }
  2019. if ($category == 133) {
  2020. $list['fittype'] = $this->input->post('fittype', true);
  2021. $list['acother'] = $this->input->post('acother', true);
  2022. }
  2023. $list['color'] = $this->input->post('color', true);
  2024. $list['lowe'] = $this->input->post('lowe', true);
  2025. if (!$post['purchase']) {
  2026. $post['purchase'] = 1;
  2027. }
  2028. if ($category == 127) {
  2029. $list['type'] = $this->input->post('type', true);
  2030. $list['headroad'] = $this->input->post('headroad', true);
  2031. $list['density'] = $this->input->post('density', true);
  2032. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2033. $list['lacesize'] = $this->input->post('lacesize', true);
  2034. }
  2035. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2036. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2037. }
  2038. if ($category == 128) {
  2039. $list['lacetype'] = $this->input->post('lacetype', true);
  2040. $list['haircap'] = $this->input->post('haircap', true);
  2041. $list['density'] = $this->input->post('density', true);
  2042. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2043. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2044. $list['wigother'] = $this->input->post('wigother', true);
  2045. $list['wigother1'] = $this->input->post('wigother1', true);
  2046. $list['wigother2'] = $this->input->post('wigother2', true);
  2047. }
  2048. if ($category == 129) {
  2049. $list['wide'] = $this->input->post('wide', true);
  2050. }
  2051. if ($category == 131) {
  2052. $list['gifttype'] = $this->input->post('gifttype', true);
  2053. $list['giftother'] = $this->input->post('giftother', true);
  2054. }
  2055. if ($category == 134) {
  2056. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2057. }
  2058. if ($category == 1297) {
  2059. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2060. $list['sywigother'] = $this->input->post('sywigother', true);
  2061. }
  2062. if ($category == 130 || $category == 133 || $category == 1702) {
  2063. $list['items'] = $this->input->post('items', true);
  2064. $list['weight'] = $this->input->post('weight', true);
  2065. }
  2066. if ($category == 1702) {
  2067. $list['syhairther'] = $this->input->post('syhairther', true);
  2068. }
  2069. foreach ($list as $k => $v) {
  2070. if ($v != 0) {
  2071. $num .= $v;
  2072. $features .= $v . '-';
  2073. $typeclass = $this->typeclass->read($v);
  2074. if ($k != 'size') {
  2075. $title .= $typeclass['title'] . " ";
  2076. }
  2077. }
  2078. }
  2079. $typeclass = $this->typeclass->read($list['size']);
  2080. $title .= $typeclass['title'];
  2081. $time = time();
  2082. $post['title'] = rtrim($title, ' ');
  2083. $post['number'] = $num;
  2084. $post['features'] = '-' . $features;
  2085. $post['time'] = $time; //操作时间
  2086. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2087. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2088. exit;
  2089. }
  2090. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2091. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2092. exit;
  2093. }
  2094. $uid = $this->whlabel->read($id);
  2095. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2096. if ($datanum > 0) {
  2097. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2098. exit;
  2099. }
  2100. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2101. {
  2102. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2103. if ($yza) {
  2104. if ($post['features'] != $yza[0]['features']) {
  2105. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2106. exit;
  2107. }
  2108. }
  2109. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2110. if ($yzb) {
  2111. if ($post['sku'] != $yzb[0]['sku']) {
  2112. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2113. exit;
  2114. }
  2115. }
  2116. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2117. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2118. exit;
  2119. }
  2120. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2121. foreach ($data as $v) {
  2122. $post['id'] = $v['id'];
  2123. $this->whlabel->save($post, $v['id']);
  2124. }
  2125. } else {
  2126. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2127. if ($data > 0) {
  2128. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2129. exit;
  2130. } else {
  2131. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2132. foreach ($data as $v) {
  2133. $post['id'] = $v['id'];
  2134. $this->whlabel->save($post, $v['id']);
  2135. }
  2136. }
  2137. }
  2138. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2139. exit;
  2140. }
  2141. $uid = $this->whlabel->read($arg_array[0]);
  2142. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2143. $this->data['enter'] = $uid;
  2144. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2145. $this->data['wlshop'] = $wlshop;
  2146. $this->_Template('whlabel_enteredit', $this->data);
  2147. }
  2148. //入库浏览
  2149. public function _enter()
  2150. {
  2151. $post = $this->input->post(NULL, TRUE);
  2152. if (isset($post['s'])) {
  2153. $id_arr = $this->input->post('s');
  2154. $id_arr = explode(',', $id_arr);
  2155. if (!$id_arr) {
  2156. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2157. exit;
  2158. }
  2159. //循环删除记录
  2160. foreach ($id_arr as $v) {
  2161. $sid = $this->whlabel->read($v);
  2162. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2163. if ($count > 0) {
  2164. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2165. exit;
  2166. }
  2167. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2168. foreach ($info_list as $va) {
  2169. $this->whlabel->remove($va['id']);
  2170. }
  2171. }
  2172. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2173. exit;
  2174. }
  2175. $sp = array();
  2176. $s = $this->shop->find_all('1=1', 'id,shopname');
  2177. foreach ($s as $v) {
  2178. $sp[$v['id']] = $v['shopname'];
  2179. }
  2180. $wh = array();
  2181. $w = $this->warehouse->find_all('1=1', 'id,title');
  2182. foreach ($w as $v) {
  2183. $wh[$v['id']] = $v['title'];
  2184. }
  2185. if (isset($post['page'])) {
  2186. $page = $this->input->post('page', true);
  2187. $perpage = $this->input->post('perpage', true);
  2188. $category = $this->input->post('category', true);
  2189. $size = $this->input->post('size', true);
  2190. $grade = $this->input->post('grade', true);
  2191. $color = $this->input->post('color', true);
  2192. $lowe = $this->input->post('lowe', true);
  2193. $sku = $this->input->post('sku', true);
  2194. $warehouse = $this->input->post('warehouse', true);
  2195. $purchase = $this->input->post('purchase', true);
  2196. $ktime = $this->input->post('ktime', true);
  2197. $jtime = $this->input->post('jtime', true);
  2198. $ktime = strtotime($ktime);
  2199. $jtime = strtotime($jtime);
  2200. $where = "1=1";
  2201. $gj = "";
  2202. $ck = "";
  2203. if ($category) {
  2204. $where .= " and features like '%-$category-%'";
  2205. }
  2206. if ($size) {
  2207. $where .= " and features like '%-$size-%'";
  2208. }
  2209. if ($grade) {
  2210. $where .= " and features like '%-$grade-%'";
  2211. }
  2212. if ($color) {
  2213. $where .= " and features like '%-$color-%'";
  2214. }
  2215. if ($lowe) {
  2216. $where .= " and features like '%-$lowe-%'";
  2217. }
  2218. if ($warehouse) {
  2219. $where .= " and warehouse = '$warehouse'";
  2220. }
  2221. if ($purchase) {
  2222. $where .= " and purchase = '$purchase'";
  2223. }
  2224. if ($sku) {
  2225. $where .= " and sku like '%$sku%'";
  2226. }
  2227. if ($ktime && $jtime) {
  2228. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2229. }
  2230. //数据排序
  2231. $order_str = "enter desc";
  2232. if (empty($page)) {
  2233. $start = 0;
  2234. $perpage = 1;
  2235. } else {
  2236. $start = ($page - 1) * $perpage;
  2237. }
  2238. //取得信息列表
  2239. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2240. foreach ($info_list as $k => $v) {
  2241. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2242. if ($v['shop'] == '') {
  2243. $s = '通用';
  2244. } else {
  2245. $info_list[$k]['shop'] = '';
  2246. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2247. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2248. }
  2249. }
  2250. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2251. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2252. $info_list[$k]['g'] = $g;
  2253. }
  2254. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2255. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2256. $pagenum = ceil($total / $perpage);
  2257. $over = $total - ($start + $perpage);
  2258. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2259. echo json_encode($rows);
  2260. exit;
  2261. }
  2262. $this->_Template('whlabel_enter', $this->data);
  2263. }
  2264. //出库浏览
  2265. public function _out()
  2266. {
  2267. $post = $this->input->post(NULL, TRUE);
  2268. if (isset($post['page'])) {
  2269. $page = $this->input->post('page', true);
  2270. $perpage = $this->input->post('perpage', true);
  2271. $category = $this->input->post('category', true);
  2272. $size = $this->input->post('size', true);
  2273. $grade = $this->input->post('grade', true);
  2274. $color = $this->input->post('color', true);
  2275. $lowe = $this->input->post('lowe', true);
  2276. $sku = $this->input->post('sku', true);
  2277. $warehouse = $this->input->post('warehouse', true);
  2278. $purchase = $this->input->post('purchase', true);
  2279. $state = $this->input->post('state', true);
  2280. $ktime = $this->input->post('ktime', true);
  2281. $jtime = $this->input->post('jtime', true);
  2282. $ktime = strtotime($ktime);
  2283. $jtime = strtotime($jtime);
  2284. $where = "state=3";
  2285. $gj = "";
  2286. $ck = "";
  2287. if ($category) {
  2288. $where .= " and features like '%-$category-%'";
  2289. }
  2290. if ($size) {
  2291. $where .= " and features like '%-$size-%'";
  2292. }
  2293. if ($grade) {
  2294. $where .= " and features like '%-$grade-%'";
  2295. }
  2296. if ($color) {
  2297. $where .= " and features like '%-$color-%'";
  2298. }
  2299. if ($lowe) {
  2300. $where .= " and features like '%-$lowe-%'";
  2301. }
  2302. if ($state) {
  2303. $where .= " and state = '$state'";
  2304. }
  2305. if ($warehouse) {
  2306. $where .= " and warehouse = '$warehouse'";
  2307. }
  2308. if ($purchase) {
  2309. $where .= " and purchase = '$purchase'";
  2310. }
  2311. if ($sku) {
  2312. $where .= " and sku = '$sku'";
  2313. }
  2314. if ($ktime && $jtime) {
  2315. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2316. }
  2317. //数据排序
  2318. $order_str = "id desc";
  2319. if (empty($page)) {
  2320. $start = 0;
  2321. $perpage = 1;
  2322. } else {
  2323. $start = ($page - 1) * $perpage;
  2324. }
  2325. //取得信息列表
  2326. $info_list = $this->whlabel->find_all($where, 'sku');
  2327. $rows = array();
  2328. $list = array();
  2329. foreach ($info_list as $key => $value) {
  2330. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2331. }
  2332. $rows = array_unique($rows); //删除重复记录
  2333. foreach ($rows as $key => $value) {
  2334. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2335. $ck = $this->warehouse->read($data['warehouse']);
  2336. $warehouse = $ck['title'];
  2337. $gy = $this->purchase->read($data['purchase']);
  2338. $purchase = $gy['purchase'];
  2339. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2340. $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);
  2341. }
  2342. $total = count($list);
  2343. $pagenum = ceil($total / $perpage);
  2344. $over = $total - ($start + $perpage);
  2345. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2346. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2347. echo json_encode($rows);
  2348. exit;
  2349. }
  2350. $this->_Template('whlabel_out', $this->data);
  2351. }
  2352. //出库标签浏览
  2353. public function _label()
  2354. {
  2355. $post = $this->input->post(NULL, TRUE);
  2356. if (isset($post['page'])) {
  2357. $page = $this->input->post('page', true);
  2358. $perpage = $this->input->post('perpage', true);
  2359. $sku = $this->input->post('sku', true);
  2360. $warehouse = $this->input->post('warehouse', true);
  2361. $purchase = $this->input->post('purchase', true);
  2362. $orderinfo = $this->input->post('orderinfo', true);
  2363. $waybill = $this->input->post('waybill', true);
  2364. $category = $this->input->post('category', true);
  2365. $size = $this->input->post('size', true);
  2366. $grade = $this->input->post('grade', true);
  2367. $color = $this->input->post('color', true);
  2368. $lowe = $this->input->post('lowe', true);
  2369. $where = "state=1";
  2370. if ($sku) {
  2371. $where .= " and sku = '$sku'";
  2372. }
  2373. if ($warehouse) {
  2374. $where .= " and warehouse = '$warehouse'";
  2375. }
  2376. if ($purchase) {
  2377. $where .= " and purchase = '$purchase'";
  2378. }
  2379. if ($orderinfo) {
  2380. $where .= " and orderinfo = '$orderinfo'";
  2381. }
  2382. if ($waybill) {
  2383. $where .= " and waybill = '$waybill'";
  2384. }
  2385. if ($category) {
  2386. $where .= " and features like '%-$category-%'";
  2387. }
  2388. if ($size) {
  2389. $where .= " and features like '%-$size-%'";
  2390. }
  2391. if ($grade) {
  2392. $where .= " and features like '%-$grade-%'";
  2393. }
  2394. if ($color) {
  2395. $where .= " and features like '%-$color-%'";
  2396. }
  2397. if ($lowe) {
  2398. $where .= " and features like '%-$lowe-%'";
  2399. }
  2400. //数据排序
  2401. $order_str = "outk desc";
  2402. if (empty($page)) {
  2403. $start = 0;
  2404. $perpage = 1;
  2405. } else {
  2406. $start = ($page - 1) * $perpage;
  2407. }
  2408. //取得信息列表
  2409. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2410. foreach ($info_list as $key => $value) {
  2411. $warehouse = $this->warehouse->read($value['warehouse']);
  2412. $info_list[$key]['warehouse'] = $warehouse['title'];
  2413. $purchase = $this->purchase->read($value['purchase']);
  2414. $info_list[$key]['purchase'] = $purchase['title'];
  2415. if ($value['outk'] != 0) {
  2416. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2417. } else {
  2418. $info_list[$key]['outk'] = "";
  2419. }
  2420. if ($value['orderinfo'] == 0) {
  2421. $info_list[$key]['orderinfo'] = "";
  2422. }
  2423. if ($value['waybill'] == 0) {
  2424. $info_list[$key]['waybill'] = "";
  2425. }
  2426. }
  2427. $total = $this->whlabel->find_count($where);
  2428. $pagenum = ceil($total / $perpage);
  2429. $over = $total - ($start + $perpage);
  2430. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2431. echo json_encode($rows);
  2432. exit;
  2433. }
  2434. $this->_Template('whlabel_label', $this->data);
  2435. }
  2436. //独立站出库订单
  2437. public function _outorder()
  2438. {
  2439. if (isset($_SESSION['api'])) {
  2440. $user = $this->user->get_api($_SESSION['api']);
  2441. $usp = $user;
  2442. $fgshop = "";
  2443. $sid = "";
  2444. $user = explode('|', trim($user['shop'], '|'));
  2445. foreach ($user as $value) {
  2446. $fgshop .= " shop = " . $value . " or";
  2447. $sid .= " id = " . $value . " or";
  2448. }
  2449. } else {
  2450. echo "请重新登录";
  2451. }
  2452. $post = $this->input->post(NULL, TRUE);
  2453. if (isset($post['page'])) {
  2454. $page = $this->input->post('page', true);
  2455. $perpage = $this->input->post('perpage', true);
  2456. $warehouse = $this->input->post('warehouse', true);
  2457. $xztime = $this->input->post('xztime', true);
  2458. $timetk = $this->input->post('timetkk', true);
  2459. $timetj = $this->input->post('timetjj', true);
  2460. $shop = $this->input->post('shop', true);
  2461. $source = $this->input->post('source', true);
  2462. $orderinfo = $this->input->post('orderinfo', true);
  2463. $number = $this->input->post('number', true);
  2464. $sfxh = $this->input->post('sfxh', true);
  2465. $express = $this->input->post('express', true);
  2466. $waybill = $this->input->post('waybill', true);
  2467. $library = $this->input->post('library', true);
  2468. $country = $this->input->post('country', true);
  2469. $so = $this->input->post('so', true);
  2470. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2471. $print = $this->input->post('print', true);
  2472. $state = $this->input->post('state', true);
  2473. $orderurl = $this->input->post('orderurl', true);
  2474. $productid = $this->input->post('productid', true);
  2475. $timetk = strtotime($timetk);
  2476. $timetj = strtotime($timetj);
  2477. /**
  2478. $sj = $this->input->post('sj',true);
  2479. if($sj)
  2480. {
  2481. $sj = $this->input->post('sj',true);
  2482. }
  2483. else
  2484. {
  2485. $sj = "fullorder";
  2486. }
  2487. **/
  2488. $sj = "fullorder";
  2489. $where = "1=1";
  2490. if ($warehouse) {
  2491. $where .= " and type = '$warehouse'";
  2492. }
  2493. if ($timetk && $timetj) {
  2494. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2495. }
  2496. if ($orderinfo) {
  2497. $where .= " and orderinfo = '$orderinfo'";
  2498. }
  2499. if ($number) {
  2500. $where .= " and number = '$number'";
  2501. }
  2502. if ($express) {
  2503. $where .= " and express = '$express'";
  2504. }
  2505. if ($waybill) {
  2506. $where .= " and waybill = '$waybill'";
  2507. }
  2508. if ($library) {
  2509. $where .= " and library = '$library'";
  2510. }
  2511. if ($print) {
  2512. $where .= " and print = '$print'";
  2513. }
  2514. if ($libraryconfirm) {
  2515. $where .= " and libraryconfirm = '$libraryconfirm'";
  2516. }
  2517. if ($state) {
  2518. $where .= " and state = '$state'";
  2519. }
  2520. if ($shop) {
  2521. $where .= " and shop = '$shop'";
  2522. }
  2523. if ($country) {
  2524. $where .= " and country = '$country'";
  2525. }
  2526. if ($sfxh != '') {
  2527. $where .= " and sfxh = '$sfxh'";
  2528. }
  2529. if ($so) {
  2530. $where .= " and shipremarks like '%$so%'";
  2531. }
  2532. if ($source) {
  2533. if ($source == '2d') {
  2534. $where .= " and source >= '2'";
  2535. } else {
  2536. $where .= " and source = '$source'";
  2537. }
  2538. }
  2539. if (isset($_SESSION['api'])) {
  2540. foreach ($user as $value) {
  2541. $fgshop .= " shop = " . $value . " or";
  2542. }
  2543. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2544. }
  2545. if ($orderurl) {
  2546. $url = $this->orderurl->read($orderurl);
  2547. $where .= " and link like '%" . $url['url'] . "%'";
  2548. }
  2549. if($productid){
  2550. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2551. }
  2552. //数据排序
  2553. $order_str = "librarytime desc";
  2554. if (empty($page)) {
  2555. $start = 0;
  2556. $perpage = 1;
  2557. } else {
  2558. $start = ($page - 1) * $perpage;
  2559. }
  2560. //取得信息列表
  2561. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2562. //格式化数据
  2563. foreach ($info_list as $key => $value) {
  2564. $shop = $this->shop->read($value['shop']);
  2565. $info_list[$key]['shop'] = $shop['shopname'];
  2566. $express = $this->express->read($value['express']);
  2567. $info_list[$key]['express'] = $express['servicename'];
  2568. $warehouse = $this->warehouse->read($value['type']);
  2569. $info_list[$key]['type'] = $warehouse['title'];
  2570. if ($value['librarytime'] == '0') {
  2571. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2572. } else {
  2573. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2574. }
  2575. }
  2576. $total = $this->$sj->find_count($where);
  2577. $pagenum = ceil($total / $perpage);
  2578. $over = $total - ($start + $perpage);
  2579. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2580. echo json_encode($rows);
  2581. exit;
  2582. }
  2583. $this->data['express'] = $this->express->find_all();
  2584. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2585. $this->data['wlshop'] = $wlshop;
  2586. $user = $this->user->get_api($_SESSION['api']);
  2587. $powerid = $this->power->read($user['power']);
  2588. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2589. $pid = '';
  2590. foreach ($powertext as $v) {
  2591. $pid .= " id = " . $v . " or";
  2592. }
  2593. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2594. $this->data['fullorderexcel'] = $fullorderexcel;
  2595. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2596. $this->data['orderurl'] = $orderurl;
  2597. $this->_Template('whlabel_outorder', $this->data);
  2598. }
  2599. //tt出库
  2600. public function _toutorder()
  2601. {
  2602. $fgshop = "";
  2603. $sid = "";
  2604. if (isset($_SESSION['api'])) {
  2605. $user = $this->user->get_api($_SESSION['api']);
  2606. $usp = $user;
  2607. $user = explode('|', trim($user['shop'], '|'));
  2608. foreach ($user as $value) {
  2609. $fgshop .= " shop = " . $value . " or";
  2610. $sid .= " id = " . $value . " or";
  2611. }
  2612. } else {
  2613. echo "请重新登录";
  2614. die;
  2615. }
  2616. $post = $this->input->post(NULL, TRUE);
  2617. if (isset($post['page'])) {
  2618. $page = $this->input->post('page', true);
  2619. $perpage = $this->input->post('perpage', true);
  2620. $warehouse = $this->input->post('warehouse', true);
  2621. $xztime = $this->input->post('xztime', true);
  2622. $timetk = $this->input->post('timetkk', true);
  2623. $timetj = $this->input->post('timetjj', true);
  2624. $shop = $this->input->post('shop', true);
  2625. $source = $this->input->post('source', true);
  2626. $orderinfo = $this->input->post('orderinfo', true);
  2627. $number = $this->input->post('number', true);
  2628. $sfxh = $this->input->post('sfxh', true);
  2629. $express = $this->input->post('express', true);
  2630. $waybill = $this->input->post('waybill', true);
  2631. $library = $this->input->post('library', true);
  2632. $country = $this->input->post('country', true);
  2633. $so = $this->input->post('so', true);
  2634. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2635. $print = $this->input->post('print', true);
  2636. $state = $this->input->post('state', true);
  2637. $orderurl = $this->input->post('orderurl', true);
  2638. $timetk = strtotime($timetk);
  2639. $timetj = strtotime($timetj);
  2640. /**
  2641. $sj = $this->input->post('sj',true);
  2642. if($sj)
  2643. {
  2644. $sj = $this->input->post('sj',true);
  2645. }
  2646. else
  2647. {
  2648. $sj = "fullorder";
  2649. }
  2650. **/
  2651. $sj = "fullordertt";
  2652. $where = "1=1";
  2653. if ($warehouse) {
  2654. $where .= " and type = '$warehouse'";
  2655. }
  2656. if ($timetk && $timetj) {
  2657. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2658. }
  2659. if ($orderinfo) {
  2660. $where .= " and orderinfo = '$orderinfo'";
  2661. }
  2662. if ($number) {
  2663. $where .= " and number = '$number'";
  2664. }
  2665. if ($express) {
  2666. $where .= " and express = '$express'";
  2667. }
  2668. if ($waybill) {
  2669. $where .= " and waybill = '$waybill'";
  2670. }
  2671. if ($library) {
  2672. $where .= " and library = '$library'";
  2673. }
  2674. if ($print) {
  2675. $where .= " and print = '$print'";
  2676. }
  2677. if ($libraryconfirm) {
  2678. $where .= " and libraryconfirm = '$libraryconfirm'";
  2679. }
  2680. if ($state) {
  2681. $where .= " and state = '$state'";
  2682. }
  2683. if ($shop) {
  2684. $where .= " and shop = '$shop'";
  2685. }
  2686. if ($country) {
  2687. $where .= " and country = '$country'";
  2688. }
  2689. if ($sfxh != '') {
  2690. $where .= " and sfxh = '$sfxh'";
  2691. }
  2692. if ($so) {
  2693. $where .= " and shipremarks like '%$so%'";
  2694. }
  2695. if ($source) {
  2696. if ($source == '2d') {
  2697. $where .= " and source >= '2'";
  2698. } else {
  2699. $where .= " and source = '$source'";
  2700. }
  2701. }
  2702. if (isset($_SESSION['api'])) {
  2703. foreach ($user as $value) {
  2704. $fgshop .= " shop = " . $value . " or";
  2705. }
  2706. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2707. }
  2708. if ($orderurl) {
  2709. $url = $this->orderurl->read($orderurl);
  2710. $where .= " and link like '%" . $url['url'] . "%'";
  2711. }
  2712. //数据排序
  2713. $order_str = "librarytime desc";
  2714. if (empty($page)) {
  2715. $start = 0;
  2716. $perpage = 1;
  2717. } else {
  2718. $start = ($page - 1) * $perpage;
  2719. }
  2720. //取得信息列表
  2721. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2722. //格式化数据
  2723. foreach ($info_list as $key => $value) {
  2724. $shop = $this->shop->read($value['shop']);
  2725. $info_list[$key]['shop'] = $shop['shopname'];
  2726. $express = $this->express->read($value['express']);
  2727. $info_list[$key]['express'] = $express['servicename'];
  2728. $warehouse = $this->warehouse->read($value['type']);
  2729. $info_list[$key]['type'] = $warehouse['title'];
  2730. if ($value['librarytime'] == '0') {
  2731. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2732. } else {
  2733. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2734. }
  2735. }
  2736. $total = $this->$sj->find_count($where);
  2737. $pagenum = ceil($total / $perpage);
  2738. $over = $total - ($start + $perpage);
  2739. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2740. echo json_encode($rows);
  2741. exit;
  2742. }
  2743. $this->data['express'] = $this->express->find_all();
  2744. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2745. $this->data['wlshop'] = $wlshop;
  2746. $user = $this->user->get_api($_SESSION['api']);
  2747. $powerid = $this->power->read($user['power']);
  2748. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2749. $pid = '';
  2750. foreach ($powertext as $v) {
  2751. $pid .= " id = " . $v . " or";
  2752. }
  2753. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2754. $this->data['fullorderexcel'] = $fullorderexcel;
  2755. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2756. $this->data['orderurl'] = $orderurl;
  2757. $this->_Template('whlabel_toutorder', $this->data);
  2758. }
  2759. //tt出库
  2760. public function _aoutorder()
  2761. {
  2762. if (isset($_SESSION['api'])) {
  2763. $user = $this->user->get_api($_SESSION['api']);
  2764. $usp = $user;
  2765. $fgshop = "";
  2766. $sid = "";
  2767. $user = explode('|', trim($user['shop'], '|'));
  2768. foreach ($user as $value) {
  2769. $fgshop .= " shop = " . $value . " or";
  2770. $sid .= " id = " . $value . " or";
  2771. }
  2772. } else {
  2773. echo "请重新登录";
  2774. }
  2775. $post = $this->input->post(NULL, TRUE);
  2776. if (isset($post['page'])) {
  2777. $page = $this->input->post('page', true);
  2778. $perpage = $this->input->post('perpage', true);
  2779. $warehouse = $this->input->post('warehouse', true);
  2780. $xztime = $this->input->post('xztime', true);
  2781. $timetk = $this->input->post('timetkk', true);
  2782. $timetj = $this->input->post('timetjj', true);
  2783. $shop = $this->input->post('shop', true);
  2784. $source = $this->input->post('source', true);
  2785. $orderinfo = $this->input->post('orderinfo', true);
  2786. $number = $this->input->post('number', true);
  2787. $sfxh = $this->input->post('sfxh', true);
  2788. $express = $this->input->post('express', true);
  2789. $waybill = $this->input->post('waybill', true);
  2790. $library = $this->input->post('library', true);
  2791. $country = $this->input->post('country', true);
  2792. $so = $this->input->post('so', true);
  2793. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2794. $print = $this->input->post('print', true);
  2795. $state = $this->input->post('state', true);
  2796. $orderurl = $this->input->post('orderurl', true);
  2797. $timetk = strtotime($timetk);
  2798. $timetj = strtotime($timetj);
  2799. /**
  2800. $sj = $this->input->post('sj',true);
  2801. if($sj)
  2802. {
  2803. $sj = $this->input->post('sj',true);
  2804. }
  2805. else
  2806. {
  2807. $sj = "fullorder";
  2808. }
  2809. **/
  2810. $sj = "fullorderamz";
  2811. $where = "1=1";
  2812. if ($warehouse) {
  2813. $where .= " and type = '$warehouse'";
  2814. }
  2815. if ($timetk && $timetj) {
  2816. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2817. }
  2818. if ($orderinfo) {
  2819. $where .= " and orderinfo = '$orderinfo'";
  2820. }
  2821. if ($number) {
  2822. $where .= " and number = '$number'";
  2823. }
  2824. if ($express) {
  2825. $where .= " and express = '$express'";
  2826. }
  2827. if ($waybill) {
  2828. $where .= " and waybill = '$waybill'";
  2829. }
  2830. if ($library) {
  2831. $where .= " and library = '$library'";
  2832. }
  2833. if ($print) {
  2834. $where .= " and print = '$print'";
  2835. }
  2836. if ($libraryconfirm) {
  2837. $where .= " and libraryconfirm = '$libraryconfirm'";
  2838. }
  2839. if ($state) {
  2840. $where .= " and state = '$state'";
  2841. }
  2842. if ($shop) {
  2843. $where .= " and shop = '$shop'";
  2844. }
  2845. if ($country) {
  2846. $where .= " and country = '$country'";
  2847. }
  2848. if ($sfxh != '') {
  2849. $where .= " and sfxh = '$sfxh'";
  2850. }
  2851. if ($so) {
  2852. $where .= " and shipremarks like '%$so%'";
  2853. }
  2854. if ($source) {
  2855. if ($source == '2d') {
  2856. $where .= " and source >= '2'";
  2857. } else {
  2858. $where .= " and source = '$source'";
  2859. }
  2860. }
  2861. if (isset($_SESSION['api'])) {
  2862. foreach ($user as $value) {
  2863. $fgshop .= " shop = " . $value . " or";
  2864. }
  2865. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2866. }
  2867. if ($orderurl) {
  2868. $url = $this->orderurl->read($orderurl);
  2869. $where .= " and link like '%" . $url['url'] . "%'";
  2870. }
  2871. //数据排序
  2872. $order_str = "librarytime desc";
  2873. if (empty($page)) {
  2874. $start = 0;
  2875. $perpage = 1;
  2876. } else {
  2877. $start = ($page - 1) * $perpage;
  2878. }
  2879. //取得信息列表
  2880. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2881. //格式化数据
  2882. foreach ($info_list as $key => $value) {
  2883. $shop = $this->shop->read($value['shop']);
  2884. $info_list[$key]['shop'] = $shop['shopname'];
  2885. $express = $this->express->read($value['express']);
  2886. $info_list[$key]['express'] = $express['servicename'];
  2887. $warehouse = $this->warehouse->read($value['type']);
  2888. $info_list[$key]['type'] = $warehouse['title'];
  2889. if ($value['librarytime'] == '0') {
  2890. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2891. } else {
  2892. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2893. }
  2894. }
  2895. $total = $this->$sj->find_count($where);
  2896. $pagenum = ceil($total / $perpage);
  2897. $over = $total - ($start + $perpage);
  2898. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2899. echo json_encode($rows);
  2900. exit;
  2901. }
  2902. $this->data['express'] = $this->express->find_all();
  2903. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2904. $this->data['wlshop'] = $wlshop;
  2905. $user = $this->user->get_api($_SESSION['api']);
  2906. $powerid = $this->power->read($user['power']);
  2907. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2908. $pid = '';
  2909. foreach ($powertext as $v) {
  2910. $pid .= " id = " . $v . " or";
  2911. }
  2912. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2913. $this->data['fullorderexcel'] = $fullorderexcel;
  2914. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2915. $this->data['orderurl'] = $orderurl;
  2916. $this->_Template('whlabel_aoutorder', $this->data);
  2917. }
  2918. //速卖通出库订单
  2919. public function _soutorder()
  2920. {
  2921. if (isset($_SESSION['api'])) {
  2922. $user = $this->user->get_api($_SESSION['api']);
  2923. $usp = $user;
  2924. $fgshop = "";
  2925. $sid = "";
  2926. $user = explode('|', trim($user['shop'], '|'));
  2927. foreach ($user as $value) {
  2928. $sid .= " id = " . $value . " or";
  2929. }
  2930. }
  2931. $post = $this->input->post(NULL, TRUE);
  2932. if (isset($post['page'])) {
  2933. $page = $this->input->post('page', true);
  2934. $perpage = $this->input->post('perpage', true);
  2935. $warehouse = $this->input->post('warehouse', true);
  2936. $xztime = $this->input->post('xztime', true);
  2937. $timetk = $this->input->post('timetkk', true);
  2938. $timetj = $this->input->post('timetjj', true);
  2939. $shop = $this->input->post('shop', true);
  2940. $source = $this->input->post('source', true);
  2941. $orderinfo = $this->input->post('orderinfo', true);
  2942. $number = $this->input->post('number', true);
  2943. $express = $this->input->post('express', true);
  2944. $waybill = $this->input->post('waybill', true);
  2945. $library = $this->input->post('library', true);
  2946. $country = $this->input->post('country', true);
  2947. $sfxh = $this->input->post('sfxh', true);
  2948. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2949. $print = $this->input->post('print', true);
  2950. $state = $this->input->post('state', true);
  2951. $so = $this->input->post('so', true);
  2952. $timetk = strtotime($timetk);
  2953. $timetj = strtotime($timetj);
  2954. /**
  2955. $sj = $this->input->post('sj',true);
  2956. if($sj)
  2957. {
  2958. $sj = $this->input->post('sj',true);
  2959. }
  2960. else
  2961. {
  2962. $sj = "fullorder";
  2963. }
  2964. **/
  2965. $sj = "fullordersmt";
  2966. $where = "1=1";
  2967. if ($warehouse) {
  2968. $where .= " and type = '$warehouse'";
  2969. }
  2970. if ($timetk && $timetj) {
  2971. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2972. }
  2973. if ($orderinfo) {
  2974. $where .= " and orderinfo = '$orderinfo'";
  2975. }
  2976. if ($number) {
  2977. $where .= " and number = '$number'";
  2978. }
  2979. if ($express) {
  2980. $where .= " and express = '$express'";
  2981. }
  2982. if ($waybill) {
  2983. $where .= " and waybill = '$waybill'";
  2984. }
  2985. if ($library) {
  2986. $where .= " and library = '$library'";
  2987. }
  2988. if ($print) {
  2989. $where .= " and print = '$print'";
  2990. }
  2991. if ($libraryconfirm) {
  2992. $where .= " and libraryconfirm = '$libraryconfirm'";
  2993. }
  2994. if ($state) {
  2995. $where .= " and state = '$state'";
  2996. }
  2997. if ($shop) {
  2998. $where .= " and shop = '$shop'";
  2999. }
  3000. if ($sfxh != '') {
  3001. $where .= " and sfxh = '$sfxh'";
  3002. }
  3003. if ($so) {
  3004. $where .= " and shipremarks like '%$so%'";
  3005. }
  3006. if ($source) {
  3007. $where .= " and source = '$source'";
  3008. }
  3009. if ($country) {
  3010. $where .= " and country = '$country'";
  3011. } else {
  3012. if (isset($_SESSION['api'])) {
  3013. foreach ($user as $value) {
  3014. $fgshop .= " shop = " . $value . " or";
  3015. }
  3016. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3017. }
  3018. }
  3019. //数据排序
  3020. $order_str = "librarytime desc";
  3021. if (empty($page)) {
  3022. $start = 0;
  3023. $perpage = 1;
  3024. } else {
  3025. $start = ($page - 1) * $perpage;
  3026. }
  3027. //取得信息列表
  3028. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3029. //格式化数据
  3030. foreach ($info_list as $key => $value) {
  3031. $shop = $this->shop->read($value['shop']);
  3032. $info_list[$key]['shop'] = $shop['shopname'];
  3033. $express = $this->express->read($value['express']);
  3034. $info_list[$key]['express'] = $express['servicename'];
  3035. $warehouse = $this->warehouse->read($value['type']);
  3036. $info_list[$key]['type'] = $warehouse['title'];
  3037. if ($value['librarytime'] == '0') {
  3038. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3039. } else {
  3040. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3041. }
  3042. }
  3043. $total = $this->$sj->find_count($where);
  3044. $pagenum = ceil($total / $perpage);
  3045. $over = $total - ($start + $perpage);
  3046. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3047. echo json_encode($rows);
  3048. exit;
  3049. }
  3050. $this->data['express'] = $this->express->find_all();
  3051. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3052. $this->data['wlshop'] = $wlshop;
  3053. $user = $this->user->get_api($_SESSION['api']);
  3054. $powerid = $this->power->read($user['power']);
  3055. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3056. $pid = '';
  3057. foreach ($powertext as $v) {
  3058. $pid .= " id = " . $v . " or";
  3059. }
  3060. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3061. $this->data['fullorderexcel'] = $fullorderexcel;
  3062. $this->_Template('whlabel_soutorder', $this->data);
  3063. }
  3064. //订单退库
  3065. public function _retreat()
  3066. {
  3067. $post = $this->input->post(NULL, TRUE);
  3068. if (isset($post['page'])) {
  3069. $page = $this->input->post('page', true);
  3070. $perpage = $this->input->post('perpage', true);
  3071. $warehouse = $this->input->post('warehouse', true);
  3072. $timetk = $this->input->post('timetk', true);
  3073. $timetj = $this->input->post('timetj', true);
  3074. $shop = $this->input->post('shop', true);
  3075. $source = $this->input->post('source', true);
  3076. $state = $this->input->post('state', true);
  3077. $review = $this->input->post('review', true);
  3078. $state = $this->input->post('state', true);
  3079. $express = $this->input->post('express', true);
  3080. $orderinfo = $this->input->post('orderinfo', true);
  3081. $user = $this->input->post('user', true);
  3082. $name = $this->input->post('name', true);
  3083. $waybill = $this->input->post('waybill', true);
  3084. $timetk = strtotime($timetk);
  3085. $timetj = strtotime($timetj);
  3086. $where = "(state=206 or state=210) and mergeid = 0";
  3087. if ($warehouse) {
  3088. $where .= " and state = '$warehouse'";
  3089. }
  3090. if ($timetk && $timetj) {
  3091. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3092. }
  3093. if ($shop) {
  3094. $where .= " and shop = '$shop'";
  3095. }
  3096. if ($source) {
  3097. $where .= " and source = '$source'";
  3098. }
  3099. if ($state) {
  3100. $where .= " and state = '$state'";
  3101. }
  3102. if ($review) {
  3103. $where .= " and review = '$review'";
  3104. }
  3105. if ($state) {
  3106. $where .= " and state = '$state'";
  3107. }
  3108. if ($express) {
  3109. $where .= " and express = '$express'";
  3110. }
  3111. if ($orderinfo) {
  3112. $where .= " and orderinfo = '$orderinfo'";
  3113. }
  3114. if ($user) {
  3115. $where .= " and user = '$user'";
  3116. }
  3117. if ($name) {
  3118. $where .= " and name = '$name'";
  3119. }
  3120. if ($waybill) {
  3121. $where .= " and waybill = '$waybill'";
  3122. }
  3123. //数据排序
  3124. $order_str = "id desc";
  3125. if (empty($page)) {
  3126. $start = 0;
  3127. $perpage = 1;
  3128. } else {
  3129. $start = ($page - 1) * $perpage;
  3130. }
  3131. //取得信息列表
  3132. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3133. //格式化数据
  3134. foreach ($info_list as $key => $value) {
  3135. $shop = $this->shop->read($value['shop']);
  3136. $info_list[$key]['shop'] = $shop['shopname'];
  3137. $warehouse = $this->warehouse->read($value['warehouse']);
  3138. $info_list[$key]['warehouse'] = $warehouse['title'];
  3139. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3140. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3141. if ($value['waybill'] == 0) {
  3142. $info_list[$key]['waybill'] = "";
  3143. }
  3144. $express = $this->express->read($value['express']);
  3145. $info_list[$key]['express'] = $express['title'];
  3146. $typeclass = $this->typeclass->read($value['state']);
  3147. $info_list[$key]['state'] = $typeclass['title'];
  3148. }
  3149. $total = $this->fullorder->find_count($where);
  3150. $pagenum = ceil($total / $perpage);
  3151. $over = $total - ($start + $perpage);
  3152. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3153. echo json_encode($rows);
  3154. exit;
  3155. }
  3156. $this->data['express'] = $this->express->find_all();
  3157. $this->_Template('whlabel_retreat', $this->data);
  3158. }
  3159. //退库标签浏览
  3160. public function _retreatlk()
  3161. {
  3162. $post = $this->input->post(NULL, TRUE);
  3163. if (isset($post['page'])) {
  3164. $page = $this->input->post('page', true);
  3165. $perpage = $this->input->post('perpage', true);
  3166. $timetk = $this->input->post('timetk', true);
  3167. $timetj = $this->input->post('timetj', true);
  3168. $sku = $this->input->post('sku', true);
  3169. $warehouse = $this->input->post('warehouse', true);
  3170. $purchase = $this->input->post('purchase', true);
  3171. $orderinfo = $this->input->post('orderinfo', true);
  3172. $waybill = $this->input->post('waybill', true);
  3173. $category = $this->input->post('category', true);
  3174. $size = $this->input->post('size', true);
  3175. $grade = $this->input->post('grade', true);
  3176. $color = $this->input->post('color', true);
  3177. $lowe = $this->input->post('lowe', true);
  3178. $state = $this->input->post('state', true);
  3179. $timetk = strtotime($timetk);
  3180. $timetj = strtotime($timetj);
  3181. $where = "state=2";
  3182. if ($timetk && $timetj) {
  3183. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3184. }
  3185. if ($sku) {
  3186. $where .= " and sku = '$sku'";
  3187. }
  3188. if ($warehouse) {
  3189. $where .= " and warehouse = '$warehouse'";
  3190. }
  3191. if ($purchase) {
  3192. $where .= " and purchase = '$purchase'";
  3193. }
  3194. if ($orderinfo) {
  3195. $where .= " and orderinfo = '$orderinfo'";
  3196. }
  3197. if ($waybill) {
  3198. $where .= " and waybill = '$waybill'";
  3199. }
  3200. if ($category) {
  3201. $where .= " and features like '%-$category-%'";
  3202. }
  3203. if ($size) {
  3204. $where .= " and features like '%-$size-%'";
  3205. }
  3206. if ($grade) {
  3207. $where .= " and features like '%-$grade-%'";
  3208. }
  3209. if ($color) {
  3210. $where .= " and features like '%-$color-%'";
  3211. }
  3212. if ($lowe) {
  3213. $where .= " and features like '%-$lowe-%'";
  3214. }
  3215. //数据排序
  3216. $order_str = "time desc";
  3217. if (empty($page)) {
  3218. $start = 0;
  3219. $perpage = 1;
  3220. } else {
  3221. $start = ($page - 1) * $perpage;
  3222. }
  3223. //取得信息列表
  3224. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3225. foreach ($info_list as $key => $value) {
  3226. $warehouse = $this->warehouse->read($value['warehouse']);
  3227. $info_list[$key]['warehouse'] = $warehouse['title'];
  3228. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3229. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3230. $purchase = $this->purchase->read($value['purchase']);
  3231. $info_list[$key]['purchase'] = $purchase['title'];
  3232. if ($value['outk'] != 0) {
  3233. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3234. } else {
  3235. $info_list[$key]['outk'] = "";
  3236. }
  3237. if ($value['retreat'] != 0) {
  3238. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3239. } else {
  3240. $info_list[$key]['retreat'] = "";
  3241. }
  3242. if ($value['orderinfo'] == 0) {
  3243. $info_list[$key]['orderinfo'] = "";
  3244. }
  3245. if ($value['waybill'] == 0) {
  3246. $info_list[$key]['waybill'] = "";
  3247. }
  3248. }
  3249. $total = $this->whlabel->find_count($where);
  3250. $pagenum = ceil($total / $perpage);
  3251. $over = $total - ($start + $perpage);
  3252. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3253. echo json_encode($rows);
  3254. exit;
  3255. }
  3256. $this->_Template('whlabel_retreatlk', $this->data);
  3257. }
  3258. //更换标签及浏览
  3259. public function _change()
  3260. {
  3261. $post = $this->input->post(NULL, TRUE);
  3262. if (isset($post['page'])) {
  3263. $page = $this->input->post('page', true);
  3264. $perpage = $this->input->post('perpage', true);
  3265. $timetk = $this->input->post('timetk', true);
  3266. $timetj = $this->input->post('timetj', true);
  3267. $label = $this->input->post('label', true);
  3268. $oldlabel = $this->input->post('oldlabel', true);
  3269. $timetk = strtotime($timetk);
  3270. $timetj = strtotime($timetj);
  3271. $where = "state=10 ";
  3272. if ($timetk && $timetj) {
  3273. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3274. }
  3275. if ($label) {
  3276. $where .= " and label = '$label'";
  3277. }
  3278. if ($oldlabel) {
  3279. $where .= " and oldlabel = '$oldlabel'";
  3280. }
  3281. //数据排序
  3282. $order_str = "time asc";
  3283. if (empty($page)) {
  3284. $start = 0;
  3285. $perpage = 1;
  3286. } else {
  3287. $start = ($page - 1) * $perpage;
  3288. }
  3289. //取得信息列表
  3290. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3291. foreach ($info_list as $key => $value) {
  3292. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3293. }
  3294. $total = $this->whlabel->find_count($where);
  3295. $pagenum = ceil($total / $perpage);
  3296. $over = $total - ($start + $perpage);
  3297. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3298. echo json_encode($rows);
  3299. exit;
  3300. }
  3301. $this->_Template('whlabel_change', $this->data);
  3302. }
  3303. //产品标签
  3304. public function _cpbqdc()
  3305. {
  3306. if (isset($_GET['excel'])) {
  3307. $where = "1=1";
  3308. //数据排序
  3309. $order_str = "id desc";
  3310. if (empty($page)) {
  3311. $start = 0;
  3312. $perpage = 1;
  3313. } else {
  3314. $start = ($page - 1) * $perpage;
  3315. }
  3316. $warehouse = $this->input->get('warehouse', true);
  3317. $state = $this->input->get('state', true);
  3318. $timetk = $this->input->get('timetkk', true);
  3319. $timetj = $this->input->get('timetjj', true);
  3320. $timetk = strtotime($timetk);
  3321. $timetj = strtotime($timetj);
  3322. if ($warehouse) {
  3323. $where .= " and warehouse = '$warehouse'";
  3324. }
  3325. if ($state || $state == 0) {
  3326. $where .= " and state = '$state'";
  3327. }
  3328. if ($timetk && $timetj) {
  3329. $where .= " and time > '$timetk' and time < '$timetj'";
  3330. }
  3331. //取得信息列表
  3332. $info_list = $this->whlabel->find_all($where, '*');
  3333. $rows = array();
  3334. $list = array();
  3335. foreach ($info_list as $key => $value) {
  3336. $rows[$value['time']] = $value; //所有数据sku
  3337. }
  3338. foreach ($rows as $value) {
  3339. $warehouse = $this->warehouse->read($value['warehouse']);
  3340. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3341. $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);
  3342. }
  3343. $title = "产品标签统计表";
  3344. $titlename = "<table border=1>
  3345. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3346. <tr align='center'>
  3347. <td>仓库</td>
  3348. <td>SKU</td>
  3349. <td>产品</td>
  3350. <td>入库时间</td>
  3351. <td>操作时间</td>
  3352. <td>备注</td>
  3353. <td>数量</td>
  3354. </tr>
  3355. </table>";
  3356. $filename = $title . ".xls";
  3357. $tail = "";
  3358. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3359. }
  3360. }
  3361. //进销存导出
  3362. public function _exceljxc()
  3363. {
  3364. $classid = $this->classid->sku();
  3365. $pm = $classid;
  3366. $typeclass = array();
  3367. $tc = $this->typeclass->find_all();
  3368. foreach ($tc as $v) {
  3369. $typeclass[$v['id']] = $v;
  3370. }
  3371. $prc = array();
  3372. $purchase = $this->purchase->find_all();
  3373. foreach ($purchase as $k => $v) {
  3374. $prc[$v['id']] = $v['title'];
  3375. }
  3376. if (isset($_GET['excel'])) {
  3377. $where = "sku != 'Preset'";
  3378. //数据排序
  3379. $order_str = "id desc";
  3380. if (empty($page)) {
  3381. $start = 0;
  3382. $perpage = 1;
  3383. } else {
  3384. $start = ($page - 1) * $perpage;
  3385. }
  3386. $category = $this->input->get('category', true);
  3387. $warehouse = $this->input->get('warehouse', true);
  3388. $excelid = $this->input->get('sid', true);
  3389. if ($category) {
  3390. $where .= " and features like '%-$category-%'";
  3391. }
  3392. if ($warehouse) {
  3393. $where .= " and warehouse = '$warehouse'";
  3394. }
  3395. $xzid = '';
  3396. if ($excelid) {
  3397. $excelid = explode(',', trim($excelid, ','));
  3398. foreach ($excelid as $key => $value) {
  3399. $xzid .= " id = " . $value . " or";
  3400. }
  3401. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3402. }
  3403. //取得信息列表
  3404. /**
  3405. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3406. $rows = array();$list = array();
  3407. foreach ($info_list as $key=>$value)
  3408. {
  3409. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3410. }
  3411. **/
  3412. $wt = array();
  3413. $whlabel_type = $this->whlabel_type->find_all();
  3414. foreach ($whlabel_type as $v) {
  3415. $wt[$v['id']] = $v['title'];
  3416. }
  3417. $wh = array();
  3418. $w = $this->warehouse->find_all('1=1', 'id,title');
  3419. foreach ($w as $v) {
  3420. $wh[$v['id']] = $v['title'];
  3421. }
  3422. $list = array();
  3423. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3424. foreach ($rows as $key => $value) {
  3425. if (isset($wt[$value['type']])) {
  3426. $rows[$key]['type'] = $wt[$value['type']];
  3427. } else {
  3428. $rows[$key]['type'] = '未设置';
  3429. }
  3430. $bm = '03';
  3431. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3432. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3433. $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');
  3434. $details = array();
  3435. $cpid = array();
  3436. $cpbz = array();
  3437. $c = 0;
  3438. $g = 0;
  3439. $x = 0;
  3440. $t = 0;
  3441. $s = 0;
  3442. $q = 0;
  3443. foreach ($sd as $k => $v) {
  3444. if ($v['state'] == 0) {
  3445. $c++;
  3446. if ($v['cpid'] != 0) {
  3447. $cpid[$v['cpid']] = $v['cpid'];
  3448. }
  3449. if ($v['cpbz'] != '') {
  3450. $cpbz[$v['cpbz']] = $v['cpbz'];
  3451. }
  3452. }
  3453. if ($v['state'] != 9) {
  3454. $g++;
  3455. }
  3456. if ($v['state'] == 1) {
  3457. $x++;
  3458. }
  3459. if ($v['state'] == 2) {
  3460. $t++;
  3461. }
  3462. if ($v['state'] == 8) {
  3463. $s++;
  3464. }
  3465. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3466. $q++;
  3467. }
  3468. $details[$v['details']] = $v['details'];
  3469. }
  3470. $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'] . '"');
  3471. $rows[$key]['details'] = implode("、", $details);
  3472. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3473. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3474. $number = $value['number'];
  3475. $ftime = time() - 15 * 24 * 3600;
  3476. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3477. $rows[$key]['number'] = $g;
  3478. $rows[$key]['c'] = $c;
  3479. $rows[$key]['x'] = $x;
  3480. $rows[$key]['t'] = $t;
  3481. $rows[$key]['s'] = $s;
  3482. $rows[$key]['q'] = $q;
  3483. $rows[$key]['z'] = $z;
  3484. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3485. $features = explode('-', trim($features, '-'));
  3486. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3487. // $pm = $classid;
  3488. // $jm = $classid;
  3489. // foreach($features as $k=>$v)
  3490. // {
  3491. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3492. // {
  3493. // if($typeclass[$v]['bm'] != '')
  3494. // {
  3495. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3496. // }
  3497. // }
  3498. // if($v != 0)
  3499. // {
  3500. // if(!isset($typeclass[$v]))
  3501. // {
  3502. // continue;
  3503. // }
  3504. // if(isset($pm[$typeclass[$v]['classid']]))
  3505. // {
  3506. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3507. // {
  3508. // $tz = explode('|',$typeclass[$v]['zh']);
  3509. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3510. // }
  3511. // else
  3512. // {
  3513. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3514. // }
  3515. // }
  3516. // if(isset($jm[$typeclass[$v]['classid']]))
  3517. // {
  3518. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3519. // }
  3520. // }
  3521. // }
  3522. // $jm = array_filter($jm);
  3523. // $rows[$key]['bs'] = implode("-",$jm);
  3524. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3525. // $zh = implode(" ",$pm);
  3526. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3527. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3528. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3529. // $rows[$key]['features'] = $zh;
  3530. }
  3531. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3532. $final_list = [];
  3533. foreach ($list as $k => $v) {
  3534. if (empty($v['sku'])) {
  3535. continue;
  3536. }
  3537. $final_list[] = [
  3538. "warehouse" => $v["warehouse"],
  3539. "purchase" => $v["purchase"],
  3540. "details" => $v["details"],
  3541. "cpid" => $v["cpid"],
  3542. "dbcontent" => $v["dbcontent"],
  3543. "sku" => $v["sku"],
  3544. "cs" => $v["bm"],
  3545. "bs" => $v["jm"],
  3546. "title" => $v["title"],
  3547. "features" => $v["pm"],
  3548. "cpbz" => $v["cpbz"],
  3549. "sm" => $v["sm"],
  3550. "type" => $v["type"],
  3551. "number" => $v["number"],
  3552. "c" => $v["c"],
  3553. "x" => $v["x"],
  3554. "t" => $v["t"],
  3555. "s" => $v["s"],
  3556. "q" => $v["q"],
  3557. "z" => $v["z"],
  3558. "weight" => $v['weight'],
  3559. ];
  3560. }
  3561. $title = "总进销存统计表";
  3562. $titlename = "<table border=1>
  3563. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3564. <tr align='center'>
  3565. <td>仓库</td>
  3566. <td>供应商</td>
  3567. <td>位置</td>
  3568. <td>库存编码</td>
  3569. <td>类目</td>
  3570. <td>SKU</td>
  3571. <td>用友编码</td>
  3572. <td>用友料号</td>
  3573. <td>商品名称</td>
  3574. <td>商品中文</td>
  3575. <td>产品备注</td>
  3576. <td>说明</td>
  3577. <td>类型</td>
  3578. <td>入库总量</td>
  3579. <td>库存数量</td>
  3580. <td>销售数量</td>
  3581. <td>退货数量</td>
  3582. <td>删除数量</td>
  3583. <td>其它操作</td>
  3584. <td>占单数量</td>
  3585. <td>重量(g)</td>
  3586. </tr>
  3587. </table>";
  3588. $filename = $title . ".xls";
  3589. $tail = "";
  3590. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3591. }
  3592. }
  3593. //入库导出
  3594. public function _excelr()
  3595. {
  3596. if (isset($_GET['excel'])) {
  3597. $category = $this->input->get('category', true);
  3598. $size = $this->input->get('size', true);
  3599. $grade = $this->input->get('grade', true);
  3600. $color = $this->input->get('color', true);
  3601. $lowe = $this->input->get('lowe', true);
  3602. $sku = $this->input->get('sku', true);
  3603. $warehouse = $this->input->get('warehouse', true);
  3604. $purchase = $this->input->get('purchase', true);
  3605. $ktime = $this->input->get('ktime', true);
  3606. $jtime = $this->input->get('jtime', true);
  3607. $ktime = strtotime($ktime);
  3608. $jtime = strtotime($jtime);
  3609. $where = "1=1";
  3610. $gj = "";
  3611. $ck = "";
  3612. if ($category) {
  3613. $where .= " and features like '%-$category-%'";
  3614. }
  3615. if ($size) {
  3616. $where .= " and features like '%-$size-%'";
  3617. }
  3618. if ($grade) {
  3619. $where .= " and features like '%-$grade-%'";
  3620. }
  3621. if ($color) {
  3622. $where .= " and features like '%-$color-%'";
  3623. }
  3624. if ($lowe) {
  3625. $where .= " and features like '%-$lowe-%'";
  3626. }
  3627. if ($warehouse) {
  3628. $where .= " and warehouse = '$warehouse'";
  3629. }
  3630. if ($purchase) {
  3631. $where .= " and purchase = '$purchase'";
  3632. }
  3633. if ($sku) {
  3634. $where .= " and sku = '$sku'";
  3635. }
  3636. if ($ktime && $jtime) {
  3637. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3638. }
  3639. //数据排序
  3640. $order_str = "id desc";
  3641. if (empty($page)) {
  3642. $start = 0;
  3643. $perpage = 1;
  3644. } else {
  3645. $start = ($page - 1) * $perpage;
  3646. }
  3647. $list = array();
  3648. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3649. foreach ($rows as $value) {
  3650. $ck = $this->warehouse->read($value['warehouse']);
  3651. $warehouse = $ck['title'];
  3652. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3653. $retreatwarehouse = $tkck['title'];
  3654. $gy = $this->purchase->read($value['purchase']);
  3655. $purchase = $gy['title'];
  3656. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3657. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3658. }
  3659. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3660. $titlename = "<table border=1>
  3661. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3662. <tr align='center'>
  3663. <td>仓库</td>
  3664. <td>SKU</td>
  3665. <td>产品</td>
  3666. <td>时间</td>
  3667. <td>数量</td>
  3668. </tr>
  3669. </table>";
  3670. $filename = $title . ".xls";
  3671. $tail = "";
  3672. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3673. }
  3674. }
  3675. //出库、退库导出
  3676. public function _excelct()
  3677. {
  3678. $classid = $this->classid->sku();
  3679. $pm = $classid;
  3680. $typeclass = array();
  3681. $tc = $this->typeclass->find_all();
  3682. foreach ($tc as $v) {
  3683. $typeclass[$v['id']] = $v;
  3684. }
  3685. $prc = array();
  3686. $purchase = $this->purchase->find_all();
  3687. foreach ($purchase as $k => $v) {
  3688. $prc[$v['id']] = $v['title'];
  3689. }
  3690. if (isset($_GET['excel'])) {
  3691. $wh = array();
  3692. $w = $this->warehouse->find_all('1=1', 'id,title');
  3693. foreach ($w as $v) {
  3694. $wh[$v['id']] = $v['title'];
  3695. }
  3696. $type = $this->input->get('excel', true);
  3697. $category = $this->input->get('category', true);
  3698. $size = $this->input->get('size', true);
  3699. $grade = $this->input->get('grade', true);
  3700. $color = $this->input->get('color', true);
  3701. $lowe = $this->input->get('lowe', true);
  3702. $sku = $this->input->get('sku', true);
  3703. $title = $this->input->get('title', true);
  3704. $warehouse = $this->input->get('warehouse', true);
  3705. $purchase = $this->input->get('purchase', true);
  3706. $lacetype = $this->input->get('lacetype', true);
  3707. $haircap = $this->input->get('haircap', true);
  3708. $lacecolor = $this->input->get('lacecolor', true);
  3709. $density = $this->input->get('density', true);
  3710. $details = $this->input->get('details', true);
  3711. $state = $this->input->get('state', true);
  3712. $shop = $this->input->get('shop', true);
  3713. $hairnumber = $this->input->get('hairnumber', true);
  3714. $type_leixi = $this->input->get('type', true);
  3715. $cpbz = $this->input->get('cpbz', true);
  3716. $sm = $this->input->get('sm', true);
  3717. $sid = $this->input->get('sid', true);
  3718. $ktime = $this->input->get('ktime', true);
  3719. $jtime = $this->input->get('jtime', true);
  3720. $ktime = strtotime($ktime);
  3721. $jtime = strtotime($jtime);
  3722. //$where = " 1=1 ";
  3723. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3724. $where = " sku != '' ";
  3725. $gj = "";
  3726. $ck = "";
  3727. if ($category) {
  3728. $where .= " and features like '%-$category-%'";
  3729. }
  3730. if ($size) {
  3731. $where .= " and features like '%-$size-%'";
  3732. }
  3733. if ($grade) {
  3734. $where .= " and features like '%-$grade-%'";
  3735. }
  3736. if ($color) {
  3737. $where .= " and features like '%-$color-%'";
  3738. }
  3739. if ($lowe) {
  3740. $where .= " and features like '%-$lowe-%'";
  3741. }
  3742. if ($warehouse) {
  3743. $where .= " and warehouse = '$warehouse'";
  3744. }
  3745. if ($purchase) {
  3746. $where .= " and purchase = '$purchase'";
  3747. }
  3748. if ($state) {
  3749. $where .= " and state = '$state'";
  3750. }
  3751. if ($lacetype) {
  3752. $where .= " and features like '%-$lacetype-%'";
  3753. }
  3754. if ($lacecolor) {
  3755. $where .= " and features like '%-$lacecolor-%'";
  3756. }
  3757. if ($density) {
  3758. $where .= " and features like '%-$density-%'";
  3759. }
  3760. if ($haircap) {
  3761. $where .= " and features like '%-$haircap-%'";
  3762. }
  3763. if ($details) {
  3764. $where .= " and details = '$details'";
  3765. }
  3766. if ($shop) {
  3767. $where .= " and shop like '%$shop%'";
  3768. }
  3769. if ($title) {
  3770. $title = trim($title, ' ');
  3771. $title = trim($title, ' ');
  3772. $where .= " and title like '%$title%'";
  3773. }
  3774. if (!empty($hairnumber)) {
  3775. $where .= " and features like '%-128-%' ";
  3776. if ($hairnumber < 0) {
  3777. $class_list = $this->typeclass->find_all('classid = 43');
  3778. foreach ($class_list as $v) {
  3779. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3780. }
  3781. } else {
  3782. $where .= " and features like '%-$hairnumber-%'";
  3783. }
  3784. }
  3785. if ($type_leixi) {
  3786. $where .= " and type = '$type_leixi'";
  3787. }
  3788. if ($cpbz) {
  3789. $where .= " and cpbz like '%$cpbz%' ";
  3790. }
  3791. if ($sm) {
  3792. $where .= " and sm like '%$sm%' ";
  3793. }
  3794. if ($sku) {
  3795. $sku = trim($sku, ' ');
  3796. $sku = trim($sku, ' ');
  3797. $where .= " and sku like '%$sku%'";
  3798. }
  3799. if ($ktime && $jtime) {
  3800. if ($type == 1) {
  3801. $tl = '出库';
  3802. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3803. } else if ($type == 2) {
  3804. $tl = '退库';
  3805. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3806. } else if ($type == 3) {
  3807. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3808. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3809. } else if ($type == 4) {
  3810. $tl = '出库+零售';
  3811. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3812. } else if ($type == 5) {
  3813. $tl = '零售';
  3814. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3815. }
  3816. }
  3817. $sidwhere = '';
  3818. if ($sid) {
  3819. $sd = "";
  3820. $s = explode(',', trim($sid, ','));
  3821. foreach ($s as $value) {
  3822. $sd .= " id = " . $value . " or";
  3823. }
  3824. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3825. }
  3826. //数据排序
  3827. $order_str = "time desc";
  3828. if (empty($page)) {
  3829. $start = 0;
  3830. $perpage = 1;
  3831. } else {
  3832. $start = ($page - 1) * $perpage;
  3833. }
  3834. //取得信息列表
  3835. if ($type != 3 && $type != 5) {
  3836. if ($type == 1 || $type == 4) {
  3837. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3838. foreach ($info_list as $key => $value) {
  3839. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3840. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3841. $warehouse = $this->warehouse->read($value['warehouse']);
  3842. $info_list[$key]['warehouse'] = $warehouse['title'];
  3843. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3844. $features = explode('-', trim($features, '-'));
  3845. $pm = $classid;
  3846. foreach ($features as $k => $v) {
  3847. if ($v != 0) {
  3848. if (!isset($typeclass[$v])) {
  3849. continue;
  3850. }
  3851. if (isset($pm[$typeclass[$v]['classid']])) {
  3852. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3853. $tz = explode('|', $typeclass[$v]['zh']);
  3854. $pm[$typeclass[$v]['classid']] = $tz[0];
  3855. } else {
  3856. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3857. }
  3858. }
  3859. }
  3860. }
  3861. $zh = implode(" ", $pm);
  3862. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3863. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3864. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3865. $info_list[$key]['features'] = $zh;
  3866. }
  3867. $final_list = [];
  3868. foreach($info_list as $k=>$v){
  3869. $number = "";
  3870. if(!empty($v['orderinfo'])){
  3871. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3872. if(!empty($tmp_info['number'])){
  3873. $number = $tmp_info['number'];
  3874. }
  3875. }
  3876. $final_list[] = [
  3877. 'warehouse'=>$v['warehouse'],
  3878. 'purchase'=>$v['purchase'],
  3879. 'sku'=>$v['sku'],
  3880. 'title'=>$v['title'],
  3881. 'features'=>$v['features'],
  3882. 'label'=>$v['label'],
  3883. 'orderinfo'=>$v['orderinfo'],
  3884. 'number'=>$number,
  3885. 'waybill'=>$v['waybill'],
  3886. 'outk'=>$v['outk'],
  3887. ];
  3888. }
  3889. } else {
  3890. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3891. foreach ($info_list as $key => $value) {
  3892. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3893. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3894. $warehouse = $this->warehouse->read($value['warehouse']);
  3895. $info_list[$key]['warehouse'] = $warehouse['title'];
  3896. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3897. $features = explode('-', trim($features, '-'));
  3898. $pm = $classid;
  3899. foreach ($features as $k => $v) {
  3900. if ($v != 0) {
  3901. if (!isset($typeclass[$v])) {
  3902. continue;
  3903. }
  3904. if (isset($pm[$typeclass[$v]['classid']])) {
  3905. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3906. $tz = explode('|', $typeclass[$v]['zh']);
  3907. $pm[$typeclass[$v]['classid']] = $tz[0];
  3908. } else {
  3909. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3910. }
  3911. }
  3912. }
  3913. }
  3914. $zh = implode(" ", $pm);
  3915. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3916. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3917. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3918. $info_list[$key]['features'] = $zh;
  3919. }
  3920. $final_list = [];
  3921. foreach($info_list as $k=>$v){
  3922. $number = "";
  3923. if(!empty($v['orderinfo'])){
  3924. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3925. if(!empty($tmp_info['number'])){
  3926. $number = $tmp_info['number'];
  3927. }
  3928. }
  3929. $final_list[] = [
  3930. 'warehouse'=>$v['warehouse'],
  3931. 'purchase'=>$v['purchase'],
  3932. 'sku'=>$v['sku'],
  3933. 'title'=>$v['title'],
  3934. 'features'=>$v['features'],
  3935. 'label'=>$v['label'],
  3936. 'orderinfo'=>$v['orderinfo'],
  3937. 'number'=>$number,
  3938. 'waybill'=>$v['waybill'],
  3939. 'retreat'=>$v['retreat'],
  3940. ];
  3941. }
  3942. }
  3943. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3944. $titlename = "<table border=1>
  3945. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3946. <tr align='center'>
  3947. <td>仓库</td>
  3948. <td>供应商</td>
  3949. <td>SKU</td>
  3950. <td>商品名称</td>
  3951. <td>商品中文</td>
  3952. <td>标签</td>
  3953. <td>订单号</td>
  3954. <td>订单编码</td>
  3955. <td>运单号</td>
  3956. <td>" . $tl . "时间(中国时间)</td>
  3957. </tr>
  3958. </table>";
  3959. $filename = $title . ".xls";
  3960. $tail = "";
  3961. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3962. } else if ($type == 5) {
  3963. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3964. foreach ($info_list as $key => $value) {
  3965. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3966. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3967. $warehouse = $this->warehouse->read($value['warehouse']);
  3968. $info_list[$key]['warehouse'] = $warehouse['title'];
  3969. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3970. $features = explode('-', trim($features, '-'));
  3971. $pm = $classid;
  3972. foreach ($features as $k => $v) {
  3973. if ($v != 0) {
  3974. if (!isset($typeclass[$v])) {
  3975. continue;
  3976. }
  3977. if (isset($pm[$typeclass[$v]['classid']])) {
  3978. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3979. $tz = explode('|', $typeclass[$v]['zh']);
  3980. $pm[$typeclass[$v]['classid']] = $tz[0];
  3981. } else {
  3982. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3983. }
  3984. }
  3985. }
  3986. }
  3987. $zh = implode(" ", $pm);
  3988. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3989. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3990. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3991. $info_list[$key]['features'] = $zh;
  3992. }
  3993. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3994. $titlename = "<table border=1>
  3995. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3996. <tr align='center'>
  3997. <td>仓库</td>
  3998. <td>供应商</td>
  3999. <td>SKU</td>
  4000. <td>商品名称</td>
  4001. <td>商品中文</td>
  4002. <td>标签</td>
  4003. <td>" . $tl . "时间(中国时间)</td>
  4004. </tr>
  4005. </table>";
  4006. $filename = $title . ".xls";
  4007. $tail = "";
  4008. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4009. } else {
  4010. /**
  4011. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4012. $rows = array();$list = array();
  4013. foreach ($info_list as $key=>$value)
  4014. {
  4015. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4016. }
  4017. **/
  4018. $wh = array();
  4019. $w = $this->warehouse->find_all('1=1', 'id,title');
  4020. foreach ($w as $v) {
  4021. $wh[$v['id']] = $v['title'];
  4022. }
  4023. $wt = array();
  4024. $whlabel_type = $this->whlabel_type->find_all();
  4025. foreach ($whlabel_type as $v) {
  4026. $wt[$v['id']] = $v['title'];
  4027. }
  4028. $classid = $this->classid->sku();
  4029. $list = array();
  4030. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4031. foreach ($rows as $key => $value) {
  4032. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4033. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4034. $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');
  4035. $details = array();
  4036. $cpid = array();
  4037. $cpbz = array();
  4038. $c = 0;
  4039. $g = 0;
  4040. $x = 0;
  4041. $t = 0;
  4042. $s = 0;
  4043. $q = 0;
  4044. foreach ($sd as $k => $v) {
  4045. if ($v['state'] == 0) {
  4046. $c++;
  4047. }
  4048. if ($v['state'] != 9) {
  4049. $g++;
  4050. }
  4051. if ($v['outk'] > 1) {
  4052. $x++;
  4053. }
  4054. if ($v['retreat'] > 0) {
  4055. $t++;
  4056. }
  4057. if ($v['state'] == 8) {
  4058. $s++;
  4059. }
  4060. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4061. $q++;
  4062. }
  4063. $details[$v['details']] = $v['details'];
  4064. if ($v['cpid'] != 0) {
  4065. $cpid[$v['cpid']] = $v['cpid'];
  4066. }
  4067. if ($v['cpbz'] != '') {
  4068. $cpbz[$v['cpbz']] = $v['cpbz'];
  4069. }
  4070. }
  4071. if (isset($wt[$value['type']])) {
  4072. $rows[$key]['type'] = $wt[$value['type']];
  4073. } else {
  4074. $rows[$key]['type'] = '未设置';
  4075. }
  4076. $rows[$key]['details'] = implode("、", $details);
  4077. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4078. $ftime = time() - 15 * 24 * 3600;
  4079. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4080. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4081. $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);
  4082. $rows[$key]['c'] = $c;
  4083. $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);
  4084. $rows[$key]['t'] = $t;
  4085. $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'] . '"');
  4086. $rows[$key]['z'] = $z;
  4087. // $jm = $classid;
  4088. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4089. $features = explode('-', trim($features, '-'));
  4090. // $pm = $classid;
  4091. // foreach ($features as $k => $v) {
  4092. // if ($v != 0) {
  4093. // if (!isset($typeclass[$v])) {
  4094. // continue;
  4095. // }
  4096. // if (isset($pm[$typeclass[$v]['classid']])) {
  4097. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4098. // $tz = explode('|', $typeclass[$v]['zh']);
  4099. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4100. // } else {
  4101. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4102. // }
  4103. // if (isset($jm[$typeclass[$v]['classid']])) {
  4104. // if ($typeclass[$v]['jm']) {
  4105. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4106. // }
  4107. // }
  4108. // }
  4109. // }
  4110. // }
  4111. // $zh = implode(" ", $pm);
  4112. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4113. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4114. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4115. // $rows[$key]['features'] = $zh;
  4116. // $jm = array_filter($jm); //去除空值
  4117. // $jm = implode("-", $jm);
  4118. // $rows[$key]['jm'] = $jm;
  4119. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4120. }
  4121. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4122. // echo "<pre>";
  4123. // print_r($tmp_list);
  4124. // die;
  4125. $final_list =[];
  4126. foreach($tmp_list as $k=>$v){
  4127. $final_list[] = [
  4128. "warehouse"=>$v['warehouse'],
  4129. "purchase"=>$v['purchase'],
  4130. "details"=>$v['details'],
  4131. "cpid"=>$v['cpid'],
  4132. "sku"=>$v['sku'],
  4133. "title"=>$v['title'],
  4134. "features"=>$v['pm'],
  4135. "cpbz"=>$v['cpbz'],
  4136. "sm"=>$v['sm'],
  4137. "type"=>$v['type'],
  4138. "g"=>$v["g"],
  4139. "c"=>$v["c"],
  4140. "x"=>$v["x"],
  4141. "t"=>$v["t"],
  4142. "z"=>$v["z"],
  4143. "jm"=>$v["jm"],
  4144. "weight"=>$v["weight"],
  4145. "asd"=>$v["asd"],
  4146. ];
  4147. }
  4148. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4149. $titlename = "<table border=1>
  4150. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4151. <tr align='center'>
  4152. <td>仓库</td>
  4153. <td>供应商</td>
  4154. <td>位置</td>
  4155. <td>库存编码</td>
  4156. <td>SKU</td>
  4157. <td>商品名称</td>
  4158. <td>商品中文</td>
  4159. <td>产品备注</td>
  4160. <td>说明</td>
  4161. <td>类型</td>
  4162. <td>入库总量</td>
  4163. <td>库存数量</td>
  4164. <td>销售数量</td>
  4165. <td>退货数量</td>
  4166. <td>占单数量</td>
  4167. <td>料号</td>
  4168. <td>重量</td>
  4169. <td>类目</td>
  4170. </tr>
  4171. </table>";
  4172. $filename = $title . ".xls";
  4173. $tail = "";
  4174. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4175. }
  4176. }
  4177. }
  4178. //出库+入库数据整合
  4179. public function _excelcr()
  4180. {
  4181. if (isset($_GET['excel'])) {
  4182. $type = $this->input->get('excel', true);
  4183. $category = $this->input->get('category', true);
  4184. $size = $this->input->get('size', true);
  4185. $grade = $this->input->get('grade', true);
  4186. $color = $this->input->get('color', true);
  4187. $lowe = $this->input->get('lowe', true);
  4188. $sku = $this->input->get('sku', true);
  4189. $warehouse = $this->input->get('warehouse', true);
  4190. $purchase = $this->input->get('purchase', true);
  4191. $state = $this->input->get('state', true);
  4192. $sid = $this->input->get('sid', true);
  4193. $ktime = $this->input->get('ktime', true);
  4194. $jtime = $this->input->get('jtime', true);
  4195. $ktime = strtotime($ktime);
  4196. $jtime = strtotime($jtime);
  4197. $where = "1=1";
  4198. $gj = "";
  4199. $ck = "";
  4200. if ($category) {
  4201. $where .= " and features like '%-$category-%'";
  4202. }
  4203. if ($size) {
  4204. $where .= " and features like '%-$size-%'";
  4205. }
  4206. if ($grade) {
  4207. $where .= " and features like '%-$grade-%'";
  4208. }
  4209. if ($color) {
  4210. $where .= " and features like '%-$color-%'";
  4211. }
  4212. if ($lowe) {
  4213. $where .= " and features like '%-$lowe-%'";
  4214. }
  4215. if ($warehouse) {
  4216. $where .= " and warehouse = '$warehouse'";
  4217. }
  4218. if ($purchase) {
  4219. $where .= " and purchase = '$purchase'";
  4220. }
  4221. if ($state) {
  4222. $where .= " and state = '$state'";
  4223. }
  4224. if ($sku) {
  4225. $where .= " and sku like '%$sku%'";
  4226. }
  4227. if ($ktime && $jtime) {
  4228. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4229. }
  4230. $sidwhere = '';
  4231. if ($sid) {
  4232. $sd = "";
  4233. $s = explode(',', trim($sid, ','));
  4234. foreach ($s as $value) {
  4235. $sd .= " id = " . $value . " or";
  4236. }
  4237. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4238. }
  4239. //取得信息列表
  4240. $timeread = $ktime;
  4241. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4242. $timelist = array();
  4243. for ($i = 0; $i < $timenum; $i++) {
  4244. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4245. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4246. }
  4247. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4248. //echo "<pre>";
  4249. //print_r($info_list);
  4250. //exit();
  4251. $rows = array();
  4252. $list = array();
  4253. foreach ($info_list as $key => $value) {
  4254. $thistime = $timelist;
  4255. if (isset($rows[strtolower($value['sku'])])) {
  4256. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4257. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4258. }
  4259. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4260. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4261. }
  4262. } else {
  4263. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4264. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4265. }
  4266. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4267. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4268. }
  4269. $rows[strtolower($value['sku'])] = $thistime;
  4270. }
  4271. }
  4272. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4273. <head>
  4274. <!--[if gte mso 9]><xml>
  4275. <x:ExcelWorkbook>
  4276. <x:ExcelWorksheets>
  4277. <x:ExcelWorksheet>
  4278. <x:Name>EXCEL</x:Name>
  4279. <x:WorksheetOptions>
  4280. <x:Print>
  4281. <x:ValidPrinterInfo />
  4282. </x:Print>
  4283. </x:WorksheetOptions>
  4284. </x:ExcelWorksheet>
  4285. </x:ExcelWorksheets>
  4286. </x:ExcelWorkbook>
  4287. </xml>
  4288. <![endif]-->
  4289. </head><body>";
  4290. $str .= "<table border=1><tr><td>SKU</td>";
  4291. foreach ($timelist as $k => $v) {
  4292. $str .= "<td>" . $k . "出库</td>";
  4293. $str .= "<td>" . $k . "入库</td>";
  4294. }
  4295. $str .= "</tr></table>";
  4296. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4297. foreach ($rows as $key => $val) {
  4298. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4299. foreach ($val as $k => $v) {
  4300. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4301. if ($val[$k]['r'] > 0) {
  4302. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4303. } else {
  4304. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4305. }
  4306. }
  4307. $str .= "</tr>";
  4308. }
  4309. $str .= "</table>";
  4310. $str .= "</body></html>";
  4311. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4312. header("Content-type: application/octet-stream");
  4313. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4314. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4315. header("Pragma: no-cache");
  4316. header("Expires: 0");
  4317. exit($str);
  4318. }
  4319. }
  4320. //数量调整模板导出
  4321. public function _presetout()
  4322. {
  4323. if (isset($_GET['excel'])) {
  4324. $where = "sku != 'Preset' and purchase != 0";
  4325. //数据排序
  4326. $order_str = "id desc";
  4327. if (empty($page)) {
  4328. $start = 0;
  4329. $perpage = 1;
  4330. } else {
  4331. $start = ($page - 1) * $perpage;
  4332. }
  4333. //取得信息列表
  4334. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4335. $rows = array();
  4336. $list = array();
  4337. foreach ($info_list as $value) {
  4338. $warehouse = $this->warehouse->read($value['warehouse']);
  4339. $number = $value['number'];
  4340. $ftime = time() - 15 * 24 * 3600;
  4341. $purchase = $this->purchase->read($value['purchase']);
  4342. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4343. }
  4344. $title = "库存模板";
  4345. $titlename = "<table border=1>
  4346. <tr align='center'>
  4347. <td>仓库</td>
  4348. <td>供应商编码</td>
  4349. <td>SKU</td>
  4350. <td>增减数量(正数或负数)</td>
  4351. <td>增减备注</td>
  4352. <td>扣减方式:0减少库存1删除库存</td>
  4353. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4354. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4355. </tr>
  4356. </table>";
  4357. $filename = $title . ".xls";
  4358. $tail = "";
  4359. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4360. }
  4361. }
  4362. //数量调整模板导入
  4363. public function _presetedit()
  4364. {
  4365. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4366. $config['upload_path'] = '.' . $dir;
  4367. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4368. $config['allowed_types'] = 'xls|xlsx|csv';
  4369. $config['max_size'] = 10240;
  4370. $this->load->library('upload', $config);
  4371. $this->upload->initialize($config);
  4372. if ($this->upload->do_upload('userfile')) {
  4373. $full_path = $dir . $this->upload->data('file_name');
  4374. $fileName = '.' . $full_path;
  4375. if (!file_exists($fileName)) {
  4376. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4377. exit;
  4378. } else {
  4379. require_once "./data/excel/PHPExcel/IOFactory.php";
  4380. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4381. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4382. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4383. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4384. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4385. ++$column; //如果列数大于26行
  4386. $list = array();
  4387. for ($i = 2; $i <= $row; $i++) // 行数循环
  4388. {
  4389. $data = array();
  4390. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4391. {
  4392. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4393. }
  4394. $list[] = $data;
  4395. }
  4396. }
  4397. $i = 0;
  4398. $j = 0;
  4399. $ed = array();
  4400. foreach ($list as $key => $value) {
  4401. $time = time();
  4402. if ($value['0'] == "") {
  4403. continue;
  4404. }
  4405. $warehouse = $this->warehouse->get_title($value['0']);
  4406. $purchase = $this->purchase->get_bm($value['1']);
  4407. $sku = $value['2'];
  4408. $num = $value['3']; //调整数量
  4409. $text = $value['4']; //扣减说明
  4410. $type = $value['5']; //调整方式0扣减1删除
  4411. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4412. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4413. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4414. if (!$purchase) //如果没有这个SKU
  4415. {
  4416. $ed[] = array($purchase . '-不存在此供应商编码');
  4417. $j++;
  4418. continue;
  4419. }
  4420. if (!$d) //如果没有这个SKU
  4421. {
  4422. $ed[] = array($sku . '-库存中不存在此SKU');
  4423. $j++;
  4424. continue;
  4425. }
  4426. if (!isset($warehouse['id'])) {
  4427. $ed[] = array($sku . '-仓库名错误!');
  4428. $j++;
  4429. continue;
  4430. }
  4431. if ($type != '0' && $type != '1') {
  4432. $ed[] = array($sku . '-扣减方式填写错误!');
  4433. $j++;
  4434. continue;
  4435. }
  4436. if ($num < 0) //扣减库存
  4437. {
  4438. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4439. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4440. $j++;
  4441. continue;
  4442. }
  4443. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4444. if (count($data) < abs($num)) {
  4445. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4446. $j++;
  4447. continue;
  4448. }
  4449. if ($type == 0) //如果扣减方式为 扣减库存
  4450. {
  4451. for ($i = 0; $i < abs($num); $i++) {
  4452. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4453. }
  4454. } else if ($type == 1) {
  4455. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4456. if (count($zt) > 0) {
  4457. $ed[] = array($sku . '-有在途库存无法删除!');
  4458. $j++;
  4459. continue;
  4460. }
  4461. for ($i = 0; $i < abs($num); $i++) {
  4462. $this->whlabel->remove($data[$i]['id']);
  4463. }
  4464. }
  4465. } else if ($num > 0) //增加库存
  4466. {
  4467. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4468. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4469. $j++;
  4470. continue;
  4471. }
  4472. $post['sku'] = $d['sku'];
  4473. $post['shop'] = $d['shop'];
  4474. $post['warehouse'] = $warehouse['id'];
  4475. $post['purchase'] = $purchase['id'];
  4476. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4477. $post['state'] = 0;
  4478. $post['title'] = $d['title'];
  4479. $post['number'] = $d['number'];
  4480. $post['features'] = $d['features'];
  4481. $post['enter'] = $time;
  4482. $post['time'] = $time; //操作时间
  4483. $post['rktype'] = $rktype;
  4484. for ($i = 0; $i < $num; $i++) {
  4485. $post['label'] = time() . rand(100, 999) . $i;
  4486. $this->whlabel->insert($post);
  4487. }
  4488. }
  4489. sleep(1); //防止入库时间一样,需要延迟1秒
  4490. }
  4491. if ($j > 0) {
  4492. $tt = date('Ymd', time());
  4493. $title = '库存导入错误信息-' . $tt;
  4494. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4495. $tail = "\n";
  4496. $filename = $title . ".xls";
  4497. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4498. $dir = '/data/excel/' . $time . '/';
  4499. $file_name = 'error_' . $time . rand(1000, 9999);
  4500. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4501. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4502. fwrite($myfile, $ecl);
  4503. fclose($myfile);
  4504. $error = $dir . $file_name . '.xls';
  4505. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4506. exit;
  4507. } else {
  4508. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4509. exit;
  4510. }
  4511. }
  4512. }
  4513. public function _presetedittwo(){
  4514. $data = $this->input->post(NULL, TRUE);
  4515. if(empty($list)){
  4516. $raw_data = $this->input->raw_input_stream;
  4517. // 解码 JSON
  4518. $data = json_decode($raw_data, true);
  4519. }
  4520. if(empty($data)){
  4521. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4522. }
  4523. $list = [];
  4524. if(isset($data['list'])){
  4525. $list = $data['list'];
  4526. }
  4527. $i = 0;
  4528. $j = 0;
  4529. $ed = array();
  4530. foreach ($list as $key => $value) {
  4531. $time = time();
  4532. if ($value['0'] == "") {
  4533. continue;
  4534. }
  4535. $warehouse = $this->warehouse->get_title($value['0']);
  4536. $purchase = $this->purchase->get_bm($value['1']);
  4537. $sku = $value['2'];
  4538. $num = $value['3']; //调整数量
  4539. $text = $value['4']; //扣减说明
  4540. $type = $value['5']; //调整方式0扣减1删除
  4541. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4542. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4543. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4544. if (!$purchase) //如果没有这个SKU
  4545. {
  4546. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4547. $j++;
  4548. continue;
  4549. }
  4550. if (!$d) //如果没有这个SKU
  4551. {
  4552. $ed[] = array($sku . '-库存中不存在此SKU');
  4553. $j++;
  4554. continue;
  4555. }
  4556. if (!isset($warehouse['id'])) {
  4557. $ed[] = array($sku . '-仓库名错误!');
  4558. $j++;
  4559. continue;
  4560. }
  4561. if ($type != '0' && $type != '1') {
  4562. $ed[] = array($sku . '-扣减方式填写错误!');
  4563. $j++;
  4564. continue;
  4565. }
  4566. if ($num < 0) //扣减库存
  4567. {
  4568. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4569. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4570. $j++;
  4571. continue;
  4572. }
  4573. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4574. if (count($data) < abs($num)) {
  4575. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4576. $j++;
  4577. continue;
  4578. }
  4579. if ($type == 0) //如果扣减方式为 扣减库存
  4580. {
  4581. for ($i = 0; $i < abs($num); $i++) {
  4582. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4583. }
  4584. } else if ($type == 1) {
  4585. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4586. if (count($zt) > 0) {
  4587. $ed[] = array($sku . '-有在途库存无法删除!');
  4588. $j++;
  4589. continue;
  4590. }
  4591. for ($i = 0; $i < abs($num); $i++) {
  4592. $this->whlabel->remove($data[$i]['id']);
  4593. }
  4594. }
  4595. } else if ($num > 0) //增加库存
  4596. {
  4597. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4598. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4599. $j++;
  4600. continue;
  4601. }
  4602. $post['sku'] = $d['sku'];
  4603. $post['shop'] = $d['shop'];
  4604. $post['warehouse'] = $warehouse['id'];
  4605. $post['purchase'] = $purchase['id'];
  4606. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4607. $post['state'] = 0;
  4608. $post['title'] = $d['title'];
  4609. $post['number'] = $d['number'];
  4610. $post['features'] = $d['features'];
  4611. $post['enter'] = $time;
  4612. $post['time'] = $time; //操作时间
  4613. $post['rktype'] = $rktype;
  4614. $post['sku_master_id'] = $d['sku_master_id'];
  4615. $post['sku_shop_id'] = $d['sku_shop_id'];
  4616. for ($i = 0; $i < $num; $i++) {
  4617. $post['label'] = time() . rand(100, 999) . $i;
  4618. $this->whlabel->insert($post);
  4619. }
  4620. }
  4621. sleep(1); //防止入库时间一样,需要延迟1秒
  4622. }
  4623. if ($j > 0) {
  4624. $tt = date('Ymd', time());
  4625. $title = '库存导入错误信息-' . $tt;
  4626. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4627. $tail = "\n";
  4628. $filename = $title . ".xls";
  4629. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4630. $dir = '/data/excel/' . $time . '/';
  4631. $file_name = 'error_' . $time . rand(1000, 9999);
  4632. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4633. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4634. fwrite($myfile, $ecl);
  4635. fclose($myfile);
  4636. $error = $dir . $file_name . '.xls';
  4637. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4638. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4639. exit;
  4640. } else {
  4641. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4642. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4643. exit;
  4644. }
  4645. }
  4646. //笛卡儿积
  4647. function cp($ps, $sets, $list)
  4648. {
  4649. $result = array();
  4650. $j = 0;
  4651. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4652. if ($i == 0) {
  4653. $result = $sets[$i];
  4654. }
  4655. $tmp = array();
  4656. foreach ($result as $res) {
  4657. foreach ($sets[$i + 1] as $set) {
  4658. $tmp[] = $res . ',' . $set;
  4659. }
  4660. }
  4661. $result = $tmp;
  4662. }
  4663. $this->db->trans_begin();
  4664. foreach ($result as $v) {
  4665. $post = array();
  4666. $title = "";
  4667. $num = "";
  4668. $data = explode(',', $v);
  4669. for ($i = 0; $i < count($list); $i++) {
  4670. $post[$list[$i]] = $data[$i];
  4671. $typeclass = $this->typeclass->read($data[$i]);
  4672. $title = $title . $typeclass['title'] . " ";
  4673. if ($data[$i] != 0) {
  4674. $num .= $data[$i]; //所有数据ID拼接
  4675. }
  4676. }
  4677. foreach ($ps as $kp => $vp) {
  4678. $post[$kp] = $vp;
  4679. }
  4680. $post['number'] = $num;
  4681. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4682. if ($info_list) {
  4683. $j++;
  4684. } else {
  4685. $skunum = $this->whlabel->find_count();
  4686. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4687. $post['title'] = rtrim($title, ' ');
  4688. $this->whlabel->insert($post);
  4689. }
  4690. }
  4691. if ($this->db->trans_status() === FALSE) {
  4692. $this->db->trans_commit();
  4693. return NULL;
  4694. } else {
  4695. $this->db->trans_commit();
  4696. return $j;
  4697. }
  4698. }
  4699. public function _kj($arg_array)
  4700. {
  4701. if (isset($_POST['sku'])) {
  4702. $time = time();
  4703. $sku = $this->input->post('sku', true);
  4704. $warehouse = $this->input->post('warehouse', true);
  4705. $num = $this->input->post('num', true);
  4706. $text = $this->input->post('text', true);
  4707. $purchase = $this->input->post('purchase', true);
  4708. $cktype = $this->input->post('cktype', true);
  4709. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4710. if ($cktype != 1 && $text == '') {
  4711. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4712. exit;
  4713. }
  4714. if ($num > count($order)) {
  4715. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4716. exit;
  4717. } else {
  4718. for ($i = 0; $i < $num; $i++) {
  4719. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4720. }
  4721. }
  4722. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4723. exit;
  4724. }
  4725. $uid = $this->whlabel->read($arg_array[0]);
  4726. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4727. $this->data['data'] = $uid;
  4728. $this->_Template('whlabel_kj', $this->data);
  4729. }
  4730. public function _summary($arg_array)
  4731. {
  4732. $prc = array();
  4733. $purchase = $this->purchase->find_all();
  4734. foreach ($purchase as $k => $v) {
  4735. $prc[$v['id']] = $v['title'];
  4736. }
  4737. if (isset($_GET['excel'])) {
  4738. $ktime = $this->input->get('ktime', true);
  4739. $jtime = $this->input->get('jtime', true);
  4740. $ktime = strtotime($ktime);
  4741. $jtime = strtotime($jtime);
  4742. $where = "1=1";
  4743. if ($ktime && $jtime) {
  4744. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4745. }
  4746. //数据排序
  4747. $order_str = "time desc";
  4748. if (empty($page)) {
  4749. $start = 0;
  4750. $perpage = 1;
  4751. } else {
  4752. $start = ($page - 1) * $perpage;
  4753. }
  4754. //取得信息列表
  4755. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4756. foreach ($info_list as $key => $value) {
  4757. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4758. $warehouse = $this->warehouse->read($value['warehouse']);
  4759. $info_list[$key]['warehouse'] = $warehouse['title'];
  4760. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4761. $details = array();
  4762. $cpid = array();
  4763. foreach ($x as $k => $v) {
  4764. if ($v['details'] != '') {
  4765. $details[$v['details']] = $v['details'];
  4766. }
  4767. if ($v['cpid'] != 0) {
  4768. $cpid[$v['cpid']] = $v['cpid'];
  4769. }
  4770. }
  4771. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4772. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4773. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4774. $info_list[$key]['s'] = $s;
  4775. $info_list[$key]['x'] = count($x);
  4776. }
  4777. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4778. $titlename = "<table border=1>
  4779. <tr align='center'>
  4780. <td>仓库</td>
  4781. <td>供应商</td>
  4782. <td>出库位置</td>
  4783. <td>出库编码</td>
  4784. <td>SKU</td>
  4785. <td>产品名</td>
  4786. <td>总剩余库存</td>
  4787. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4788. </tr>
  4789. </table>";
  4790. $filename = $title . ".xls";
  4791. $tail = "";
  4792. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4793. }
  4794. }
  4795. //usps发货清单
  4796. public function _manifest()
  4797. {
  4798. if (isset($_POST['manifest'])) {
  4799. $wltext = $this->input->post('wltext', true);
  4800. $time = time() - 16 * 3600;
  4801. $ptime = strtotime(date('Y-m-d', $time));
  4802. $waybill = array();
  4803. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4804. foreach ($fullorder as $v) {
  4805. $waybill[$v['waybill']] = $v['waybill'];
  4806. }
  4807. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4808. foreach ($fullordersmt as $v) {
  4809. $waybill[$v['waybill']] = $v['waybill'];
  4810. }
  4811. $wltext = explode(';', $wltext);
  4812. foreach ($wltext as $v) {
  4813. if (isset($waybill[$v])) {
  4814. unset($waybill[$v]);
  4815. }
  4816. }
  4817. $data = $this->usps->get_manifest($waybill);
  4818. if (isset($data['Description'])) {
  4819. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4820. exit;
  4821. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4822. $bctime = date('Ymd', time());
  4823. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4824. echo json_encode(array('msg' => $pdf, 'success' => true));
  4825. exit;
  4826. } else {
  4827. echo json_encode(array('msg' => $data, 'success' => false));
  4828. exit;
  4829. }
  4830. }
  4831. }
  4832. public function _pdf($pdf, $title, $bctime)
  4833. {
  4834. $pdf_path = './data/pdf/' . $bctime . '/';
  4835. $file_base64 = $pdf;
  4836. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4837. $file_base64 = base64_decode($file_base64);
  4838. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4839. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4840. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4841. }
  4842. /**
  4843. *
  4844. *
  4845. *
  4846. 进销存占单异常索引
  4847. *
  4848. *
  4849. *
  4850. **/
  4851. public function _abnormal()
  4852. {
  4853. $post = $this->input->post(NULL, TRUE);
  4854. if (isset($post['page'])) {
  4855. $page = $this->input->post('page', true);
  4856. $perpage = $this->input->post('perpage', true);
  4857. $sku = $this->input->post('sku', true);
  4858. $where = "1=1";
  4859. //数据排序
  4860. $order_str = "id desc";
  4861. if (empty($page)) {
  4862. $start = 0;
  4863. $perpage = 1;
  4864. } else {
  4865. $start = ($page - 1) * $perpage;
  4866. }
  4867. //取得信息列表
  4868. $info_list = $this->whlabel->find_all($where, '*');
  4869. $rows = array();
  4870. $list = array();
  4871. foreach ($info_list as $key => $value) {
  4872. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4873. }
  4874. foreach ($rows as $value) {
  4875. $warehouse = $this->warehouse->read($value['warehouse']);
  4876. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4877. $number = $value['number'];
  4878. $ftime = time() - 15 * 24 * 3600;
  4879. if ($value['shop'] != '') {
  4880. $shop = $value['shop'];
  4881. $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');
  4882. $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');
  4883. $order = array_merge($orderdlz, $ordersmt);
  4884. $od = 0;
  4885. $a = '';
  4886. $orid = '';
  4887. foreach ($order as $v) {
  4888. $or = explode('|', ltrim($v['whlabel'], '|'));
  4889. for ($i = 0; $i < count($or); $i++) {
  4890. $orod = explode('-', $or[$i]);
  4891. if ($orod[0] == $number) {
  4892. $od += $orod[1];
  4893. }
  4894. }
  4895. $orid .= $v['number'] . '-';
  4896. }
  4897. } else {
  4898. $orderdlz = $this->fullorder->find_all("time > '$ftime' 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 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. $qt = array();
  4905. foreach ($order as $v) {
  4906. $or = explode('|', ltrim($v['whlabel'], '|'));
  4907. for ($i = 0; $i < count($or); $i++) {
  4908. $orod = explode('-', $or[$i]);
  4909. if ($orod[0] == $number) {
  4910. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4911. if ($czzs > 0) {
  4912. if (isset($qt[$v['shop']])) {
  4913. if ($qt[$v['shop']] < $orod[1]) {
  4914. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4915. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4916. } else {
  4917. $qt[$v['shop']] -= $orod[1];
  4918. }
  4919. } else {
  4920. $qt[$v['shop']] = $czzs;
  4921. }
  4922. } else {
  4923. $od += $orod[1];
  4924. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. $z = $od . '(' . $orid . ')'; //查看订单号
  4931. //$z = $od;
  4932. if ($od > $c) {
  4933. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4934. }
  4935. }
  4936. $listdata = array_slice($list, $start, $perpage);
  4937. $total = count($list);
  4938. $pagenum = ceil($total / $perpage);
  4939. $over = $total - ($start + $perpage);
  4940. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4941. echo json_encode($rows);
  4942. exit;
  4943. }
  4944. $this->_Template('whlabel_abnormal', $this->data);
  4945. }
  4946. /**
  4947. *
  4948. *
  4949. *
  4950. 进销存占单异常索引
  4951. *
  4952. *
  4953. *
  4954. **/
  4955. public function _error()
  4956. {
  4957. $post = $this->input->post(NULL, TRUE);
  4958. if (isset($post['page'])) {
  4959. $page = $this->input->post('page', true);
  4960. $perpage = $this->input->post('perpage', true);
  4961. $sku = $this->input->post('sku', true);
  4962. $warehouse = $this->input->post('warehouse', true);
  4963. $ktime = $this->input->post('ktime', true);
  4964. $jtime = $this->input->post('jtime', true);
  4965. $ktime = strtotime($ktime);
  4966. $jtime = strtotime($jtime);
  4967. $where = "sku != 'Preset'";
  4968. $gj = '';
  4969. if ($sku) {
  4970. $where .= " and sku like '%$sku%'";
  4971. } else {
  4972. if ($ktime && $jtime) {
  4973. $gj = " and time > '$ktime' and time < '$jtime'";
  4974. }
  4975. }
  4976. if ($warehouse) {
  4977. $where .= " and warehouse = '$warehouse'";
  4978. }
  4979. //数据排序
  4980. $order_str = "id desc";
  4981. if (empty($page)) {
  4982. $start = 0;
  4983. $perpage = 1;
  4984. } else {
  4985. $start = ($page - 1) * $perpage;
  4986. }
  4987. //取得信息列表
  4988. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4989. $rows = array();
  4990. $list = array();
  4991. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4992. // foreach ($info_list as $value)
  4993. // {
  4994. // $warehouse = $this->warehouse->read($value['warehouse']);
  4995. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4996. // $number = $value['number'];$ftime = time()-15*24*3600;
  4997. // if($c < 1)
  4998. // {
  4999. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5000. // }
  5001. // }
  5002. $warehouse_list = $this->warehouse->find_all();
  5003. $warehouse_list = array_column($warehouse_list, null, 'id');
  5004. foreach ($info_list as $value) {
  5005. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5006. 'title' => "",
  5007. ];
  5008. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5009. $number = $value['number'];
  5010. $ftime = time() - 15 * 24 * 3600;
  5011. if ($c < 1) {
  5012. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5013. }
  5014. }
  5015. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5016. // $query = $this->db->query($sql);
  5017. // $info_list = $query->result_array();
  5018. // $sql_two = "select title,id from crowd_warehouse";
  5019. // $query_two = $this->db->query($sql_two);
  5020. // $warehouse_list = $query_two->result_array();
  5021. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5022. // foreach ($info_list as $value)
  5023. // {
  5024. // if(isset($warehouse_arr[$value['warehouse']])){
  5025. // $warehouse = $warehouse_arr[$value['warehouse']];
  5026. // }else{
  5027. // $warehouse = [
  5028. // 'id'=>0,
  5029. // 'title'=>"异常",
  5030. // ];
  5031. // }
  5032. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5033. // $number = $value['number'];$ftime = time()-15*24*3600;
  5034. // if($c < 1)
  5035. // {
  5036. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5037. // }
  5038. // }
  5039. $listdata = array_slice($list, $start, $perpage);
  5040. $total = count($list);
  5041. $pagenum = ceil($total / $perpage);
  5042. $over = $total - ($start + $perpage);
  5043. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5044. echo json_encode($rows);
  5045. exit;
  5046. }
  5047. if (isset($post['s'])) {
  5048. $id_arr = $this->input->post('s');
  5049. $id_arr = explode(',', trim($id_arr, ','));
  5050. if (!$id_arr) {
  5051. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5052. exit;
  5053. }
  5054. //循环删除记录
  5055. foreach ($id_arr as $v) {
  5056. $dd = $this->whlabel->read($v);
  5057. if (!isset($dd['id'])) {
  5058. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5059. exit;
  5060. }
  5061. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5062. if (isset($zt[0])) {
  5063. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5064. exit;
  5065. }
  5066. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5067. foreach ($deldd as $vv) {
  5068. $this->whlabel->remove($vv['id']);
  5069. }
  5070. }
  5071. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5072. exit;
  5073. }
  5074. $this->_Template('whlabel_error', $this->data);
  5075. }
  5076. public function _errorexcel()
  5077. {
  5078. $post = $this->input->post(NULL, TRUE);
  5079. if (isset($_GET['page'])) {
  5080. $page = $this->input->get('page', true);
  5081. $perpage = $this->input->get('perpage', true);
  5082. $sku = $this->input->get('sku', true);
  5083. $warehouse = $this->input->get('warehouse', true);
  5084. $ktime = $this->input->get('ktime', true);
  5085. $jtime = $this->input->get('jtime', true);
  5086. $ktime = strtotime($ktime);
  5087. $jtime = strtotime($jtime);
  5088. $where = "sku != 'Preset'";
  5089. $gj = '';
  5090. if ($sku) {
  5091. $where .= " and sku like '%$sku%'";
  5092. } else {
  5093. if ($ktime && $jtime) {
  5094. $gj = " and time > '$ktime' and time < '$jtime'";
  5095. }
  5096. }
  5097. if ($warehouse) {
  5098. $where .= " and warehouse = '$warehouse'";
  5099. }
  5100. //数据排序
  5101. $order_str = "id desc";
  5102. if (empty($page)) {
  5103. $start = 0;
  5104. $perpage = 1;
  5105. } else {
  5106. $start = ($page - 1) * $perpage;
  5107. }
  5108. //取得信息列表
  5109. $rows = array();
  5110. $list = array();
  5111. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5112. foreach ($info_list as $value) {
  5113. $warehouse = $this->warehouse->read($value['warehouse']);
  5114. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5115. $number = $value['number'];
  5116. $ftime = time() - 15 * 24 * 3600;
  5117. if ($c < 1) {
  5118. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5119. }
  5120. }
  5121. $title = "0库存汇总";
  5122. $titlename = "<table border=1>
  5123. <tr align='center'>
  5124. <td>仓库</td>
  5125. <td>SKU</td>
  5126. <td>产品</td>
  5127. <td>当前库存</td>
  5128. </tr>
  5129. </table>";
  5130. $filename = $title . ".xls";
  5131. $tail = "";
  5132. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5133. }
  5134. }
  5135. /**
  5136. *
  5137. *
  5138. * 占单
  5139. *
  5140. *
  5141. **/
  5142. public function _kcyz()
  5143. {
  5144. $post = $this->input->post(NULL, TRUE);
  5145. if (isset($post['warehouse'])) {
  5146. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5147. exit; //不再使用
  5148. $warehouse = $this->input->post('warehouse', true);
  5149. $whlabel = $this->input->post('whlabel', true);
  5150. $id = $this->input->post('id', true);
  5151. $shop = $this->input->post('shop', true);
  5152. $number = $this->input->post('number', true);
  5153. if (!$whlabel || $whlabel == '|') {
  5154. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5155. exit;
  5156. }
  5157. $pp = explode('|', trim($whlabel, '|'));
  5158. $x = 0;
  5159. $save = array();
  5160. foreach ($pp as $va) {
  5161. $num = explode('-', $va);
  5162. if ($number) {
  5163. $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 = '')"); //通用
  5164. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5165. } else {
  5166. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5167. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5168. }
  5169. $x++;
  5170. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5171. $save[] = $x - 1;
  5172. continue; //提前先加X不然出错,所以要减1
  5173. }
  5174. }
  5175. if (isset($save[0])) {
  5176. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5177. exit;
  5178. } else {
  5179. echo json_encode(array('success' => true));
  5180. exit;
  5181. }
  5182. }
  5183. }
  5184. public function _db()
  5185. {
  5186. $post = $this->input->post(NULL, TRUE);
  5187. if (isset($post['page'])) {
  5188. $page = $this->input->post('page', true);
  5189. $perpage = $this->input->post('perpage', true);
  5190. $sku = $this->input->post('sku', true);
  5191. $number = $this->input->post('number', true);
  5192. $warehouse = $this->input->post('warehouse', true);
  5193. $purchase = $this->input->post('purchase', true);
  5194. $orderinfo = $this->input->post('orderinfo', true);
  5195. $waybill = $this->input->post('waybill', true);
  5196. $category = $this->input->post('category', true);
  5197. $size = $this->input->post('size', true);
  5198. $grade = $this->input->post('grade', true);
  5199. $color = $this->input->post('color', true);
  5200. $lowe = $this->input->post('lowe', true);
  5201. $state = $this->input->post('state', true);
  5202. $label = $this->input->post('label', true);
  5203. $timetk = $this->input->post('timetkk', true);
  5204. $timetj = $this->input->post('timetjj', true);
  5205. $timetk = strtotime($timetk);
  5206. $timetj = strtotime($timetj);
  5207. $where = "dbtime > 0";
  5208. if ($timetk && $timetj) {
  5209. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5210. }
  5211. if ($sku) {
  5212. $where .= " and sku = '$sku'";
  5213. }
  5214. if ($warehouse) {
  5215. $where .= " and warehouse = '$warehouse'";
  5216. if ($warehouse == 12) {
  5217. $w = 'specialstock';
  5218. } else {
  5219. $w = 'whlabel';
  5220. }
  5221. }
  5222. if ($purchase) {
  5223. $where .= " and purchase = '$purchase'";
  5224. }
  5225. if ($category) {
  5226. $where .= " and features like '%-$category-%'";
  5227. }
  5228. if ($size) {
  5229. $where .= " and features like '%-$size-%'";
  5230. }
  5231. if ($grade) {
  5232. $where .= " and features like '%-$grade-%'";
  5233. }
  5234. if ($color) {
  5235. $where .= " and features like '%-$color-%'";
  5236. }
  5237. if ($lowe) {
  5238. $where .= " and features like '%-$lowe-%'";
  5239. }
  5240. if ($state != '') {
  5241. $where .= " and state = '$state'";
  5242. }
  5243. //数据排序
  5244. $order_str = "dbtime desc";
  5245. if (empty($page)) {
  5246. $start = 0;
  5247. $perpage = 1;
  5248. } else {
  5249. $start = ($page - 1) * $perpage;
  5250. }
  5251. //取得信息列表
  5252. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5253. foreach ($info_list as $key => $value) {
  5254. $warehouse = $this->$w->read($value['warehouse']);
  5255. $info_list[$key]['warehouse'] = $warehouse['title'];
  5256. $purchase = $this->purchase->read($value['purchase']);
  5257. $info_list[$key]['purchase'] = $purchase['title'];
  5258. if ($value['enter'] != 0) {
  5259. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5260. } else {
  5261. $info_list[$key]['enter'] = "";
  5262. }
  5263. if ($value['dbtime'] != 0) {
  5264. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5265. } else {
  5266. $info_list[$key]['dbtime'] = "";
  5267. }
  5268. if ($value['state'] == 0) {
  5269. $info_list[$key]['state'] = "在库";
  5270. } else if ($value['state'] == 1) {
  5271. $info_list[$key]['state'] = "出库";
  5272. } else if ($value['state'] == 2) {
  5273. $info_list[$key]['state'] = "退库";
  5274. } else if ($value['state'] == 3) {
  5275. $info_list[$key]['state'] = "调拨中";
  5276. } else if ($value['state'] == 4) {
  5277. $info_list[$key]['state'] = "再加工";
  5278. } else if ($value['state'] == 5) {
  5279. $info_list[$key]['state'] = "维修中";
  5280. } else if ($value['state'] == 6) {
  5281. $info_list[$key]['state'] = "盘亏";
  5282. } else if ($value['state'] == 7) {
  5283. $info_list[$key]['state'] = "更换标签";
  5284. } else if ($value['state'] == 8) {
  5285. $info_list[$key]['state'] = "其它";
  5286. } else if ($value['state'] == 9) {
  5287. $info_list[$key]['state'] = "预设";
  5288. }
  5289. }
  5290. $total = $this->whlabel->find_count($where);
  5291. $pagenum = ceil($total / $perpage);
  5292. $over = $total - ($start + $perpage);
  5293. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5294. echo json_encode($rows);
  5295. exit;
  5296. }
  5297. if (isset($post['outsku'])) {
  5298. $time = time();
  5299. $cz = $this->input->post('cz', true);
  5300. $label = $this->input->post('outsku', true);
  5301. $sl = $this->input->post('sl', true);
  5302. $num = $this->input->post('num', true);
  5303. //$warehouse = $this->input->post('warehouse',true);
  5304. if (!$sl) {
  5305. $sl = 1;
  5306. }
  5307. if (!$warehouse) {
  5308. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5309. exit;
  5310. }
  5311. $dblabel = $this->whlabellabel->get_label($label);
  5312. if ($dblabel) {
  5313. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5314. if (count($data) < 1) {
  5315. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5316. exit;
  5317. }
  5318. if (count($data) < $num) {
  5319. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5320. exit;
  5321. }
  5322. for ($i = 0; $i < $sl; $i++) {
  5323. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5324. }
  5325. echo json_encode(array('success' => true));
  5326. exit;
  5327. } else {
  5328. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5329. exit;
  5330. }
  5331. }
  5332. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5333. $this->_Template('whlabel_db', $this->data);
  5334. }
  5335. public function _dbrk()
  5336. {
  5337. $post = $this->input->post(NULL, TRUE);
  5338. if (isset($post['page'])) {
  5339. $page = $this->input->post('page', true);
  5340. $perpage = $this->input->post('perpage', true);
  5341. $sku = $this->input->post('sku', true);
  5342. $number = $this->input->post('number', true);
  5343. $warehouse = $this->input->post('warehouse', true);
  5344. $purchase = $this->input->post('purchase', true);
  5345. $orderinfo = $this->input->post('orderinfo', true);
  5346. $waybill = $this->input->post('waybill', true);
  5347. $category = $this->input->post('category', true);
  5348. $size = $this->input->post('size', true);
  5349. $grade = $this->input->post('grade', true);
  5350. $color = $this->input->post('color', true);
  5351. $lowe = $this->input->post('lowe', true);
  5352. $state = $this->input->post('state', true);
  5353. $label = $this->input->post('label', true);
  5354. $ctime = $this->input->post('ctime', true);
  5355. $timetk = $this->input->post('timetkk', true);
  5356. $timetj = $this->input->post('timetjj', true);
  5357. $timetk = strtotime($timetk);
  5358. $timetj = strtotime($timetj);
  5359. $where = "dbtime > 0";
  5360. if ($timetk && $timetj) {
  5361. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5362. }
  5363. if ($sku) {
  5364. $where .= " and sku = '$sku'";
  5365. }
  5366. if ($warehouse) {
  5367. $where .= " and warehouse = '$warehouse'";
  5368. }
  5369. if ($purchase) {
  5370. $where .= " and purchase = '$purchase'";
  5371. }
  5372. if ($category) {
  5373. $where .= " and features like '%-$category-%'";
  5374. }
  5375. if ($size) {
  5376. $where .= " and features like '%-$size-%'";
  5377. }
  5378. if ($grade) {
  5379. $where .= " and features like '%-$grade-%'";
  5380. }
  5381. if ($color) {
  5382. $where .= " and features like '%-$color-%'";
  5383. }
  5384. if ($lowe) {
  5385. $where .= " and features like '%-$lowe-%'";
  5386. }
  5387. if ($state != '') {
  5388. $where .= " and state = '$state'";
  5389. }
  5390. //数据排序
  5391. $order_str = "dbtime desc";
  5392. if (empty($page)) {
  5393. $start = 0;
  5394. $perpage = 1;
  5395. } else {
  5396. $start = ($page - 1) * $perpage;
  5397. }
  5398. //取得信息列表
  5399. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5400. foreach ($info_list as $key => $value) {
  5401. $warehouse = $this->warehouse->read($value['warehouse']);
  5402. $info_list[$key]['warehouse'] = $warehouse['title'];
  5403. $purchase = $this->purchase->read($value['purchase']);
  5404. $info_list[$key]['purchase'] = $purchase['title'];
  5405. if ($value['enter'] != 0) {
  5406. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5407. } else {
  5408. $info_list[$key]['enter'] = "";
  5409. }
  5410. if ($value['dbtime'] != 0) {
  5411. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5412. } else {
  5413. $info_list[$key]['dbtime'] = "";
  5414. }
  5415. if ($value['state'] == 0) {
  5416. $info_list[$key]['state'] = "在库";
  5417. } else if ($value['state'] == 1) {
  5418. $info_list[$key]['state'] = "出库";
  5419. } else if ($value['state'] == 2) {
  5420. $info_list[$key]['state'] = "退库";
  5421. } else if ($value['state'] == 3) {
  5422. $info_list[$key]['state'] = "调拨中";
  5423. } else if ($value['state'] == 4) {
  5424. $info_list[$key]['state'] = "再加工";
  5425. } else if ($value['state'] == 5) {
  5426. $info_list[$key]['state'] = "维修中";
  5427. } else if ($value['state'] == 6) {
  5428. $info_list[$key]['state'] = "盘亏";
  5429. } else if ($value['state'] == 7) {
  5430. $info_list[$key]['state'] = "更换标签";
  5431. } else if ($value['state'] == 8) {
  5432. $info_list[$key]['state'] = "其它";
  5433. } else if ($value['state'] == 9) {
  5434. $info_list[$key]['state'] = "预设";
  5435. }
  5436. }
  5437. $total = $this->whlabel->find_count($where);
  5438. $pagenum = ceil($total / $perpage);
  5439. $over = $total - ($start + $perpage);
  5440. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5441. echo json_encode($rows);
  5442. exit;
  5443. }
  5444. if (isset($post['rsku'])) {
  5445. $cz = $this->input->post('cz', true);
  5446. $label = $this->input->post('rsku', true);
  5447. $sl = $this->input->post('sl', true);
  5448. $warehouse = $this->input->post('warehouse', true);
  5449. if (!$sl) {
  5450. $sl = 1;
  5451. }
  5452. if (!$warehouse) {
  5453. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5454. exit;
  5455. }
  5456. $dblabel = $this->whlabellabel->get_label($label);
  5457. if ($dblabel) {
  5458. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5459. if (count($data) < 1) {
  5460. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5461. exit;
  5462. }
  5463. if ($sl > count($data)) {
  5464. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5465. exit;
  5466. }
  5467. $time = time();
  5468. for ($i = 0; $i < $sl; $i++) {
  5469. $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']);
  5470. }
  5471. echo json_encode(array('success' => true));
  5472. exit;
  5473. } else {
  5474. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5475. exit;
  5476. }
  5477. }
  5478. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5479. $this->_Template('whlabel_dbrk', $this->data);
  5480. }
  5481. public function _whlabelczdc()
  5482. {
  5483. if (isset($_GET['excel'])) {
  5484. //数据排序
  5485. $order_str = "id desc";
  5486. if (empty($page)) {
  5487. $start = 0;
  5488. $perpage = 1;
  5489. } else {
  5490. $start = ($page - 1) * $perpage;
  5491. }
  5492. $state = $this->input->get('state', true);
  5493. $sku = $this->input->get('sku', true);
  5494. $ctime = $this->input->get('ctime', true);
  5495. $category = $this->input->get('category', true);
  5496. $size = $this->input->get('size', true);
  5497. $grade = $this->input->get('grade', true);
  5498. $color = $this->input->get('color', true);
  5499. $lowe = $this->input->get('lowe', true);
  5500. $timetk = $this->input->get('timetkk', true);
  5501. $timetj = $this->input->get('timetjj', true);
  5502. $timetk = strtotime($timetk);
  5503. $timetj = strtotime($timetj);
  5504. $where = "dbtime > 0";
  5505. if ($timetk && $timetj) {
  5506. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5507. }
  5508. if ($category) {
  5509. $where .= " and features like '%-$category-%'";
  5510. }
  5511. if ($size) {
  5512. $where .= " and features like '%-$size-%'";
  5513. }
  5514. if ($grade) {
  5515. $where .= " and features like '%-$grade-%'";
  5516. }
  5517. if ($color) {
  5518. $where .= " and features like '%-$color-%'";
  5519. }
  5520. if ($lowe) {
  5521. $where .= " and features like '%-$lowe-%'";
  5522. }
  5523. //取得信息列表
  5524. $info_list = $this->whlabel->find_all($where, '*');
  5525. $rows = array();
  5526. $list = array();
  5527. foreach ($info_list as $key => $value) {
  5528. $rows[$value['sku']] = $value; //所有数据sku
  5529. }
  5530. foreach ($rows as $value) {
  5531. $warehouse = $this->warehouse->read($value['warehouse']);
  5532. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5533. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5534. if ($value['orderinfo'] == 0) {
  5535. $info_list[$key]['orderinfo'] = "";
  5536. }
  5537. if ($value['waybill'] == 0) {
  5538. $info_list[$key]['waybill'] = "";
  5539. }
  5540. if ($value['state'] == 0) {
  5541. $value['state'] = "在库";
  5542. } else if ($value['state'] == 3) {
  5543. $value['state'] = "调拨中";
  5544. }
  5545. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5546. }
  5547. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5548. $titlename = "<table border=1>
  5549. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5550. <tr align='center'>
  5551. <td>SKU</td>
  5552. <td>产品</td>
  5553. <td>调拨数量</td>
  5554. <td>入库数量</td>
  5555. </tr>
  5556. </table>";
  5557. $filename = $title . ".xls";
  5558. $tail = "";
  5559. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5560. }
  5561. }
  5562. public function _print($arg_array)
  5563. {
  5564. if (isset($_SESSION['api'])) {
  5565. $user = $this->user->get_api($_SESSION['api']);
  5566. $usp = $user;
  5567. $fgshop = "";
  5568. $sid = "";
  5569. $wid = "";
  5570. $wtype = "";
  5571. $usersp = explode('|', trim($user['shop'], '|'));
  5572. $userwh = explode('|', trim($user['warehouse'], '|'));
  5573. foreach ($usersp as $value) {
  5574. $fgshop .= " shop = " . $value . " or";
  5575. $sid .= " id = " . $value . " or";
  5576. }
  5577. foreach ($userwh as $value) {
  5578. $wid .= " id = " . $value . " or";
  5579. $wtype .= " type = " . $value . " or";
  5580. }
  5581. }
  5582. $post = $this->input->post(NULL, TRUE);
  5583. if (isset($post['tmsku'])) {
  5584. $tmsku = $this->input->post('tmsku', true);
  5585. if (is_numeric($tmsku)) {
  5586. $yyh = $this->whlabellabel->get_label($tmsku);
  5587. } else {
  5588. $yyh = $this->whlabellabel->get_sku($tmsku);
  5589. if(empty($yyh)){
  5590. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5591. if($r['code'] == -1 ){
  5592. echo json_encode(array('success' => false));
  5593. exit;
  5594. }else{
  5595. echo json_encode(array('features' => $r['data'], 'success' => true));
  5596. exit;
  5597. }
  5598. }
  5599. }
  5600. if ($yyh) {
  5601. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5602. exit;
  5603. } else {
  5604. echo json_encode(array('success' => false));
  5605. exit;
  5606. }
  5607. }
  5608. $classid = $this->classid->sku();
  5609. $pm = $classid;
  5610. $scsku = $classid;
  5611. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5612. if (isset($post['warehouse'])) {
  5613. if ($post['warehouse']) {
  5614. $list = array();
  5615. $num = "";
  5616. $title = "";
  5617. $features = "";
  5618. $order = 0;
  5619. $post['shop'] = '';
  5620. $brand = $this->input->post('brand', true);
  5621. if ($brand != '0,') {
  5622. $b = $this->brand->read(rtrim($brand, ','));
  5623. if ($b) {
  5624. $post['shop'] = str_replace('|', ',', $b['shop']);
  5625. }
  5626. }
  5627. $post['details'] = $this->input->post('details', true); //打印数量
  5628. $xbqnum = $this->input->post('xbqnum', true);
  5629. $post['purchase'] = $this->input->post('purchase', true);
  5630. $post['warehouse'] = $this->input->post('warehouse', true);
  5631. $post['purchase'] = $this->input->post('purchase', true);
  5632. $post['retreatwarehouse'] = $post['warehouse'];
  5633. $post['cpbz'] = $this->input->post('cpbz', true);
  5634. $post['state'] = 9;
  5635. $category = $this->input->post('category', true);
  5636. $list['category'] = $category;
  5637. $list['hairtype'] = $this->input->post('hairtype', true);
  5638. $list['grade'] = $this->input->post('grade', true);
  5639. $size = $this->input->post('size', true);
  5640. $list['size'] = rtrim($size, ',');
  5641. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5642. $list['extension'] = $this->input->post('extension', true);
  5643. if ($category == 1297) {
  5644. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5645. }
  5646. if ($category == 1702) {
  5647. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5648. $list['syother'] = $this->input->post('syother', true);
  5649. }
  5650. if ($category == 133) {
  5651. $list['fittype'] = $this->input->post('fittype', true);
  5652. $list['acother'] = $this->input->post('acother', true);
  5653. }
  5654. $list['color'] = $this->input->post('color', true);
  5655. $list['lowe'] = $this->input->post('lowe', true);
  5656. if ($category == 127) {
  5657. $list['type'] = $this->input->post('type', true);
  5658. $list['headroad'] = $this->input->post('headroad', true);
  5659. $list['density'] = $this->input->post('density', true);
  5660. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5661. $list['lacesize'] = $this->input->post('lacesize', true);
  5662. }
  5663. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5664. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5665. }
  5666. if ($category == 128) {
  5667. $list['lacetype'] = $this->input->post('lacetype', true);
  5668. $list['haircap'] = $this->input->post('haircap', true);
  5669. $list['density'] = $this->input->post('density', true);
  5670. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5671. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5672. $list['wigother'] = $this->input->post('wigother', true);
  5673. $list['wigother1'] = $this->input->post('wigother1', true);
  5674. $list['wigother2'] = $this->input->post('wigother2', true);
  5675. }
  5676. if ($category == 129) {
  5677. $list['wide'] = $this->input->post('wide', true);
  5678. }
  5679. if ($category == 131) {
  5680. $list['gifttype'] = $this->input->post('gifttype', true);
  5681. $list['giftother'] = $this->input->post('giftother', true);
  5682. }
  5683. if ($category == 134) {
  5684. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5685. }
  5686. if ($category == 1297) {
  5687. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5688. $list['sywigother'] = $this->input->post('sywigother', true);
  5689. }
  5690. if ($category == 130 || $category == 133 || $category == 1702) {
  5691. $list['items'] = $this->input->post('items', true);
  5692. $list['weight'] = $this->input->post('weight', true);
  5693. }
  5694. if ($category == 1702) {
  5695. $list['syhairther'] = $this->input->post('syhairther', true);
  5696. }
  5697. foreach ($list as $k => $v) {
  5698. if ($v != 0) {
  5699. $num .= $v;
  5700. $features .= $v . '-';
  5701. $post[$k] = $v;
  5702. $typeclass = $this->typeclass->read($v);
  5703. if (isset($pm[$typeclass['classid']])) {
  5704. if (stripos($typeclass['zh'], '|') !== false) {
  5705. $exzh = explode('|', $typeclass['zh']);
  5706. $pm[$typeclass['classid']] = $exzh[0];
  5707. } else {
  5708. $pm[$typeclass['classid']] = $typeclass['zh'];
  5709. }
  5710. }
  5711. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5712. if ($k != 'size') {
  5713. $title .= $typeclass['title'] . " ";
  5714. }
  5715. }
  5716. }
  5717. $typeclass = $this->typeclass->read($list['size']);
  5718. $title .= $typeclass['title'];
  5719. $time = time();
  5720. $post['title'] = rtrim($title, ' ');
  5721. $post['number'] = $num;
  5722. $post['features'] = '-' . $features;
  5723. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5724. $featurespp = explode('-', trim($featurespp, '-'));
  5725. if (isset($featurespp[5])) {
  5726. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5727. } else {
  5728. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5729. }
  5730. $post['enter'] = $time;
  5731. $post['time'] = $time; //操作时间
  5732. $scsku = implode("-", $scsku);
  5733. $zh = implode(" ", $pm);
  5734. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5735. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5736. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5737. $post['sku'] = $bqsku;
  5738. $label = time() . rand(0, 9);
  5739. $post['label'] = $label;
  5740. $cpid = $this->whlabellabel->find_count();
  5741. $post['cpid'] = $cpid + 1;
  5742. $cpid = $post['cpid'];
  5743. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5744. //if($whlabelbarcode)
  5745. //{
  5746. //$post['label'] = $whlabelbarcode['label'];
  5747. //if(!$this->whlabellabel->insert($post))
  5748. //{
  5749. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5750. //}
  5751. //}
  5752. //else
  5753. //{
  5754. $this->db->trans_begin();
  5755. $this->whlabellabel->insert($post);
  5756. //$this->whlabelbarcode->insert($post);
  5757. if ($this->db->trans_status() === TRUE) {
  5758. $this->db->trans_commit();
  5759. } else {
  5760. $this->db->trans_rollback();
  5761. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5762. exit;
  5763. }
  5764. //}
  5765. $warehouse_name = "";
  5766. $warehouse = $post['warehouse'];
  5767. if($warehouse == 12){
  5768. $warehouse_name = "特殊库存库";
  5769. }
  5770. // if($warehouse == 13){
  5771. // $warehouse_name = "许昌仓";
  5772. // }
  5773. // if($warehouse == 5){
  5774. // $warehouse_name = "美国店";
  5775. // }
  5776. // if($warehouse == 16){
  5777. // $warehouse_name = "定制头套仓";
  5778. // }
  5779. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5780. if(!empty($warehouse_name)){
  5781. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5782. }
  5783. $purchase = $this->purchase->read($post['purchase']);
  5784. 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));
  5785. exit; //特殊仓目前不需要仓库选项
  5786. }
  5787. }
  5788. if (isset($_SESSION['api'])) {
  5789. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5790. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5791. $this->data['wlshop'] = $wlshop;
  5792. $this->data['warehouse'] = $warehouse;
  5793. }
  5794. $whlabelwz = $this->whlabelwz->find_all();
  5795. $this->data['whlabelwz'] = $whlabelwz;
  5796. $this->_Template('whlabel_print', $this->data);
  5797. }
  5798. public function _usaprint($arg_array)
  5799. {
  5800. if (isset($_SESSION['api'])) {
  5801. $user = $this->user->get_api($_SESSION['api']);
  5802. $usp = $user;
  5803. $fgshop = "";
  5804. $sid = "";
  5805. $wid = "";
  5806. $wtype = "";
  5807. $usersp = explode('|', trim($user['shop'], '|'));
  5808. $userwh = explode('|', trim($user['warehouse'], '|'));
  5809. foreach ($usersp as $value) {
  5810. $fgshop .= " shop = " . $value . " or";
  5811. $sid .= " id = " . $value . " or";
  5812. }
  5813. foreach ($userwh as $value) {
  5814. $wid .= " id = " . $value . " or";
  5815. $wtype .= " type = " . $value . " or";
  5816. }
  5817. }
  5818. $post = $this->input->post(NULL, TRUE);
  5819. if (isset($post['tmsku'])) {
  5820. $tmsku = $this->input->post('tmsku', true);
  5821. if (is_numeric($tmsku)) {
  5822. $yyh = $this->whlabellabel->get_label($tmsku);
  5823. } else {
  5824. $yyh = $this->whlabellabel->get_sku($tmsku);
  5825. }
  5826. if ($yyh) {
  5827. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5828. exit;
  5829. } else {
  5830. echo json_encode(array('success' => false));
  5831. exit;
  5832. }
  5833. }
  5834. $classid = $this->classid->sku();
  5835. $pm = $classid;
  5836. $scsku = $classid;
  5837. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5838. if (isset($post['warehouse'])) {
  5839. if ($post['warehouse']) {
  5840. $list = array();
  5841. $num = "";
  5842. $title = "";
  5843. $features = "";
  5844. $order = 0;
  5845. $post['shop'] = '';
  5846. $brand = $this->input->post('brand', true);
  5847. if ($brand != '0,') {
  5848. $b = $this->brand->read(rtrim($brand, ','));
  5849. if ($b) {
  5850. $post['shop'] = str_replace('|', ',', $b['shop']);
  5851. }
  5852. }
  5853. $post['details'] = $this->input->post('details', true); //打印数量
  5854. $xbqnum = $this->input->post('xbqnum', true);
  5855. $post['purchase'] = $this->input->post('purchase', true);
  5856. $post['warehouse'] = $this->input->post('warehouse', true);
  5857. $post['purchase'] = $this->input->post('purchase', true);
  5858. $post['retreatwarehouse'] = $post['warehouse'];
  5859. $post['cpbz'] = $this->input->post('cpbz', true);
  5860. $post['state'] = 9;
  5861. $category = $this->input->post('category', true);
  5862. $list['category'] = $category;
  5863. $list['hairtype'] = $this->input->post('hairtype', true);
  5864. $list['grade'] = $this->input->post('grade', true);
  5865. $size = $this->input->post('size', true);
  5866. $list['size'] = rtrim($size, ',');
  5867. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5868. $list['extension'] = $this->input->post('extension', true);
  5869. if ($category == 1297) {
  5870. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5871. }
  5872. if ($category == 1702) {
  5873. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5874. $list['syother'] = $this->input->post('syother', true);
  5875. }
  5876. if ($category == 133) {
  5877. $list['fittype'] = $this->input->post('fittype', true);
  5878. $list['acother'] = $this->input->post('acother', true);
  5879. }
  5880. $list['color'] = $this->input->post('color', true);
  5881. $list['lowe'] = $this->input->post('lowe', true);
  5882. if ($category == 127) {
  5883. $list['type'] = $this->input->post('type', true);
  5884. $list['headroad'] = $this->input->post('headroad', true);
  5885. $list['density'] = $this->input->post('density', true);
  5886. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5887. $list['lacesize'] = $this->input->post('lacesize', true);
  5888. }
  5889. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5890. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5891. }
  5892. if ($category == 128) {
  5893. $list['lacetype'] = $this->input->post('lacetype', true);
  5894. $list['haircap'] = $this->input->post('haircap', true);
  5895. $list['density'] = $this->input->post('density', true);
  5896. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5897. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5898. $list['wigother'] = $this->input->post('wigother', true);
  5899. $list['wigother1'] = $this->input->post('wigother1', true);
  5900. $list['wigother2'] = $this->input->post('wigother2', true);
  5901. }
  5902. if ($category == 129) {
  5903. $list['wide'] = $this->input->post('wide', true);
  5904. }
  5905. if ($category == 131) {
  5906. $list['gifttype'] = $this->input->post('gifttype', true);
  5907. $list['giftother'] = $this->input->post('giftother', true);
  5908. }
  5909. if ($category == 134) {
  5910. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5911. }
  5912. if ($category == 1297) {
  5913. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5914. $list['sywigother'] = $this->input->post('sywigother', true);
  5915. }
  5916. if ($category == 130 || $category == 133 || $category == 1702) {
  5917. $list['items'] = $this->input->post('items', true);
  5918. $list['weight'] = $this->input->post('weight', true);
  5919. }
  5920. if ($category == 1702) {
  5921. $list['syhairther'] = $this->input->post('syhairther', true);
  5922. }
  5923. foreach ($list as $k => $v) {
  5924. if ($v != 0) {
  5925. $num .= $v;
  5926. $features .= $v . '-';
  5927. $post[$k] = $v;
  5928. $typeclass = $this->typeclass->read($v);
  5929. if (isset($pm[$typeclass['classid']])) {
  5930. if (stripos($typeclass['zh'], '|') !== false) {
  5931. $exzh = explode('|', $typeclass['zh']);
  5932. $pm[$typeclass['classid']] = $exzh[0];
  5933. } else {
  5934. $pm[$typeclass['classid']] = $typeclass['zh'];
  5935. }
  5936. }
  5937. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5938. if ($k != 'size') {
  5939. $title .= $typeclass['title'] . " ";
  5940. }
  5941. }
  5942. }
  5943. $typeclass = $this->typeclass->read($list['size']);
  5944. $title .= $typeclass['title'];
  5945. $time = time();
  5946. $post['title'] = rtrim($title, ' ');
  5947. $post['number'] = $num;
  5948. $post['features'] = '-' . $features;
  5949. $fp = $this->whlabel->get_features($post['features']);
  5950. if (!$fp) {
  5951. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5952. exit;
  5953. }
  5954. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5955. $featurespp = explode('-', trim($featurespp, '-'));
  5956. if (isset($featurespp[5])) {
  5957. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5958. } else {
  5959. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5960. }
  5961. $post['enter'] = $time;
  5962. $post['time'] = $time; //操作时间
  5963. $scsku = implode("-", $scsku);
  5964. $zh = implode(" ", $pm);
  5965. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5966. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5967. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5968. $post['sku'] = $fp['sku'];
  5969. $post['label'] = $fp['sku'];
  5970. $cpid = $this->whlabellabel->find_count();
  5971. $post['cpid'] = $cpid + 1;
  5972. $cpid = $post['cpid'];
  5973. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5974. //if($whlabelbarcode)
  5975. //{
  5976. //$post['label'] = $whlabelbarcode['label'];
  5977. //if(!$this->whlabellabel->insert($post))
  5978. //{
  5979. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5980. //}
  5981. //}
  5982. //else
  5983. //{
  5984. $this->db->trans_begin();
  5985. $this->whlabellabel->insert($post);
  5986. //$this->whlabelbarcode->insert($post);
  5987. if ($this->db->trans_status() === TRUE) {
  5988. $this->db->trans_commit();
  5989. } else {
  5990. $this->db->trans_rollback();
  5991. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5992. exit;
  5993. }
  5994. //}
  5995. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5996. $purchase = $this->purchase->read($post['purchase']);
  5997. 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));
  5998. exit; //特殊仓目前不需要仓库选项
  5999. }
  6000. }
  6001. if (isset($_SESSION['api'])) {
  6002. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6003. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6004. $this->data['wlshop'] = $wlshop;
  6005. $this->data['warehouse'] = $warehouse;
  6006. }
  6007. $whlabelwz = $this->whlabelwz->find_all();
  6008. $this->data['whlabelwz'] = $whlabelwz;
  6009. $this->_Template('whlabel_usaprint', $this->data);
  6010. }
  6011. public function _printrk($arg_array)
  6012. {
  6013. $prc = array();
  6014. $purchase = $this->purchase->find_all();
  6015. foreach ($purchase as $k => $v) {
  6016. $prc[$v['id']] = $v['title'];
  6017. }
  6018. $post = $this->input->post(NULL, TRUE);
  6019. if (isset($post['page'])) {
  6020. $page = $this->input->post('page', true);
  6021. $perpage = $this->input->post('perpage', true);
  6022. $sku = $this->input->post('sku', true);
  6023. $bs = $this->input->post('bs', true);
  6024. $number = $this->input->post('number', true);
  6025. $warehouse = $this->input->post('warehouse', true);
  6026. $purchase = $this->input->post('purchase', true);
  6027. $orderinfo = $this->input->post('orderinfo', true);
  6028. $waybill = $this->input->post('waybill', true);
  6029. $category = $this->input->post('category', true);
  6030. $size = $this->input->post('size', true);
  6031. $grade = $this->input->post('grade', true);
  6032. $color = $this->input->post('color', true);
  6033. $lowe = $this->input->post('lowe', true);
  6034. $state = $this->input->post('state', true);
  6035. $label = $this->input->post('label', true);
  6036. $timetk = $this->input->post('ktime', true);
  6037. $timetj = $this->input->post('jtime', true);
  6038. $timetk = strtotime($timetk);
  6039. $timetj = strtotime($timetj);
  6040. $where = "1=1 ";
  6041. if ($timetk && $timetj) {
  6042. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6043. }
  6044. if ($sku) {
  6045. $where .= " and sku = '$sku'";
  6046. }
  6047. if ($bs != '') {
  6048. $where .= " and bs = '$bs'";
  6049. }
  6050. if ($number) {
  6051. $where .= " and number = '$number'";
  6052. }
  6053. if ($warehouse) {
  6054. $where .= " and warehouse = '$warehouse'";
  6055. }
  6056. if ($purchase) {
  6057. $where .= " and purchase = '$purchase'";
  6058. }
  6059. if ($orderinfo) {
  6060. $where .= " and orderinfo = '$orderinfo'";
  6061. }
  6062. if ($waybill) {
  6063. $where .= " and waybill = '$waybill'";
  6064. }
  6065. if ($category) {
  6066. $where .= " and features like '%-$category-%'";
  6067. }
  6068. if ($size) {
  6069. $where .= " and features like '%-$size-%'";
  6070. }
  6071. if ($grade) {
  6072. $where .= " and features like '%-$grade-%'";
  6073. }
  6074. if ($color) {
  6075. $where .= " and features like '%-$color-%'";
  6076. }
  6077. if ($lowe) {
  6078. $where .= " and features like '%-$lowe-%'";
  6079. }
  6080. if ($label) {
  6081. $where .= " and label = '$label'";
  6082. }
  6083. if ($state || $state == 0) {
  6084. $where .= " and state = '$state'";
  6085. }
  6086. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6087. //数据排序
  6088. $order_str = "enter desc";
  6089. if (empty($page)) {
  6090. $start = 0;
  6091. $perpage = 1;
  6092. } else {
  6093. $start = ($page - 1) * $perpage;
  6094. }
  6095. //取得信息列表
  6096. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6097. foreach ($info_list as $key => $value) {
  6098. $warehouse = $this->warehouse->read($value['warehouse']);
  6099. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6100. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6101. if ($value['state'] == 0) {
  6102. $info_list[$key]['state'] = "在库";
  6103. } else if ($value['state'] == 1) {
  6104. $info_list[$key]['state'] = "出库";
  6105. } else if ($value['state'] == 2) {
  6106. $info_list[$key]['state'] = "退库";
  6107. } else if ($value['state'] == 3) {
  6108. $info_list[$key]['state'] = "调拨中";
  6109. } else if ($value['state'] == 4) {
  6110. $info_list[$key]['state'] = "再加工";
  6111. } else if ($value['state'] == 5) {
  6112. $info_list[$key]['state'] = "维修中";
  6113. } else if ($value['state'] == 6) {
  6114. $info_list[$key]['state'] = "盘亏";
  6115. } else if ($value['state'] == 7) {
  6116. $info_list[$key]['state'] = "更换标签";
  6117. } else if ($value['state'] == 8) {
  6118. $info_list[$key]['state'] = "其它";
  6119. } else if ($value['state'] == 9) {
  6120. $info_list[$key]['state'] = "预设";
  6121. } else if ($value['state'] == 10) {
  6122. $info_list[$key]['state'] = "美店零售";
  6123. }
  6124. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6125. }
  6126. $total = $this->$ck->find_count($where);
  6127. $pagenum = ceil($total / $perpage);
  6128. $over = $total - ($start + $perpage);
  6129. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6130. echo json_encode($rows);
  6131. exit;
  6132. }
  6133. if (isset($post['tmsku'])) {
  6134. $time = time();
  6135. $tmsku = $this->input->post('tmsku', true);
  6136. //$post['shop'] = $this->input->post('shop',true);
  6137. $num = $this->input->post('num', true);
  6138. $rktype = $this->input->post('rktype', true);
  6139. if ($num > 200) {
  6140. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6141. exit;
  6142. }
  6143. if (!$rktype) {
  6144. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6145. }
  6146. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6147. /**
  6148. $wz = array();
  6149. foreach ($rk as $key=>$value)
  6150. {
  6151. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6152. }
  6153. if(count($wz) > 1)
  6154. {
  6155. $wz = array_values($wz);
  6156. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6157. }
  6158. **/
  6159. if (isset($rk[0]['purchase'])) {
  6160. $rk = $rk[0];
  6161. $j = 0;
  6162. $post['purchase'] = $rk['purchase'];
  6163. $post['warehouse'] = $rk['warehouse'];
  6164. $post['retreatwarehouse'] = $rk['warehouse'];
  6165. $post['sku'] = $rk['sku'];
  6166. $post['number'] = $rk['number'];
  6167. $post['features'] = $rk['features'];
  6168. $post['title'] = $rk['title'];
  6169. $post['enter'] = $time;
  6170. $post['time'] = $time;
  6171. $post['bs'] = 1;
  6172. $post['shop'] = $rk['shop'];
  6173. $post['details'] = $rk['details'];
  6174. $post['cpid'] = $rk['cpid'];
  6175. $post['cpbz'] = $rk['cpbz'];
  6176. //$post['rktype'] = $rktype;
  6177. $warehouse = $this->warehouse->read($rk['warehouse']);
  6178. if ($warehouse['bdck'] == '') {
  6179. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6180. exit;
  6181. } else {
  6182. $bdck = $warehouse['bdck'];
  6183. }
  6184. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6185. if (isset($pdwz['details'])) {
  6186. if ($pdwz['details'] != $post['details']) {
  6187. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6188. exit;
  6189. }
  6190. }
  6191. $post['featurespp'] = $rk['featurespp'];
  6192. if ($post['warehouse'] == '5') {
  6193. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6194. if ($yza) {
  6195. if ($post['features'] != $yza[0]['features']) {
  6196. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6197. exit;
  6198. }
  6199. }
  6200. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6201. if ($yzb) {
  6202. if ($post['sku'] != $yzb[0]['sku']) {
  6203. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6204. exit;
  6205. }
  6206. }
  6207. }
  6208. for ($i = 0; $i < $num; $i++) {
  6209. $post['label'] = time() . rand(100, 999) . $i;
  6210. if ($this->$bdck->insert($post)) {
  6211. $j++;
  6212. }
  6213. }
  6214. /**
  6215. if($post['warehouse'] != 12)
  6216. {
  6217. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6218. }
  6219. **/
  6220. if ($j == $num) {
  6221. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6222. exit;
  6223. } else {
  6224. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6225. exit;
  6226. }
  6227. } else {
  6228. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6229. exit;
  6230. }
  6231. }
  6232. $this->_Template('whlabel_printrk', $this->data);
  6233. }
  6234. public function _printxzrk($arg_array)
  6235. {
  6236. $post = $this->input->post(NULL, TRUE);
  6237. if (isset($post['wzid'])) {
  6238. $time = time();
  6239. $id = $this->input->post('wzid', true);
  6240. //$post['shop'] = $this->input->post('shop',true);
  6241. $num = 1;
  6242. $rk = $this->whlabellabel->read($id);
  6243. if (isset($rk['purchase'])) {
  6244. $x = 0;
  6245. $post['purchase'] = $rk['purchase'];
  6246. $post['warehouse'] = $rk['warehouse'];
  6247. $post['retreatwarehouse'] = $rk['warehouse'];
  6248. $post['sku'] = $rk['sku'];
  6249. $post['number'] = $rk['number'];
  6250. $post['features'] = $rk['features'];
  6251. $post['title'] = $rk['title'];
  6252. $post['enter'] = $time;
  6253. $post['time'] = $time;
  6254. $post['bs'] = 1;
  6255. $post['shop'] = $rk['shop'];
  6256. $post['details'] = $rk['details'];
  6257. $post['cpid'] = $rk['cpid'];
  6258. $post['cpbz'] = $rk['cpbz'];
  6259. $warehouse = $this->warehouse->read($rk['warehouse']);
  6260. if ($warehouse['bdck'] == '') {
  6261. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6262. exit;
  6263. } else {
  6264. $bdck = $warehouse['bdck'];
  6265. }
  6266. $post['featurespp'] = $rk['featurespp'];
  6267. $this->db->trans_begin();
  6268. for ($i = 0; $i < $num; $i++) {
  6269. $post['label'] = time() . rand(100, 999) . $i;
  6270. $this->$bdck->insert($post);
  6271. }
  6272. /**
  6273. if($post['warehouse'] != 12)
  6274. {
  6275. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6276. }
  6277. **/
  6278. if ($this->db->trans_status() === TRUE) {
  6279. $this->db->trans_commit();
  6280. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6281. exit;
  6282. } else {
  6283. $this->db->trans_rollback();
  6284. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6285. exit;
  6286. }
  6287. } else {
  6288. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6289. exit;
  6290. }
  6291. }
  6292. }
  6293. public function _printck($arg_array)
  6294. {
  6295. $prc = array();
  6296. $purchase = $this->purchase->find_all();
  6297. foreach ($purchase as $k => $v) {
  6298. $prc[$v['id']] = $v['title'];
  6299. }
  6300. $post = $this->input->post(NULL, TRUE);
  6301. if (isset($post['page'])) {
  6302. $page = $this->input->post('page', true);
  6303. $perpage = $this->input->post('perpage', true);
  6304. $sku = $this->input->post('sku', true);
  6305. $bs = $this->input->post('bs', true);
  6306. $number = $this->input->post('number', true);
  6307. $warehouse = $this->input->post('warehouse', true);
  6308. $purchase = $this->input->post('purchase', true);
  6309. $orderinfo = $this->input->post('orderinfo', true);
  6310. $waybill = $this->input->post('waybill', true);
  6311. $category = $this->input->post('category', true);
  6312. $size = $this->input->post('size', true);
  6313. $grade = $this->input->post('grade', true);
  6314. $color = $this->input->post('color', true);
  6315. $lowe = $this->input->post('lowe', true);
  6316. $state = $this->input->post('state', true);
  6317. $label = $this->input->post('label', true);
  6318. $timetk = $this->input->post('ktime', true);
  6319. $timetj = $this->input->post('jtime', true);
  6320. $timetk = strtotime($timetk);
  6321. $timetj = strtotime($timetj);
  6322. $where = "state=1 ";
  6323. if ($timetk && $timetj) {
  6324. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6325. }
  6326. if ($sku) {
  6327. $where .= " and sku = '$sku'";
  6328. }
  6329. if ($bs != '') {
  6330. $where .= " and bs = '$bs'";
  6331. }
  6332. if ($number) {
  6333. $where .= " and number = '$number'";
  6334. }
  6335. if ($warehouse) {
  6336. $where .= " and warehouse = '$warehouse'";
  6337. }
  6338. if ($purchase) {
  6339. $where .= " and purchase = '$purchase'";
  6340. }
  6341. if ($orderinfo) {
  6342. $where .= " and orderinfo = '$orderinfo'";
  6343. }
  6344. if ($waybill) {
  6345. $where .= " and waybill = '$waybill'";
  6346. }
  6347. if ($category) {
  6348. $where .= " and features like '%-$category-%'";
  6349. }
  6350. if ($size) {
  6351. $where .= " and features like '%-$size-%'";
  6352. }
  6353. if ($grade) {
  6354. $where .= " and features like '%-$grade-%'";
  6355. }
  6356. if ($color) {
  6357. $where .= " and features like '%-$color-%'";
  6358. }
  6359. if ($lowe) {
  6360. $where .= " and features like '%-$lowe-%'";
  6361. }
  6362. if ($label) {
  6363. $where .= " and label = '$label'";
  6364. }
  6365. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6366. //数据排序
  6367. $order_str = "outk desc";
  6368. if (empty($page)) {
  6369. $start = 0;
  6370. $perpage = 1;
  6371. } else {
  6372. $start = ($page - 1) * $perpage;
  6373. }
  6374. //取得信息列表
  6375. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6376. foreach ($info_list as $key => $value) {
  6377. $warehouse = $this->warehouse->read($value['warehouse']);
  6378. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6379. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6380. if ($value['state'] == 0) {
  6381. $info_list[$key]['state'] = "在库";
  6382. } else if ($value['state'] == 1) {
  6383. $info_list[$key]['state'] = "出库";
  6384. } else if ($value['state'] == 2) {
  6385. $info_list[$key]['state'] = "退库";
  6386. } else if ($value['state'] == 3) {
  6387. $info_list[$key]['state'] = "调拨中";
  6388. } else if ($value['state'] == 4) {
  6389. $info_list[$key]['state'] = "再加工";
  6390. } else if ($value['state'] == 5) {
  6391. $info_list[$key]['state'] = "维修中";
  6392. } else if ($value['state'] == 6) {
  6393. $info_list[$key]['state'] = "盘亏";
  6394. } else if ($value['state'] == 7) {
  6395. $info_list[$key]['state'] = "更换标签";
  6396. } else if ($value['state'] == 8) {
  6397. $info_list[$key]['state'] = "其它";
  6398. } else if ($value['state'] == 9) {
  6399. $info_list[$key]['state'] = "预设";
  6400. } else if ($value['state'] == 10) {
  6401. $info_list[$key]['state'] = "美店零售";
  6402. }
  6403. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6404. }
  6405. $total = $this->$ck->find_count($where);
  6406. $pagenum = ceil($total / $perpage);
  6407. $over = $total - ($start + $perpage);
  6408. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6409. echo json_encode($rows);
  6410. exit;
  6411. }
  6412. if (isset($post['tmsku'])) {
  6413. $time = time();
  6414. $tmsku = $this->input->post('tmsku', true);
  6415. //$post['shop'] = $this->input->post('shop',true);
  6416. $num = $this->input->post('num', true);
  6417. $cktype = $this->input->post('cktype', true);
  6418. $label = $this->whlabellabel->get_label($tmsku);
  6419. if (!$cktype) {
  6420. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6421. }
  6422. if (!isset($label['warehouse'])) {
  6423. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6424. exit;
  6425. }
  6426. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6427. if (stripos($label['features'], '-126-') !== false) {
  6428. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6429. } else {
  6430. $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 = ''");
  6431. }
  6432. $j = 0;
  6433. if (count($ck) >= $num) {
  6434. for ($i = 0; $i < $num; $i++) {
  6435. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6436. {
  6437. $j++;
  6438. }
  6439. }
  6440. if ($j == $num) {
  6441. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6442. exit;
  6443. } else {
  6444. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6445. exit;
  6446. }
  6447. } else {
  6448. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6449. exit;
  6450. }
  6451. }
  6452. if(isset($_SESSION['api']))
  6453. {
  6454. $user = $this->user->get_api($_SESSION['api']);
  6455. if(in_array($user['power'],[1,27])){
  6456. $vip = 1;
  6457. }
  6458. }
  6459. else
  6460. {
  6461. $vip = 0;
  6462. header('Location: /');exit;
  6463. }
  6464. $this->data['vip'] = $vip;
  6465. $this->_Template('whlabel_printck', $this->data);
  6466. }
  6467. public function _printexcel()
  6468. {
  6469. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6470. $config['upload_path'] = '.' . $dir;
  6471. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6472. $config['allowed_types'] = 'xls|xlsx|csv';
  6473. $config['max_size'] = 10240;
  6474. $this->load->library('upload', $config);
  6475. $this->upload->initialize($config);
  6476. if ($this->upload->do_upload('userfile')) {
  6477. $full_path = $dir . $this->upload->data('file_name');
  6478. $fileName = '.' . $full_path;
  6479. if (!file_exists($fileName)) {
  6480. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6481. exit;
  6482. } else {
  6483. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6484. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6485. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6486. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6487. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6488. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6489. ++$column; //如果列数大于26行
  6490. $list = array();
  6491. for ($i = 2; $i <= $row; $i++) // 行数循环
  6492. {
  6493. $data = array();
  6494. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6495. {
  6496. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6497. }
  6498. $list[] = $data;
  6499. }
  6500. }
  6501. $ed = array();
  6502. $i = 0;
  6503. $j = 0;
  6504. $dcdata = array();
  6505. $yc = '';
  6506. $cmf_arr = array_column($list, '1');
  6507. array_multisort($cmf_arr, SORT_ASC, $list);
  6508. foreach ($list as $key => $value) {
  6509. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6510. if ($typeclass) {
  6511. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6512. } else {
  6513. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6514. $i++;
  6515. continue;
  6516. }
  6517. }
  6518. if ($i > 0) {
  6519. $yc = $i . '条异常';
  6520. }
  6521. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6522. exit;
  6523. }
  6524. }
  6525. public function _uck()
  6526. {
  6527. if (isset($_GET['excel'])) {
  6528. $tc = array();
  6529. $typeclass = $this->typeclass->find_all();
  6530. foreach ($typeclass as $v) {
  6531. $tc[$v['id']] = $v['zh'];
  6532. }
  6533. $data = array();
  6534. $t = array();
  6535. $rq = '';
  6536. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6537. $ts = $ts / (24 * 3600);
  6538. for ($i = 0; $i < $ts; $i++) {
  6539. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6540. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6541. }
  6542. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6543. foreach ($info_list as $k => $v) {
  6544. $features = explode('-', trim($v['features'], '-'));
  6545. if (!isset($features[3]) || !isset($features[4])) {
  6546. continue;
  6547. }
  6548. $data[$k][0] = $tc[$features[0]]; //类型
  6549. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6550. $data[$k][2] = $tc[$features[4]]; //曲度
  6551. $data[$k][3] = '';
  6552. if (isset($data[$k][1])) {
  6553. $data[$k][3] .= $data[$k][1];
  6554. }
  6555. if (isset($data[$k][2])) {
  6556. $data[$k][3] .= $data[$k][2];
  6557. }
  6558. if (isset($features[5])) {
  6559. $data[$k][3] .= $tc[$features[5]];
  6560. }
  6561. if (isset($features[2])) {
  6562. $data[$k][3] .= $tc[$features[2]];
  6563. }
  6564. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6565. $data[$k][4] = $v['sku'];
  6566. $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())) . '))'); //月初库存
  6567. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6568. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6569. $ztrq = '';
  6570. $ztsl = '';
  6571. if (count($zt) > 0) {
  6572. foreach ($zt as $vv) {
  6573. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6574. $ztsl .= $vv['num'] . '<br>';
  6575. }
  6576. }
  6577. $data[$k][] = trim($ztsl, '<br>');
  6578. $data[$k][] = trim($ztrq, '<br>');
  6579. $byck = 0;
  6580. foreach ($t as $vv) {
  6581. $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));
  6582. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6583. $byck += $sl;
  6584. }
  6585. $data[$k][] = ($byck > 0) ? $byck : '';
  6586. }
  6587. $title = "详情 " . date("Y-m-d", time());
  6588. $titlename = "<table border=1>
  6589. <tr align='center'>
  6590. <td>类别</td>
  6591. <td>颜色</td>
  6592. <td>曲度</td>
  6593. <td>名称</td>
  6594. <td>SKU</td>
  6595. <td>月初库存</td>
  6596. <td>剩余库存</td>
  6597. <td>在途数量</td>
  6598. <td>预达日期</td>" .
  6599. $rq
  6600. . "<td>本月出库</td></tr>
  6601. </table>";
  6602. $filename = $title . ".xls";
  6603. $tail = "";
  6604. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6605. }
  6606. }
  6607. public function _whlabelexcelzh()
  6608. {
  6609. if (isset($_GET['excel'])) {
  6610. $where = "sku != 'Preset'";
  6611. //数据排序
  6612. $order_str = "id desc";
  6613. if (empty($page)) {
  6614. $start = 0;
  6615. $perpage = 1;
  6616. } else {
  6617. $start = ($page - 1) * $perpage;
  6618. }
  6619. $category = $this->input->get('category', true);
  6620. $warehouse = $this->input->get('warehouse', true);
  6621. $excelid = $this->input->get('sid', true);
  6622. if ($category) {
  6623. $where .= " and features like '%-$category-%'";
  6624. }
  6625. if ($warehouse) {
  6626. $where .= " and warehouse = '$warehouse'";
  6627. }
  6628. $xzid = '';
  6629. if ($excelid) {
  6630. $excelid = explode(',', trim($excelid, ','));
  6631. foreach ($excelid as $key => $value) {
  6632. $xzid .= " id = " . $value . " or";
  6633. }
  6634. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6635. }
  6636. //取得信息列表
  6637. /**
  6638. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6639. $rows = array();$list = array();
  6640. foreach ($info_list as $key=>$value)
  6641. {
  6642. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6643. }
  6644. **/
  6645. $list = array();
  6646. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6647. foreach ($rows as $key => $value) {
  6648. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6649. $zh = '';
  6650. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6651. foreach ($zt as $v) {
  6652. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6653. }
  6654. $zt = array_sum(array_column($zt, 'num'));
  6655. $number = $value['number'];
  6656. $ftime = time() - 15 * 24 * 3600;
  6657. $warehouse = $this->warehouse->read($value['warehouse']);
  6658. $rows[$key]['warehouse'] = $warehouse['title'];
  6659. $rows[$key]['number'] = $c;
  6660. $rows[$key]['features'] = $zh;
  6661. $rows[$key]['hb'] = $c + $zt;
  6662. }
  6663. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6664. $titlename = "<table border=1>
  6665. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6666. <tr align='center'>
  6667. <td>仓库</td>
  6668. <td>SKU</td>
  6669. <td>产品</td>
  6670. <td>库存数量</td>
  6671. <td>在途数量及预达日期</td>
  6672. <td>在途+库存数量</td>
  6673. </tr>
  6674. </table>";
  6675. $filename = $title . ".xls";
  6676. $tail = "";
  6677. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6678. }
  6679. if (isset($_GET['excel'])) {
  6680. $warehouse = $this->input->get('warehouse', true);
  6681. $sku = $this->input->get('sku', true);
  6682. $cz = $this->input->get('cz', true);
  6683. $text = $this->input->post('text', true);
  6684. $xztime = $this->input->get('xztime', true);
  6685. $timetk = $this->input->get('timetk', true);
  6686. $timetj = $this->input->get('timetj', true);
  6687. $timetk = strtotime($timetk);
  6688. $timetj = strtotime($timetj);
  6689. $where = "time = '0' ";
  6690. if ($warehouse) {
  6691. $where .= " and warehouse = '$warehouse'";
  6692. }
  6693. if ($sku) {
  6694. $where .= " and sku = '$sku'";
  6695. }
  6696. if ($text) {
  6697. $where .= " and text like '%$text%'";
  6698. }
  6699. if ($cz != '') {
  6700. $where .= " and cz = '$cz'";
  6701. }
  6702. if ($timetk && $timetj) {
  6703. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6704. }
  6705. //数据排序
  6706. $order_str = $xztime . " desc";
  6707. //取得信息列表
  6708. $zh = array();
  6709. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6710. foreach ($info_list as $v) {
  6711. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6712. $warehouse = $this->warehouse->read($v['warehouse']);
  6713. $v['warehouse'] = $warehouse['title'];
  6714. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6715. $v['stime'] = date('Y-m-d', $v['stime']);
  6716. if (isset($zh[$v['features']])) {
  6717. $zh[$v['features']]['num'] += $v['num'];
  6718. } else {
  6719. $zh[$v['features']] = $v;
  6720. }
  6721. $zh[$v['features']]['features'] = $c;
  6722. }
  6723. $title = "在途数据" . date('Y-m-d', time());
  6724. $titlename = "<table border=1>
  6725. <tr align='center'>
  6726. <td>仓库</td>
  6727. <td>SKU</td>
  6728. <td>名称</td>
  6729. <td>在途数量</td>
  6730. <td>库存数量</td>
  6731. <td>添加在途日期</td>
  6732. <td>预达日期</td>
  6733. <td>备注</td>
  6734. </tr>
  6735. </table>";
  6736. $filename = $title . ".xls";
  6737. $tail = "";
  6738. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6739. }
  6740. }
  6741. public function _fc()
  6742. {
  6743. $vip = 0;
  6744. if (isset($_SESSION['api'])) {
  6745. $user = $this->user->get_api($_SESSION['api']);
  6746. if ($user['vip'] == 1) {
  6747. $vip = 1;
  6748. }
  6749. } else {
  6750. header('Location: /');
  6751. exit;
  6752. }
  6753. $post = $this->input->post(NULL, TRUE);
  6754. if (isset($post['page'])) {
  6755. $page = $this->input->post('page', true);
  6756. $perpage = $this->input->post('perpage', true);
  6757. $category = $this->input->post('category', true);
  6758. $size = $this->input->post('size', true);
  6759. $grade = $this->input->post('grade', true);
  6760. $color = $this->input->post('color', true);
  6761. $lowe = $this->input->post('lowe', true);
  6762. $sku = $this->input->post('sku');
  6763. $title = $this->input->post('title');
  6764. $warehouse = $this->input->post('warehouse', true);
  6765. $usa = $this->input->post('usa', true);
  6766. $purchase = $this->input->post('purchase', true);
  6767. $lacetype = $this->input->post('lacetype', true);
  6768. $haircap = $this->input->post('haircap', true);
  6769. $density = $this->input->post('density', true);
  6770. $details = $this->input->post('details', true);
  6771. $state = $this->input->post('state', true);
  6772. $ktime = $this->input->post('ktime', true);
  6773. $jtime = $this->input->post('jtime', true);
  6774. $ktime = strtotime($ktime);
  6775. $jtime = strtotime($jtime);
  6776. $where = "state = '11'";
  6777. $gj = "";
  6778. $ck = "";
  6779. if ($lacetype) {
  6780. $where .= " and features like '%-$lacetype-%'";
  6781. }
  6782. if ($category) {
  6783. $where .= " and features like '%-$category-%'";
  6784. }
  6785. if ($size) {
  6786. $where .= " and features like '%-$size-%'";
  6787. }
  6788. if ($grade) {
  6789. $where .= " and features like '%-$grade-%'";
  6790. }
  6791. if ($color) {
  6792. $where .= " and features like '%-$color-%'";
  6793. }
  6794. if ($lowe) {
  6795. $where .= " and features like '%-$lowe-%'";
  6796. }
  6797. if ($haircap) {
  6798. $where .= " and features like '%-$haircap-%'";
  6799. }
  6800. if ($density) {
  6801. $where .= " and features like '%-$density-%'";
  6802. }
  6803. if ($usa) {
  6804. if (!$warehouse) {
  6805. $where .= " and (warehouse = '5' or warehouse = '8')";
  6806. }
  6807. }
  6808. if ($warehouse) {
  6809. $where .= " and warehouse = '$warehouse'";
  6810. }
  6811. if ($details) {
  6812. $where .= " and details = '$details'";
  6813. }
  6814. if ($purchase) {
  6815. $where .= " and purchase = '$purchase'";
  6816. }
  6817. if ($state) {
  6818. $where .= " and state = '$state'";
  6819. }
  6820. if ($ktime && $jtime) {
  6821. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6822. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6823. }
  6824. //数据排序
  6825. $order_str = "id desc";
  6826. if (empty($page)) {
  6827. $start = 0;
  6828. $perpage = 1;
  6829. } else {
  6830. $start = ($page - 1) * $perpage;
  6831. }
  6832. if ($sku) {
  6833. $sku = trim($sku, ' ');
  6834. $sku = trim($sku, ' ');
  6835. $where .= " and sku like '%$sku%'";
  6836. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6837. } else if ($title) {
  6838. $title = trim($title, ' ');
  6839. $title = trim($title, ' ');
  6840. $where .= " and title like '%$title%'";
  6841. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6842. } else {
  6843. //$where .= " and time > '$ktime' and time < '$jtime'";
  6844. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6845. }
  6846. //取得信息列表
  6847. $rows = array();
  6848. $list = array();
  6849. foreach ($info_list as $key => $value) {
  6850. $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'] . '"');
  6851. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6852. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6853. $warehouse = $this->warehouse->read($value['warehouse']);
  6854. $info_list[$key]['warehouse'] = $warehouse['title'];
  6855. $info_list[$key]['number'] = $g;
  6856. $info_list[$key]['features'] = $x;
  6857. $info_list[$key]['x'] = $s;
  6858. }
  6859. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6860. $pagenum = ceil($total / $perpage);
  6861. $over = $total - ($start + $perpage);
  6862. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6863. echo json_encode($rows);
  6864. exit;
  6865. }
  6866. $this->data['vip'] = $vip;
  6867. $this->_Template('whlabel_fc', $this->data);
  6868. }
  6869. public function _fcmb()
  6870. {
  6871. $where = "sku != 'Preset'";
  6872. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6873. foreach ($rows as $k => $v) {
  6874. $warehouse = $this->warehouse->read($v['warehouse']);
  6875. $rows[$k]['warehouse'] = $warehouse['title'];
  6876. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6877. $rows[$k]['t'] = '';
  6878. $rows[$k]['n'] = '';
  6879. }
  6880. $title = "封货产品数据导入模板";
  6881. $titlename = "<table border=1>
  6882. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6883. <tr align='center'>
  6884. <td>仓库</td>
  6885. <td>SKU</td>
  6886. <td>产品</td>
  6887. <td>封存产品总数量</td>
  6888. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6889. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6890. </tr>
  6891. </table>";
  6892. $filename = $title . ".xls";
  6893. $tail = "";
  6894. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6895. }
  6896. public function _fcexcel()
  6897. {
  6898. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6899. $config['upload_path'] = '.' . $dir;
  6900. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6901. $config['allowed_types'] = 'xls|xlsx|csv';
  6902. $config['max_size'] = 10240;
  6903. $this->load->library('upload', $config);
  6904. $this->upload->initialize($config);
  6905. if ($this->upload->do_upload('userfile')) {
  6906. $full_path = $dir . $this->upload->data('file_name');
  6907. $fileName = '.' . $full_path;
  6908. if (!file_exists($fileName)) {
  6909. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6910. exit;
  6911. } else {
  6912. libxml_use_internal_errors(true);
  6913. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6914. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6915. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6916. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6917. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6918. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6919. ++$column; //如果列数大于26行
  6920. $list = array();
  6921. for ($i = 2; $i <= $row; $i++) // 行数循环
  6922. {
  6923. $data = array();
  6924. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6925. {
  6926. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6927. }
  6928. $list[] = $data;
  6929. }
  6930. }
  6931. $i = 0;
  6932. $j = 0;
  6933. $ed = array();
  6934. foreach ($list as $key => $value) {
  6935. $time = time();
  6936. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6937. continue;
  6938. }
  6939. $warehouse = $this->warehouse->get_title($value['0']);
  6940. $sku = $value['1'];
  6941. $type = $value['4']; //调整方式0扣减1删除
  6942. $num = $value['5']; //调整数量
  6943. //$text = $value['4'];//扣减说明
  6944. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6945. if (!$d) //如果没有这个SKU
  6946. {
  6947. $ed[] = array($sku . '-库存中不存在此SKU');
  6948. $j++;
  6949. continue;
  6950. }
  6951. if (!isset($warehouse['id'])) {
  6952. $ed[] = array($sku . '-仓库名错误!');
  6953. $j++;
  6954. continue;
  6955. }
  6956. if ($type == 1 || $type == 2) //扣减库存
  6957. {
  6958. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6959. if (count($data) < abs($num)) {
  6960. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6961. $j++;
  6962. continue;
  6963. }
  6964. if ($type == 1) //转入库存
  6965. {
  6966. for ($i = 0; $i < abs($num); $i++) {
  6967. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6968. }
  6969. } else if ($type == 2) //删除
  6970. {
  6971. for ($i = 0; $i < abs($num); $i++) {
  6972. $this->whlabel->remove($data[$i]['id']);
  6973. }
  6974. }
  6975. } else if ($type == 0) //增加库存
  6976. {
  6977. $post['sku'] = $d['sku'];
  6978. $post['shop'] = '';
  6979. $post['warehouse'] = $warehouse['id'];
  6980. $post['purchase'] = $d['purchase'];
  6981. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6982. $post['state'] = 11;
  6983. $post['title'] = $d['title'];
  6984. $post['number'] = $d['number'];
  6985. $post['features'] = $d['features'];
  6986. $post['enter'] = $time;
  6987. $post['time'] = $time; //操作时间
  6988. for ($i = 0; $i < $num; $i++) {
  6989. $post['label'] = time() . rand(100, 999) . $i;
  6990. $this->whlabel->insert($post);
  6991. }
  6992. }
  6993. sleep(1); //防止入库时间一样,需要延迟1秒
  6994. }
  6995. if ($j > 0) {
  6996. $tt = date('Ymd', time());
  6997. $title = '库存导入错误信息-' . $tt;
  6998. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6999. $tail = "\n";
  7000. $filename = $title . ".xls";
  7001. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7002. $dir = '/data/excel/' . $time . '/';
  7003. $file_name = 'error_' . $time . rand(1000, 9999);
  7004. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7005. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7006. fwrite($myfile, $ecl);
  7007. fclose($myfile);
  7008. $error = $dir . $file_name . '.xls';
  7009. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7010. exit;
  7011. } else {
  7012. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7013. exit;
  7014. }
  7015. }
  7016. }
  7017. public function _fcjxc($arg_array)
  7018. {
  7019. if (isset($_GET['excel'])) {
  7020. $category = $this->input->get('category', true);
  7021. $size = $this->input->get('size', true);
  7022. $grade = $this->input->get('grade', true);
  7023. $color = $this->input->get('color', true);
  7024. $lowe = $this->input->get('lowe', true);
  7025. $sku = $this->input->get('sku');
  7026. $title = $this->input->get('title');
  7027. $warehouse = $arg_array[0];
  7028. $usa = $this->input->get('usa', true);
  7029. $purchase = $this->input->get('purchase', true);
  7030. $lacetype = $this->input->get('lacetype', true);
  7031. $haircap = $this->input->get('haircap', true);
  7032. $density = $this->input->get('density', true);
  7033. $title = $this->input->get('title', true);
  7034. $state = $this->input->get('state', true);
  7035. $ktime = $this->input->get('ktime', true);
  7036. $jtime = $this->input->get('jtime', true);
  7037. $where = "state=11";
  7038. $gj = "";
  7039. $ck = "";
  7040. if ($lacetype) {
  7041. $where .= " and features like '%-$lacetype-%'";
  7042. }
  7043. if ($category) {
  7044. $where .= " and features like '%-$category-%'";
  7045. }
  7046. if ($size) {
  7047. $where .= " and features like '%-$size-%'";
  7048. }
  7049. if ($grade) {
  7050. $where .= " and features like '%-$grade-%'";
  7051. }
  7052. if ($color) {
  7053. $where .= " and features like '%-$color-%'";
  7054. }
  7055. if ($lowe) {
  7056. $where .= " and features like '%-$lowe-%'";
  7057. }
  7058. if ($haircap) {
  7059. $where .= " and features like '%-$haircap-%'";
  7060. }
  7061. if ($density) {
  7062. $where .= " and features like '%-$density-%'";
  7063. }
  7064. if ($usa) {
  7065. if (!$warehouse) {
  7066. $where .= " and (warehouse = '5' or warehouse = '8')";
  7067. }
  7068. }
  7069. if ($warehouse) {
  7070. $where .= " and warehouse = '$warehouse'";
  7071. }
  7072. if ($purchase) {
  7073. $where .= " and purchase = '$purchase'";
  7074. }
  7075. if ($state) {
  7076. $where .= " and state = '$state'";
  7077. }
  7078. $order_str = "id desc";
  7079. if ($sku) {
  7080. $sku = trim($sku, ' ');
  7081. $sku = trim($sku, ' ');
  7082. $where .= " and sku like '%$sku%'";
  7083. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7084. } else if ($title) {
  7085. $title = trim($title, ' ');
  7086. $title = trim($title, ' ');
  7087. $where .= " and title like '%$title%'";
  7088. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7089. } else {
  7090. //$where .= " and time > '$ktime' and time < '$jtime'";
  7091. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7092. }
  7093. //取得信息列表
  7094. $rows = array();
  7095. $list = array();
  7096. foreach ($info_list as $key => $value) {
  7097. $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'] . '"');
  7098. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7099. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7100. $rows[$key] = $value;
  7101. $warehouse = $this->warehouse->read($value['warehouse']);
  7102. $rows[$key]['warehouse'] = $warehouse['title'];
  7103. $rows[$key]['features'] = $g;
  7104. $rows[$key]['a'] = $x;
  7105. $rows[$key]['b'] = $s;
  7106. }
  7107. $title = "总统计表";
  7108. $titlename = "<table border=1>
  7109. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7110. <tr align='center'>
  7111. <td>仓库</td>
  7112. <td>SKU</td>
  7113. <td>产品名称</td>
  7114. <td>录入总量</td>
  7115. <td>取出总量</td>
  7116. <td>剩余总量</td>
  7117. </tr>
  7118. </table>";
  7119. $filename = $title . ".xls";
  7120. $tail = "";
  7121. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7122. }
  7123. $vip = 0;
  7124. if (isset($_SESSION['api'])) {
  7125. $user = $this->user->get_api($_SESSION['api']);
  7126. if ($user['vip'] == 1) {
  7127. $vip = 1;
  7128. }
  7129. } else {
  7130. header('Location: /');
  7131. exit;
  7132. }
  7133. $post = $this->input->post(NULL, TRUE);
  7134. if (isset($post['page'])) {
  7135. $page = $this->input->post('page', true);
  7136. $perpage = $this->input->post('perpage', true);
  7137. $category = $this->input->post('category', true);
  7138. $size = $this->input->post('size', true);
  7139. $grade = $this->input->post('grade', true);
  7140. $color = $this->input->post('color', true);
  7141. $lowe = $this->input->post('lowe', true);
  7142. $sku = $this->input->post('sku');
  7143. $title = $this->input->post('title');
  7144. $warehouse = $arg_array[0];
  7145. $usa = $this->input->post('usa', true);
  7146. $purchase = $this->input->post('purchase', true);
  7147. $lacetype = $this->input->post('lacetype', true);
  7148. $haircap = $this->input->post('haircap', true);
  7149. $density = $this->input->post('density', true);
  7150. $title = $this->input->post('title', true);
  7151. $state = $this->input->post('state', true);
  7152. $ktime = $this->input->post('ktime', true);
  7153. $jtime = $this->input->post('jtime', true);
  7154. $ktime = strtotime($ktime);
  7155. $jtime = strtotime($jtime);
  7156. $where = "state=11";
  7157. $gj = "";
  7158. $ck = "";
  7159. if ($lacetype) {
  7160. $where .= " and features like '%-$lacetype-%'";
  7161. }
  7162. if ($category) {
  7163. $where .= " and features like '%-$category-%'";
  7164. }
  7165. if ($size) {
  7166. $where .= " and features like '%-$size-%'";
  7167. }
  7168. if ($grade) {
  7169. $where .= " and features like '%-$grade-%'";
  7170. }
  7171. if ($color) {
  7172. $where .= " and features like '%-$color-%'";
  7173. }
  7174. if ($lowe) {
  7175. $where .= " and features like '%-$lowe-%'";
  7176. }
  7177. if ($haircap) {
  7178. $where .= " and features like '%-$haircap-%'";
  7179. }
  7180. if ($density) {
  7181. $where .= " and features like '%-$density-%'";
  7182. }
  7183. if ($usa) {
  7184. if (!$warehouse) {
  7185. $where .= " and (warehouse = '5' or warehouse = '8')";
  7186. }
  7187. }
  7188. if ($warehouse) {
  7189. $where .= " and warehouse = '$warehouse'";
  7190. }
  7191. if ($purchase) {
  7192. $where .= " and purchase = '$purchase'";
  7193. }
  7194. if ($state) {
  7195. $where .= " and state = '$state'";
  7196. }
  7197. if ($ktime && $jtime) {
  7198. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7199. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7200. }
  7201. //数据排序
  7202. $order_str = "id desc";
  7203. $xs = 0;
  7204. $rows = array();
  7205. $list = array();
  7206. if (empty($page)) {
  7207. $start = 0;
  7208. $perpage = 1;
  7209. } else {
  7210. $start = ($page - 1) * $perpage;
  7211. }
  7212. if ($sku || $title) {
  7213. if ($title) {
  7214. $title = trim($title, ' ');
  7215. $title = trim($title, ' ');
  7216. $where .= " and title like '%$title%'";
  7217. } else {
  7218. $sku = trim($sku, ' ');
  7219. $sku = trim($sku, ' ');
  7220. $where .= " and sku like '%$sku%'";
  7221. }
  7222. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7223. foreach ($info_list as $key => $value) {
  7224. $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'] . '"');
  7225. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7226. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7227. $rows[$key] = $value;
  7228. $warehouse = $this->warehouse->read($value['warehouse']);
  7229. $rows[$key]['warehouse'] = $warehouse['title'];
  7230. $rows[$key]['features'] = $g;
  7231. $rows[$key]['a'] = $x;
  7232. $rows[$key]['b'] = $s;
  7233. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7234. $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天销量
  7235. $yj = $c / ($xl / 30);
  7236. if ($yj < 7) {
  7237. $rows[$key]['y'] = round($yj) . '天销量';
  7238. } else {
  7239. $rows[$key]['y'] = '正常';
  7240. }
  7241. }
  7242. } else {
  7243. //$where .= " and time > '$ktime' and time < '$jtime'";
  7244. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7245. foreach ($info_list as $key => $value) {
  7246. $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'] . '"');
  7247. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7248. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7249. $zs[$key] = $value;
  7250. $warehouse = $this->warehouse->read($value['warehouse']);
  7251. $zs[$key]['warehouse'] = $warehouse['title'];
  7252. $zs[$key]['features'] = $g;
  7253. $zs[$key]['a'] = $x;
  7254. $zs[$key]['b'] = $s;
  7255. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7256. $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天销量
  7257. $yj = $c / ($xl / 30);
  7258. if ($yj < 7) {
  7259. $zs[$key]['y'] = round($yj) . '天销量';
  7260. $rows[$key] = $zs[$key];
  7261. }
  7262. }
  7263. }
  7264. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7265. $pagenum = ceil($total / $perpage);
  7266. $over = $total - ($start + $perpage);
  7267. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7268. echo json_encode($rows);
  7269. exit;
  7270. }
  7271. $this->data['arg_array'] = $arg_array[0];
  7272. $this->_Template('whlabel_fcjxc', $this->data);
  7273. }
  7274. public function _0kcdel()
  7275. {
  7276. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7277. $config['upload_path'] = '.' . $dir;
  7278. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7279. $config['allowed_types'] = 'xls|xlsx|csv';
  7280. $config['max_size'] = 10240;
  7281. $this->load->library('upload', $config);
  7282. $this->upload->initialize($config);
  7283. if ($this->upload->do_upload('userfile')) {
  7284. $full_path = $dir . $this->upload->data('file_name');
  7285. $fileName = '.' . $full_path;
  7286. if (!file_exists($fileName)) {
  7287. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7288. exit;
  7289. } else {
  7290. require_once "./data/excel/PHPExcel/IOFactory.php";
  7291. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7292. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7293. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7294. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7295. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7296. ++$column; //如果列数大于26行
  7297. $list = array();
  7298. for ($i = 2; $i <= $row; $i++) // 行数循环
  7299. {
  7300. $data = array();
  7301. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7302. {
  7303. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7304. }
  7305. $list[] = $data;
  7306. }
  7307. }
  7308. $i = 0;
  7309. $j = 0;
  7310. $ed = array();
  7311. foreach ($list as $key => $value) {
  7312. $time = time();
  7313. if ($value['0'] == "" || $value['1'] == "") {
  7314. continue;
  7315. }
  7316. $warehouse = $this->warehouse->get_title($value['0']);
  7317. $sku = $value['1'];
  7318. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7319. if (!$d) //如果没有这个SKU
  7320. {
  7321. $ed[] = array($sku . '-库存中不存在此SKU');
  7322. $j++;
  7323. continue;
  7324. }
  7325. if (!isset($warehouse['id'])) {
  7326. $ed[] = array($sku . '-仓库名错误!');
  7327. $j++;
  7328. continue;
  7329. }
  7330. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7331. if ($z < 1) {
  7332. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7333. foreach ($z as $v) {
  7334. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7335. if (count($zt) > 0) {
  7336. $ed[] = array($sku . '-有在途库存无法删除!');
  7337. $j++;
  7338. continue;
  7339. }
  7340. $this->whlabel->remove($v['id']);
  7341. }
  7342. } else {
  7343. $ed[] = array($sku . '-非0库存!');
  7344. $j++;
  7345. continue;
  7346. }
  7347. }
  7348. if ($j > 0) {
  7349. $tt = date('Ymd', time());
  7350. $title = '删除0库存错误信息-' . $tt;
  7351. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7352. $tail = "\n";
  7353. $filename = $title . ".xls";
  7354. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7355. $dir = '/data/excel/' . $time . '/';
  7356. $file_name = 'error_' . $time . rand(1000, 9999);
  7357. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7358. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7359. fwrite($myfile, $ecl);
  7360. fclose($myfile);
  7361. $error = $dir . $file_name . '.xls';
  7362. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7363. exit;
  7364. } else {
  7365. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7366. exit;
  7367. }
  7368. }
  7369. }
  7370. public function _gbhtype()
  7371. {
  7372. $post = $this->input->post(NULL, TRUE);
  7373. if (isset($post['s'])) {
  7374. $n = $this->input->post('n');
  7375. $d = $this->input->post('s');
  7376. if (!$d) {
  7377. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7378. exit;
  7379. }
  7380. $d = explode(',', trim($d, ','));
  7381. $t = $this->whlabel_type->read($n);
  7382. //循环删除记录
  7383. foreach ($d as $v) {
  7384. $u = $this->whlabel->read($v);
  7385. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7386. foreach ($data as $val) {
  7387. $this->whlabel->save(array('type' => $n), $val['id']);
  7388. }
  7389. }
  7390. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7391. }
  7392. }
  7393. //出库、退库导出
  7394. public function _dccrtype()
  7395. {
  7396. $classid = $this->classid->sku();
  7397. $pm = $classid;
  7398. $typeclass = array();
  7399. $tc = $this->typeclass->find_all();
  7400. foreach ($tc as $v) {
  7401. $typeclass[$v['id']] = $v;
  7402. }
  7403. $prc = array();
  7404. $purchase = $this->purchase->find_all();
  7405. foreach ($purchase as $k => $v) {
  7406. $prc[$v['id']] = $v['title'];
  7407. }
  7408. if (isset($_GET['sid'])) {
  7409. $wh = array();
  7410. $w = $this->warehouse->find_all('1=1', 'id,title');
  7411. foreach ($w as $v) {
  7412. $wh[$v['id']] = $v['title'];
  7413. }
  7414. $type = $this->input->get('excel', true);
  7415. $category = $this->input->get('category', true);
  7416. $size = $this->input->get('size', true);
  7417. $grade = $this->input->get('grade', true);
  7418. $color = $this->input->get('color', true);
  7419. $lowe = $this->input->get('lowe', true);
  7420. $sku = $this->input->get('sku', true);
  7421. $warehouse = $this->input->get('warehouse', true);
  7422. $lacetype = $this->input->get('lacetype', true);
  7423. $lacecolor = $this->input->get('lacecolor', true);
  7424. $density = $this->input->get('density', true);
  7425. $haircap = $this->input->get('haircap', true);
  7426. $purchase = $this->input->get('purchase', true);
  7427. $title = $this->input->get('title', true);
  7428. $state = $this->input->get('state', true);
  7429. $sid = $this->input->get('sid', true);
  7430. $ktime = $this->input->get('ktime', true);
  7431. $jtime = $this->input->get('jtime', true);
  7432. $ktime = strtotime($ktime);
  7433. $jtime = strtotime($jtime);
  7434. $where = "1=1";
  7435. $gj = "";
  7436. $ck = "";
  7437. if ($category) {
  7438. $where .= " and features like '%-$category-%'";
  7439. }
  7440. if ($size) {
  7441. $where .= " and features like '%-$size-%'";
  7442. }
  7443. if ($grade) {
  7444. $where .= " and features like '%-$grade-%'";
  7445. }
  7446. if ($color) {
  7447. $where .= " and features like '%-$color-%'";
  7448. }
  7449. if ($lowe) {
  7450. $where .= " and features like '%-$lowe-%'";
  7451. }
  7452. if ($warehouse) {
  7453. $where .= " and warehouse = '$warehouse'";
  7454. }
  7455. if ($purchase) {
  7456. $where .= " and purchase = '$purchase'";
  7457. }
  7458. if ($state) {
  7459. $where .= " and state = '$state'";
  7460. }
  7461. if ($lacetype) {
  7462. $where .= " and features like '%-$lacetype-%'";
  7463. }
  7464. if ($lacecolor) {
  7465. $where .= " and features like '%-$lacecolor-%'";
  7466. }
  7467. if ($density) {
  7468. $where .= " and features like '%-$density-%'";
  7469. }
  7470. if ($haircap) {
  7471. $where .= " and features like '%-$haircap-%'";
  7472. }
  7473. if ($title) {
  7474. $title = trim($title, ' ');
  7475. $title = trim($title, ' ');
  7476. $where .= " and title like '%$title%'";
  7477. }
  7478. if ($sku) {
  7479. $sku = trim($sku, ' ');
  7480. $sku = trim($sku, ' ');
  7481. $where .= " and sku like '%$sku%'";
  7482. }
  7483. if ($ktime && $jtime) {
  7484. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7485. }
  7486. $sidwhere = '';
  7487. if ($sid) {
  7488. $sd = "";
  7489. $s = explode(',', trim($sid, ','));
  7490. foreach ($s as $value) {
  7491. $sd .= " id = " . $value . " or";
  7492. }
  7493. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7494. }
  7495. //数据排序
  7496. $order_str = "time desc";
  7497. if (empty($page)) {
  7498. $start = 0;
  7499. $perpage = 1;
  7500. } else {
  7501. $start = ($page - 1) * $perpage;
  7502. }
  7503. $wh = array();
  7504. $w = $this->warehouse->find_all('1=1', 'id,title');
  7505. foreach ($w as $v) {
  7506. $wh[$v['id']] = $v['title'];
  7507. }
  7508. $wt = array();
  7509. $whlabel_type = $this->whlabel_type->find_all();
  7510. foreach ($whlabel_type as $v) {
  7511. $wt[$v['id']] = $v['title'];
  7512. }
  7513. $classid = $this->classid->sku();
  7514. $list = array();
  7515. $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');
  7516. foreach ($rows_r as $key => $value) {
  7517. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7518. $pm = $classid;
  7519. $jm = $classid;
  7520. $rows_r[$key]['enter'] = '入库';
  7521. $rows_r[$key]['time'] = $value['enter'];
  7522. if ($value['rktype'] == 1) {
  7523. $rows_r[$key]['rktype'] = '采购入库';
  7524. } else if ($value['rktype'] == 2) {
  7525. $rows_r[$key]['rktype'] = '盘盈调整';
  7526. } else if ($value['rktype'] == 3) {
  7527. $rows_r[$key]['rktype'] = '其他调整入库';
  7528. } else if ($value['rktype'] == 4) {
  7529. $rows_r[$key]['rktype'] = '其他调整入库';
  7530. } else if ($value['rktype'] == 5) {
  7531. $rows_r[$key]['rktype'] = '退库入库';
  7532. } else if ($value['rktype'] == 6) {
  7533. $rows_r[$key]['rktype'] = '退货可用入库';
  7534. } else if ($value['rktype'] == 7) {
  7535. $rows_r[$key]['rktype'] = '形态转换入库';
  7536. } else {
  7537. $rows_r[$key]['rktype'] = '';
  7538. }
  7539. $features = explode('-', trim($value['features'], '-'));
  7540. foreach ($features as $v) {
  7541. if (isset($typeclass[$v])) {
  7542. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7543. $pm[$typeclass[$v]['classid']] = $zh[0];
  7544. }
  7545. if (isset($typeclass[$v])) {
  7546. if (isset($jm[$typeclass[$v]['classid']])) {
  7547. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7548. }
  7549. }
  7550. }
  7551. $zh = implode(" ", $pm);
  7552. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7553. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7554. $rows_r[$key]['zh'] = $zh;
  7555. $jm = array_filter($jm);
  7556. $rows_r[$key]['features'] = implode("-", $jm);
  7557. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7558. }
  7559. $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');
  7560. foreach ($rows_c as $key => $value) {
  7561. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7562. $pm = $classid;
  7563. $jm = $classid;
  7564. $rows_c[$key]['time'] = $value['outk'];
  7565. $rows_c[$key]['outk'] = '出库';
  7566. if ($value['cktype'] == 1) {
  7567. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7568. } else if ($value['cktype'] == 2) {
  7569. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7570. } else if ($value['cktype'] == 3) {
  7571. $rows_c[$key]['cktype'] = '盘亏调整';
  7572. } else if ($value['cktype'] == 4) {
  7573. $rows_c[$key]['cktype'] = '其他调整出库';
  7574. } else if ($value['cktype'] == 5) {
  7575. $rows_c[$key]['cktype'] = '形态转换出库';
  7576. } else {
  7577. $rows_c[$key]['cktype'] = '';
  7578. }
  7579. unset($rows_c[$key]['state']);
  7580. $features = explode('-', trim($value['features'], '-'));
  7581. foreach ($features as $v) {
  7582. if (isset($typeclass[$v])) {
  7583. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7584. $pm[$typeclass[$v]['classid']] = $zh[0];
  7585. }
  7586. if (isset($typeclass[$v])) {
  7587. if (isset($jm[$typeclass[$v]['classid']])) {
  7588. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7589. }
  7590. }
  7591. }
  7592. $zh = implode(" ", $pm);
  7593. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7594. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7595. $rows_c[$key]['zh'] = $zh;
  7596. $jm = array_filter($jm);
  7597. $rows_c[$key]['features'] = implode("-", $jm);
  7598. $rows_c[$key]['number'] = 1;
  7599. }
  7600. $merged = $rows_r;
  7601. foreach ($rows_c as $key => $value) {
  7602. if (isset($merged[$key])) {
  7603. $merged[] = $value;
  7604. } else {
  7605. $merged[$key] = $value;
  7606. }
  7607. }
  7608. usort($merged, function ($a, $b) {
  7609. return $a['time'] - $b['time'];
  7610. });
  7611. foreach ($merged as $key => $value) {
  7612. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7613. }
  7614. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7615. $titlename = "<table border=1>
  7616. <tr align='center'>
  7617. <td>仓库</td>
  7618. <td>SKU</td>
  7619. <td>商品名称</td>
  7620. <td>仓库品名</td>
  7621. <td>料号</td>
  7622. <td>时间</td>
  7623. <td>操作</td>
  7624. <td>类型</td>
  7625. <td>数量</td>
  7626. <td>备注</td>
  7627. </tr>
  7628. </table>";
  7629. $filename = $title . ".xlsx";
  7630. $tail = "";
  7631. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7632. }
  7633. }
  7634. /*************************************处理exceljs导出****************************************************/
  7635. public function _excelrjs(){
  7636. if (isset($_GET['excel'])) {
  7637. $category = $this->input->get('category', true);
  7638. $size = $this->input->get('size', true);
  7639. $grade = $this->input->get('grade', true);
  7640. $color = $this->input->get('color', true);
  7641. $lowe = $this->input->get('lowe', true);
  7642. $sku = $this->input->get('sku', true);
  7643. $warehouse = $this->input->get('warehouse', true);
  7644. $purchase = $this->input->get('purchase', true);
  7645. $ktime = $this->input->get('ktime', true);
  7646. $jtime = $this->input->get('jtime', true);
  7647. $ktime = strtotime($ktime);
  7648. $jtime = strtotime($jtime);
  7649. $where = "1=1";
  7650. $gj = "";
  7651. $ck = "";
  7652. if ($category) {
  7653. $where .= " and features like '%-$category-%'";
  7654. }
  7655. if ($size) {
  7656. $where .= " and features like '%-$size-%'";
  7657. }
  7658. if ($grade) {
  7659. $where .= " and features like '%-$grade-%'";
  7660. }
  7661. if ($color) {
  7662. $where .= " and features like '%-$color-%'";
  7663. }
  7664. if ($lowe) {
  7665. $where .= " and features like '%-$lowe-%'";
  7666. }
  7667. if ($warehouse) {
  7668. $where .= " and warehouse = '$warehouse'";
  7669. }
  7670. if ($purchase) {
  7671. $where .= " and purchase = '$purchase'";
  7672. }
  7673. if ($sku) {
  7674. $where .= " and sku = '$sku'";
  7675. }
  7676. if ($ktime && $jtime) {
  7677. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7678. }
  7679. //数据排序
  7680. $order_str = "id desc";
  7681. if (empty($page)) {
  7682. $start = 0;
  7683. $perpage = 1;
  7684. } else {
  7685. $start = ($page - 1) * $perpage;
  7686. }
  7687. $list = array();
  7688. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7689. foreach ($rows as $value) {
  7690. $ck = $this->warehouse->read($value['warehouse']);
  7691. $warehouse = $ck['title'];
  7692. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7693. $retreatwarehouse = $tkck['title'];
  7694. $gy = $this->purchase->read($value['purchase']);
  7695. $purchase = $gy['title'];
  7696. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7697. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7698. }
  7699. if(empty($list)){
  7700. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7701. }else{
  7702. $final_list = [];
  7703. foreach($list as $v){
  7704. $final_list[] = array_values($v);
  7705. }
  7706. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7707. array_unshift($final_list,[
  7708. "仓库","SKU","商品名称","时间","数量"
  7709. ]);
  7710. array_unshift($final_list,[
  7711. $title,"","","",""
  7712. ]);
  7713. $merges = [
  7714. [
  7715. "s"=>["r"=>0,"c"=>0],
  7716. "e"=>["r"=>0,"c"=>4]
  7717. ]
  7718. ];
  7719. $cols = [
  7720. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7721. ];
  7722. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7723. }
  7724. }
  7725. }
  7726. //出库、退库导出
  7727. public function _excelctjs()
  7728. {
  7729. $classid = $this->classid->sku();
  7730. $pm = $classid;
  7731. $typeclass = array();
  7732. $tc = $this->typeclass->find_all();
  7733. foreach ($tc as $v) {
  7734. $typeclass[$v['id']] = $v;
  7735. }
  7736. $prc = array();
  7737. $purchase = $this->purchase->find_all();
  7738. foreach ($purchase as $k => $v) {
  7739. $prc[$v['id']] = $v['title'];
  7740. }
  7741. if (isset($_GET['excel'])) {
  7742. $wh = array();
  7743. $w = $this->warehouse->find_all('1=1', 'id,title');
  7744. foreach ($w as $v) {
  7745. $wh[$v['id']] = $v['title'];
  7746. }
  7747. $type = $this->input->get('excel', true);
  7748. $category = $this->input->get('category', true);
  7749. $size = $this->input->get('size', true);
  7750. $grade = $this->input->get('grade', true);
  7751. $color = $this->input->get('color', true);
  7752. $lowe = $this->input->get('lowe', true);
  7753. $sku = $this->input->get('sku', true);
  7754. $title = $this->input->get('title', true);
  7755. $warehouse = $this->input->get('warehouse', true);
  7756. $purchase = $this->input->get('purchase', true);
  7757. $lacetype = $this->input->get('lacetype', true);
  7758. $haircap = $this->input->get('haircap', true);
  7759. $lacecolor = $this->input->get('lacecolor', true);
  7760. $density = $this->input->get('density', true);
  7761. $details = $this->input->get('details', true);
  7762. $state = $this->input->get('state', true);
  7763. $shop = $this->input->get('shop', true);
  7764. $hairnumber = $this->input->get('hairnumber', true);
  7765. $type_leixi = $this->input->get('type', true);
  7766. $cpbz = $this->input->get('cpbz', true);
  7767. $sm = $this->input->get('sm', true);
  7768. $sid = $this->input->get('sid', true);
  7769. $ktime = $this->input->get('ktime', true);
  7770. $jtime = $this->input->get('jtime', true);
  7771. $ktime = strtotime($ktime);
  7772. $jtime = strtotime($jtime);
  7773. //$where = " 1=1 ";
  7774. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7775. $where = " sku != '' ";
  7776. $gj = "";
  7777. $ck = "";
  7778. if ($category) {
  7779. $where .= " and features like '%-$category-%'";
  7780. }
  7781. if ($size) {
  7782. $where .= " and features like '%-$size-%'";
  7783. }
  7784. if ($grade) {
  7785. $where .= " and features like '%-$grade-%'";
  7786. }
  7787. if ($color) {
  7788. $where .= " and features like '%-$color-%'";
  7789. }
  7790. if ($lowe) {
  7791. $where .= " and features like '%-$lowe-%'";
  7792. }
  7793. if ($warehouse) {
  7794. $where .= " and warehouse = '$warehouse'";
  7795. }
  7796. if ($purchase) {
  7797. $where .= " and purchase = '$purchase'";
  7798. }
  7799. if ($state) {
  7800. $where .= " and state = '$state'";
  7801. }
  7802. if ($lacetype) {
  7803. $where .= " and features like '%-$lacetype-%'";
  7804. }
  7805. if ($lacecolor) {
  7806. $where .= " and features like '%-$lacecolor-%'";
  7807. }
  7808. if ($density) {
  7809. $where .= " and features like '%-$density-%'";
  7810. }
  7811. if ($haircap) {
  7812. $where .= " and features like '%-$haircap-%'";
  7813. }
  7814. if ($details) {
  7815. $where .= " and details = '$details'";
  7816. }
  7817. if ($shop) {
  7818. $where .= " and shop like '%$shop%'";
  7819. }
  7820. if ($title) {
  7821. $title = trim($title, ' ');
  7822. $title = trim($title, ' ');
  7823. $where .= " and title like '%$title%'";
  7824. }
  7825. if (!empty($hairnumber)) {
  7826. $where .= " and features like '%-128-%' ";
  7827. if ($hairnumber < 0) {
  7828. $class_list = $this->typeclass->find_all('classid = 43');
  7829. foreach ($class_list as $v) {
  7830. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7831. }
  7832. } else {
  7833. $where .= " and features like '%-$hairnumber-%'";
  7834. }
  7835. }
  7836. if ($type_leixi) {
  7837. $where .= " and type = '$type_leixi'";
  7838. }
  7839. if ($cpbz) {
  7840. $where .= " and cpbz like '%$cpbz%' ";
  7841. }
  7842. if ($sm) {
  7843. $where .= " and sm like '%$sm%' ";
  7844. }
  7845. if ($sku) {
  7846. $sku = trim($sku, ' ');
  7847. $sku = trim($sku, ' ');
  7848. $where .= " and sku like '%$sku%'";
  7849. }
  7850. if ($ktime && $jtime) {
  7851. if ($type == 1) {
  7852. $tl = '出库';
  7853. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7854. } else if ($type == 2) {
  7855. $tl = '退库';
  7856. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7857. } else if ($type == 3) {
  7858. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7859. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7860. } else if ($type == 4) {
  7861. $tl = '出库+零售';
  7862. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7863. } else if ($type == 5) {
  7864. $tl = '零售';
  7865. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7866. }
  7867. }
  7868. $sidwhere = '';
  7869. if ($sid) {
  7870. $sd = "";
  7871. $s = explode(',', trim($sid, ','));
  7872. foreach ($s as $value) {
  7873. $sd .= " id = " . $value . " or";
  7874. }
  7875. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7876. }
  7877. //数据排序
  7878. $order_str = "time desc";
  7879. if (empty($page)) {
  7880. $start = 0;
  7881. $perpage = 1;
  7882. } else {
  7883. $start = ($page - 1) * $perpage;
  7884. }
  7885. //取得信息列表
  7886. if ($type != 3 && $type != 5) {
  7887. if ($type == 1 || $type == 4) {
  7888. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7889. foreach ($info_list as $key => $value) {
  7890. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7891. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7892. $warehouse = $this->warehouse->read($value['warehouse']);
  7893. $info_list[$key]['warehouse'] = $warehouse['title'];
  7894. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7895. $features = explode('-', trim($features, '-'));
  7896. $pm = $classid;
  7897. foreach ($features as $k => $v) {
  7898. if ($v != 0) {
  7899. if (!isset($typeclass[$v])) {
  7900. continue;
  7901. }
  7902. if (isset($pm[$typeclass[$v]['classid']])) {
  7903. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7904. $tz = explode('|', $typeclass[$v]['zh']);
  7905. $pm[$typeclass[$v]['classid']] = $tz[0];
  7906. } else {
  7907. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7908. }
  7909. }
  7910. }
  7911. }
  7912. $zh = implode(" ", $pm);
  7913. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7914. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7915. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7916. $info_list[$key]['features'] = $zh;
  7917. }
  7918. $final_list = [];
  7919. foreach($info_list as $k=>$v){
  7920. $number = "";
  7921. if(!empty($v['orderinfo'])){
  7922. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7923. if(!empty($tmp_info['number'])){
  7924. $number = $tmp_info['number'];
  7925. }
  7926. }
  7927. $final_list[] = [
  7928. 'warehouse'=>$v['warehouse'],
  7929. 'purchase'=>$v['purchase'],
  7930. 'sku'=>$v['sku'],
  7931. 'title'=>$v['title'],
  7932. 'features'=>$v['features'],
  7933. 'label'=>$v['label'],
  7934. 'orderinfo'=>$v['orderinfo'],
  7935. 'number'=>$number,
  7936. 'waybill'=>$v['waybill'],
  7937. 'outk'=>$v['outk'],
  7938. ];
  7939. }
  7940. } else {
  7941. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7942. foreach ($info_list as $key => $value) {
  7943. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7944. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7945. $warehouse = $this->warehouse->read($value['warehouse']);
  7946. $info_list[$key]['warehouse'] = $warehouse['title'];
  7947. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7948. $features = explode('-', trim($features, '-'));
  7949. $pm = $classid;
  7950. foreach ($features as $k => $v) {
  7951. if ($v != 0) {
  7952. if (!isset($typeclass[$v])) {
  7953. continue;
  7954. }
  7955. if (isset($pm[$typeclass[$v]['classid']])) {
  7956. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7957. $tz = explode('|', $typeclass[$v]['zh']);
  7958. $pm[$typeclass[$v]['classid']] = $tz[0];
  7959. } else {
  7960. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7961. }
  7962. }
  7963. }
  7964. }
  7965. $zh = implode(" ", $pm);
  7966. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7967. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7968. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7969. $info_list[$key]['features'] = $zh;
  7970. }
  7971. $final_list = [];
  7972. foreach($info_list as $k=>$v){
  7973. $number = "";
  7974. if(!empty($v['orderinfo'])){
  7975. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7976. if(!empty($tmp_info['number'])){
  7977. $number = $tmp_info['number'];
  7978. }
  7979. }
  7980. $final_list[] = [
  7981. 'warehouse'=>$v['warehouse'],
  7982. 'purchase'=>$v['purchase'],
  7983. 'sku'=>$v['sku'],
  7984. 'title'=>$v['title'],
  7985. 'features'=>$v['features'],
  7986. 'label'=>$v['label'],
  7987. 'orderinfo'=>$v['orderinfo'],
  7988. 'number'=>$number,
  7989. 'waybill'=>$v['waybill'],
  7990. 'retreat'=>$v['retreat'],
  7991. ];
  7992. }
  7993. }
  7994. if(empty($final_list)){
  7995. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7996. }else{
  7997. $end_list = [];
  7998. foreach($final_list as $v){
  7999. $end_list[] = array_values($v);
  8000. }
  8001. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8002. array_unshift($end_list,[
  8003. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8004. ]);
  8005. array_unshift($end_list,[
  8006. $title,"","","","","","","","",""
  8007. ]);
  8008. $merges = [
  8009. [
  8010. "s"=>["r"=>0,"c"=>0],
  8011. "e"=>["r"=>0,"c"=>9]
  8012. ]
  8013. ];
  8014. $cols = [
  8015. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8016. ];
  8017. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8018. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8019. ] )));
  8020. }
  8021. } else if ($type == 5) {
  8022. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8023. foreach ($info_list as $key => $value) {
  8024. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8025. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8026. $warehouse = $this->warehouse->read($value['warehouse']);
  8027. $info_list[$key]['warehouse'] = $warehouse['title'];
  8028. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8029. $features = explode('-', trim($features, '-'));
  8030. $pm = $classid;
  8031. foreach ($features as $k => $v) {
  8032. if ($v != 0) {
  8033. if (!isset($typeclass[$v])) {
  8034. continue;
  8035. }
  8036. if (isset($pm[$typeclass[$v]['classid']])) {
  8037. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8038. $tz = explode('|', $typeclass[$v]['zh']);
  8039. $pm[$typeclass[$v]['classid']] = $tz[0];
  8040. } else {
  8041. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8042. }
  8043. }
  8044. }
  8045. }
  8046. $zh = implode(" ", $pm);
  8047. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8048. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8049. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8050. $info_list[$key]['features'] = $zh;
  8051. }
  8052. if(empty($info_list)){
  8053. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8054. }else{
  8055. $final_list = [];
  8056. foreach($info_list as $v){
  8057. $final_list[] = array_values($v);
  8058. }
  8059. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8060. array_unshift($final_list,[
  8061. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8062. ]);
  8063. array_unshift($final_list,[
  8064. $title,"","","","","","",
  8065. ]);
  8066. $merges = [
  8067. [
  8068. "s"=>["r"=>0,"c"=>0],
  8069. "e"=>["r"=>0,"c"=>6]
  8070. ]
  8071. ];
  8072. $cols = [
  8073. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8074. ];
  8075. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8076. }
  8077. } else {
  8078. $wh = array();
  8079. $w = $this->warehouse->find_all('1=1', 'id,title');
  8080. foreach ($w as $v) {
  8081. $wh[$v['id']] = $v['title'];
  8082. }
  8083. $wt = array();
  8084. $whlabel_type = $this->whlabel_type->find_all();
  8085. foreach ($whlabel_type as $v) {
  8086. $wt[$v['id']] = $v['title'];
  8087. }
  8088. $classid = $this->classid->sku();
  8089. $list = array();
  8090. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8091. foreach ($rows as $key => $value) {
  8092. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8093. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8094. $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');
  8095. $details = array();
  8096. $cpid = array();
  8097. $cpbz = array();
  8098. $c = 0;
  8099. $g = 0;
  8100. $x = 0;
  8101. $t = 0;
  8102. $s = 0;
  8103. $q = 0;
  8104. foreach ($sd as $k => $v) {
  8105. if ($v['state'] == 0) {
  8106. $c++;
  8107. }
  8108. if ($v['state'] != 9) {
  8109. $g++;
  8110. }
  8111. if ($v['outk'] > 1) {
  8112. $x++;
  8113. }
  8114. if ($v['retreat'] > 0) {
  8115. $t++;
  8116. }
  8117. if ($v['state'] == 8) {
  8118. $s++;
  8119. }
  8120. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8121. $q++;
  8122. }
  8123. $details[$v['details']] = $v['details'];
  8124. if ($v['cpid'] != 0) {
  8125. $cpid[$v['cpid']] = $v['cpid'];
  8126. }
  8127. if ($v['cpbz'] != '') {
  8128. $cpbz[$v['cpbz']] = $v['cpbz'];
  8129. }
  8130. }
  8131. if (isset($wt[$value['type']])) {
  8132. $rows[$key]['type'] = $wt[$value['type']];
  8133. } else {
  8134. $rows[$key]['type'] = '未设置';
  8135. }
  8136. $rows[$key]['details'] = implode("、", $details);
  8137. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8138. $ftime = time() - 15 * 24 * 3600;
  8139. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8140. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8141. $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);
  8142. $rows[$key]['c'] = $c;
  8143. $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);
  8144. $rows[$key]['t'] = $t;
  8145. $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'] . '"');
  8146. $rows[$key]['z'] = $z;
  8147. // $jm = $classid;
  8148. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8149. $features = explode('-', trim($features, '-'));
  8150. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8151. }
  8152. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8153. $final_list =[];
  8154. foreach($tmp_list as $k=>$v){
  8155. $final_list[] = [
  8156. "warehouse"=>$v['warehouse'],
  8157. "purchase"=>$v['purchase'],
  8158. "details"=>$v['details'],
  8159. "cpid"=>$v['cpid'],
  8160. "sku"=>$v['sku'],
  8161. "title"=>$v['title'],
  8162. "features"=>$v['pm'],
  8163. "cpbz"=>$v['cpbz'],
  8164. "sm"=>$v['sm'],
  8165. "type"=>$v['type'],
  8166. "g"=>$v["g"],
  8167. "c"=>$v["c"],
  8168. "x"=>$v["x"],
  8169. "t"=>$v["t"],
  8170. "z"=>$v["z"],
  8171. "jm"=>$v["jm"],
  8172. "weight"=>$v["weight"],
  8173. "asd"=>$v["asd"],
  8174. ];
  8175. }
  8176. if(empty($final_list)){
  8177. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8178. }else{
  8179. $end_list = [];
  8180. foreach($final_list as $v){
  8181. $end_list[] = array_values($v);
  8182. }
  8183. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8184. array_unshift($end_list,[
  8185. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8186. ]);
  8187. array_unshift($end_list,[
  8188. $title,"","","","","","","","","","","","","","","","","",""
  8189. ]);
  8190. $merges = [
  8191. [
  8192. "s"=>["r"=>0,"c"=>0],
  8193. "e"=>["r"=>0,"c"=>6]
  8194. ]
  8195. ];
  8196. $cols = [
  8197. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8198. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8199. ];
  8200. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8201. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8202. ])));
  8203. }
  8204. }
  8205. }
  8206. }
  8207. public function _exceljxcjs(){
  8208. $classid = $this->classid->sku();
  8209. $pm = $classid;
  8210. $typeclass = array();
  8211. $tc = $this->typeclass->find_all();
  8212. foreach ($tc as $v) {
  8213. $typeclass[$v['id']] = $v;
  8214. }
  8215. $prc = array();
  8216. $purchase = $this->purchase->find_all();
  8217. foreach ($purchase as $k => $v) {
  8218. $prc[$v['id']] = $v['title'];
  8219. }
  8220. if(!isset($_GET['excel'])){
  8221. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8222. }
  8223. $where = "sku != 'Preset'";
  8224. //数据排序
  8225. $order_str = "id desc";
  8226. if (empty($page)) {
  8227. $start = 0;
  8228. $perpage = 1;
  8229. } else {
  8230. $start = ($page - 1) * $perpage;
  8231. }
  8232. $category = $this->input->get('category', true);
  8233. $warehouse = $this->input->get('warehouse', true);
  8234. $excelid = $this->input->get('sid', true);
  8235. if ($category) {
  8236. $where .= " and features like '%-$category-%'";
  8237. }
  8238. if ($warehouse) {
  8239. $where .= " and warehouse = '$warehouse'";
  8240. }
  8241. $xzid = '';
  8242. if ($excelid) {
  8243. $excelid = explode(',', trim($excelid, ','));
  8244. foreach ($excelid as $key => $value) {
  8245. $xzid .= " id = " . $value . " or";
  8246. }
  8247. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8248. }
  8249. $wt = array();
  8250. $whlabel_type = $this->whlabel_type->find_all();
  8251. foreach ($whlabel_type as $v) {
  8252. $wt[$v['id']] = $v['title'];
  8253. }
  8254. $wh = array();
  8255. $w = $this->warehouse->find_all('1=1', 'id,title');
  8256. foreach ($w as $v) {
  8257. $wh[$v['id']] = $v['title'];
  8258. }
  8259. $list = array();
  8260. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8261. foreach ($rows as $key => $value) {
  8262. if (isset($wt[$value['type']])) {
  8263. $rows[$key]['type'] = $wt[$value['type']];
  8264. } else {
  8265. $rows[$key]['type'] = '未设置';
  8266. }
  8267. $bm = '03';
  8268. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8269. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8270. $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');
  8271. $details = array();
  8272. $cpid = array();
  8273. $cpbz = array();
  8274. $c = 0;
  8275. $g = 0;
  8276. $x = 0;
  8277. $t = 0;
  8278. $s = 0;
  8279. $q = 0;
  8280. foreach ($sd as $k => $v) {
  8281. if ($v['state'] == 0) {
  8282. $c++;
  8283. if ($v['cpid'] != 0) {
  8284. $cpid[$v['cpid']] = $v['cpid'];
  8285. }
  8286. if ($v['cpbz'] != '') {
  8287. $cpbz[$v['cpbz']] = $v['cpbz'];
  8288. }
  8289. }
  8290. if ($v['state'] != 9) {
  8291. $g++;
  8292. }
  8293. if ($v['state'] == 1) {
  8294. $x++;
  8295. }
  8296. if ($v['state'] == 2) {
  8297. $t++;
  8298. }
  8299. if ($v['state'] == 8) {
  8300. $s++;
  8301. }
  8302. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8303. $q++;
  8304. }
  8305. $details[$v['details']] = $v['details'];
  8306. }
  8307. $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'] . '"');
  8308. $rows[$key]['details'] = implode("、", $details);
  8309. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8310. $number = $value['number'];
  8311. $ftime = time() - 15 * 24 * 3600;
  8312. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8313. $rows[$key]['number'] = $g;
  8314. $rows[$key]['c'] = $c;
  8315. $rows[$key]['x'] = $x;
  8316. $rows[$key]['t'] = $t;
  8317. $rows[$key]['s'] = $s;
  8318. $rows[$key]['q'] = $q;
  8319. $rows[$key]['z'] = $z;
  8320. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8321. $features = explode('-', trim($features, '-'));
  8322. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8323. }
  8324. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8325. $final_list = [];
  8326. foreach ($list as $k => $v) {
  8327. if (empty($v['sku'])) {
  8328. continue;
  8329. }
  8330. $final_list[] = [
  8331. $v["warehouse"],
  8332. $v["purchase"],
  8333. $v["details"],
  8334. $v["cpid"],
  8335. $v["dbcontent"],
  8336. $v["sku"],
  8337. $v["bm"],
  8338. $v["jm"],
  8339. $v["title"],
  8340. $v["pm"],
  8341. $v["cpbz"],
  8342. $v["sm"],
  8343. $v["type"],
  8344. $v["number"],
  8345. $v["c"],
  8346. $v["x"],
  8347. $v["t"],
  8348. $v["s"],
  8349. $v["q"],
  8350. $v["z"],
  8351. $v['weight'],
  8352. ];
  8353. }
  8354. if(empty($final_list)){
  8355. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8356. }
  8357. $title = "总进销存统计表";
  8358. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8359. $merges = [
  8360. [
  8361. "s"=>["r"=>0,"c"=>0],
  8362. "e"=>["r"=>0,"c"=>21]
  8363. ]
  8364. ];
  8365. $cols = [
  8366. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8367. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8368. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8369. ];
  8370. array_unshift($final_list, $first_row);
  8371. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8372. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8373. }
  8374. public function _summaryjs($arg_array)
  8375. {
  8376. $prc = array();
  8377. $purchase = $this->purchase->find_all();
  8378. foreach ($purchase as $k => $v) {
  8379. $prc[$v['id']] = $v['title'];
  8380. }
  8381. if (isset($_GET['excel'])) {
  8382. $ktime = $this->input->get('ktime', true);
  8383. $jtime = $this->input->get('jtime', true);
  8384. $ktime = strtotime($ktime);
  8385. $jtime = strtotime($jtime);
  8386. $where = "1=1";
  8387. if ($ktime && $jtime) {
  8388. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8389. }
  8390. //数据排序
  8391. $order_str = "time desc";
  8392. if (empty($page)) {
  8393. $start = 0;
  8394. $perpage = 1;
  8395. } else {
  8396. $start = ($page - 1) * $perpage;
  8397. }
  8398. //取得信息列表
  8399. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8400. foreach ($info_list as $key => $value) {
  8401. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8402. $warehouse = $this->warehouse->read($value['warehouse']);
  8403. $info_list[$key]['warehouse'] = $warehouse['title'];
  8404. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8405. $details = array();
  8406. $cpid = array();
  8407. foreach ($x as $k => $v) {
  8408. if ($v['details'] != '') {
  8409. $details[$v['details']] = $v['details'];
  8410. }
  8411. if ($v['cpid'] != 0) {
  8412. $cpid[$v['cpid']] = $v['cpid'];
  8413. }
  8414. }
  8415. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8416. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8417. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8418. $info_list[$key]['s'] = $s;
  8419. $info_list[$key]['x'] = count($x);
  8420. }
  8421. if(empty($info_list)){
  8422. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8423. }
  8424. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8425. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8426. $merges = [
  8427. [
  8428. "s"=>["r"=>0,"c"=>0],
  8429. "e"=>["r"=>0,"c"=>7]
  8430. ]
  8431. ];
  8432. $cols = [
  8433. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8434. ];
  8435. $final_list = [];
  8436. foreach($info_list as $k => $v){
  8437. $final_list[] = array_values($v);
  8438. }
  8439. array_unshift($final_list, $first_row);
  8440. array_unshift($final_list,[
  8441. $title,"","","","","","","","",
  8442. ]);
  8443. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8444. $titlename = "<table border=1>
  8445. <tr align='center'>
  8446. <td>仓库</td>
  8447. <td>供应商</td>
  8448. <td>出库位置</td>
  8449. <td>出库编码</td>
  8450. <td>SKU</td>
  8451. <td>产品名</td>
  8452. <td>总剩余库存</td>
  8453. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8454. </tr>
  8455. </table>";
  8456. $filename = $title . ".xls";
  8457. $tail = "";
  8458. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8459. }
  8460. }
  8461. public function _uckjs()
  8462. {
  8463. if (isset($_GET['excel'])) {
  8464. $tc = array();
  8465. $typeclass = $this->typeclass->find_all();
  8466. foreach ($typeclass as $v) {
  8467. $tc[$v['id']] = $v['zh'];
  8468. }
  8469. $first_row = [
  8470. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8471. ];
  8472. $t = array();
  8473. $rq = '';
  8474. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8475. $ts = $ts / (24 * 3600);
  8476. for ($i = 0; $i < $ts; $i++) {
  8477. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8478. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8479. }
  8480. $day_len = count($t);
  8481. $first_row[] = "本月出库";
  8482. $merges = [
  8483. ];
  8484. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8485. $excel_key = 1;
  8486. $final_list = [];
  8487. foreach ($info_list as $k => $v) {
  8488. $features = explode('-', trim($v['features'], '-'));
  8489. if (!isset($features[3]) || !isset($features[4])) {
  8490. continue;
  8491. }
  8492. $tmp = [];
  8493. $tmp[0] = $tc[$features[0]]; //类型
  8494. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8495. $tmp[2] = $tc[$features[4]]; //曲度
  8496. $tmp[3] = '';
  8497. if (isset($data[$k][1])) {
  8498. $tmp[3] .=$tmp[1];
  8499. }
  8500. if (isset($data[$k][2])) {
  8501. $tmp[3] .= $tmp[2];
  8502. }
  8503. if (isset($features[5])) {
  8504. $tmp[3] .= $tc[$features[5]];
  8505. }
  8506. if (isset($features[2])) {
  8507. $tmp[3] .= $tc[$features[2]];
  8508. }
  8509. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8510. $tmp[4] = $v['sku'];
  8511. $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())) . '))'); //月初库存
  8512. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8513. $tmp[7] ="";
  8514. $tmp[8] ="";
  8515. $byck = 0;
  8516. foreach ($t as $vv) {
  8517. $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));
  8518. $tmp[] = ($sl > 0) ? $sl : '';
  8519. $byck += $sl;
  8520. }
  8521. $tmp[] = ($byck > 0) ? $byck : '';
  8522. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8523. // $ztrq = '';
  8524. // $ztsl = '';
  8525. // if (count($zt) > 0) {
  8526. // foreach ($zt as $vv) {
  8527. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8528. // $ztsl .= $vv['num'] . '<br>';
  8529. // }
  8530. // }
  8531. if(empty($zt)){
  8532. $final_list[] = $tmp;
  8533. $excel_key = $excel_key + 1;
  8534. }else{
  8535. $len = count($zt);
  8536. if($len == 1){
  8537. $tmp[7] = $zt[0]['num'] ;
  8538. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8539. $final_list[] = $tmp;
  8540. $excel_key = $excel_key + 1;
  8541. }else{
  8542. foreach($zt as $vv){
  8543. $tmp[7] = "";
  8544. $tmp[8] = "";
  8545. $tmp[7] = $vv['num'];
  8546. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8547. $final_list[] = $tmp;
  8548. }
  8549. $merges[] = [
  8550. "s"=>["r"=>$excel_key,"c"=>0],
  8551. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8552. ];
  8553. $merges[] = [
  8554. "s"=>["r"=>$excel_key,"c"=>1],
  8555. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8556. ];
  8557. $merges[] = [
  8558. "s"=>["r"=>$excel_key,"c"=>2],
  8559. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8560. ];
  8561. $merges[] = [
  8562. "s"=>["r"=>$excel_key,"c"=>3],
  8563. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8564. ];
  8565. $merges[] = [
  8566. "s"=>["r"=>$excel_key,"c"=>4],
  8567. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8568. ];
  8569. $merges[] = [
  8570. "s"=>["r"=>$excel_key,"c"=>5],
  8571. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8572. ];
  8573. $merges[] = [
  8574. "s"=>["r"=>$excel_key,"c"=>6],
  8575. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8576. ];
  8577. for($i=1;$i<=$day_len;$i++){
  8578. $merges[] = [
  8579. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8580. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8581. ];
  8582. }
  8583. $merges[] = [
  8584. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8585. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8586. ];
  8587. $excel_key = $excel_key + $len;
  8588. }
  8589. }
  8590. }
  8591. $title = "详情 " . date("Y-m-d", time());
  8592. if(empty($final_list)){
  8593. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8594. }
  8595. $cols = [
  8596. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8597. ];
  8598. array_unshift($final_list, $first_row);
  8599. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8600. }
  8601. }
  8602. public function _whlabelexcelzhjs(){
  8603. if(empty($_GET['excel'])){
  8604. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8605. }
  8606. $where = "sku != 'Preset' and sku != '' ";
  8607. //数据排序
  8608. $order_str = "id desc";
  8609. if (empty($page)) {
  8610. $start = 0;
  8611. $perpage = 1;
  8612. } else {
  8613. $start = ($page - 1) * $perpage;
  8614. }
  8615. $category = $this->input->get('category', true);
  8616. $warehouse = $this->input->get('warehouse', true);
  8617. $excelid = $this->input->get('sid', true);
  8618. if ($category) {
  8619. $where .= " and features like '%-$category-%'";
  8620. }
  8621. if ($warehouse) {
  8622. $where .= " and warehouse = '$warehouse'";
  8623. }
  8624. $xzid = '';
  8625. if ($excelid) {
  8626. $excelid = explode(',', trim($excelid, ','));
  8627. foreach ($excelid as $key => $value) {
  8628. $xzid .= " id = " . $value . " or";
  8629. }
  8630. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8631. }
  8632. $merges = [
  8633. [
  8634. "s"=>["r"=>0,"c"=>0],
  8635. "e"=>["r"=>0,"c"=>6]
  8636. ]
  8637. ];
  8638. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8639. $excel_index = 2;
  8640. $final_list = [];
  8641. foreach ($rows as $key => $value) {
  8642. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8643. $zh = '';
  8644. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8645. // foreach ($zt_list as $v) {
  8646. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8647. // }
  8648. $zt = array_sum(array_column($zt_list, 'num'));
  8649. $number = $value['number'];
  8650. $ftime = time() - 15 * 24 * 3600;
  8651. $warehouse = $this->warehouse->read($value['warehouse']);
  8652. // $rows[$key]['warehouse'] = $warehouse['title'];
  8653. // $rows[$key]['number'] = $c;
  8654. // $rows[$key]['features'] = $zh;
  8655. //$rows[$key]['hb'] = $c + $zt;
  8656. $tmp = [];
  8657. $tmp[0] = $warehouse['title'];
  8658. $tmp[1] = $value['sku'];
  8659. $tmp[2] = $value['title'];
  8660. $tmp[3] = $c;
  8661. $tmp[4] = "";
  8662. $tmp[5] = $c + $zt;
  8663. if(empty($zt_list)){
  8664. $tmp[4] = "";
  8665. $final_list[] = $tmp;
  8666. $excel_index = $excel_index + 1;
  8667. }else{
  8668. if(count($zt_list) == 1){
  8669. $tmp[4] = "";
  8670. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8671. $final_list[] = $tmp;
  8672. $excel_index = $excel_index + 1;
  8673. }else{
  8674. $len = count($zt_list);
  8675. foreach ($zt_list as $v){
  8676. $tmp[4] = "";
  8677. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8678. $final_list[] = $tmp;
  8679. }
  8680. $merges[] = [
  8681. "s"=>["r"=>$excel_index,"c"=>0],
  8682. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8683. ];
  8684. $merges[] = [
  8685. "s"=>["r"=>$excel_index,"c"=>1],
  8686. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8687. ];
  8688. $merges[] = [
  8689. "s"=>["r"=>$excel_index,"c"=>2],
  8690. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8691. ];
  8692. $merges[] = [
  8693. "s"=>["r"=>$excel_index,"c"=>3],
  8694. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8695. ];
  8696. $merges[] = [
  8697. "s"=>["r"=>$excel_index,"c"=>5],
  8698. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8699. ];
  8700. $excel_index = $excel_index + $len;
  8701. }
  8702. }
  8703. }
  8704. $first_row = [
  8705. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8706. ];
  8707. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8708. if(empty($final_list)){
  8709. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8710. }
  8711. $cols = [
  8712. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8713. ];
  8714. array_unshift($final_list, $first_row);
  8715. array_unshift($final_list, [
  8716. $title,"","","","",""
  8717. ]);
  8718. $end_list = [];
  8719. foreach ($final_list as $key => $value) {
  8720. $end_list[] = array_values($value);
  8721. }
  8722. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8723. }
  8724. //出库、退库导出
  8725. public function _dccrtypejs()
  8726. {
  8727. $classid = $this->classid->sku();
  8728. $pm = $classid;
  8729. $typeclass = array();
  8730. $tc = $this->typeclass->find_all();
  8731. foreach ($tc as $v) {
  8732. $typeclass[$v['id']] = $v;
  8733. }
  8734. $prc = array();
  8735. $purchase = $this->purchase->find_all();
  8736. foreach ($purchase as $k => $v) {
  8737. $prc[$v['id']] = $v['title'];
  8738. }
  8739. if (isset($_GET['sid'])) {
  8740. $wh = array();
  8741. $w = $this->warehouse->find_all('1=1', 'id,title');
  8742. foreach ($w as $v) {
  8743. $wh[$v['id']] = $v['title'];
  8744. }
  8745. $type = $this->input->get('excel', true);
  8746. $category = $this->input->get('category', true);
  8747. $size = $this->input->get('size', true);
  8748. $grade = $this->input->get('grade', true);
  8749. $color = $this->input->get('color', true);
  8750. $lowe = $this->input->get('lowe', true);
  8751. $sku = $this->input->get('sku', true);
  8752. $warehouse = $this->input->get('warehouse', true);
  8753. $lacetype = $this->input->get('lacetype', true);
  8754. $lacecolor = $this->input->get('lacecolor', true);
  8755. $density = $this->input->get('density', true);
  8756. $haircap = $this->input->get('haircap', true);
  8757. $purchase = $this->input->get('purchase', true);
  8758. $title = $this->input->get('title', true);
  8759. $state = $this->input->get('state', true);
  8760. $sid = $this->input->get('sid', true);
  8761. $ktime = $this->input->get('ktime', true);
  8762. $jtime = $this->input->get('jtime', true);
  8763. $ktime = strtotime($ktime);
  8764. $jtime = strtotime($jtime);
  8765. $where = "1=1";
  8766. $gj = "";
  8767. $ck = "";
  8768. if ($category) {
  8769. $where .= " and features like '%-$category-%'";
  8770. }
  8771. if ($size) {
  8772. $where .= " and features like '%-$size-%'";
  8773. }
  8774. if ($grade) {
  8775. $where .= " and features like '%-$grade-%'";
  8776. }
  8777. if ($color) {
  8778. $where .= " and features like '%-$color-%'";
  8779. }
  8780. if ($lowe) {
  8781. $where .= " and features like '%-$lowe-%'";
  8782. }
  8783. if ($warehouse) {
  8784. $where .= " and warehouse = '$warehouse'";
  8785. }
  8786. if ($purchase) {
  8787. $where .= " and purchase = '$purchase'";
  8788. }
  8789. if ($state) {
  8790. $where .= " and state = '$state'";
  8791. }
  8792. if ($lacetype) {
  8793. $where .= " and features like '%-$lacetype-%'";
  8794. }
  8795. if ($lacecolor) {
  8796. $where .= " and features like '%-$lacecolor-%'";
  8797. }
  8798. if ($density) {
  8799. $where .= " and features like '%-$density-%'";
  8800. }
  8801. if ($haircap) {
  8802. $where .= " and features like '%-$haircap-%'";
  8803. }
  8804. if ($title) {
  8805. $title = trim($title, ' ');
  8806. $title = trim($title, ' ');
  8807. $where .= " and title like '%$title%'";
  8808. }
  8809. if ($sku) {
  8810. $sku = trim($sku, ' ');
  8811. $sku = trim($sku, ' ');
  8812. $where .= " and sku like '%$sku%'";
  8813. }
  8814. if ($ktime && $jtime) {
  8815. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8816. }
  8817. $sidwhere = '';
  8818. if ($sid) {
  8819. $sd = "";
  8820. $s = explode(',', trim($sid, ','));
  8821. foreach ($s as $value) {
  8822. $sd .= " id = " . $value . " or";
  8823. }
  8824. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8825. }
  8826. //数据排序
  8827. $order_str = "time desc";
  8828. if (empty($page)) {
  8829. $start = 0;
  8830. $perpage = 1;
  8831. } else {
  8832. $start = ($page - 1) * $perpage;
  8833. }
  8834. $wh = array();
  8835. $w = $this->warehouse->find_all('1=1', 'id,title');
  8836. foreach ($w as $v) {
  8837. $wh[$v['id']] = $v['title'];
  8838. }
  8839. $wt = array();
  8840. $whlabel_type = $this->whlabel_type->find_all();
  8841. foreach ($whlabel_type as $v) {
  8842. $wt[$v['id']] = $v['title'];
  8843. }
  8844. $classid = $this->classid->sku();
  8845. $list = array();
  8846. $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');
  8847. foreach ($rows_r as $key => $value) {
  8848. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8849. $pm = $classid;
  8850. $jm = $classid;
  8851. $rows_r[$key]['enter'] = '入库';
  8852. $rows_r[$key]['time'] = $value['enter'];
  8853. if ($value['rktype'] == 1) {
  8854. $rows_r[$key]['rktype'] = '采购入库';
  8855. } else if ($value['rktype'] == 2) {
  8856. $rows_r[$key]['rktype'] = '盘盈调整';
  8857. } else if ($value['rktype'] == 3) {
  8858. $rows_r[$key]['rktype'] = '其他调整入库';
  8859. } else if ($value['rktype'] == 4) {
  8860. $rows_r[$key]['rktype'] = '其他调整入库';
  8861. } else if ($value['rktype'] == 5) {
  8862. $rows_r[$key]['rktype'] = '退库入库';
  8863. } else if ($value['rktype'] == 6) {
  8864. $rows_r[$key]['rktype'] = '退货可用入库';
  8865. } else if ($value['rktype'] == 7) {
  8866. $rows_r[$key]['rktype'] = '形态转换入库';
  8867. } else {
  8868. $rows_r[$key]['rktype'] = '';
  8869. }
  8870. $features = explode('-', trim($value['features'], '-'));
  8871. foreach ($features as $v) {
  8872. if (isset($typeclass[$v])) {
  8873. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8874. $pm[$typeclass[$v]['classid']] = $zh[0];
  8875. }
  8876. if (isset($typeclass[$v])) {
  8877. if (isset($jm[$typeclass[$v]['classid']])) {
  8878. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8879. }
  8880. }
  8881. }
  8882. $zh = implode(" ", $pm);
  8883. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8884. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8885. $rows_r[$key]['zh'] = $zh;
  8886. $jm = array_filter($jm);
  8887. $rows_r[$key]['features'] = implode("-", $jm);
  8888. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8889. }
  8890. $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');
  8891. foreach ($rows_c as $key => $value) {
  8892. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8893. $pm = $classid;
  8894. $jm = $classid;
  8895. $rows_c[$key]['time'] = $value['outk'];
  8896. $rows_c[$key]['outk'] = '出库';
  8897. if ($value['cktype'] == 1) {
  8898. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8899. } else if ($value['cktype'] == 2) {
  8900. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8901. } else if ($value['cktype'] == 3) {
  8902. $rows_c[$key]['cktype'] = '盘亏调整';
  8903. } else if ($value['cktype'] == 4) {
  8904. $rows_c[$key]['cktype'] = '其他调整出库';
  8905. } else if ($value['cktype'] == 5) {
  8906. $rows_c[$key]['cktype'] = '形态转换出库';
  8907. } else {
  8908. $rows_c[$key]['cktype'] = '';
  8909. }
  8910. unset($rows_c[$key]['state']);
  8911. $features = explode('-', trim($value['features'], '-'));
  8912. foreach ($features as $v) {
  8913. if (isset($typeclass[$v])) {
  8914. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8915. $pm[$typeclass[$v]['classid']] = $zh[0];
  8916. }
  8917. if (isset($typeclass[$v])) {
  8918. if (isset($jm[$typeclass[$v]['classid']])) {
  8919. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8920. }
  8921. }
  8922. }
  8923. $zh = implode(" ", $pm);
  8924. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8925. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8926. $rows_c[$key]['zh'] = $zh;
  8927. $jm = array_filter($jm);
  8928. $rows_c[$key]['features'] = implode("-", $jm);
  8929. $rows_c[$key]['number'] = 1;
  8930. }
  8931. $merged = $rows_r;
  8932. foreach ($rows_c as $key => $value) {
  8933. if (isset($merged[$key])) {
  8934. $merged[] = $value;
  8935. } else {
  8936. $merged[$key] = $value;
  8937. }
  8938. }
  8939. usort($merged, function ($a, $b) {
  8940. return $a['time'] - $b['time'];
  8941. });
  8942. foreach ($merged as $key => $value) {
  8943. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8944. }
  8945. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8946. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8947. $cols = [
  8948. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8949. ];
  8950. $final_list= [];
  8951. foreach($merged as $key => $value){
  8952. $final_list[] = array_values($value) ;
  8953. }
  8954. if(empty($merged)){
  8955. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8956. }
  8957. array_unshift($final_list, $first_row);
  8958. $end_list = [];
  8959. foreach ($final_list as $key => $value) {
  8960. $end_list[] = array_values($value);
  8961. }
  8962. $merges = [];
  8963. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8964. }
  8965. }
  8966. public function _errorexceljs()
  8967. {
  8968. $post = $this->input->post(NULL, TRUE);
  8969. if (isset($_GET['page'])) {
  8970. $page = $this->input->get('page', true);
  8971. $perpage = $this->input->get('perpage', true);
  8972. $sku = $this->input->get('sku', true);
  8973. $warehouse = $this->input->get('warehouse', true);
  8974. $ktime = $this->input->get('ktime', true);
  8975. $jtime = $this->input->get('jtime', true);
  8976. $ktime = strtotime($ktime);
  8977. $jtime = strtotime($jtime);
  8978. $where = "sku != 'Preset'";
  8979. $gj = '';
  8980. if ($sku) {
  8981. $where .= " and sku like '%$sku%'";
  8982. } else {
  8983. if ($ktime && $jtime) {
  8984. $gj = " and time > '$ktime' and time < '$jtime'";
  8985. }
  8986. }
  8987. if ($warehouse) {
  8988. $where .= " and warehouse = '$warehouse'";
  8989. }
  8990. //数据排序
  8991. $order_str = "id desc";
  8992. if (empty($page)) {
  8993. $start = 0;
  8994. $perpage = 1;
  8995. } else {
  8996. $start = ($page - 1) * $perpage;
  8997. }
  8998. //取得信息列表
  8999. $rows = array();
  9000. $list = array();
  9001. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9002. foreach ($info_list as $value) {
  9003. $warehouse = $this->warehouse->read($value['warehouse']);
  9004. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9005. $number = $value['number'];
  9006. $ftime = time() - 15 * 24 * 3600;
  9007. if ($c < 1) {
  9008. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9009. }
  9010. }
  9011. $title = "0库存汇总";
  9012. $first_row = ["仓库","SKU","产品","当前库存"];
  9013. $cols = [
  9014. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9015. ];
  9016. $final_list= [];
  9017. foreach($list as $key => $value){
  9018. $final_list[] = array_values($value) ;
  9019. }
  9020. if(empty($final_list)){
  9021. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9022. }
  9023. array_unshift($final_list, $first_row);
  9024. $merges = [];
  9025. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9026. }
  9027. }
  9028. }