Whlabel.php 317 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. } else if ($arg == 'typedy') //进销存浏览店员页面
  62. {
  63. $this->_typedy($arg_array);
  64. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  65. {
  66. $this->_typedy_ck($arg_array);
  67. } else if ($arg == 'typeck') {
  68. $this->_typeck($arg_array);
  69. } else if ($arg == 'whlabeckdc') {
  70. $this->_whlabeckdc($arg_array);
  71. } else if ($arg == 'usatype') //美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  75. {
  76. $this->_usatypeapp();
  77. } else if ($arg == 'enteradd') //入库操作
  78. {
  79. $this->_enteradd();
  80. } else if ($arg == 'enteredit') //修改
  81. {
  82. $this->_enteredit($arg_array);
  83. } else if ($arg == 'enter') //入库浏览
  84. {
  85. $this->_enter();
  86. } else if ($arg == 'out') //出库浏览
  87. {
  88. $this->_out();
  89. } else if ($arg == 'label') //出库标签浏览
  90. {
  91. $this->_label();
  92. } else if ($arg == 'outorder') //独立站出库订单
  93. {
  94. $this->_outorder();
  95. } else if ($arg == 'soutorder') //速卖通出库订单
  96. {
  97. $this->_soutorder();
  98. } else if ($arg == 'toutorder') //TT出库订单
  99. {
  100. $this->_toutorder();
  101. }else if ($arg == 'aoutorder') //amz出库订单
  102. {
  103. $this->_aoutorder();
  104. } else if ($arg == 'retreat') //退库订单
  105. {
  106. $this->_retreat();
  107. } else if ($arg == 'retreatlk') //退库订单
  108. {
  109. $this->_retreatlk();
  110. } else if ($arg == 'change') //更换标签
  111. {
  112. $this->_change();
  113. } else if ($arg == 'del') //删除
  114. {
  115. $this->_del();
  116. } else if ($arg == 'exceljxc') //进销存信息导出
  117. {
  118. $this->_exceljxc();
  119. } else if ($arg == 'excelr') //入库信息导出
  120. {
  121. $this->_excelr();
  122. } else if ($arg == 'excelct') //出库、退库信息导出
  123. {
  124. $this->_excelct();
  125. } else if ($arg == 'dccrtype') //根据出入库类型导出
  126. {
  127. $this->_dccrtype();
  128. } else if ($arg == 'excelcr') //出库、退库信息导出
  129. {
  130. $this->_excelcr();
  131. } else if ($arg == 'kcyz') //库存验证
  132. {
  133. $this->_kcyz();
  134. } else if ($arg == 'kj') //库存扣减
  135. {
  136. $this->_kj($arg_array);
  137. } else if ($arg == 'presetout') //预设库存导入
  138. {
  139. $this->_presetout($arg_array);
  140. } else if ($arg == 'presetedit') //预设库存导入
  141. {
  142. $this->_presetedit($arg_array);
  143. }else if ($arg == 'presetedittwo') //预设库存导入
  144. {
  145. $this->_presetedittwo($arg_array);
  146. } else if ($arg == 'summary') //汇总导出
  147. {
  148. $this->_summary($arg_array);
  149. } else if ($arg == 'manifest') //usps发货清单
  150. {
  151. $this->_manifest();
  152. } else if ($arg == 'abnormal') //占单异常
  153. {
  154. $this->_abnormal();
  155. } else if ($arg == 'error') //0库存SKU
  156. {
  157. $this->_error();
  158. } else if ($arg == 'errorexcel') //0库存SKU导出
  159. {
  160. $this->_errorexcel();
  161. } else if ($arg == 'db') {
  162. $this->_db();
  163. } else if ($arg == 'dbrk') {
  164. $this->_dbrk();
  165. } else if ($arg == 'whlabelczdc') {
  166. $this->_whlabelczdc();
  167. } else if ($arg == 'print') {
  168. $this->_print($arg_array);
  169. } else if ($arg == 'usaprint') {
  170. $this->_usaprint($arg_array);
  171. } else if ($arg == 'printck') {
  172. $this->_printck($arg_array);
  173. } else if ($arg == 'printrk') {
  174. $this->_printrk($arg_array);
  175. } else if ($arg == 'printxzrk') {
  176. $this->_printxzrk($arg_array);
  177. } else if ($arg == 'printexcel') {
  178. $this->_printexcel($arg_array);
  179. } else if ($arg == 'uck') {
  180. $this->_uck();
  181. } else if ($arg == 'whlabelexcelzh') {
  182. $this->_whlabelexcelzh();
  183. } else if ($arg == 'fc') {
  184. $this->_fc();
  185. } else if ($arg == 'fcmb') {
  186. $this->_fcmb();
  187. } else if ($arg == 'fcexcel') {
  188. $this->_fcexcel();
  189. } else if ($arg == 'fcjxc') {
  190. $this->_fcjxc($arg_array);
  191. } else if ($arg == '0kcdel') {
  192. $this->_0kcdel(); //导表删除0库存
  193. } else if ($arg == 'gbhtype') {
  194. $this->_gbhtype(); //更改备货状态
  195. } else if($arg == 'excelrjs'){
  196. $this->_excelrjs();
  197. } else if($arg == 'excelctjs'){
  198. $this->_excelctjs();
  199. }else if ($arg == 'exceljxcjs') //进销存信息导出
  200. {
  201. $this->_exceljxcjs();
  202. } else if ($arg == 'summaryjs') //汇总导出
  203. {
  204. $this->_summaryjs($arg_array);
  205. }else if($arg == 'uckjs'){
  206. $this->_uckjs();
  207. }else if ($arg == 'whlabelexcelzhjs') {
  208. $this->_whlabelexcelzhjs();
  209. }else if($arg == 'dccrtypejs'){
  210. $this->_dccrtypejs();
  211. }else if($arg == 'errorexceljs'){
  212. $this->_errorexceljs();
  213. }else if($arg == "w_t_cs"){
  214. $this->_w_t_cs(); //首页
  215. }else {
  216. $this->_index();
  217. }
  218. }
  219. public function _w_t_cs(){
  220. $vip = 0;
  221. if (isset($_SESSION['api'])) {
  222. $user = $this->user->get_api($_SESSION['api']);
  223. $fgshop = "";
  224. $sid = "";
  225. $usersp = explode('|', trim($user['shop'], '|'));
  226. foreach ($usersp as $value) {
  227. $fgshop .= " shop = " . $value . " or";
  228. $sid .= " id = " . $value . " or";
  229. }
  230. if ($user['vip'] == 1) {
  231. $vip = 1;
  232. }
  233. } else {
  234. header('Location: /');
  235. exit;
  236. }
  237. $prc = array();
  238. $purchase = $this->purchase->find_all();
  239. foreach ($purchase as $k => $v) {
  240. $prc[$v['id']] = $v['title'];
  241. }
  242. $company = array();
  243. $ct = $this->company->find_all();
  244. foreach ($ct as $k => $v) {
  245. $company[$v['id']] = $v['title'];
  246. }
  247. $sp = array();
  248. $s = $this->shop->find_all('1=1', 'id,shopname');
  249. foreach ($s as $v) {
  250. $sp[$v['id']] = $v['shopname'];
  251. }
  252. $wh = array();
  253. $w = $this->warehouse->find_all('1=1', 'id,title');
  254. foreach ($w as $v) {
  255. $wh[$v['id']] = $v['title'];
  256. }
  257. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  258. $this->data['shop'] = $wlshop;
  259. $this->data['vip'] = $vip;
  260. $this->_Template('whlabel_typejs', $this->data);
  261. }
  262. //管理
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if (isset($post['page'])) {
  267. $page = $this->input->post('page', true);
  268. $perpage = $this->input->post('perpage', true);
  269. $sku = $this->input->post('sku', true);
  270. $number = $this->input->post('number', true);
  271. $warehouse = $this->input->post('warehouse', true);
  272. $purchase = $this->input->post('purchase', true);
  273. $orderinfo = $this->input->post('orderinfo', true);
  274. $waybill = $this->input->post('waybill', true);
  275. $category = $this->input->post('category', true);
  276. $size = $this->input->post('size', true);
  277. $grade = $this->input->post('grade', true);
  278. $color = $this->input->post('color', true);
  279. $lowe = $this->input->post('lowe', true);
  280. $state = $this->input->post('state', true);
  281. $label = $this->input->post('label', true);
  282. $timetk = $this->input->post('timetkk', true);
  283. $timetj = $this->input->post('timetjj', true);
  284. $timetk = strtotime($timetk);
  285. $timetj = strtotime($timetj);
  286. $where = "1=1 ";
  287. if ($timetk && $timetj) {
  288. $where .= " and time > '$timetk' and time < '$timetj'";
  289. }
  290. if ($sku) {
  291. $where .= " and sku = '$sku'";
  292. }
  293. if ($number) {
  294. $where .= " and number = '$number'";
  295. }
  296. if ($warehouse) {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if ($purchase) {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if ($orderinfo) {
  303. $where .= " and orderinfo = '$orderinfo'";
  304. }
  305. if ($waybill) {
  306. $where .= " and waybill = '$waybill'";
  307. }
  308. if ($category) {
  309. $where .= " and features like '%-$category-%'";
  310. }
  311. if ($size) {
  312. $where .= " and features like '%-$size-%'";
  313. }
  314. if ($grade) {
  315. $where .= " and features like '%-$grade-%'";
  316. }
  317. if ($color) {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if ($lowe) {
  321. $where .= " and features like '%-$lowe-%'";
  322. }
  323. if ($label) {
  324. $where .= " and label = '$label'";
  325. }
  326. if ($state != '') {
  327. $where .= " and state = '$state'";
  328. }
  329. //数据排序
  330. $order_str = "time desc";
  331. if (empty($page)) {
  332. $start = 0;
  333. $perpage = 1;
  334. } else {
  335. $start = ($page - 1) * $perpage;
  336. }
  337. //取得信息列表
  338. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  339. foreach ($info_list as $key => $value) {
  340. $warehouse = $this->warehouse->read($value['warehouse']);
  341. $info_list[$key]['warehouse'] = $warehouse['title'];
  342. $purchase = $this->purchase->read($value['purchase']);
  343. $info_list[$key]['purchase'] = $purchase['title'];
  344. if ($value['enter'] != 0) {
  345. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  346. } else {
  347. $info_list[$key]['enter'] = "";
  348. }
  349. if ($value['outk'] != 0) {
  350. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  351. } else {
  352. $info_list[$key]['outk'] = "";
  353. }
  354. if ($value['printing'] != 0) {
  355. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  356. } else {
  357. $info_list[$key]['printing'] = "";
  358. }
  359. if ($value['orderinfo'] == 0) {
  360. $info_list[$key]['orderinfo'] = "";
  361. }
  362. if ($value['waybill'] == 0) {
  363. $info_list[$key]['waybill'] = "";
  364. }
  365. if ($value['state'] == 0) {
  366. $info_list[$key]['state'] = "在库";
  367. } else if ($value['state'] == 1) {
  368. $info_list[$key]['state'] = "出库";
  369. } else if ($value['state'] == 2) {
  370. $info_list[$key]['state'] = "退库";
  371. } else if ($value['state'] == 3) {
  372. $info_list[$key]['state'] = "调拨中";
  373. } else if ($value['state'] == 4) {
  374. $info_list[$key]['state'] = "再加工";
  375. } else if ($value['state'] == 5) {
  376. $info_list[$key]['state'] = "维修中";
  377. } else if ($value['state'] == 6) {
  378. $info_list[$key]['state'] = "盘亏";
  379. } else if ($value['state'] == 7) {
  380. $info_list[$key]['state'] = "更换标签";
  381. } else if ($value['state'] == 8) {
  382. $info_list[$key]['state'] = "其它";
  383. } else if ($value['state'] == 9) {
  384. $info_list[$key]['state'] = "预设";
  385. } else if ($value['state'] == 10) {
  386. $info_list[$key]['state'] = "美店零售";
  387. }
  388. if ($value['text'] == "") {
  389. $info_list[$key]['text'] = "";
  390. }
  391. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  392. }
  393. $total = $this->whlabel->find_count($where);
  394. $pagenum = ceil($total / $perpage);
  395. $over = $total - ($start + $perpage);
  396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  397. echo json_encode($rows);
  398. exit;
  399. }
  400. if (isset($post['outsku'])) {
  401. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  402. $cz = $this->input->post('cz', true);
  403. if ($cz == '1') {
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. } else {
  416. $sku = $this->input->post('outsku', true);
  417. if ($sku) {
  418. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  419. if (count($data) < 1) {
  420. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  421. exit;
  422. }
  423. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  424. echo json_encode(array('success' => true));
  425. exit;
  426. }
  427. }
  428. }
  429. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  430. $this->_Template('whlabel', $this->data);
  431. }
  432. //在库标签
  433. public function _existence()
  434. {
  435. $post = $this->input->post(NULL, TRUE);
  436. if (isset($post['s'])) {
  437. $id_arr = $this->input->post('s');
  438. $id_arr = explode(',', $id_arr);
  439. if (!$id_arr) {
  440. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  441. exit;
  442. }
  443. //循环删除记录
  444. foreach ($id_arr as $v) {
  445. $sid = $this->whlabel->read($v);
  446. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  447. if ($count > 0) {
  448. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  449. exit;
  450. }
  451. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  452. if (count($zt) > 0) {
  453. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  454. exit;
  455. }
  456. $this->whlabel->remove($v);
  457. }
  458. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  459. exit;
  460. }
  461. if (isset($post['page'])) {
  462. $page = $this->input->post('page', true);
  463. $perpage = $this->input->post('perpage', true);
  464. $warehouse = $this->input->post('warehouse', true);
  465. $label = $this->input->post('label', true);
  466. $where = "1=1 and state = 0";
  467. if ($warehouse) {
  468. $where .= " and warehouse = '$warehouse'";
  469. }
  470. if ($label) {
  471. $where .= " and label = '$label'";
  472. }
  473. //数据排序
  474. $order_str = "time asc";
  475. if (empty($page)) {
  476. $start = 0;
  477. $perpage = 1;
  478. } else {
  479. $start = ($page - 1) * $perpage;
  480. }
  481. //取得信息列表
  482. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  483. foreach ($info_list as $key => $value) {
  484. if ($value['enter'] != 0) {
  485. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  486. } else {
  487. $info_list[$key]['enter'] = "";
  488. }
  489. if ($value['printing'] != 0) {
  490. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  491. } else {
  492. $info_list[$key]['printing'] = "";
  493. }
  494. }
  495. $total = $this->whlabel->find_count($where);
  496. $pagenum = ceil($total / $perpage);
  497. $over = $total - ($start + $perpage);
  498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  499. echo json_encode($rows);
  500. exit;
  501. }
  502. $this->_Template('whlabel_existence', $this->data);
  503. }
  504. //进销存浏览
  505. public function _typedy($arg_array)
  506. {
  507. $prc = array();
  508. $purchase = $this->purchase->find_all();
  509. foreach ($purchase as $k => $v) {
  510. $prc[$v['id']] = $v['title'];
  511. }
  512. $post = $this->input->post(NULL, TRUE);
  513. if (isset($post['page'])) {
  514. $page = $this->input->post('page', true);
  515. $perpage = $this->input->post('perpage', true);
  516. $category = $this->input->post('category', true);
  517. $size = $this->input->post('size', true);
  518. $grade = $this->input->post('grade', true);
  519. $color = $this->input->post('color', true);
  520. $lowe = $this->input->post('lowe', true);
  521. $sku = $this->input->post('sku');
  522. $title = $this->input->post('title');
  523. $warehouse = $this->input->post('warehouse', true);
  524. $usa = $this->input->post('usa', true);
  525. $purchase = $this->input->post('purchase', true);
  526. $lacetype = $this->input->post('lacetype', true);
  527. $haircap = $this->input->post('haircap', true);
  528. $density = $this->input->post('density', true);
  529. $details = $this->input->post('details', true);
  530. $state = $this->input->post('state', true);
  531. $lacecolor = $this->input->post('lacecolor', true);
  532. $hairnumber = $this->input->post('hairnumber', true);
  533. $cklx = $this->input->post('cklx', true);
  534. $ktime = $this->input->post('ktime', true);
  535. $jtime = $this->input->post('jtime', true);
  536. $sm = $this->input->post('sm', true);
  537. $cpbz = $this->input->post('cpbz', true);
  538. $type = $this->input->post('type', true);
  539. $ktime = strtotime($ktime);
  540. $jtime = strtotime($jtime);
  541. $where = "1=1";
  542. $gj = "";
  543. $ck = "";
  544. if ($usa) {
  545. if (!$warehouse) {
  546. $where .= " and (warehouse = '5' or warehouse = '8')";
  547. }
  548. }
  549. if ($warehouse) {
  550. $where .= " and warehouse = '$warehouse'";
  551. }
  552. if ($details) {
  553. $where .= " and details = '$details'";
  554. }
  555. if ($purchase) {
  556. $where .= " and purchase = '$purchase'";
  557. }
  558. if (isset($state)) {
  559. if($state >-1){
  560. $where .= " and state = '$state'";
  561. }
  562. }
  563. if ($lacetype) {
  564. $where .= " and features like '%-$lacetype-%'";
  565. }
  566. if ($category) {
  567. $where .= " and features like '%-$category-%'";
  568. }
  569. if ($size) {
  570. $where .= " and features like '%-$size-%'";
  571. }
  572. if ($grade) {
  573. $where .= " and features like '%-$grade-%'";
  574. }
  575. if ($color) {
  576. $where .= " and features like '%-$color-%'";
  577. }
  578. if ($lowe) {
  579. $where .= " and features like '%-$lowe-%'";
  580. }
  581. if ($haircap) {
  582. $where .= " and features like '%-$haircap-%'";
  583. }
  584. if ($density) {
  585. $where .= " and features like '%-$density-%'";
  586. }
  587. if ($lacecolor) {
  588. $where .= " and features like '%-$lacecolor-%'";
  589. }
  590. if($sm){
  591. $where .= " and sm like '%".$sm."%'";
  592. }
  593. if($cpbz){
  594. $where .= " and cpbz like '%".$cpbz."%'";
  595. }
  596. if($type){
  597. $where .= " and type = ".$type."";
  598. }
  599. if (!empty($hairnumber)) {
  600. $where .= " and features like '%-128-%' ";
  601. if ($hairnumber < 0) {
  602. $class_list = $this->typeclass->find_all('classid = 43');
  603. foreach ($class_list as $v) {
  604. $where .= " and features not like '%-" . $v['id'] . "-%'";
  605. }
  606. } else {
  607. $where .= " and features like '%-$hairnumber-%'";
  608. }
  609. }
  610. $where_add = '';
  611. if ($cklx) {
  612. $shop = $this->shop->read($cklx);
  613. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  614. }
  615. if ($ktime && $jtime) {
  616. $gj = " and enter > '$ktime' and enter < '$jtime'";
  617. $ck = " and outk > '$ktime' and outk < '$jtime'";
  618. }
  619. //数据排序
  620. $order_str = "id desc";
  621. if (empty($page)) {
  622. $start = 0;
  623. $perpage = 1;
  624. } else {
  625. $start = ($page - 1) * $perpage;
  626. }
  627. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  628. if ($sku) {
  629. $sku = trim($sku, ' ');
  630. $sku = trim($sku, ' ');
  631. $where .= " and sku like '%$sku%'";
  632. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  633. } else if ($title) {
  634. $title = trim($title, ' ');
  635. $title = trim($title, ' ');
  636. $where .= " and title like '%$title%'";
  637. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  638. } else {
  639. //$where .= " and time > '$ktime' and time < '$jtime'";
  640. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  641. }
  642. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  643. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  644. foreach ($info_list as $k => $v) {
  645. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  646. unset($info_list[$k]['pm']);
  647. unset($info_list[$k]['jm']);
  648. unset($info_list[$k]['bm']);
  649. }
  650. //取得信息列表
  651. $rows = array();
  652. $list = array();
  653. foreach ($info_list as $key => $value) {
  654. $warehouse = $this->warehouse->read($value['warehouse']);
  655. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  656. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  657. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  658. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  659. $info_list[$key]['label'] = $value['sm'];
  660. $number = $value['number'];
  661. $ftime = time() - 15 * 24 * 3600;
  662. $info_list[$key]['warehouse'] = $warehouse['title'];
  663. $info_list[$key]['features'] = count($c);
  664. $z = count($z); //查看订单号
  665. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  666. $ztdata = '';
  667. if (count($zt) > 0) {
  668. foreach ($zt as $vv) {
  669. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  670. }
  671. }
  672. $info_list[$key]['number'] = $ztdata;
  673. $info_list[$key]['sm'] = $z;
  674. $details = array();
  675. $cpid = array();
  676. foreach ($c as $k => $v) {
  677. $details[$v['details']] = $v['details'];
  678. if ($v['cpid'] != 0) {
  679. $cpid[$v['cpid']] = $v['cpid'];
  680. }
  681. }
  682. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  683. if ($value['shop'] != '') {
  684. $shop = explode(',', trim($value['shop'], ','));
  685. $shop = $this->shop->read($shop[0]);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. }
  688. }
  689. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  690. $pagenum = ceil($total / $perpage);
  691. $over = $total - ($start + $perpage);
  692. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  693. echo json_encode($rows);
  694. exit;
  695. }
  696. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  697. $this->_Template('whlabel_typedy', $this->data);
  698. }
  699. //进销存浏览
  700. public function _typedy_ck($arg_array)
  701. {
  702. $prc = array();
  703. $purchase = $this->purchase->find_all();
  704. foreach ($purchase as $k => $v) {
  705. $prc[$v['id']] = $v['title'];
  706. }
  707. $post = $this->input->post(NULL, TRUE);
  708. if (isset($post['page'])) {
  709. $page = $this->input->post('page', true);
  710. $perpage = $this->input->post('perpage', true);
  711. $category = $this->input->post('category', true);
  712. $size = $this->input->post('size', true);
  713. $grade = $this->input->post('grade', true);
  714. $color = $this->input->post('color', true);
  715. $lowe = $this->input->post('lowe', true);
  716. $sku = $this->input->post('sku');
  717. $title = $this->input->post('title');
  718. $warehouse = $this->input->post('warehouse', true);
  719. $usa = $this->input->post('usa', true);
  720. $purchase = $this->input->post('purchase', true);
  721. $lacetype = $this->input->post('lacetype', true);
  722. $haircap = $this->input->post('haircap', true);
  723. $density = $this->input->post('density', true);
  724. $details = $this->input->post('details', true);
  725. $state = $this->input->post('state', true);
  726. $lacecolor = $this->input->post('lacecolor', true);
  727. $cklx = $this->input->post('cklx', true);
  728. $ktime = $this->input->post('ktime', true);
  729. $jtime = $this->input->post('jtime', true);
  730. $ktime = strtotime($ktime);
  731. $jtime = strtotime($jtime);
  732. $where = "1=1";
  733. $gj = "";
  734. $ck = "";
  735. if ($lacetype) {
  736. $where .= " and features like '%-$lacetype-%'";
  737. }
  738. if ($category) {
  739. $where .= " and features like '%-$category-%'";
  740. }
  741. if ($size) {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if ($grade) {
  745. $where .= " and features like '%-$grade-%'";
  746. }
  747. if ($color) {
  748. $where .= " and features like '%-$color-%'";
  749. }
  750. if ($lowe) {
  751. $where .= " and features like '%-$lowe-%'";
  752. }
  753. if ($haircap) {
  754. $where .= " and features like '%-$haircap-%'";
  755. }
  756. if ($density) {
  757. $where .= " and features like '%-$density-%'";
  758. }
  759. if ($lacecolor) {
  760. $where .= " and features like '%-$lacecolor-%'";
  761. }
  762. if ($usa) {
  763. if (!$warehouse) {
  764. $where .= " and (warehouse = '5' or warehouse = '8')";
  765. }
  766. }
  767. if ($warehouse) {
  768. $where .= " and warehouse = '$warehouse'";
  769. }
  770. if ($details) {
  771. $where .= " and details = '$details'";
  772. }
  773. if ($purchase) {
  774. $where .= " and purchase = '$purchase'";
  775. }
  776. if ($state) {
  777. $where .= " and state = '$state'";
  778. }
  779. $where_add = '';
  780. if ($cklx) {
  781. $shop = $this->shop->read($cklx);
  782. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  783. }
  784. if ($ktime && $jtime) {
  785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  787. }
  788. //数据排序
  789. $order_str = "id desc";
  790. if (empty($page)) {
  791. $start = 0;
  792. $perpage = 1;
  793. } else {
  794. $start = ($page - 1) * $perpage;
  795. }
  796. if ($sku) {
  797. $sku = trim($sku, ' ');
  798. $sku = trim($sku, ' ');
  799. $where .= " and sku like '%$sku%'";
  800. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  801. } else if ($title) {
  802. $title = trim($title, ' ');
  803. $title = trim($title, ' ');
  804. $where .= " and title like '%$title%'";
  805. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  806. } else {
  807. //$where .= " and time > '$ktime' and time < '$jtime'";
  808. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  809. }
  810. //取得信息列表
  811. $rows = array();
  812. $list = array();
  813. foreach ($info_list as $key => $value) {
  814. $warehouse = $this->warehouse->read($value['warehouse']);
  815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  816. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  817. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  818. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  819. $ftime = time() - 15 * 24 * 3600;
  820. $info_list[$key]['warehouse'] = $warehouse['title'];
  821. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  822. //$z = count($z);//查看订单号
  823. //$info_list[$key]['zd'] = $z;
  824. $details = array();
  825. $cpid = array();
  826. foreach ($c as $k => $v) {
  827. $details[$v['details']] = $v['details'];
  828. if ($v['cpid'] != 0) {
  829. $cpid[$v['cpid']] = $v['cpid'];
  830. }
  831. }
  832. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  833. if ($value['shop'] != '') {
  834. $shop = explode(',', trim($value['shop'], ','));
  835. $shop = $this->shop->read($shop[0]);
  836. $info_list[$key]['shop'] = $shop['shopname'];
  837. }
  838. }
  839. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  840. $pagenum = ceil($total / $perpage);
  841. $over = $total - ($start + $perpage);
  842. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  843. echo json_encode($rows);
  844. exit;
  845. }
  846. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  847. $this->_Template('whlabel_typedy_ck', $this->data);
  848. }
  849. public function _typeck($arg_array)
  850. {
  851. $prc = array();
  852. $purchase = $this->purchase->find_all();
  853. foreach ($purchase as $k => $v) {
  854. $prc[$v['id']] = $v['title'];
  855. }
  856. $post = $this->input->post(NULL, TRUE);
  857. if (isset($post['page'])) {
  858. $page = $this->input->post('page', true);
  859. $perpage = $this->input->post('perpage', true);
  860. $category = $this->input->post('category', true);
  861. $size = $this->input->post('size', true);
  862. $grade = $this->input->post('grade', true);
  863. $color = $this->input->post('color', true);
  864. $lacecolor = $this->input->post('lacecolor', true);
  865. $lowe = $this->input->post('lowe', true);
  866. $sku = $this->input->post('sku');
  867. $title = $this->input->post('title');
  868. $warehouse = 13;
  869. $usa = $this->input->post('usa', true);
  870. $purchase = $this->input->post('purchase', true);
  871. $lacetype = $this->input->post('lacetype', true);
  872. $haircap = $this->input->post('haircap', true);
  873. $density = $this->input->post('density', true);
  874. $details = $this->input->post('details', true);
  875. $state = $this->input->post('state', true);
  876. $ktime = $this->input->post('ktime', true);
  877. $jtime = $this->input->post('jtime', true);
  878. $ktime = strtotime($ktime);
  879. $jtime = strtotime($jtime);
  880. $where = "1=1";
  881. $gj = "";
  882. $ck = "";
  883. if ($lacetype) {
  884. $where .= " and features like '%-$lacetype-%'";
  885. }
  886. if ($category) {
  887. $where .= " and features like '%-$category-%'";
  888. }
  889. if ($size) {
  890. $where .= " and features like '%-$size-%'";
  891. }
  892. if ($grade) {
  893. $where .= " and features like '%-$grade-%'";
  894. }
  895. if ($color) {
  896. $where .= " and features like '%-$color-%'";
  897. }
  898. if ($lacecolor) {
  899. $where .= " and features like '%-$lacecolor-%'";
  900. }
  901. if ($lowe) {
  902. $where .= " and features like '%-$lowe-%'";
  903. }
  904. if ($haircap) {
  905. $where .= " and features like '%-$haircap-%'";
  906. }
  907. if ($density) {
  908. $where .= " and features like '%-$density-%'";
  909. }
  910. if ($warehouse) {
  911. $where .= " and warehouse = '$warehouse'";
  912. }
  913. if ($details) {
  914. $where .= " and details = '$details'";
  915. }
  916. if ($purchase) {
  917. $where .= " and purchase = '$purchase'";
  918. }
  919. if ($state) {
  920. $where .= " and state = '$state'";
  921. }
  922. if ($ktime && $jtime) {
  923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  925. }
  926. //数据排序
  927. $order_str = "id desc";
  928. if (empty($page)) {
  929. $start = 0;
  930. $perpage = 1;
  931. } else {
  932. $start = ($page - 1) * $perpage;
  933. }
  934. if ($sku) {
  935. $sku = trim($sku, ' ');
  936. $sku = trim($sku, ' ');
  937. $where .= " and sku like '%$sku%'";
  938. } else if ($title) {
  939. $title = trim($title, ' ');
  940. $title = trim($title, ' ');
  941. $where .= " and title like '%$title%'";
  942. }
  943. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  944. //取得信息列表
  945. $t = array();
  946. $typeclass = $this->typeclass->find_all();
  947. foreach ($typeclass as $v) {
  948. $t[$v['id']] = $v;
  949. }
  950. $rows = array();
  951. $list = array();
  952. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  953. foreach ($info_list as $key => $value) {
  954. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  955. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  956. $warehouse = $this->warehouse->read($value['warehouse']);
  957. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  958. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  959. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  960. $number = $value['number'];
  961. $ftime = time() - 15 * 24 * 3600;
  962. $z = count($z); //查看订单号
  963. $info_list[$key]['warehouse'] = $warehouse['title'];
  964. $info_list[$key]['features'] = count($c);
  965. $info_list[$key]['number'] = $z;
  966. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  967. $details = array();
  968. $cpid = array();
  969. foreach ($c as $k => $v) {
  970. $details[$v['details']] = $v['details'];
  971. if ($v['cpid'] != 0) {
  972. $cpid[$v['cpid']] = $v['cpid'];
  973. }
  974. }
  975. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  976. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  977. unset($info_list[$key]['pm']);
  978. unset($info_list[$key]['jm']);
  979. unset($info_list[$key]['bm']);
  980. }
  981. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  982. $pagenum = ceil($total / $perpage);
  983. $over = $total - ($start + $perpage);
  984. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  985. echo json_encode($rows);
  986. exit;
  987. }
  988. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  989. $this->_Template('whlabel_typeck', $this->data);
  990. }
  991. //进销存导出
  992. public function _whlabeckdc()
  993. {
  994. $prc = array();
  995. $purchase = $this->purchase->find_all();
  996. foreach ($purchase as $k => $v) {
  997. $prc[$v['id']] = $v['title'];
  998. }
  999. if (isset($_GET['excel'])) {
  1000. $where = "sku != 'Preset'";
  1001. //数据排序
  1002. $order_str = "id desc";
  1003. if (empty($page)) {
  1004. $start = 0;
  1005. $perpage = 1;
  1006. } else {
  1007. $start = ($page - 1) * $perpage;
  1008. }
  1009. $category = $this->input->get('category', true);
  1010. $color = $this->input->get('color', true);
  1011. $lowe = $this->input->get('lowe', true);
  1012. $lacetype = $this->input->get('lacetype', true);
  1013. $size = $this->input->get('size', true);
  1014. $density = $this->input->get('density', true);
  1015. $haircap = $this->input->get('haircap', true);
  1016. $sku = $this->input->get('sku', true);
  1017. $details = $this->input->get('details', true);
  1018. $warehouse = 13;
  1019. $excelid = $this->input->get('sid', true);
  1020. if ($category) {
  1021. $where .= " and features like '%-$category-%'";
  1022. }
  1023. if ($color) {
  1024. $where .= " and features like '%-$color-%'";
  1025. }
  1026. if ($lowe) {
  1027. $where .= " and features like '%-$lowe-%'";
  1028. }
  1029. if ($lacetype) {
  1030. $where .= " and features like '%-$lacetype-%'";
  1031. }
  1032. if ($size) {
  1033. $where .= " and features like '%-$size-%'";
  1034. }
  1035. if ($density) {
  1036. $where .= " and features like '%-$density-%'";
  1037. }
  1038. if ($haircap) {
  1039. $where .= " and features like '%-$haircap-%'";
  1040. }
  1041. if ($warehouse) {
  1042. $where .= " and warehouse = '$warehouse'";
  1043. }
  1044. if ($sku) {
  1045. $where .= " and sku like '%$sku%'";
  1046. }
  1047. if ($details) {
  1048. $where .= " and details = '$details'";
  1049. }
  1050. $xzid = '';
  1051. if ($excelid) {
  1052. $excelid = explode(',', trim($excelid, ','));
  1053. foreach ($excelid as $key => $value) {
  1054. $xzid .= " id = " . $value . " or";
  1055. }
  1056. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1057. }
  1058. //取得信息列表
  1059. /**
  1060. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1061. $rows = array();$list = array();
  1062. foreach ($info_list as $key=>$value)
  1063. {
  1064. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1065. }
  1066. **/
  1067. $wh = array();
  1068. $w = $this->warehouse->find_all('1=1', 'id,title');
  1069. foreach ($w as $v) {
  1070. $wh[$v['id']] = $v['title'];
  1071. }
  1072. $tc = array();
  1073. $tcdata = array();
  1074. $list = array();
  1075. $classid = $this->classid->sku();
  1076. $tcall = $this->typeclass->find_all();
  1077. $typeclass = array();
  1078. foreach ($tcall as $v)
  1079. {
  1080. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1081. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1082. }
  1083. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1084. foreach ($rows as $key => $value) {
  1085. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1086. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1087. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1088. $rows[$key]['cpbz'] = $u9_info['bm'];
  1089. $rows[$key]['cs'] = $u9_info['jm'];
  1090. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1091. $details = array();
  1092. $cpid = array();
  1093. $cpbz = array();
  1094. $c = 0;
  1095. $g = 0;
  1096. $x = 0;
  1097. $t = 0;
  1098. $s = 0;
  1099. $q = 0;
  1100. foreach ($sd as $k => $v) {
  1101. if ($v['state'] == 0) {
  1102. $c++;
  1103. }
  1104. if ($v['state'] != 9) {
  1105. $g++;
  1106. }
  1107. if ($v['state'] == 1) {
  1108. $x++;
  1109. }
  1110. if ($v['state'] == 2) {
  1111. $t++;
  1112. }
  1113. if ($v['state'] == 8) {
  1114. $s++;
  1115. }
  1116. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1117. $q++;
  1118. }
  1119. $details[$v['details']] = $v['details'];
  1120. if ($v['cpid'] != 0) {
  1121. $cpid[$v['cpid']] = $v['cpid'];
  1122. }
  1123. if ($v['cpbz'] != '') {
  1124. $cpbz[$v['cpbz']] = $v['cpbz'];
  1125. }
  1126. }
  1127. $rows[$key]['details'] = implode("、", $details);
  1128. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1129. $number = $value['number'];
  1130. $ftime = time() - 15 * 24 * 3600;
  1131. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1132. $rows[$key]['number'] = $g;
  1133. $rows[$key]['features'] = $c;
  1134. $rows[$key]['x'] = $x;
  1135. $rows[$key]['t'] = $t;
  1136. $rows[$key]['s'] = $s;
  1137. $rows[$key]['q'] = $q;
  1138. $rows[$key]['wzsl'] = count($details);
  1139. //cpbzs
  1140. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1141. $unique_arr = array_unique($tmp_cpbzs);
  1142. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1143. }
  1144. $title = "进销存统计表" . date('Y-m-d', time());
  1145. $titlename = "<table border=1>
  1146. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1147. <tr align='center'>
  1148. <td>仓库</td>
  1149. <td>供应商</td>
  1150. <td>位置</td>
  1151. <td>库存编码</td>
  1152. <td>SKU</td>
  1153. <td>用友编码</td>
  1154. <td>用友料号</td>
  1155. <td>产品英文名</td>
  1156. <td>产品中文名</td>
  1157. <td>备注</td>
  1158. <td>入库总量</td>
  1159. <td>库存数量</td>
  1160. <td>销售数量</td>
  1161. <td>退货数量</td>
  1162. <td>删除数量</td>
  1163. <td>其它操作</td>
  1164. <td>位置数量</td>
  1165. </tr>
  1166. </table>";
  1167. $filename = $title . ".xls";
  1168. $tail = "";
  1169. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1170. }
  1171. }
  1172. public function _type()
  1173. {
  1174. $vip = 0;
  1175. if (isset($_SESSION['api'])) {
  1176. $user = $this->user->get_api($_SESSION['api']);
  1177. $fgshop = "";
  1178. $sid = "";
  1179. $usersp = explode('|', trim($user['shop'], '|'));
  1180. foreach ($usersp as $value) {
  1181. $fgshop .= " shop = " . $value . " or";
  1182. $sid .= " id = " . $value . " or";
  1183. }
  1184. if ($user['vip'] == 1) {
  1185. $vip = 1;
  1186. }
  1187. } else {
  1188. header('Location: /');
  1189. exit;
  1190. }
  1191. $prc = array();
  1192. $purchase = $this->purchase->find_all();
  1193. foreach ($purchase as $k => $v) {
  1194. $prc[$v['id']] = $v['title'];
  1195. }
  1196. $company = array();
  1197. $ct = $this->company->find_all();
  1198. foreach ($ct as $k => $v) {
  1199. $company[$v['id']] = $v['title'];
  1200. }
  1201. $sp = array();
  1202. $s = $this->shop->find_all('1=1', 'id,shopname');
  1203. foreach ($s as $v) {
  1204. $sp[$v['id']] = $v['shopname'];
  1205. }
  1206. $wh = array();
  1207. $w = $this->warehouse->find_all('1=1', 'id,title');
  1208. foreach ($w as $v) {
  1209. $wh[$v['id']] = $v['title'];
  1210. }
  1211. $post = $this->input->post(NULL, TRUE);
  1212. if (isset($post['page'])) {
  1213. $page = $this->input->post('page', true);
  1214. $perpage = $this->input->post('perpage', true);
  1215. $category = $this->input->post('category', true);
  1216. $size = $this->input->post('size', true);
  1217. $grade = $this->input->post('grade', true);
  1218. $color = $this->input->post('color', true);
  1219. $lowe = $this->input->post('lowe', true);
  1220. $sku = $this->input->post('sku');
  1221. $title = $this->input->post('title');
  1222. $warehouse = $this->input->post('warehouse', true);
  1223. $usa = $this->input->post('usa', true);
  1224. $purchase = $this->input->post('purchase', true);
  1225. $lacetype = $this->input->post('lacetype', true);
  1226. $haircap = $this->input->post('haircap', true);
  1227. $density = $this->input->post('density', true);
  1228. $details = $this->input->post('details', true);
  1229. $state = $this->input->post('state', true);
  1230. $shop = $this->input->post('shop', true);
  1231. $lacecolor = $this->input->post('lacecolor', true);
  1232. $hairnumber = $this->input->post('hairnumber', true);
  1233. $type = $this->input->post('type', true);
  1234. $ktime = $this->input->post('ktime', true);
  1235. $jtime = $this->input->post('jtime', true);
  1236. $ktime = strtotime($ktime);
  1237. $jtime = strtotime($jtime);
  1238. $cpbz = $this->input->post('cpbz', true);
  1239. $sm = $this->input->post('sm', true);
  1240. $where = "1=1";
  1241. $gj = "";
  1242. $ck = "";
  1243. if ($usa) {
  1244. if (!$warehouse) {
  1245. $where .= " and (warehouse = '5' or warehouse = '8')";
  1246. }
  1247. }
  1248. if ($warehouse) {
  1249. $where .= " and warehouse = '$warehouse'";
  1250. }
  1251. if ($details) {
  1252. $where .= " and details = '$details'";
  1253. }
  1254. if ($purchase) {
  1255. $where .= " and purchase = '$purchase'";
  1256. }
  1257. if ($state) {
  1258. $where .= " and state = '$state'";
  1259. }
  1260. if ($shop) {
  1261. $where .= " and shop like '%$shop%'";
  1262. }
  1263. if ($type) {
  1264. $where .= " and type = '$type'";
  1265. }
  1266. if ($ktime && $jtime) {
  1267. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1268. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1269. }
  1270. if ($cpbz) {
  1271. $where .= " and cpbz like '%$cpbz%' ";
  1272. }
  1273. if ($sm) {
  1274. $where .= " and sm like '%$sm%' ";
  1275. }
  1276. if ($lacecolor) {
  1277. $where .= " and features like '%-$lacecolor-%'";
  1278. }
  1279. if ($lacetype) {
  1280. $where .= " and features like '%-$lacetype-%'";
  1281. }
  1282. if ($category) {
  1283. $where .= " and features like '%-$category-%'";
  1284. }
  1285. if ($size) {
  1286. $where .= " and features like '%-$size-%'";
  1287. }
  1288. if ($grade) {
  1289. $where .= " and features like '%-$grade-%'";
  1290. }
  1291. if ($color) {
  1292. $where .= " and features like '%-$color-%'";
  1293. }
  1294. if ($lowe) {
  1295. $where .= " and features like '%-$lowe-%'";
  1296. }
  1297. if ($haircap) {
  1298. $where .= " and features like '%-$haircap-%'";
  1299. }
  1300. if ($density) {
  1301. $where .= " and features like '%-$density-%'";
  1302. }
  1303. if (!empty($hairnumber)) {
  1304. $where .= " and features like '%-128-%' ";
  1305. if ($hairnumber < 0) {
  1306. $class_list = $this->typeclass->find_all('classid = 43');
  1307. foreach ($class_list as $v) {
  1308. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1309. }
  1310. } else {
  1311. $where .= " and features like '%-$hairnumber-%'";
  1312. }
  1313. }
  1314. //数据排序
  1315. $order_str = "id desc";
  1316. if (empty($page)) {
  1317. $start = 0;
  1318. $perpage = 1;
  1319. } else {
  1320. $start = ($page - 1) * $perpage;
  1321. }
  1322. $fjnr = '';
  1323. if ($sku) {
  1324. $sku = trim($sku, ' ');
  1325. $sku = trim($sku, ' ');
  1326. $fjnr .= " and sku like '%$sku%'";
  1327. }
  1328. if ($title) {
  1329. $title = trim($title, ' ');
  1330. $title = trim($title, ' ');
  1331. $fjnr .= " and title like '%$title%'";
  1332. }
  1333. $wt = array();
  1334. $whlabel_type = $this->whlabel_type->find_all();
  1335. foreach ($whlabel_type as $v) {
  1336. $wt[$v['id']] = $v['title'];
  1337. }
  1338. //$where .= " and time > '$ktime' and time < '$jtime'";
  1339. $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
  1340. //取得信息列表
  1341. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1342. $rows = array();
  1343. $list = array();
  1344. foreach ($info_list as $key => $value) {
  1345. if (isset($wt[$value['type']])) {
  1346. $info_list[$key]['type'] = $wt[$value['type']];
  1347. } else {
  1348. $info_list[$key]['type'] = '未设置';
  1349. }
  1350. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1351. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1352. $ztdata = '';
  1353. if (count($zt) > 0) {
  1354. foreach ($zt as $vv) {
  1355. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1356. }
  1357. }
  1358. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1359. $cdata = array_filter($qbdata, function ($item) {
  1360. return $item['state'] < 1;
  1361. });
  1362. $c = array_sum(array_column($cdata, 'jnum'));
  1363. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1364. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1365. });
  1366. $g = array_sum(array_column($gdata, 'jnum'));
  1367. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1368. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1369. });
  1370. $x = array_sum(array_column($xdata, 'jnum'));
  1371. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1373. });
  1374. $t = array_sum(array_column($tdata, 'jnum'));
  1375. // $zdata = array_filter($qbdata, function ($item) {
  1376. // return $item['zd'] != "" && $item['state'] < 1;
  1377. // });
  1378. // $z = array_sum(array_column($zdata, 'jnum'));
  1379. $zdata = array_filter($qbdata, function ($item) {
  1380. return $item['zd'] != "" && $item['state'] < 1;
  1381. });
  1382. $z = array_sum(array_column($zdata, 'jnum'));
  1383. //$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');
  1384. //$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'].'"');
  1385. //$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'].'"');
  1386. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1387. //$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'].'"');
  1388. $details = array();
  1389. $cpid = array();
  1390. $od = array();
  1391. $odid = '';
  1392. $companytitle = '';
  1393. $shop_list = [];
  1394. foreach ($qbdata as $v) {
  1395. if ($v['zd'] != "" && $v['state'] < 1) {
  1396. if (!isset($od[$v['zd']])) {
  1397. $od[$v['zd']] = 1; //所有数据sku
  1398. } else {
  1399. $od[$v['zd']] = $od[$v['zd']] + 1;
  1400. }
  1401. }
  1402. $details[$v['details']] = $v['details'];
  1403. if ($v['state'] < 1) {
  1404. //$details[$v['details']] = $v['details'];
  1405. if ($v['cpid'] != 0) {
  1406. $cpid[$v['cpid']] = $v['cpid'];
  1407. }
  1408. }
  1409. if($v['state'] == 0){
  1410. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1411. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1412. }
  1413. if ($v['shop'] != '') {
  1414. $shop = explode(',', trim($v['shop'], ','));
  1415. foreach ($shop as $vv) {
  1416. if (!in_array($vv, $shop_list)) {
  1417. $shop_list[] = $vv;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. }
  1423. foreach ($od as $k => $vv) {
  1424. $odid .= $k . '数量' . $vv;
  1425. }
  1426. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1427. $info_list[$key]['label'] = $value['sm'];
  1428. $number = $value['number'];
  1429. $ftime = time() - 15 * 24 * 3600;
  1430. $z = $z . '(' . $odid . ')'; //查看订单号
  1431. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1432. $info_list[$key]['features'] = $c;
  1433. $info_list[$key]['number'] = $ztdata;
  1434. $info_list[$key]['sm'] = $g;
  1435. $info_list[$key]['x'] = $x;
  1436. $info_list[$key]['t'] = $t;
  1437. $info_list[$key]['z'] = $z;
  1438. /**
  1439. foreach ($cdata as $k=>$v)
  1440. {
  1441. $details[$v['details']] = $v['details'];
  1442. if($v['cpid'] != 0)
  1443. {
  1444. $cpid[$v['cpid']] = $v['cpid'];
  1445. }
  1446. }
  1447. **/
  1448. $info_list[$key]['shop'] = '';
  1449. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1450. // if ($value['shop'] != '') {
  1451. // $shop = explode(',', trim($value['shop'], ','));
  1452. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1453. // }
  1454. $shop_list = array_unique($shop_list);
  1455. $shop_str = '';
  1456. foreach ($shop_list as $v) {
  1457. if(isset($sp[$v])){
  1458. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1459. }
  1460. }
  1461. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1462. /**
  1463. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1464. if(isset($companytitle[0]))
  1465. {
  1466. foreach ($companytitle as $k=>$v)
  1467. {
  1468. if($v['companytitle'] != '')
  1469. {
  1470. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1471. }
  1472. }
  1473. }
  1474. **/
  1475. }
  1476. $final_all_list = [];
  1477. foreach ($info_list as $k => $v) {
  1478. $final_all_list[] = [
  1479. 'id' => $v['id'],
  1480. "warehouse" => $v["warehouse"],
  1481. "purchase" => $v["purchase"],
  1482. "sku" => $v["sku"],
  1483. "title" => $v["title"] . "<br/>" . $v["pm"],
  1484. "details" => $v["details"],
  1485. "shop" => $v["shop"],
  1486. "cpbz" => $v["cpbz"],
  1487. 'label' => $v['label'],
  1488. "type" => $v["type"],
  1489. "features" => $v["features"],
  1490. "number" => $v["number"],
  1491. "sm" => $v["sm"],
  1492. "x" => $v["x"],
  1493. "t" => $v["t"],
  1494. "z" => $v["z"]
  1495. ];
  1496. }
  1497. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1498. $pagenum = ceil($total / $perpage);
  1499. $over = $total - ($start + $perpage);
  1500. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1501. echo json_encode($rows);
  1502. exit;
  1503. }
  1504. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1505. $this->data['shop'] = $wlshop;
  1506. $this->data['vip'] = $vip;
  1507. $this->_Template('whlabel_type', $this->data);
  1508. }
  1509. //美仓进销存浏览
  1510. public function _usatype()
  1511. {
  1512. if (isset($_SESSION['api'])) {
  1513. $user = $this->user->get_api($_SESSION['api']);
  1514. $usp = $user;
  1515. $fgshop = "";
  1516. $sid = "";
  1517. $wid = "";
  1518. $wtype = "";
  1519. $userwh = explode('|', trim($user['warehouse'], '|'));
  1520. foreach ($userwh as $value) {
  1521. $wid .= " id = " . $value . " or";
  1522. $wtype .= " type = " . $value . " or";
  1523. }
  1524. }
  1525. $prc = array();
  1526. $purchase = $this->purchase->find_all();
  1527. foreach ($purchase as $k => $v) {
  1528. $prc[$v['id']] = $v['title'];
  1529. }
  1530. $post = $this->input->post(NULL, TRUE);
  1531. if (isset($post['page'])) {
  1532. $page = $this->input->post('page', true);
  1533. $perpage = $this->input->post('perpage', true);
  1534. $category = $this->input->post('category', true);
  1535. $size = $this->input->post('size', true);
  1536. $grade = $this->input->post('grade', true);
  1537. $color = $this->input->post('color', true);
  1538. $lowe = $this->input->post('lowe', true);
  1539. $sku = $this->input->post('sku');
  1540. $title = $this->input->post('title');
  1541. $warehouse = $this->input->post('warehouse', true);
  1542. $usa = $this->input->post('usa', true);
  1543. $purchase = $this->input->post('purchase', true);
  1544. $lacetype = $this->input->post('lacetype', true);
  1545. $haircap = $this->input->post('haircap', true);
  1546. $density = $this->input->post('density', true);
  1547. $details = $this->input->post('details', true);
  1548. $state = $this->input->post('state', true);
  1549. $lacecolor = $this->input->post('lacecolor', true);
  1550. $cklx = $this->input->post('cklx', true);
  1551. $ktime = $this->input->post('ktime', true);
  1552. $jtime = $this->input->post('jtime', true);
  1553. $ktime = strtotime($ktime);
  1554. $jtime = strtotime($jtime);
  1555. $where = "1=1";
  1556. $gj = "";
  1557. $ck = "";
  1558. if ($lacetype) {
  1559. $where .= " and features like '%-$lacetype-%'";
  1560. }
  1561. if ($category) {
  1562. $where .= " and features like '%-$category-%'";
  1563. }
  1564. if ($size) {
  1565. $where .= " and features like '%-$size-%'";
  1566. }
  1567. if ($grade) {
  1568. $where .= " and features like '%-$grade-%'";
  1569. }
  1570. if ($color) {
  1571. $where .= " and features like '%-$color-%'";
  1572. }
  1573. if ($lowe) {
  1574. $where .= " and features like '%-$lowe-%'";
  1575. }
  1576. if ($haircap) {
  1577. $where .= " and features like '%-$haircap-%'";
  1578. }
  1579. if ($density) {
  1580. $where .= " and features like '%-$density-%'";
  1581. }
  1582. if ($lacecolor) {
  1583. $where .= " and features like '%-$lacecolor-%'";
  1584. }
  1585. if ($usa) {
  1586. if (!$warehouse) {
  1587. $where .= " and (warehouse = '5' or warehouse = '8')";
  1588. }
  1589. }
  1590. if ($warehouse) {
  1591. $where .= " and warehouse = '$warehouse'";
  1592. }
  1593. if ($details) {
  1594. $where .= " and details = '$details'";
  1595. }
  1596. if ($purchase) {
  1597. $where .= " and purchase = '$purchase'";
  1598. }
  1599. if ($state) {
  1600. $where .= " and state = '$state'";
  1601. }
  1602. $where_add = '';
  1603. if ($cklx) {
  1604. $shop = $this->shop->read($cklx);
  1605. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1606. }
  1607. if ($ktime && $jtime) {
  1608. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1609. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1610. }
  1611. //数据排序
  1612. $order_str = "id desc";
  1613. if (empty($page)) {
  1614. $start = 0;
  1615. $perpage = 1;
  1616. } else {
  1617. $start = ($page - 1) * $perpage;
  1618. }
  1619. if ($sku) {
  1620. $sku = trim($sku, ' ');
  1621. $sku = trim($sku, ' ');
  1622. $where .= " and sku like '%$sku%'";
  1623. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1624. } else if ($title) {
  1625. $title = trim($title, ' ');
  1626. $title = trim($title, ' ');
  1627. $where .= " and title like '%$title%'";
  1628. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1629. } else {
  1630. //$where .= " and time > '$ktime' and time < '$jtime'";
  1631. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1632. }
  1633. //取得信息列表
  1634. $rows = array();
  1635. $list = array();
  1636. foreach ($info_list as $key => $value) {
  1637. $warehouse = $this->warehouse->read($value['warehouse']);
  1638. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1639. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1640. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1641. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1642. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1643. $od = array();
  1644. $odid = '';
  1645. foreach ($z as $v) {
  1646. if (!isset($od[$v['zd']])) {
  1647. $od[$v['zd']] = 1; //所有数据sku
  1648. } else {
  1649. $od[$v['zd']] = $od[$v['zd']] + 1;
  1650. }
  1651. }
  1652. foreach ($od as $k => $vv) {
  1653. $odid .= $k . '数量' . $vv . ' ';
  1654. }
  1655. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1656. $info_list[$key]['features'] = $c;
  1657. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1658. $ztdata = '';
  1659. if (count($zt) > 0) {
  1660. foreach ($zt as $vv) {
  1661. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1662. }
  1663. }
  1664. $info_list[$key]['warehouse'] = $ztdata;
  1665. $info_list[$key]['g'] = $g;
  1666. $info_list[$key]['x'] = $x;
  1667. $info_list[$key]['t'] = $t;
  1668. $info_list[$key]['z'] = $z;
  1669. }
  1670. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1671. $pagenum = ceil($total / $perpage);
  1672. $over = $total - ($start + $perpage);
  1673. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1674. echo json_encode($rows);
  1675. exit;
  1676. }
  1677. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1678. $this->data['warehouse'] = $warehouse;
  1679. $this->_Template('whlabel_typeusa', $this->data);
  1680. }
  1681. //美仓进销存浏览
  1682. public function _usatypeapp()
  1683. {
  1684. $post = $this->input->post(NULL, TRUE);
  1685. if (isset($post['page'])) {
  1686. $page = $this->input->post('page', true);
  1687. $perpage = $this->input->post('perpage', true);
  1688. $sku = $this->input->post('sku', true);
  1689. $warehouse = 5;
  1690. $title = $this->input->post('title', true);
  1691. $state = $this->input->post('state', true);
  1692. $ktime = $this->input->post('ktime', true);
  1693. $jtime = $this->input->post('jtime', true);
  1694. $ktime = strtotime($ktime);
  1695. $jtime = strtotime($jtime);
  1696. $where = "1=1";
  1697. $gj = "";
  1698. $ck = "";
  1699. if ($title) {
  1700. $st = explode(' ', trim($title, ' '));
  1701. foreach ($st as $v) {
  1702. $where .= " and title like '%$v%'";
  1703. }
  1704. }
  1705. if ($warehouse) {
  1706. $where .= " and warehouse = '$warehouse'";
  1707. }
  1708. if ($state) {
  1709. $where .= " and state = '$state'";
  1710. }
  1711. if ($sku) {
  1712. $where .= " and sku like '%$sku%'";
  1713. }
  1714. if ($ktime && $jtime) {
  1715. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1716. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1717. }
  1718. //数据排序
  1719. $order_str = "id desc";
  1720. if (empty($page)) {
  1721. $start = 0;
  1722. $perpage = 1;
  1723. } else {
  1724. $start = ($page - 1) * $perpage;
  1725. }
  1726. //取得信息列表
  1727. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1728. $rows = array();
  1729. $list = array();
  1730. foreach ($info_list as $key => $value) {
  1731. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1732. }
  1733. $rowsdq = array_slice($rows, $start, $perpage);
  1734. foreach ($rowsdq as $value) {
  1735. $warehouse = $this->warehouse->read($value['warehouse']);
  1736. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1737. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1738. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1739. $od = array();
  1740. $odid = '';
  1741. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1742. }
  1743. $total = count($rows);
  1744. $pagenum = ceil($total / $perpage);
  1745. $over = $total - ($start + $perpage);
  1746. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1747. echo json_encode($rows);
  1748. exit;
  1749. }
  1750. $this->_Template('phone/p_usatypeapp', $this->data);
  1751. }
  1752. //入库操作
  1753. public function _enteradd()
  1754. {
  1755. $dt = 0;
  1756. if (isset($_SESSION['api'])) {
  1757. $user = $this->user->get_api($_SESSION['api']);
  1758. $usp = $user;
  1759. $fgshop = "";
  1760. $sid = "";
  1761. $user = explode('|', trim($user['shop'], '|'));
  1762. foreach ($user as $value) {
  1763. $fgshop .= " shop = " . $value . " or";
  1764. $sid .= " id = " . $value . " or";
  1765. }
  1766. }
  1767. $tc = $this->typeclass->find_all();
  1768. $typeclass = array();
  1769. foreach ($tc as $v) {
  1770. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1771. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1772. }
  1773. $post = $this->input->post(NULL, TRUE);
  1774. if (isset($post['sku'])) {
  1775. $list = array();
  1776. $num = "";
  1777. $title = "";
  1778. $features = "";
  1779. $order = $this->input->post('order', true);
  1780. $shop = $this->input->post('shop', true);
  1781. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1782. $sku = $this->input->post('sku', true);
  1783. $post['sm'] = $this->input->post('sm', true);
  1784. $post['warehouse'] = $this->input->post('warehouse', true);
  1785. $post['purchase'] = $this->input->post('purchase', true);
  1786. $post['retreatwarehouse'] = $post['warehouse'];
  1787. $post['state'] = $this->input->post('state', true);
  1788. $post['rktype'] = $this->input->post('rktype', true);
  1789. $post['text'] = $this->input->post('text', true);
  1790. $category = $this->input->post('category', true);
  1791. $list['category'] = $category;
  1792. $list['hairtype'] = $this->input->post('hairtype', true);
  1793. $list['grade'] = $this->input->post('grade', true);
  1794. $size = $this->input->post('size', true);
  1795. $xzsku = $this->input->post('xzsku', true);
  1796. $list['size'] = rtrim($size, ',');
  1797. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1798. $list['extension'] = $this->input->post('extension', true);
  1799. if ($category == 1297) {
  1800. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1801. }
  1802. if ($category == 1702) {
  1803. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1804. $list['syother'] = $this->input->post('syother', true);
  1805. }
  1806. if ($category == 133) {
  1807. $list['fittype'] = $this->input->post('fittype', true);
  1808. $list['acother'] = $this->input->post('acother', true);
  1809. }
  1810. $list['color'] = $this->input->post('color', true);
  1811. $list['lowe'] = $this->input->post('lowe', true);
  1812. if (!$post['purchase']) {
  1813. $post['purchase'] = 1;
  1814. }
  1815. if ($category == 127) {
  1816. $list['type'] = $this->input->post('type', true);
  1817. $list['headroad'] = $this->input->post('headroad', true);
  1818. $list['density'] = $this->input->post('density', true);
  1819. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1820. $list['lacesize'] = $this->input->post('lacesize', true);
  1821. }
  1822. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1823. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1824. }
  1825. if ($category == 128) {
  1826. $list['lacetype'] = $this->input->post('lacetype', true);
  1827. $list['haircap'] = $this->input->post('haircap', true);
  1828. $list['density'] = $this->input->post('density', true);
  1829. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1830. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1831. $list['wigother'] = $this->input->post('wigother', true);
  1832. $list['wigother1'] = $this->input->post('wigother1', true);
  1833. $list['wigother2'] = $this->input->post('wigother2', true);
  1834. }
  1835. if ($category == 129) {
  1836. $list['wide'] = $this->input->post('wide', true);
  1837. }
  1838. if ($category == 131) {
  1839. $list['gifttype'] = $this->input->post('gifttype', true);
  1840. $list['giftother'] = $this->input->post('giftother', true);
  1841. }
  1842. if ($category == 134) {
  1843. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1844. }
  1845. if ($category == 1297) {
  1846. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1847. $list['sywigother'] = $this->input->post('sywigother', true);
  1848. }
  1849. if ($category == 130 || $category == 133 || $category == 1702) {
  1850. $list['items'] = $this->input->post('items', true);
  1851. $list['weight'] = $this->input->post('weight', true);
  1852. }
  1853. if($category == 130){
  1854. $list['jfother'] = $this->input->post('jfother', true);
  1855. }
  1856. if ($category == 1702) {
  1857. $list['syhairther'] = $this->input->post('syhairther', true);
  1858. }
  1859. $classid = $this->classid->sku();
  1860. $scsku = $classid;
  1861. $pm = $classid;
  1862. foreach ($list as $k => $v) {
  1863. if ($v != 0) {
  1864. $num .= $v;
  1865. $features .= $v . '-';
  1866. $post[$k] = $v;
  1867. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1868. if ($k != 'size') {
  1869. $title .= $typeclass[$v]['title'] . " ";
  1870. }
  1871. if (isset($pm[$typeclass[$v]['classid']])) {
  1872. if ($typeclass[$v]['title'] == '9A') {
  1873. $pm[$typeclass[$v]['classid']] = '9A';
  1874. } else if ($typeclass[$v]['title'] == '10A') {
  1875. $pm[$typeclass[$v]['classid']] = '10A';
  1876. } else {
  1877. $clzh = $typeclass[$v]['zh'];
  1878. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1879. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1880. $clzh = $clzh[0];
  1881. }
  1882. $pm[$typeclass[$v]['classid']] = $clzh;
  1883. }
  1884. }
  1885. }
  1886. }
  1887. $zh = implode(" ", $pm);
  1888. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1889. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1890. if ($list['size']) {
  1891. $typeclass = $this->typeclass->read($list['size']);
  1892. $title .= $typeclass['title'];
  1893. }
  1894. $time = time();
  1895. if ($xzsku) {
  1896. $scsku = implode("-", $scsku);
  1897. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1898. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1899. $post['sku'] = trim($scsku, ' ');
  1900. } else {
  1901. $post['sku'] = $sku;
  1902. }
  1903. //$post['sku'] = trim($sku,' ');
  1904. $post['title'] = rtrim($title, ' ');
  1905. $post['number'] = $num;
  1906. $post['features'] = '-' . $features;
  1907. $post['enter'] = $time;
  1908. $post['time'] = $time; //操作时间
  1909. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1910. if ($yza) {
  1911. if ($post['features'] != $yza[0]['features']) {
  1912. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1913. exit;
  1914. }
  1915. }
  1916. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1917. if ($yzb) {
  1918. if ($post['sku'] != $yzb[0]['sku']) {
  1919. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1920. exit;
  1921. }
  1922. }
  1923. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1924. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1925. exit;
  1926. }
  1927. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1928. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1929. exit;
  1930. }
  1931. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1932. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1933. exit;
  1934. }
  1935. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1936. if (isset($yz[0]['type'])) {
  1937. $post['type'] = $yz[0]['type'];
  1938. }
  1939. if ($post['state'] == 9) //如果选择预设库存
  1940. {
  1941. $this->whlabel->insert($post);
  1942. } else {
  1943. /**
  1944. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1945. if($ljg == 1)
  1946. {
  1947. for($i=0;$i<$order;$i++)
  1948. {
  1949. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1950. $this->whlabel->insert($post);
  1951. }
  1952. }
  1953. **/
  1954. //if($post['warehouse'] == '5')
  1955. //{
  1956. //}
  1957. $yydata = $post;
  1958. $yydata['zh'] = $zh;
  1959. /**
  1960. $wl = $this->apiyy->get_cjlp($yydata);
  1961. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1962. {
  1963. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1964. }
  1965. if($wl['Data'][0]['m_isSucess'] != 1)
  1966. {
  1967. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1968. }
  1969. **/
  1970. for ($i = 0; $i < $order; $i++) {
  1971. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1972. $this->whlabel->insert($post);
  1973. }
  1974. }
  1975. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1976. exit;
  1977. }
  1978. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1979. $this->data['wlshop'] = $wlshop;
  1980. $this->_Template('whlabel_enteradd', $this->data);
  1981. }
  1982. //修改产品
  1983. public function _enteredit($arg_array)
  1984. {
  1985. $dt = 0;
  1986. if (isset($_SESSION['api'])) {
  1987. $user = $this->user->get_api($_SESSION['api']);
  1988. $usp = $user;
  1989. $fgshop = "";
  1990. $sid = "";
  1991. $user = explode('|', trim($user['shop'], '|'));
  1992. foreach ($user as $value) {
  1993. $fgshop .= " shop = " . $value . " or";
  1994. $sid .= " id = " . $value . " or";
  1995. }
  1996. }
  1997. $post = $this->input->post(NULL, TRUE);
  1998. if (isset($post['sku'])) {
  1999. $list = array();
  2000. $num = "";
  2001. $title = "";
  2002. $features = "";
  2003. $id = $this->input->post('id', true);
  2004. $order = $this->input->post('order', true);
  2005. $shop = $this->input->post('shop', true);
  2006. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2007. $post['sku'] = $this->input->post('sku', true);
  2008. $post['sm'] = $this->input->post('sm', true);
  2009. $post['warehouse'] = $this->input->post('warehouse', true);
  2010. $post['purchase'] = $this->input->post('purchase', true);
  2011. $post['retreatwarehouse'] = $post['warehouse'];
  2012. $category = $this->input->post('category', true);
  2013. $list['category'] = $category;
  2014. $list['hairtype'] = $this->input->post('hairtype', true);
  2015. $list['grade'] = $this->input->post('grade', true);
  2016. $size = $this->input->post('size', true);
  2017. $list['size'] = rtrim($size, ',');
  2018. $post['rktype'] = $this->input->post('rktype', true);
  2019. $post['text'] = $this->input->post('text', true);
  2020. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2021. $list['extension'] = $this->input->post('extension', true);
  2022. if ($category == 1297) {
  2023. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2024. }
  2025. if ($category == 1702) {
  2026. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2027. $list['syother'] = $this->input->post('syother', true);
  2028. }
  2029. if ($category == 133) {
  2030. $list['fittype'] = $this->input->post('fittype', true);
  2031. $list['acother'] = $this->input->post('acother', true);
  2032. }
  2033. $list['color'] = $this->input->post('color', true);
  2034. $list['lowe'] = $this->input->post('lowe', true);
  2035. if (!$post['purchase']) {
  2036. $post['purchase'] = 1;
  2037. }
  2038. if ($category == 127) {
  2039. $list['type'] = $this->input->post('type', true);
  2040. $list['headroad'] = $this->input->post('headroad', true);
  2041. $list['density'] = $this->input->post('density', true);
  2042. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2043. $list['lacesize'] = $this->input->post('lacesize', true);
  2044. }
  2045. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2046. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2047. }
  2048. if ($category == 128) {
  2049. $list['lacetype'] = $this->input->post('lacetype', true);
  2050. $list['haircap'] = $this->input->post('haircap', true);
  2051. $list['density'] = $this->input->post('density', true);
  2052. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2053. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2054. $list['wigother'] = $this->input->post('wigother', true);
  2055. $list['wigother1'] = $this->input->post('wigother1', true);
  2056. $list['wigother2'] = $this->input->post('wigother2', true);
  2057. }
  2058. if ($category == 129) {
  2059. $list['wide'] = $this->input->post('wide', true);
  2060. }
  2061. if ($category == 131) {
  2062. $list['gifttype'] = $this->input->post('gifttype', true);
  2063. $list['giftother'] = $this->input->post('giftother', true);
  2064. }
  2065. if ($category == 134) {
  2066. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2067. }
  2068. if ($category == 1297) {
  2069. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2070. $list['sywigother'] = $this->input->post('sywigother', true);
  2071. }
  2072. if ($category == 130 || $category == 133 || $category == 1702) {
  2073. $list['items'] = $this->input->post('items', true);
  2074. $list['weight'] = $this->input->post('weight', true);
  2075. }
  2076. if($category == 130){
  2077. $list['jfother'] = $this->input->post('jfother', true);
  2078. }
  2079. if ($category == 1702) {
  2080. $list['syhairther'] = $this->input->post('syhairther', true);
  2081. }
  2082. foreach ($list as $k => $v) {
  2083. if ($v != 0) {
  2084. $num .= $v;
  2085. $features .= $v . '-';
  2086. $typeclass = $this->typeclass->read($v);
  2087. if ($k != 'size') {
  2088. $title .= $typeclass['title'] . " ";
  2089. }
  2090. }
  2091. }
  2092. $typeclass = $this->typeclass->read($list['size']);
  2093. $title .= $typeclass['title'];
  2094. $time = time();
  2095. $post['title'] = rtrim($title, ' ');
  2096. $post['number'] = $num;
  2097. $post['features'] = '-' . $features;
  2098. $post['time'] = $time; //操作时间
  2099. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2100. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2101. exit;
  2102. }
  2103. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2104. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2105. exit;
  2106. }
  2107. $uid = $this->whlabel->read($id);
  2108. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2109. if ($datanum > 0) {
  2110. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2111. exit;
  2112. }
  2113. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2114. {
  2115. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2116. if ($yza) {
  2117. if ($post['features'] != $yza[0]['features']) {
  2118. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2119. exit;
  2120. }
  2121. }
  2122. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2123. if ($yzb) {
  2124. if ($post['sku'] != $yzb[0]['sku']) {
  2125. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2126. exit;
  2127. }
  2128. }
  2129. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2130. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2131. exit;
  2132. }
  2133. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2134. foreach ($data as $v) {
  2135. $post['id'] = $v['id'];
  2136. $this->whlabel->save($post, $v['id']);
  2137. }
  2138. } else {
  2139. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2140. if ($data > 0) {
  2141. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2142. exit;
  2143. } else {
  2144. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2145. foreach ($data as $v) {
  2146. $post['id'] = $v['id'];
  2147. $this->whlabel->save($post, $v['id']);
  2148. }
  2149. }
  2150. }
  2151. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2152. exit;
  2153. }
  2154. $uid = $this->whlabel->read($arg_array[0]);
  2155. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2156. $this->data['enter'] = $uid;
  2157. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2158. $this->data['wlshop'] = $wlshop;
  2159. $this->_Template('whlabel_enteredit', $this->data);
  2160. }
  2161. //入库浏览
  2162. public function _enter()
  2163. {
  2164. $post = $this->input->post(NULL, TRUE);
  2165. if (isset($post['s'])) {
  2166. $id_arr = $this->input->post('s');
  2167. $id_arr = explode(',', $id_arr);
  2168. if (!$id_arr) {
  2169. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2170. exit;
  2171. }
  2172. //循环删除记录
  2173. foreach ($id_arr as $v) {
  2174. $sid = $this->whlabel->read($v);
  2175. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2176. if ($count > 0) {
  2177. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2178. exit;
  2179. }
  2180. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2181. foreach ($info_list as $va) {
  2182. $this->whlabel->remove($va['id']);
  2183. }
  2184. }
  2185. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2186. exit;
  2187. }
  2188. $sp = array();
  2189. $s = $this->shop->find_all('1=1', 'id,shopname');
  2190. foreach ($s as $v) {
  2191. $sp[$v['id']] = $v['shopname'];
  2192. }
  2193. $wh = array();
  2194. $w = $this->warehouse->find_all('1=1', 'id,title');
  2195. foreach ($w as $v) {
  2196. $wh[$v['id']] = $v['title'];
  2197. }
  2198. if (isset($post['page'])) {
  2199. $page = $this->input->post('page', true);
  2200. $perpage = $this->input->post('perpage', true);
  2201. $category = $this->input->post('category', true);
  2202. $size = $this->input->post('size', true);
  2203. $grade = $this->input->post('grade', true);
  2204. $color = $this->input->post('color', true);
  2205. $lowe = $this->input->post('lowe', true);
  2206. $sku = $this->input->post('sku', true);
  2207. $warehouse = $this->input->post('warehouse', true);
  2208. $purchase = $this->input->post('purchase', true);
  2209. $ktime = $this->input->post('ktime', true);
  2210. $jtime = $this->input->post('jtime', true);
  2211. $ktime = strtotime($ktime);
  2212. $jtime = strtotime($jtime);
  2213. $where = "1=1";
  2214. $gj = "";
  2215. $ck = "";
  2216. if ($category) {
  2217. $where .= " and features like '%-$category-%'";
  2218. }
  2219. if ($size) {
  2220. $where .= " and features like '%-$size-%'";
  2221. }
  2222. if ($grade) {
  2223. $where .= " and features like '%-$grade-%'";
  2224. }
  2225. if ($color) {
  2226. $where .= " and features like '%-$color-%'";
  2227. }
  2228. if ($lowe) {
  2229. $where .= " and features like '%-$lowe-%'";
  2230. }
  2231. if ($warehouse) {
  2232. $where .= " and warehouse = '$warehouse'";
  2233. }
  2234. if ($purchase) {
  2235. $where .= " and purchase = '$purchase'";
  2236. }
  2237. if ($sku) {
  2238. $where .= " and sku like '%$sku%'";
  2239. }
  2240. if ($ktime && $jtime) {
  2241. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2242. }
  2243. //数据排序
  2244. $order_str = "enter desc";
  2245. if (empty($page)) {
  2246. $start = 0;
  2247. $perpage = 1;
  2248. } else {
  2249. $start = ($page - 1) * $perpage;
  2250. }
  2251. //取得信息列表
  2252. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2253. foreach ($info_list as $k => $v) {
  2254. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2255. if ($v['shop'] == '') {
  2256. $s = '通用';
  2257. } else {
  2258. $info_list[$k]['shop'] = '';
  2259. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2260. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2261. }
  2262. }
  2263. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2264. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2265. $info_list[$k]['g'] = $g;
  2266. }
  2267. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2268. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2269. $pagenum = ceil($total / $perpage);
  2270. $over = $total - ($start + $perpage);
  2271. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2272. echo json_encode($rows);
  2273. exit;
  2274. }
  2275. $this->_Template('whlabel_enter', $this->data);
  2276. }
  2277. //出库浏览
  2278. public function _out()
  2279. {
  2280. $post = $this->input->post(NULL, TRUE);
  2281. if (isset($post['page'])) {
  2282. $page = $this->input->post('page', true);
  2283. $perpage = $this->input->post('perpage', true);
  2284. $category = $this->input->post('category', true);
  2285. $size = $this->input->post('size', true);
  2286. $grade = $this->input->post('grade', true);
  2287. $color = $this->input->post('color', true);
  2288. $lowe = $this->input->post('lowe', true);
  2289. $sku = $this->input->post('sku', true);
  2290. $warehouse = $this->input->post('warehouse', true);
  2291. $purchase = $this->input->post('purchase', true);
  2292. $state = $this->input->post('state', true);
  2293. $ktime = $this->input->post('ktime', true);
  2294. $jtime = $this->input->post('jtime', true);
  2295. $ktime = strtotime($ktime);
  2296. $jtime = strtotime($jtime);
  2297. $where = "state=3";
  2298. $gj = "";
  2299. $ck = "";
  2300. if ($category) {
  2301. $where .= " and features like '%-$category-%'";
  2302. }
  2303. if ($size) {
  2304. $where .= " and features like '%-$size-%'";
  2305. }
  2306. if ($grade) {
  2307. $where .= " and features like '%-$grade-%'";
  2308. }
  2309. if ($color) {
  2310. $where .= " and features like '%-$color-%'";
  2311. }
  2312. if ($lowe) {
  2313. $where .= " and features like '%-$lowe-%'";
  2314. }
  2315. if ($state) {
  2316. $where .= " and state = '$state'";
  2317. }
  2318. if ($warehouse) {
  2319. $where .= " and warehouse = '$warehouse'";
  2320. }
  2321. if ($purchase) {
  2322. $where .= " and purchase = '$purchase'";
  2323. }
  2324. if ($sku) {
  2325. $where .= " and sku = '$sku'";
  2326. }
  2327. if ($ktime && $jtime) {
  2328. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2329. }
  2330. //数据排序
  2331. $order_str = "id desc";
  2332. if (empty($page)) {
  2333. $start = 0;
  2334. $perpage = 1;
  2335. } else {
  2336. $start = ($page - 1) * $perpage;
  2337. }
  2338. //取得信息列表
  2339. $info_list = $this->whlabel->find_all($where, 'sku');
  2340. $rows = array();
  2341. $list = array();
  2342. foreach ($info_list as $key => $value) {
  2343. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2344. }
  2345. $rows = array_unique($rows); //删除重复记录
  2346. foreach ($rows as $key => $value) {
  2347. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2348. $ck = $this->warehouse->read($data['warehouse']);
  2349. $warehouse = $ck['title'];
  2350. $gy = $this->purchase->read($data['purchase']);
  2351. $purchase = $gy['purchase'];
  2352. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2353. $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);
  2354. }
  2355. $total = count($list);
  2356. $pagenum = ceil($total / $perpage);
  2357. $over = $total - ($start + $perpage);
  2358. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2359. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2360. echo json_encode($rows);
  2361. exit;
  2362. }
  2363. $this->_Template('whlabel_out', $this->data);
  2364. }
  2365. //出库标签浏览
  2366. public function _label()
  2367. {
  2368. $post = $this->input->post(NULL, TRUE);
  2369. if (isset($post['page'])) {
  2370. $page = $this->input->post('page', true);
  2371. $perpage = $this->input->post('perpage', true);
  2372. $sku = $this->input->post('sku', true);
  2373. $warehouse = $this->input->post('warehouse', true);
  2374. $purchase = $this->input->post('purchase', true);
  2375. $orderinfo = $this->input->post('orderinfo', true);
  2376. $waybill = $this->input->post('waybill', true);
  2377. $category = $this->input->post('category', true);
  2378. $size = $this->input->post('size', true);
  2379. $grade = $this->input->post('grade', true);
  2380. $color = $this->input->post('color', true);
  2381. $lowe = $this->input->post('lowe', true);
  2382. $where = "state=1";
  2383. if ($sku) {
  2384. $where .= " and sku = '$sku'";
  2385. }
  2386. if ($warehouse) {
  2387. $where .= " and warehouse = '$warehouse'";
  2388. }
  2389. if ($purchase) {
  2390. $where .= " and purchase = '$purchase'";
  2391. }
  2392. if ($orderinfo) {
  2393. $where .= " and orderinfo = '$orderinfo'";
  2394. }
  2395. if ($waybill) {
  2396. $where .= " and waybill = '$waybill'";
  2397. }
  2398. if ($category) {
  2399. $where .= " and features like '%-$category-%'";
  2400. }
  2401. if ($size) {
  2402. $where .= " and features like '%-$size-%'";
  2403. }
  2404. if ($grade) {
  2405. $where .= " and features like '%-$grade-%'";
  2406. }
  2407. if ($color) {
  2408. $where .= " and features like '%-$color-%'";
  2409. }
  2410. if ($lowe) {
  2411. $where .= " and features like '%-$lowe-%'";
  2412. }
  2413. //数据排序
  2414. $order_str = "outk desc";
  2415. if (empty($page)) {
  2416. $start = 0;
  2417. $perpage = 1;
  2418. } else {
  2419. $start = ($page - 1) * $perpage;
  2420. }
  2421. //取得信息列表
  2422. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2423. foreach ($info_list as $key => $value) {
  2424. $warehouse = $this->warehouse->read($value['warehouse']);
  2425. $info_list[$key]['warehouse'] = $warehouse['title'];
  2426. $purchase = $this->purchase->read($value['purchase']);
  2427. $info_list[$key]['purchase'] = $purchase['title'];
  2428. if ($value['outk'] != 0) {
  2429. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2430. } else {
  2431. $info_list[$key]['outk'] = "";
  2432. }
  2433. if ($value['orderinfo'] == 0) {
  2434. $info_list[$key]['orderinfo'] = "";
  2435. }
  2436. if ($value['waybill'] == 0) {
  2437. $info_list[$key]['waybill'] = "";
  2438. }
  2439. }
  2440. $total = $this->whlabel->find_count($where);
  2441. $pagenum = ceil($total / $perpage);
  2442. $over = $total - ($start + $perpage);
  2443. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2444. echo json_encode($rows);
  2445. exit;
  2446. }
  2447. $this->_Template('whlabel_label', $this->data);
  2448. }
  2449. //独立站出库订单
  2450. public function _outorder()
  2451. {
  2452. if (isset($_SESSION['api'])) {
  2453. $user = $this->user->get_api($_SESSION['api']);
  2454. $usp = $user;
  2455. $fgshop = "";
  2456. $sid = "";
  2457. $user = explode('|', trim($user['shop'], '|'));
  2458. foreach ($user as $value) {
  2459. $fgshop .= " shop = " . $value . " or";
  2460. $sid .= " id = " . $value . " or";
  2461. }
  2462. } else {
  2463. echo "请重新登录";
  2464. }
  2465. $post = $this->input->post(NULL, TRUE);
  2466. if (isset($post['page'])) {
  2467. $page = $this->input->post('page', true);
  2468. $perpage = $this->input->post('perpage', true);
  2469. $warehouse = $this->input->post('warehouse', true);
  2470. $xztime = $this->input->post('xztime', true);
  2471. $timetk = $this->input->post('timetkk', true);
  2472. $timetj = $this->input->post('timetjj', true);
  2473. $shop = $this->input->post('shop', true);
  2474. $source = $this->input->post('source', true);
  2475. $orderinfo = $this->input->post('orderinfo', true);
  2476. $number = $this->input->post('number', true);
  2477. $sfxh = $this->input->post('sfxh', true);
  2478. $express = $this->input->post('express', true);
  2479. $waybill = $this->input->post('waybill', true);
  2480. $library = $this->input->post('library', true);
  2481. $country = $this->input->post('country', true);
  2482. $so = $this->input->post('so', true);
  2483. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2484. $print = $this->input->post('print', true);
  2485. $state = $this->input->post('state', true);
  2486. $orderurl = $this->input->post('orderurl', true);
  2487. $productid = $this->input->post('productid', true);
  2488. $timetk = strtotime($timetk);
  2489. $timetj = strtotime($timetj);
  2490. /**
  2491. $sj = $this->input->post('sj',true);
  2492. if($sj)
  2493. {
  2494. $sj = $this->input->post('sj',true);
  2495. }
  2496. else
  2497. {
  2498. $sj = "fullorder";
  2499. }
  2500. **/
  2501. $sj = "fullorder";
  2502. $where = "1=1";
  2503. if ($warehouse) {
  2504. $where .= " and type = '$warehouse'";
  2505. }
  2506. if ($timetk && $timetj) {
  2507. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2508. }
  2509. if ($orderinfo) {
  2510. $where .= " and orderinfo = '$orderinfo'";
  2511. }
  2512. if ($number) {
  2513. $where .= " and number = '$number'";
  2514. }
  2515. if ($express) {
  2516. $where .= " and express = '$express'";
  2517. }
  2518. if ($waybill) {
  2519. $where .= " and waybill = '$waybill'";
  2520. }
  2521. if ($library) {
  2522. $where .= " and library = '$library'";
  2523. }
  2524. if ($print) {
  2525. $where .= " and print = '$print'";
  2526. }
  2527. if ($libraryconfirm) {
  2528. $where .= " and libraryconfirm = '$libraryconfirm'";
  2529. }
  2530. if ($state) {
  2531. $where .= " and state = '$state'";
  2532. }
  2533. if ($shop) {
  2534. $where .= " and shop = '$shop'";
  2535. }
  2536. if ($country) {
  2537. $where .= " and country = '$country'";
  2538. }
  2539. if ($sfxh != '') {
  2540. $where .= " and sfxh = '$sfxh'";
  2541. }
  2542. if ($so) {
  2543. $where .= " and shipremarks like '%$so%'";
  2544. }
  2545. if ($source) {
  2546. if ($source == '2d') {
  2547. $where .= " and source >= '2'";
  2548. } else {
  2549. $where .= " and source = '$source'";
  2550. }
  2551. }
  2552. if (isset($_SESSION['api'])) {
  2553. foreach ($user as $value) {
  2554. $fgshop .= " shop = " . $value . " or";
  2555. }
  2556. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2557. }
  2558. if ($orderurl) {
  2559. $url = $this->orderurl->read($orderurl);
  2560. $where .= " and link like '%" . $url['url'] . "%'";
  2561. }
  2562. if($productid){
  2563. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2564. }
  2565. //数据排序
  2566. $order_str = "librarytime desc";
  2567. if (empty($page)) {
  2568. $start = 0;
  2569. $perpage = 1;
  2570. } else {
  2571. $start = ($page - 1) * $perpage;
  2572. }
  2573. //取得信息列表
  2574. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2575. //格式化数据
  2576. foreach ($info_list as $key => $value) {
  2577. $shop = $this->shop->read($value['shop']);
  2578. $info_list[$key]['shop'] = $shop['shopname'];
  2579. $express = $this->express->read($value['express']);
  2580. $info_list[$key]['express'] = $express['servicename'];
  2581. $warehouse = $this->warehouse->read($value['type']);
  2582. $info_list[$key]['type'] = $warehouse['title'];
  2583. if ($value['librarytime'] == '0') {
  2584. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2585. } else {
  2586. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2587. }
  2588. }
  2589. $total = $this->$sj->find_count($where);
  2590. $pagenum = ceil($total / $perpage);
  2591. $over = $total - ($start + $perpage);
  2592. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2593. echo json_encode($rows);
  2594. exit;
  2595. }
  2596. $this->data['express'] = $this->express->find_all();
  2597. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2598. $this->data['wlshop'] = $wlshop;
  2599. $user = $this->user->get_api($_SESSION['api']);
  2600. $powerid = $this->power->read($user['power']);
  2601. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2602. $pid = '';
  2603. foreach ($powertext as $v) {
  2604. $pid .= " id = " . $v . " or";
  2605. }
  2606. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2607. $this->data['fullorderexcel'] = $fullorderexcel;
  2608. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2609. $this->data['orderurl'] = $orderurl;
  2610. $this->_Template('whlabel_outorder', $this->data);
  2611. }
  2612. //tt出库
  2613. public function _toutorder()
  2614. {
  2615. $fgshop = "";
  2616. $sid = "";
  2617. if (isset($_SESSION['api'])) {
  2618. $user = $this->user->get_api($_SESSION['api']);
  2619. $usp = $user;
  2620. $user = explode('|', trim($user['shop'], '|'));
  2621. foreach ($user as $value) {
  2622. $fgshop .= " shop = " . $value . " or";
  2623. $sid .= " id = " . $value . " or";
  2624. }
  2625. } else {
  2626. echo "请重新登录";
  2627. die;
  2628. }
  2629. $post = $this->input->post(NULL, TRUE);
  2630. if (isset($post['page'])) {
  2631. $page = $this->input->post('page', true);
  2632. $perpage = $this->input->post('perpage', true);
  2633. $warehouse = $this->input->post('warehouse', true);
  2634. $xztime = $this->input->post('xztime', true);
  2635. $timetk = $this->input->post('timetkk', true);
  2636. $timetj = $this->input->post('timetjj', true);
  2637. $shop = $this->input->post('shop', true);
  2638. $source = $this->input->post('source', true);
  2639. $orderinfo = $this->input->post('orderinfo', true);
  2640. $number = $this->input->post('number', true);
  2641. $sfxh = $this->input->post('sfxh', true);
  2642. $express = $this->input->post('express', true);
  2643. $waybill = $this->input->post('waybill', true);
  2644. $library = $this->input->post('library', true);
  2645. $country = $this->input->post('country', true);
  2646. $so = $this->input->post('so', true);
  2647. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2648. $print = $this->input->post('print', true);
  2649. $state = $this->input->post('state', true);
  2650. $orderurl = $this->input->post('orderurl', true);
  2651. $timetk = strtotime($timetk);
  2652. $timetj = strtotime($timetj);
  2653. /**
  2654. $sj = $this->input->post('sj',true);
  2655. if($sj)
  2656. {
  2657. $sj = $this->input->post('sj',true);
  2658. }
  2659. else
  2660. {
  2661. $sj = "fullorder";
  2662. }
  2663. **/
  2664. $sj = "fullordertt";
  2665. $where = "1=1";
  2666. if ($warehouse) {
  2667. $where .= " and type = '$warehouse'";
  2668. }
  2669. if ($timetk && $timetj) {
  2670. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2671. }
  2672. if ($orderinfo) {
  2673. $where .= " and orderinfo = '$orderinfo'";
  2674. }
  2675. if ($number) {
  2676. $where .= " and number = '$number'";
  2677. }
  2678. if ($express) {
  2679. $where .= " and express = '$express'";
  2680. }
  2681. if ($waybill) {
  2682. $where .= " and waybill = '$waybill'";
  2683. }
  2684. if ($library) {
  2685. $where .= " and library = '$library'";
  2686. }
  2687. if ($print) {
  2688. $where .= " and print = '$print'";
  2689. }
  2690. if ($libraryconfirm) {
  2691. $where .= " and libraryconfirm = '$libraryconfirm'";
  2692. }
  2693. if ($state) {
  2694. $where .= " and state = '$state'";
  2695. }
  2696. if ($shop) {
  2697. $where .= " and shop = '$shop'";
  2698. }
  2699. if ($country) {
  2700. $where .= " and country = '$country'";
  2701. }
  2702. if ($sfxh != '') {
  2703. $where .= " and sfxh = '$sfxh'";
  2704. }
  2705. if ($so) {
  2706. $where .= " and shipremarks like '%$so%'";
  2707. }
  2708. if ($source) {
  2709. if ($source == '2d') {
  2710. $where .= " and source >= '2'";
  2711. } else {
  2712. $where .= " and source = '$source'";
  2713. }
  2714. }
  2715. if (isset($_SESSION['api'])) {
  2716. foreach ($user as $value) {
  2717. $fgshop .= " shop = " . $value . " or";
  2718. }
  2719. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2720. }
  2721. if ($orderurl) {
  2722. $url = $this->orderurl->read($orderurl);
  2723. $where .= " and link like '%" . $url['url'] . "%'";
  2724. }
  2725. //数据排序
  2726. $order_str = "librarytime desc";
  2727. if (empty($page)) {
  2728. $start = 0;
  2729. $perpage = 1;
  2730. } else {
  2731. $start = ($page - 1) * $perpage;
  2732. }
  2733. //取得信息列表
  2734. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2735. //格式化数据
  2736. foreach ($info_list as $key => $value) {
  2737. $shop = $this->shop->read($value['shop']);
  2738. $info_list[$key]['shop'] = $shop['shopname'];
  2739. $express = $this->express->read($value['express']);
  2740. $info_list[$key]['express'] = $express['servicename'];
  2741. $warehouse = $this->warehouse->read($value['type']);
  2742. $info_list[$key]['type'] = $warehouse['title'];
  2743. if ($value['librarytime'] == '0') {
  2744. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2745. } else {
  2746. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2747. }
  2748. }
  2749. $total = $this->$sj->find_count($where);
  2750. $pagenum = ceil($total / $perpage);
  2751. $over = $total - ($start + $perpage);
  2752. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2753. echo json_encode($rows);
  2754. exit;
  2755. }
  2756. $this->data['express'] = $this->express->find_all();
  2757. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2758. $this->data['wlshop'] = $wlshop;
  2759. $user = $this->user->get_api($_SESSION['api']);
  2760. $powerid = $this->power->read($user['power']);
  2761. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2762. $pid = '';
  2763. foreach ($powertext as $v) {
  2764. $pid .= " id = " . $v . " or";
  2765. }
  2766. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2767. $this->data['fullorderexcel'] = $fullorderexcel;
  2768. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2769. $this->data['orderurl'] = $orderurl;
  2770. $this->_Template('whlabel_toutorder', $this->data);
  2771. }
  2772. //tt出库
  2773. public function _aoutorder()
  2774. {
  2775. if (isset($_SESSION['api'])) {
  2776. $user = $this->user->get_api($_SESSION['api']);
  2777. $usp = $user;
  2778. $fgshop = "";
  2779. $sid = "";
  2780. $user = explode('|', trim($user['shop'], '|'));
  2781. foreach ($user as $value) {
  2782. $fgshop .= " shop = " . $value . " or";
  2783. $sid .= " id = " . $value . " or";
  2784. }
  2785. } else {
  2786. echo "请重新登录";
  2787. }
  2788. $post = $this->input->post(NULL, TRUE);
  2789. if (isset($post['page'])) {
  2790. $page = $this->input->post('page', true);
  2791. $perpage = $this->input->post('perpage', true);
  2792. $warehouse = $this->input->post('warehouse', true);
  2793. $xztime = $this->input->post('xztime', true);
  2794. $timetk = $this->input->post('timetkk', true);
  2795. $timetj = $this->input->post('timetjj', true);
  2796. $shop = $this->input->post('shop', true);
  2797. $source = $this->input->post('source', true);
  2798. $orderinfo = $this->input->post('orderinfo', true);
  2799. $number = $this->input->post('number', true);
  2800. $sfxh = $this->input->post('sfxh', true);
  2801. $express = $this->input->post('express', true);
  2802. $waybill = $this->input->post('waybill', true);
  2803. $library = $this->input->post('library', true);
  2804. $country = $this->input->post('country', true);
  2805. $so = $this->input->post('so', true);
  2806. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2807. $print = $this->input->post('print', true);
  2808. $state = $this->input->post('state', true);
  2809. $orderurl = $this->input->post('orderurl', true);
  2810. $timetk = strtotime($timetk);
  2811. $timetj = strtotime($timetj);
  2812. /**
  2813. $sj = $this->input->post('sj',true);
  2814. if($sj)
  2815. {
  2816. $sj = $this->input->post('sj',true);
  2817. }
  2818. else
  2819. {
  2820. $sj = "fullorder";
  2821. }
  2822. **/
  2823. $sj = "fullorderamz";
  2824. $where = "1=1";
  2825. if ($warehouse) {
  2826. $where .= " and type = '$warehouse'";
  2827. }
  2828. if ($timetk && $timetj) {
  2829. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2830. }
  2831. if ($orderinfo) {
  2832. $where .= " and orderinfo = '$orderinfo'";
  2833. }
  2834. if ($number) {
  2835. $where .= " and number = '$number'";
  2836. }
  2837. if ($express) {
  2838. $where .= " and express = '$express'";
  2839. }
  2840. if ($waybill) {
  2841. $where .= " and waybill = '$waybill'";
  2842. }
  2843. if ($library) {
  2844. $where .= " and library = '$library'";
  2845. }
  2846. if ($print) {
  2847. $where .= " and print = '$print'";
  2848. }
  2849. if ($libraryconfirm) {
  2850. $where .= " and libraryconfirm = '$libraryconfirm'";
  2851. }
  2852. if ($state) {
  2853. $where .= " and state = '$state'";
  2854. }
  2855. if ($shop) {
  2856. $where .= " and shop = '$shop'";
  2857. }
  2858. if ($country) {
  2859. $where .= " and country = '$country'";
  2860. }
  2861. if ($sfxh != '') {
  2862. $where .= " and sfxh = '$sfxh'";
  2863. }
  2864. if ($so) {
  2865. $where .= " and shipremarks like '%$so%'";
  2866. }
  2867. if ($source) {
  2868. if ($source == '2d') {
  2869. $where .= " and source >= '2'";
  2870. } else {
  2871. $where .= " and source = '$source'";
  2872. }
  2873. }
  2874. if (isset($_SESSION['api'])) {
  2875. foreach ($user as $value) {
  2876. $fgshop .= " shop = " . $value . " or";
  2877. }
  2878. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2879. }
  2880. if ($orderurl) {
  2881. $url = $this->orderurl->read($orderurl);
  2882. $where .= " and link like '%" . $url['url'] . "%'";
  2883. }
  2884. //数据排序
  2885. $order_str = "librarytime desc";
  2886. if (empty($page)) {
  2887. $start = 0;
  2888. $perpage = 1;
  2889. } else {
  2890. $start = ($page - 1) * $perpage;
  2891. }
  2892. //取得信息列表
  2893. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2894. //格式化数据
  2895. foreach ($info_list as $key => $value) {
  2896. $shop = $this->shop->read($value['shop']);
  2897. $info_list[$key]['shop'] = $shop['shopname'];
  2898. $express = $this->express->read($value['express']);
  2899. $info_list[$key]['express'] = $express['servicename'];
  2900. $warehouse = $this->warehouse->read($value['type']);
  2901. $info_list[$key]['type'] = $warehouse['title'];
  2902. if ($value['librarytime'] == '0') {
  2903. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2904. } else {
  2905. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2906. }
  2907. }
  2908. $total = $this->$sj->find_count($where);
  2909. $pagenum = ceil($total / $perpage);
  2910. $over = $total - ($start + $perpage);
  2911. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2912. echo json_encode($rows);
  2913. exit;
  2914. }
  2915. $this->data['express'] = $this->express->find_all();
  2916. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2917. $this->data['wlshop'] = $wlshop;
  2918. $user = $this->user->get_api($_SESSION['api']);
  2919. $powerid = $this->power->read($user['power']);
  2920. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2921. $pid = '';
  2922. foreach ($powertext as $v) {
  2923. $pid .= " id = " . $v . " or";
  2924. }
  2925. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2926. $this->data['fullorderexcel'] = $fullorderexcel;
  2927. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2928. $this->data['orderurl'] = $orderurl;
  2929. $this->_Template('whlabel_aoutorder', $this->data);
  2930. }
  2931. //速卖通出库订单
  2932. public function _soutorder()
  2933. {
  2934. if (isset($_SESSION['api'])) {
  2935. $user = $this->user->get_api($_SESSION['api']);
  2936. $usp = $user;
  2937. $fgshop = "";
  2938. $sid = "";
  2939. $user = explode('|', trim($user['shop'], '|'));
  2940. foreach ($user as $value) {
  2941. $sid .= " id = " . $value . " or";
  2942. }
  2943. }
  2944. $post = $this->input->post(NULL, TRUE);
  2945. if (isset($post['page'])) {
  2946. $page = $this->input->post('page', true);
  2947. $perpage = $this->input->post('perpage', true);
  2948. $warehouse = $this->input->post('warehouse', true);
  2949. $xztime = $this->input->post('xztime', true);
  2950. $timetk = $this->input->post('timetkk', true);
  2951. $timetj = $this->input->post('timetjj', true);
  2952. $shop = $this->input->post('shop', true);
  2953. $source = $this->input->post('source', true);
  2954. $orderinfo = $this->input->post('orderinfo', true);
  2955. $number = $this->input->post('number', true);
  2956. $express = $this->input->post('express', true);
  2957. $waybill = $this->input->post('waybill', true);
  2958. $library = $this->input->post('library', true);
  2959. $country = $this->input->post('country', true);
  2960. $sfxh = $this->input->post('sfxh', true);
  2961. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2962. $print = $this->input->post('print', true);
  2963. $state = $this->input->post('state', true);
  2964. $so = $this->input->post('so', true);
  2965. $timetk = strtotime($timetk);
  2966. $timetj = strtotime($timetj);
  2967. /**
  2968. $sj = $this->input->post('sj',true);
  2969. if($sj)
  2970. {
  2971. $sj = $this->input->post('sj',true);
  2972. }
  2973. else
  2974. {
  2975. $sj = "fullorder";
  2976. }
  2977. **/
  2978. $sj = "fullordersmt";
  2979. $where = "1=1";
  2980. if ($warehouse) {
  2981. $where .= " and type = '$warehouse'";
  2982. }
  2983. if ($timetk && $timetj) {
  2984. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2985. }
  2986. if ($orderinfo) {
  2987. $where .= " and orderinfo = '$orderinfo'";
  2988. }
  2989. if ($number) {
  2990. $where .= " and number = '$number'";
  2991. }
  2992. if ($express) {
  2993. $where .= " and express = '$express'";
  2994. }
  2995. if ($waybill) {
  2996. $where .= " and waybill = '$waybill'";
  2997. }
  2998. if ($library) {
  2999. $where .= " and library = '$library'";
  3000. }
  3001. if ($print) {
  3002. $where .= " and print = '$print'";
  3003. }
  3004. if ($libraryconfirm) {
  3005. $where .= " and libraryconfirm = '$libraryconfirm'";
  3006. }
  3007. if ($state) {
  3008. $where .= " and state = '$state'";
  3009. }
  3010. if ($shop) {
  3011. $where .= " and shop = '$shop'";
  3012. }
  3013. if ($sfxh != '') {
  3014. $where .= " and sfxh = '$sfxh'";
  3015. }
  3016. if ($so) {
  3017. $where .= " and shipremarks like '%$so%'";
  3018. }
  3019. if ($source) {
  3020. $where .= " and source = '$source'";
  3021. }
  3022. if ($country) {
  3023. $where .= " and country = '$country'";
  3024. } else {
  3025. if (isset($_SESSION['api'])) {
  3026. foreach ($user as $value) {
  3027. $fgshop .= " shop = " . $value . " or";
  3028. }
  3029. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3030. }
  3031. }
  3032. //数据排序
  3033. $order_str = "librarytime desc";
  3034. if (empty($page)) {
  3035. $start = 0;
  3036. $perpage = 1;
  3037. } else {
  3038. $start = ($page - 1) * $perpage;
  3039. }
  3040. //取得信息列表
  3041. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3042. //格式化数据
  3043. foreach ($info_list as $key => $value) {
  3044. $shop = $this->shop->read($value['shop']);
  3045. $info_list[$key]['shop'] = $shop['shopname'];
  3046. $express = $this->express->read($value['express']);
  3047. $info_list[$key]['express'] = $express['servicename'];
  3048. $warehouse = $this->warehouse->read($value['type']);
  3049. $info_list[$key]['type'] = $warehouse['title'];
  3050. if ($value['librarytime'] == '0') {
  3051. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3052. } else {
  3053. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3054. }
  3055. }
  3056. $total = $this->$sj->find_count($where);
  3057. $pagenum = ceil($total / $perpage);
  3058. $over = $total - ($start + $perpage);
  3059. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3060. echo json_encode($rows);
  3061. exit;
  3062. }
  3063. $this->data['express'] = $this->express->find_all();
  3064. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3065. $this->data['wlshop'] = $wlshop;
  3066. $user = $this->user->get_api($_SESSION['api']);
  3067. $powerid = $this->power->read($user['power']);
  3068. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3069. $pid = '';
  3070. foreach ($powertext as $v) {
  3071. $pid .= " id = " . $v . " or";
  3072. }
  3073. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3074. $this->data['fullorderexcel'] = $fullorderexcel;
  3075. $this->_Template('whlabel_soutorder', $this->data);
  3076. }
  3077. //订单退库
  3078. public function _retreat()
  3079. {
  3080. $post = $this->input->post(NULL, TRUE);
  3081. if (isset($post['page'])) {
  3082. $page = $this->input->post('page', true);
  3083. $perpage = $this->input->post('perpage', true);
  3084. $warehouse = $this->input->post('warehouse', true);
  3085. $timetk = $this->input->post('timetk', true);
  3086. $timetj = $this->input->post('timetj', true);
  3087. $shop = $this->input->post('shop', true);
  3088. $source = $this->input->post('source', true);
  3089. $state = $this->input->post('state', true);
  3090. $review = $this->input->post('review', true);
  3091. $state = $this->input->post('state', true);
  3092. $express = $this->input->post('express', true);
  3093. $orderinfo = $this->input->post('orderinfo', true);
  3094. $user = $this->input->post('user', true);
  3095. $name = $this->input->post('name', true);
  3096. $waybill = $this->input->post('waybill', true);
  3097. $timetk = strtotime($timetk);
  3098. $timetj = strtotime($timetj);
  3099. $where = "(state=206 or state=210) and mergeid = 0";
  3100. if ($warehouse) {
  3101. $where .= " and state = '$warehouse'";
  3102. }
  3103. if ($timetk && $timetj) {
  3104. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3105. }
  3106. if ($shop) {
  3107. $where .= " and shop = '$shop'";
  3108. }
  3109. if ($source) {
  3110. $where .= " and source = '$source'";
  3111. }
  3112. if ($state) {
  3113. $where .= " and state = '$state'";
  3114. }
  3115. if ($review) {
  3116. $where .= " and review = '$review'";
  3117. }
  3118. if ($state) {
  3119. $where .= " and state = '$state'";
  3120. }
  3121. if ($express) {
  3122. $where .= " and express = '$express'";
  3123. }
  3124. if ($orderinfo) {
  3125. $where .= " and orderinfo = '$orderinfo'";
  3126. }
  3127. if ($user) {
  3128. $where .= " and user = '$user'";
  3129. }
  3130. if ($name) {
  3131. $where .= " and name = '$name'";
  3132. }
  3133. if ($waybill) {
  3134. $where .= " and waybill = '$waybill'";
  3135. }
  3136. //数据排序
  3137. $order_str = "id desc";
  3138. if (empty($page)) {
  3139. $start = 0;
  3140. $perpage = 1;
  3141. } else {
  3142. $start = ($page - 1) * $perpage;
  3143. }
  3144. //取得信息列表
  3145. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3146. //格式化数据
  3147. foreach ($info_list as $key => $value) {
  3148. $shop = $this->shop->read($value['shop']);
  3149. $info_list[$key]['shop'] = $shop['shopname'];
  3150. $warehouse = $this->warehouse->read($value['warehouse']);
  3151. $info_list[$key]['warehouse'] = $warehouse['title'];
  3152. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3153. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3154. if ($value['waybill'] == 0) {
  3155. $info_list[$key]['waybill'] = "";
  3156. }
  3157. $express = $this->express->read($value['express']);
  3158. $info_list[$key]['express'] = $express['title'];
  3159. $typeclass = $this->typeclass->read($value['state']);
  3160. $info_list[$key]['state'] = $typeclass['title'];
  3161. }
  3162. $total = $this->fullorder->find_count($where);
  3163. $pagenum = ceil($total / $perpage);
  3164. $over = $total - ($start + $perpage);
  3165. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3166. echo json_encode($rows);
  3167. exit;
  3168. }
  3169. $this->data['express'] = $this->express->find_all();
  3170. $this->_Template('whlabel_retreat', $this->data);
  3171. }
  3172. //退库标签浏览
  3173. public function _retreatlk()
  3174. {
  3175. $post = $this->input->post(NULL, TRUE);
  3176. if (isset($post['page'])) {
  3177. $page = $this->input->post('page', true);
  3178. $perpage = $this->input->post('perpage', true);
  3179. $timetk = $this->input->post('timetk', true);
  3180. $timetj = $this->input->post('timetj', true);
  3181. $sku = $this->input->post('sku', true);
  3182. $warehouse = $this->input->post('warehouse', true);
  3183. $purchase = $this->input->post('purchase', true);
  3184. $orderinfo = $this->input->post('orderinfo', true);
  3185. $waybill = $this->input->post('waybill', true);
  3186. $category = $this->input->post('category', true);
  3187. $size = $this->input->post('size', true);
  3188. $grade = $this->input->post('grade', true);
  3189. $color = $this->input->post('color', true);
  3190. $lowe = $this->input->post('lowe', true);
  3191. $state = $this->input->post('state', true);
  3192. $timetk = strtotime($timetk);
  3193. $timetj = strtotime($timetj);
  3194. $where = "state=2";
  3195. if ($timetk && $timetj) {
  3196. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3197. }
  3198. if ($sku) {
  3199. $where .= " and sku = '$sku'";
  3200. }
  3201. if ($warehouse) {
  3202. $where .= " and warehouse = '$warehouse'";
  3203. }
  3204. if ($purchase) {
  3205. $where .= " and purchase = '$purchase'";
  3206. }
  3207. if ($orderinfo) {
  3208. $where .= " and orderinfo = '$orderinfo'";
  3209. }
  3210. if ($waybill) {
  3211. $where .= " and waybill = '$waybill'";
  3212. }
  3213. if ($category) {
  3214. $where .= " and features like '%-$category-%'";
  3215. }
  3216. if ($size) {
  3217. $where .= " and features like '%-$size-%'";
  3218. }
  3219. if ($grade) {
  3220. $where .= " and features like '%-$grade-%'";
  3221. }
  3222. if ($color) {
  3223. $where .= " and features like '%-$color-%'";
  3224. }
  3225. if ($lowe) {
  3226. $where .= " and features like '%-$lowe-%'";
  3227. }
  3228. //数据排序
  3229. $order_str = "time desc";
  3230. if (empty($page)) {
  3231. $start = 0;
  3232. $perpage = 1;
  3233. } else {
  3234. $start = ($page - 1) * $perpage;
  3235. }
  3236. //取得信息列表
  3237. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3238. foreach ($info_list as $key => $value) {
  3239. $warehouse = $this->warehouse->read($value['warehouse']);
  3240. $info_list[$key]['warehouse'] = $warehouse['title'];
  3241. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3242. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3243. $purchase = $this->purchase->read($value['purchase']);
  3244. $info_list[$key]['purchase'] = $purchase['title'];
  3245. if ($value['outk'] != 0) {
  3246. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3247. } else {
  3248. $info_list[$key]['outk'] = "";
  3249. }
  3250. if ($value['retreat'] != 0) {
  3251. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3252. } else {
  3253. $info_list[$key]['retreat'] = "";
  3254. }
  3255. if ($value['orderinfo'] == 0) {
  3256. $info_list[$key]['orderinfo'] = "";
  3257. }
  3258. if ($value['waybill'] == 0) {
  3259. $info_list[$key]['waybill'] = "";
  3260. }
  3261. }
  3262. $total = $this->whlabel->find_count($where);
  3263. $pagenum = ceil($total / $perpage);
  3264. $over = $total - ($start + $perpage);
  3265. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3266. echo json_encode($rows);
  3267. exit;
  3268. }
  3269. $this->_Template('whlabel_retreatlk', $this->data);
  3270. }
  3271. //更换标签及浏览
  3272. public function _change()
  3273. {
  3274. $post = $this->input->post(NULL, TRUE);
  3275. if (isset($post['page'])) {
  3276. $page = $this->input->post('page', true);
  3277. $perpage = $this->input->post('perpage', true);
  3278. $timetk = $this->input->post('timetk', true);
  3279. $timetj = $this->input->post('timetj', true);
  3280. $label = $this->input->post('label', true);
  3281. $oldlabel = $this->input->post('oldlabel', true);
  3282. $timetk = strtotime($timetk);
  3283. $timetj = strtotime($timetj);
  3284. $where = "state=10 ";
  3285. if ($timetk && $timetj) {
  3286. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3287. }
  3288. if ($label) {
  3289. $where .= " and label = '$label'";
  3290. }
  3291. if ($oldlabel) {
  3292. $where .= " and oldlabel = '$oldlabel'";
  3293. }
  3294. //数据排序
  3295. $order_str = "time asc";
  3296. if (empty($page)) {
  3297. $start = 0;
  3298. $perpage = 1;
  3299. } else {
  3300. $start = ($page - 1) * $perpage;
  3301. }
  3302. //取得信息列表
  3303. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3304. foreach ($info_list as $key => $value) {
  3305. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3306. }
  3307. $total = $this->whlabel->find_count($where);
  3308. $pagenum = ceil($total / $perpage);
  3309. $over = $total - ($start + $perpage);
  3310. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3311. echo json_encode($rows);
  3312. exit;
  3313. }
  3314. $this->_Template('whlabel_change', $this->data);
  3315. }
  3316. //产品标签
  3317. public function _cpbqdc()
  3318. {
  3319. if (isset($_GET['excel'])) {
  3320. $where = "1=1";
  3321. //数据排序
  3322. $order_str = "id desc";
  3323. if (empty($page)) {
  3324. $start = 0;
  3325. $perpage = 1;
  3326. } else {
  3327. $start = ($page - 1) * $perpage;
  3328. }
  3329. $warehouse = $this->input->get('warehouse', true);
  3330. $state = $this->input->get('state', true);
  3331. $timetk = $this->input->get('timetkk', true);
  3332. $timetj = $this->input->get('timetjj', true);
  3333. $timetk = strtotime($timetk);
  3334. $timetj = strtotime($timetj);
  3335. if ($warehouse) {
  3336. $where .= " and warehouse = '$warehouse'";
  3337. }
  3338. if ($state || $state == 0) {
  3339. $where .= " and state = '$state'";
  3340. }
  3341. if ($timetk && $timetj) {
  3342. $where .= " and time > '$timetk' and time < '$timetj'";
  3343. }
  3344. //取得信息列表
  3345. $info_list = $this->whlabel->find_all($where, '*');
  3346. $rows = array();
  3347. $list = array();
  3348. foreach ($info_list as $key => $value) {
  3349. $rows[$value['time']] = $value; //所有数据sku
  3350. }
  3351. foreach ($rows as $value) {
  3352. $warehouse = $this->warehouse->read($value['warehouse']);
  3353. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3354. $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);
  3355. }
  3356. $title = "产品标签统计表";
  3357. $titlename = "<table border=1>
  3358. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3359. <tr align='center'>
  3360. <td>仓库</td>
  3361. <td>SKU</td>
  3362. <td>产品</td>
  3363. <td>入库时间</td>
  3364. <td>操作时间</td>
  3365. <td>备注</td>
  3366. <td>数量</td>
  3367. </tr>
  3368. </table>";
  3369. $filename = $title . ".xls";
  3370. $tail = "";
  3371. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3372. }
  3373. }
  3374. //进销存导出
  3375. public function _exceljxc()
  3376. {
  3377. $classid = $this->classid->sku();
  3378. $pm = $classid;
  3379. $typeclass = array();
  3380. $tc = $this->typeclass->find_all();
  3381. foreach ($tc as $v) {
  3382. $typeclass[$v['id']] = $v;
  3383. }
  3384. $prc = array();
  3385. $purchase = $this->purchase->find_all();
  3386. foreach ($purchase as $k => $v) {
  3387. $prc[$v['id']] = $v['title'];
  3388. }
  3389. if (isset($_GET['excel'])) {
  3390. $where = "sku != 'Preset'";
  3391. //数据排序
  3392. $order_str = "id desc";
  3393. if (empty($page)) {
  3394. $start = 0;
  3395. $perpage = 1;
  3396. } else {
  3397. $start = ($page - 1) * $perpage;
  3398. }
  3399. $category = $this->input->get('category', true);
  3400. $warehouse = $this->input->get('warehouse', true);
  3401. $excelid = $this->input->get('sid', true);
  3402. if ($category) {
  3403. $where .= " and features like '%-$category-%'";
  3404. }
  3405. if ($warehouse) {
  3406. $where .= " and warehouse = '$warehouse'";
  3407. }
  3408. $xzid = '';
  3409. if ($excelid) {
  3410. $excelid = explode(',', trim($excelid, ','));
  3411. foreach ($excelid as $key => $value) {
  3412. $xzid .= " id = " . $value . " or";
  3413. }
  3414. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3415. }
  3416. //取得信息列表
  3417. /**
  3418. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3419. $rows = array();$list = array();
  3420. foreach ($info_list as $key=>$value)
  3421. {
  3422. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3423. }
  3424. **/
  3425. $wt = array();
  3426. $whlabel_type = $this->whlabel_type->find_all();
  3427. foreach ($whlabel_type as $v) {
  3428. $wt[$v['id']] = $v['title'];
  3429. }
  3430. $wh = array();
  3431. $w = $this->warehouse->find_all('1=1', 'id,title');
  3432. foreach ($w as $v) {
  3433. $wh[$v['id']] = $v['title'];
  3434. }
  3435. $list = array();
  3436. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3437. foreach ($rows as $key => $value) {
  3438. if (isset($wt[$value['type']])) {
  3439. $rows[$key]['type'] = $wt[$value['type']];
  3440. } else {
  3441. $rows[$key]['type'] = '未设置';
  3442. }
  3443. $bm = '03';
  3444. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3445. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3446. $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');
  3447. $details = array();
  3448. $cpid = array();
  3449. $cpbz = array();
  3450. $c = 0;
  3451. $g = 0;
  3452. $x = 0;
  3453. $t = 0;
  3454. $s = 0;
  3455. $q = 0;
  3456. foreach ($sd as $k => $v) {
  3457. if ($v['state'] == 0) {
  3458. $c++;
  3459. if ($v['cpid'] != 0) {
  3460. $cpid[$v['cpid']] = $v['cpid'];
  3461. }
  3462. if ($v['cpbz'] != '') {
  3463. $cpbz[$v['cpbz']] = $v['cpbz'];
  3464. }
  3465. }
  3466. if ($v['state'] != 9) {
  3467. $g++;
  3468. }
  3469. if ($v['state'] == 1) {
  3470. $x++;
  3471. }
  3472. if ($v['state'] == 2) {
  3473. $t++;
  3474. }
  3475. if ($v['state'] == 8) {
  3476. $s++;
  3477. }
  3478. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3479. $q++;
  3480. }
  3481. $details[$v['details']] = $v['details'];
  3482. }
  3483. $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'] . '"');
  3484. $rows[$key]['details'] = implode("、", $details);
  3485. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3486. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3487. $number = $value['number'];
  3488. $ftime = time() - 15 * 24 * 3600;
  3489. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3490. $rows[$key]['number'] = $g;
  3491. $rows[$key]['c'] = $c;
  3492. $rows[$key]['x'] = $x;
  3493. $rows[$key]['t'] = $t;
  3494. $rows[$key]['s'] = $s;
  3495. $rows[$key]['q'] = $q;
  3496. $rows[$key]['z'] = $z;
  3497. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3498. $features = explode('-', trim($features, '-'));
  3499. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3500. // $pm = $classid;
  3501. // $jm = $classid;
  3502. // foreach($features as $k=>$v)
  3503. // {
  3504. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3505. // {
  3506. // if($typeclass[$v]['bm'] != '')
  3507. // {
  3508. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3509. // }
  3510. // }
  3511. // if($v != 0)
  3512. // {
  3513. // if(!isset($typeclass[$v]))
  3514. // {
  3515. // continue;
  3516. // }
  3517. // if(isset($pm[$typeclass[$v]['classid']]))
  3518. // {
  3519. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3520. // {
  3521. // $tz = explode('|',$typeclass[$v]['zh']);
  3522. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3523. // }
  3524. // else
  3525. // {
  3526. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3527. // }
  3528. // }
  3529. // if(isset($jm[$typeclass[$v]['classid']]))
  3530. // {
  3531. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3532. // }
  3533. // }
  3534. // }
  3535. // $jm = array_filter($jm);
  3536. // $rows[$key]['bs'] = implode("-",$jm);
  3537. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3538. // $zh = implode(" ",$pm);
  3539. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3540. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3541. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3542. // $rows[$key]['features'] = $zh;
  3543. }
  3544. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3545. $final_list = [];
  3546. foreach ($list as $k => $v) {
  3547. if (empty($v['sku'])) {
  3548. continue;
  3549. }
  3550. $final_list[] = [
  3551. "warehouse" => $v["warehouse"],
  3552. "purchase" => $v["purchase"],
  3553. "details" => $v["details"],
  3554. "cpid" => $v["cpid"],
  3555. "dbcontent" => $v["dbcontent"],
  3556. "sku" => $v["sku"],
  3557. "cs" => $v["bm"],
  3558. "bs" => $v["jm"],
  3559. "title" => $v["title"],
  3560. "features" => $v["pm"],
  3561. "cpbz" => $v["cpbz"],
  3562. "sm" => $v["sm"],
  3563. "type" => $v["type"],
  3564. "number" => $v["number"],
  3565. "c" => $v["c"],
  3566. "x" => $v["x"],
  3567. "t" => $v["t"],
  3568. "s" => $v["s"],
  3569. "q" => $v["q"],
  3570. "z" => $v["z"],
  3571. "weight" => $v['weight'],
  3572. ];
  3573. }
  3574. $title = "总进销存统计表";
  3575. $titlename = "<table border=1>
  3576. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3577. <tr align='center'>
  3578. <td>仓库</td>
  3579. <td>供应商</td>
  3580. <td>位置</td>
  3581. <td>库存编码</td>
  3582. <td>类目</td>
  3583. <td>SKU</td>
  3584. <td>用友编码</td>
  3585. <td>用友料号</td>
  3586. <td>商品名称</td>
  3587. <td>商品中文</td>
  3588. <td>产品备注</td>
  3589. <td>库位负责人</td>
  3590. <td>类型</td>
  3591. <td>入库总量</td>
  3592. <td>库存数量</td>
  3593. <td>销售数量</td>
  3594. <td>退货数量</td>
  3595. <td>删除数量</td>
  3596. <td>其它操作</td>
  3597. <td>占单数量</td>
  3598. <td>重量(g)</td>
  3599. </tr>
  3600. </table>";
  3601. $filename = $title . ".xls";
  3602. $tail = "";
  3603. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3604. }
  3605. }
  3606. //入库导出
  3607. public function _excelr()
  3608. {
  3609. if (isset($_GET['excel'])) {
  3610. $category = $this->input->get('category', true);
  3611. $size = $this->input->get('size', true);
  3612. $grade = $this->input->get('grade', true);
  3613. $color = $this->input->get('color', true);
  3614. $lowe = $this->input->get('lowe', true);
  3615. $sku = $this->input->get('sku', true);
  3616. $warehouse = $this->input->get('warehouse', true);
  3617. $purchase = $this->input->get('purchase', true);
  3618. $ktime = $this->input->get('ktime', true);
  3619. $jtime = $this->input->get('jtime', true);
  3620. $ktime = strtotime($ktime);
  3621. $jtime = strtotime($jtime);
  3622. $where = "1=1";
  3623. $gj = "";
  3624. $ck = "";
  3625. if ($category) {
  3626. $where .= " and features like '%-$category-%'";
  3627. }
  3628. if ($size) {
  3629. $where .= " and features like '%-$size-%'";
  3630. }
  3631. if ($grade) {
  3632. $where .= " and features like '%-$grade-%'";
  3633. }
  3634. if ($color) {
  3635. $where .= " and features like '%-$color-%'";
  3636. }
  3637. if ($lowe) {
  3638. $where .= " and features like '%-$lowe-%'";
  3639. }
  3640. if ($warehouse) {
  3641. $where .= " and warehouse = '$warehouse'";
  3642. }
  3643. if ($purchase) {
  3644. $where .= " and purchase = '$purchase'";
  3645. }
  3646. if ($sku) {
  3647. $where .= " and sku = '$sku'";
  3648. }
  3649. if ($ktime && $jtime) {
  3650. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3651. }
  3652. //数据排序
  3653. $order_str = "id desc";
  3654. if (empty($page)) {
  3655. $start = 0;
  3656. $perpage = 1;
  3657. } else {
  3658. $start = ($page - 1) * $perpage;
  3659. }
  3660. $list = array();
  3661. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3662. foreach ($rows as $value) {
  3663. $ck = $this->warehouse->read($value['warehouse']);
  3664. $warehouse = $ck['title'];
  3665. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3666. $retreatwarehouse = $tkck['title'];
  3667. $gy = $this->purchase->read($value['purchase']);
  3668. $purchase = $gy['title'];
  3669. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3670. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3671. }
  3672. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3673. $titlename = "<table border=1>
  3674. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3675. <tr align='center'>
  3676. <td>仓库</td>
  3677. <td>SKU</td>
  3678. <td>产品</td>
  3679. <td>时间</td>
  3680. <td>数量</td>
  3681. </tr>
  3682. </table>";
  3683. $filename = $title . ".xls";
  3684. $tail = "";
  3685. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3686. }
  3687. }
  3688. //出库、退库导出
  3689. public function _excelct()
  3690. {
  3691. $classid = $this->classid->sku();
  3692. $pm = $classid;
  3693. $typeclass = array();
  3694. $tc = $this->typeclass->find_all();
  3695. foreach ($tc as $v) {
  3696. $typeclass[$v['id']] = $v;
  3697. }
  3698. $prc = array();
  3699. $purchase = $this->purchase->find_all();
  3700. foreach ($purchase as $k => $v) {
  3701. $prc[$v['id']] = $v['title'];
  3702. }
  3703. if (isset($_GET['excel'])) {
  3704. $wh = array();
  3705. $w = $this->warehouse->find_all('1=1', 'id,title');
  3706. foreach ($w as $v) {
  3707. $wh[$v['id']] = $v['title'];
  3708. }
  3709. $type = $this->input->get('excel', true);
  3710. $category = $this->input->get('category', true);
  3711. $size = $this->input->get('size', true);
  3712. $grade = $this->input->get('grade', true);
  3713. $color = $this->input->get('color', true);
  3714. $lowe = $this->input->get('lowe', true);
  3715. $sku = $this->input->get('sku', true);
  3716. $title = $this->input->get('title', true);
  3717. $warehouse = $this->input->get('warehouse', true);
  3718. $purchase = $this->input->get('purchase', true);
  3719. $lacetype = $this->input->get('lacetype', true);
  3720. $haircap = $this->input->get('haircap', true);
  3721. $lacecolor = $this->input->get('lacecolor', true);
  3722. $density = $this->input->get('density', true);
  3723. $details = $this->input->get('details', true);
  3724. $state = $this->input->get('state', true);
  3725. $shop = $this->input->get('shop', true);
  3726. $hairnumber = $this->input->get('hairnumber', true);
  3727. $type_leixi = $this->input->get('type', true);
  3728. $cpbz = $this->input->get('cpbz', true);
  3729. $sm = $this->input->get('sm', true);
  3730. $sid = $this->input->get('sid', true);
  3731. $ktime = $this->input->get('ktime', true);
  3732. $jtime = $this->input->get('jtime', true);
  3733. $ktime = strtotime($ktime);
  3734. $jtime = strtotime($jtime);
  3735. //$where = " 1=1 ";
  3736. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3737. $where = " sku != '' ";
  3738. $gj = "";
  3739. $ck = "";
  3740. if ($category) {
  3741. $where .= " and features like '%-$category-%'";
  3742. }
  3743. if ($size) {
  3744. $where .= " and features like '%-$size-%'";
  3745. }
  3746. if ($grade) {
  3747. $where .= " and features like '%-$grade-%'";
  3748. }
  3749. if ($color) {
  3750. $where .= " and features like '%-$color-%'";
  3751. }
  3752. if ($lowe) {
  3753. $where .= " and features like '%-$lowe-%'";
  3754. }
  3755. if ($warehouse) {
  3756. $where .= " and warehouse = '$warehouse'";
  3757. }
  3758. if ($purchase) {
  3759. $where .= " and purchase = '$purchase'";
  3760. }
  3761. if ($state) {
  3762. $where .= " and state = '$state'";
  3763. }
  3764. if ($lacetype) {
  3765. $where .= " and features like '%-$lacetype-%'";
  3766. }
  3767. if ($lacecolor) {
  3768. $where .= " and features like '%-$lacecolor-%'";
  3769. }
  3770. if ($density) {
  3771. $where .= " and features like '%-$density-%'";
  3772. }
  3773. if ($haircap) {
  3774. $where .= " and features like '%-$haircap-%'";
  3775. }
  3776. if ($details) {
  3777. $where .= " and details = '$details'";
  3778. }
  3779. if ($shop) {
  3780. $where .= " and shop like '%$shop%'";
  3781. }
  3782. if ($title) {
  3783. $title = trim($title, ' ');
  3784. $title = trim($title, ' ');
  3785. $where .= " and title like '%$title%'";
  3786. }
  3787. if (!empty($hairnumber)) {
  3788. $where .= " and features like '%-128-%' ";
  3789. if ($hairnumber < 0) {
  3790. $class_list = $this->typeclass->find_all('classid = 43');
  3791. foreach ($class_list as $v) {
  3792. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3793. }
  3794. } else {
  3795. $where .= " and features like '%-$hairnumber-%'";
  3796. }
  3797. }
  3798. if ($type_leixi) {
  3799. $where .= " and type = '$type_leixi'";
  3800. }
  3801. if ($cpbz) {
  3802. $where .= " and cpbz like '%$cpbz%' ";
  3803. }
  3804. if ($sm) {
  3805. $where .= " and sm like '%$sm%' ";
  3806. }
  3807. if ($sku) {
  3808. $sku = trim($sku, ' ');
  3809. $sku = trim($sku, ' ');
  3810. $where .= " and sku like '%$sku%'";
  3811. }
  3812. if ($ktime && $jtime) {
  3813. if ($type == 1) {
  3814. $tl = '出库';
  3815. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3816. } else if ($type == 2) {
  3817. $tl = '退库';
  3818. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3819. } else if ($type == 3) {
  3820. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3821. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3822. } else if ($type == 4) {
  3823. $tl = '出库+零售';
  3824. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3825. } else if ($type == 5) {
  3826. $tl = '零售';
  3827. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3828. }
  3829. }
  3830. $sidwhere = '';
  3831. if ($sid) {
  3832. $sd = "";
  3833. $s = explode(',', trim($sid, ','));
  3834. foreach ($s as $value) {
  3835. $sd .= " id = " . $value . " or";
  3836. }
  3837. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3838. }
  3839. //数据排序
  3840. $order_str = "time desc";
  3841. if (empty($page)) {
  3842. $start = 0;
  3843. $perpage = 1;
  3844. } else {
  3845. $start = ($page - 1) * $perpage;
  3846. }
  3847. //取得信息列表
  3848. if ($type != 3 && $type != 5) {
  3849. if ($type == 1 || $type == 4) {
  3850. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3851. foreach ($info_list as $key => $value) {
  3852. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3853. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3854. $warehouse = $this->warehouse->read($value['warehouse']);
  3855. $info_list[$key]['warehouse'] = $warehouse['title'];
  3856. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3857. $features = explode('-', trim($features, '-'));
  3858. $pm = $classid;
  3859. foreach ($features as $k => $v) {
  3860. if ($v != 0) {
  3861. if (!isset($typeclass[$v])) {
  3862. continue;
  3863. }
  3864. if (isset($pm[$typeclass[$v]['classid']])) {
  3865. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3866. $tz = explode('|', $typeclass[$v]['zh']);
  3867. $pm[$typeclass[$v]['classid']] = $tz[0];
  3868. } else {
  3869. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3870. }
  3871. }
  3872. }
  3873. }
  3874. $zh = implode(" ", $pm);
  3875. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3876. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3877. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3878. $info_list[$key]['features'] = $zh;
  3879. }
  3880. $final_list = [];
  3881. foreach($info_list as $k=>$v){
  3882. $number = "";
  3883. if(!empty($v['orderinfo'])){
  3884. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3885. if(!empty($tmp_info['number'])){
  3886. $number = $tmp_info['number'];
  3887. }
  3888. }
  3889. $final_list[] = [
  3890. 'warehouse'=>$v['warehouse'],
  3891. 'purchase'=>$v['purchase'],
  3892. 'sku'=>$v['sku'],
  3893. 'title'=>$v['title'],
  3894. 'features'=>$v['features'],
  3895. 'label'=>$v['label'],
  3896. 'orderinfo'=>$v['orderinfo'],
  3897. 'number'=>$number,
  3898. 'waybill'=>$v['waybill'],
  3899. 'outk'=>$v['outk'],
  3900. ];
  3901. }
  3902. } else {
  3903. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3904. foreach ($info_list as $key => $value) {
  3905. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3906. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3907. $warehouse = $this->warehouse->read($value['warehouse']);
  3908. $info_list[$key]['warehouse'] = $warehouse['title'];
  3909. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3910. $features = explode('-', trim($features, '-'));
  3911. $pm = $classid;
  3912. foreach ($features as $k => $v) {
  3913. if ($v != 0) {
  3914. if (!isset($typeclass[$v])) {
  3915. continue;
  3916. }
  3917. if (isset($pm[$typeclass[$v]['classid']])) {
  3918. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3919. $tz = explode('|', $typeclass[$v]['zh']);
  3920. $pm[$typeclass[$v]['classid']] = $tz[0];
  3921. } else {
  3922. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3923. }
  3924. }
  3925. }
  3926. }
  3927. $zh = implode(" ", $pm);
  3928. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3929. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3930. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3931. $info_list[$key]['features'] = $zh;
  3932. }
  3933. $final_list = [];
  3934. foreach($info_list as $k=>$v){
  3935. $number = "";
  3936. if(!empty($v['orderinfo'])){
  3937. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3938. if(!empty($tmp_info['number'])){
  3939. $number = $tmp_info['number'];
  3940. }
  3941. }
  3942. $final_list[] = [
  3943. 'warehouse'=>$v['warehouse'],
  3944. 'purchase'=>$v['purchase'],
  3945. 'sku'=>$v['sku'],
  3946. 'title'=>$v['title'],
  3947. 'features'=>$v['features'],
  3948. 'label'=>$v['label'],
  3949. 'orderinfo'=>$v['orderinfo'],
  3950. 'number'=>$number,
  3951. 'waybill'=>$v['waybill'],
  3952. 'retreat'=>$v['retreat'],
  3953. ];
  3954. }
  3955. }
  3956. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3957. $titlename = "<table border=1>
  3958. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3959. <tr align='center'>
  3960. <td>仓库</td>
  3961. <td>供应商</td>
  3962. <td>SKU</td>
  3963. <td>商品名称</td>
  3964. <td>商品中文</td>
  3965. <td>标签</td>
  3966. <td>订单号</td>
  3967. <td>订单编码</td>
  3968. <td>运单号</td>
  3969. <td>" . $tl . "时间(中国时间)</td>
  3970. </tr>
  3971. </table>";
  3972. $filename = $title . ".xls";
  3973. $tail = "";
  3974. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3975. } else if ($type == 5) {
  3976. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3977. foreach ($info_list as $key => $value) {
  3978. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3979. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3980. $warehouse = $this->warehouse->read($value['warehouse']);
  3981. $info_list[$key]['warehouse'] = $warehouse['title'];
  3982. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3983. $features = explode('-', trim($features, '-'));
  3984. $pm = $classid;
  3985. foreach ($features as $k => $v) {
  3986. if ($v != 0) {
  3987. if (!isset($typeclass[$v])) {
  3988. continue;
  3989. }
  3990. if (isset($pm[$typeclass[$v]['classid']])) {
  3991. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3992. $tz = explode('|', $typeclass[$v]['zh']);
  3993. $pm[$typeclass[$v]['classid']] = $tz[0];
  3994. } else {
  3995. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3996. }
  3997. }
  3998. }
  3999. }
  4000. $zh = implode(" ", $pm);
  4001. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4002. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4003. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4004. $info_list[$key]['features'] = $zh;
  4005. }
  4006. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4007. $titlename = "<table border=1>
  4008. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4009. <tr align='center'>
  4010. <td>仓库</td>
  4011. <td>供应商</td>
  4012. <td>SKU</td>
  4013. <td>商品名称</td>
  4014. <td>商品中文</td>
  4015. <td>标签</td>
  4016. <td>" . $tl . "时间(中国时间)</td>
  4017. </tr>
  4018. </table>";
  4019. $filename = $title . ".xls";
  4020. $tail = "";
  4021. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4022. } else {
  4023. /**
  4024. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4025. $rows = array();$list = array();
  4026. foreach ($info_list as $key=>$value)
  4027. {
  4028. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4029. }
  4030. **/
  4031. $wh = array();
  4032. $w = $this->warehouse->find_all('1=1', 'id,title');
  4033. foreach ($w as $v) {
  4034. $wh[$v['id']] = $v['title'];
  4035. }
  4036. $wt = array();
  4037. $whlabel_type = $this->whlabel_type->find_all();
  4038. foreach ($whlabel_type as $v) {
  4039. $wt[$v['id']] = $v['title'];
  4040. }
  4041. $classid = $this->classid->sku();
  4042. $list = array();
  4043. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4044. foreach ($rows as $key => $value) {
  4045. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4046. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4047. $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');
  4048. $details = array();
  4049. $cpid = array();
  4050. $cpbz = array();
  4051. $c = 0;
  4052. $g = 0;
  4053. $x = 0;
  4054. $t = 0;
  4055. $s = 0;
  4056. $q = 0;
  4057. foreach ($sd as $k => $v) {
  4058. if ($v['state'] == 0) {
  4059. $c++;
  4060. }
  4061. if ($v['state'] != 9) {
  4062. $g++;
  4063. }
  4064. if ($v['outk'] > 1) {
  4065. $x++;
  4066. }
  4067. if ($v['retreat'] > 0) {
  4068. $t++;
  4069. }
  4070. if ($v['state'] == 8) {
  4071. $s++;
  4072. }
  4073. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4074. $q++;
  4075. }
  4076. $details[$v['details']] = $v['details'];
  4077. if ($v['cpid'] != 0) {
  4078. $cpid[$v['cpid']] = $v['cpid'];
  4079. }
  4080. if ($v['cpbz'] != '') {
  4081. $cpbz[$v['cpbz']] = $v['cpbz'];
  4082. }
  4083. }
  4084. if (isset($wt[$value['type']])) {
  4085. $rows[$key]['type'] = $wt[$value['type']];
  4086. } else {
  4087. $rows[$key]['type'] = '未设置';
  4088. }
  4089. $rows[$key]['details'] = implode("、", $details);
  4090. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4091. $ftime = time() - 15 * 24 * 3600;
  4092. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4093. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4094. $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);
  4095. $rows[$key]['c'] = $c;
  4096. $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);
  4097. $rows[$key]['t'] = $t;
  4098. $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'] . '"');
  4099. $rows[$key]['z'] = $z;
  4100. // $jm = $classid;
  4101. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4102. $features = explode('-', trim($features, '-'));
  4103. // $pm = $classid;
  4104. // foreach ($features as $k => $v) {
  4105. // if ($v != 0) {
  4106. // if (!isset($typeclass[$v])) {
  4107. // continue;
  4108. // }
  4109. // if (isset($pm[$typeclass[$v]['classid']])) {
  4110. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4111. // $tz = explode('|', $typeclass[$v]['zh']);
  4112. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4113. // } else {
  4114. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4115. // }
  4116. // if (isset($jm[$typeclass[$v]['classid']])) {
  4117. // if ($typeclass[$v]['jm']) {
  4118. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4119. // }
  4120. // }
  4121. // }
  4122. // }
  4123. // }
  4124. // $zh = implode(" ", $pm);
  4125. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4126. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4127. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4128. // $rows[$key]['features'] = $zh;
  4129. // $jm = array_filter($jm); //去除空值
  4130. // $jm = implode("-", $jm);
  4131. // $rows[$key]['jm'] = $jm;
  4132. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4133. }
  4134. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4135. // echo "<pre>";
  4136. // print_r($tmp_list);
  4137. // die;
  4138. $final_list =[];
  4139. foreach($tmp_list as $k=>$v){
  4140. $final_list[] = [
  4141. "warehouse"=>$v['warehouse'],
  4142. "purchase"=>$v['purchase'],
  4143. "details"=>trim($v['details'],'、'),
  4144. "cpid"=>$v['cpid'],
  4145. "sku"=>$v['sku'],
  4146. "title"=>$v['title'],
  4147. "features"=>$v['pm'],
  4148. "cpbz"=>$v['cpbz'],
  4149. "sm"=>$v['sm'],
  4150. "type"=>$v['type'],
  4151. "g"=>$v["g"],
  4152. "c"=>$v["c"],
  4153. "x"=>$v["x"],
  4154. "t"=>$v["t"],
  4155. "z"=>$v["z"],
  4156. "jm"=>$v["jm"],
  4157. "weight"=>$v["weight"],
  4158. "asd"=>$v["asd"],
  4159. ];
  4160. }
  4161. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4162. $titlename = "<table border=1>
  4163. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4164. <tr align='center'>
  4165. <td>仓库</td>
  4166. <td>供应商</td>
  4167. <td>位置</td>
  4168. <td>库存编码</td>
  4169. <td>SKU</td>
  4170. <td>商品名称</td>
  4171. <td>商品中文</td>
  4172. <td>产品备注</td>
  4173. <td>说明</td>
  4174. <td>类型</td>
  4175. <td>入库总量</td>
  4176. <td>库存数量</td>
  4177. <td>销售数量</td>
  4178. <td>退货数量</td>
  4179. <td>占单数量</td>
  4180. <td>料号</td>
  4181. <td>重量</td>
  4182. <td>类目</td>
  4183. </tr>
  4184. </table>";
  4185. $filename = $title . ".xls";
  4186. $tail = "";
  4187. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4188. }
  4189. }
  4190. }
  4191. //出库+入库数据整合
  4192. public function _excelcr()
  4193. {
  4194. if (isset($_GET['excel'])) {
  4195. $type = $this->input->get('excel', true);
  4196. $category = $this->input->get('category', true);
  4197. $size = $this->input->get('size', true);
  4198. $grade = $this->input->get('grade', true);
  4199. $color = $this->input->get('color', true);
  4200. $lowe = $this->input->get('lowe', true);
  4201. $sku = $this->input->get('sku', true);
  4202. $warehouse = $this->input->get('warehouse', true);
  4203. $purchase = $this->input->get('purchase', true);
  4204. $state = $this->input->get('state', true);
  4205. $sid = $this->input->get('sid', true);
  4206. $ktime = $this->input->get('ktime', true);
  4207. $jtime = $this->input->get('jtime', true);
  4208. $ktime = strtotime($ktime);
  4209. $jtime = strtotime($jtime);
  4210. $where = "1=1";
  4211. $gj = "";
  4212. $ck = "";
  4213. if ($category) {
  4214. $where .= " and features like '%-$category-%'";
  4215. }
  4216. if ($size) {
  4217. $where .= " and features like '%-$size-%'";
  4218. }
  4219. if ($grade) {
  4220. $where .= " and features like '%-$grade-%'";
  4221. }
  4222. if ($color) {
  4223. $where .= " and features like '%-$color-%'";
  4224. }
  4225. if ($lowe) {
  4226. $where .= " and features like '%-$lowe-%'";
  4227. }
  4228. if ($warehouse) {
  4229. $where .= " and warehouse = '$warehouse'";
  4230. }
  4231. if ($purchase) {
  4232. $where .= " and purchase = '$purchase'";
  4233. }
  4234. if ($state) {
  4235. $where .= " and state = '$state'";
  4236. }
  4237. if ($sku) {
  4238. $where .= " and sku like '%$sku%'";
  4239. }
  4240. if ($ktime && $jtime) {
  4241. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4242. }
  4243. $sidwhere = '';
  4244. if ($sid) {
  4245. $sd = "";
  4246. $s = explode(',', trim($sid, ','));
  4247. foreach ($s as $value) {
  4248. $sd .= " id = " . $value . " or";
  4249. }
  4250. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4251. }
  4252. //取得信息列表
  4253. $timeread = $ktime;
  4254. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4255. $timelist = array();
  4256. for ($i = 0; $i < $timenum; $i++) {
  4257. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4258. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4259. }
  4260. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4261. //echo "<pre>";
  4262. //print_r($info_list);
  4263. //exit();
  4264. $rows = array();
  4265. $list = array();
  4266. foreach ($info_list as $key => $value) {
  4267. $thistime = $timelist;
  4268. if (isset($rows[strtolower($value['sku'])])) {
  4269. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4270. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4271. }
  4272. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4273. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4274. }
  4275. } else {
  4276. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4277. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4278. }
  4279. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4280. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4281. }
  4282. $rows[strtolower($value['sku'])] = $thistime;
  4283. }
  4284. }
  4285. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4286. <head>
  4287. <!--[if gte mso 9]><xml>
  4288. <x:ExcelWorkbook>
  4289. <x:ExcelWorksheets>
  4290. <x:ExcelWorksheet>
  4291. <x:Name>EXCEL</x:Name>
  4292. <x:WorksheetOptions>
  4293. <x:Print>
  4294. <x:ValidPrinterInfo />
  4295. </x:Print>
  4296. </x:WorksheetOptions>
  4297. </x:ExcelWorksheet>
  4298. </x:ExcelWorksheets>
  4299. </x:ExcelWorkbook>
  4300. </xml>
  4301. <![endif]-->
  4302. </head><body>";
  4303. $str .= "<table border=1><tr><td>SKU</td>";
  4304. foreach ($timelist as $k => $v) {
  4305. $str .= "<td>" . $k . "出库</td>";
  4306. $str .= "<td>" . $k . "入库</td>";
  4307. }
  4308. $str .= "</tr></table>";
  4309. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4310. foreach ($rows as $key => $val) {
  4311. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4312. foreach ($val as $k => $v) {
  4313. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4314. if ($val[$k]['r'] > 0) {
  4315. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4316. } else {
  4317. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4318. }
  4319. }
  4320. $str .= "</tr>";
  4321. }
  4322. $str .= "</table>";
  4323. $str .= "</body></html>";
  4324. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4325. header("Content-type: application/octet-stream");
  4326. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4327. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4328. header("Pragma: no-cache");
  4329. header("Expires: 0");
  4330. exit($str);
  4331. }
  4332. }
  4333. //数量调整模板导出
  4334. public function _presetout()
  4335. {
  4336. if (isset($_GET['excel'])) {
  4337. $where = "sku != 'Preset' and purchase != 0";
  4338. //数据排序
  4339. $order_str = "id desc";
  4340. if (empty($page)) {
  4341. $start = 0;
  4342. $perpage = 1;
  4343. } else {
  4344. $start = ($page - 1) * $perpage;
  4345. }
  4346. //取得信息列表
  4347. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4348. $rows = array();
  4349. $list = array();
  4350. foreach ($info_list as $value) {
  4351. $warehouse = $this->warehouse->read($value['warehouse']);
  4352. $number = $value['number'];
  4353. $ftime = time() - 15 * 24 * 3600;
  4354. $purchase = $this->purchase->read($value['purchase']);
  4355. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4356. }
  4357. $title = "库存模板";
  4358. $titlename = "<table border=1>
  4359. <tr align='center'>
  4360. <td>仓库</td>
  4361. <td>供应商编码</td>
  4362. <td>SKU</td>
  4363. <td>增减数量(正数或负数)</td>
  4364. <td>增减备注</td>
  4365. <td>扣减方式:0减少库存1删除库存</td>
  4366. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4367. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4368. </tr>
  4369. </table>";
  4370. $filename = $title . ".xls";
  4371. $tail = "";
  4372. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4373. }
  4374. }
  4375. //数量调整模板导入
  4376. public function _presetedit()
  4377. {
  4378. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4379. $config['upload_path'] = '.' . $dir;
  4380. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4381. $config['allowed_types'] = 'xls|xlsx|csv';
  4382. $config['max_size'] = 10240;
  4383. $this->load->library('upload', $config);
  4384. $this->upload->initialize($config);
  4385. if ($this->upload->do_upload('userfile')) {
  4386. $full_path = $dir . $this->upload->data('file_name');
  4387. $fileName = '.' . $full_path;
  4388. if (!file_exists($fileName)) {
  4389. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4390. exit;
  4391. } else {
  4392. require_once "./data/excel/PHPExcel/IOFactory.php";
  4393. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4394. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4395. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4396. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4397. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4398. ++$column; //如果列数大于26行
  4399. $list = array();
  4400. for ($i = 2; $i <= $row; $i++) // 行数循环
  4401. {
  4402. $data = array();
  4403. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4404. {
  4405. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4406. }
  4407. $list[] = $data;
  4408. }
  4409. }
  4410. $i = 0;
  4411. $j = 0;
  4412. $ed = array();
  4413. foreach ($list as $key => $value) {
  4414. $time = time();
  4415. if ($value['0'] == "") {
  4416. continue;
  4417. }
  4418. $warehouse = $this->warehouse->get_title($value['0']);
  4419. $purchase = $this->purchase->get_bm($value['1']);
  4420. $sku = $value['2'];
  4421. $num = $value['3']; //调整数量
  4422. $text = $value['4']; //扣减说明
  4423. $type = $value['5']; //调整方式0扣减1删除
  4424. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4425. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4426. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4427. if (!$purchase) //如果没有这个SKU
  4428. {
  4429. $ed[] = array($purchase . '-不存在此供应商编码');
  4430. $j++;
  4431. continue;
  4432. }
  4433. if (!$d) //如果没有这个SKU
  4434. {
  4435. $ed[] = array($sku . '-库存中不存在此SKU');
  4436. $j++;
  4437. continue;
  4438. }
  4439. if (!isset($warehouse['id'])) {
  4440. $ed[] = array($sku . '-仓库名错误!');
  4441. $j++;
  4442. continue;
  4443. }
  4444. if ($type != '0' && $type != '1') {
  4445. $ed[] = array($sku . '-扣减方式填写错误!');
  4446. $j++;
  4447. continue;
  4448. }
  4449. if ($num < 0) //扣减库存
  4450. {
  4451. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4452. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4453. $j++;
  4454. continue;
  4455. }
  4456. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4457. if (count($data) < abs($num)) {
  4458. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4459. $j++;
  4460. continue;
  4461. }
  4462. if ($type == 0) //如果扣减方式为 扣减库存
  4463. {
  4464. for ($i = 0; $i < abs($num); $i++) {
  4465. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4466. }
  4467. } else if ($type == 1) {
  4468. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4469. if (count($zt) > 0) {
  4470. $ed[] = array($sku . '-有在途库存无法删除!');
  4471. $j++;
  4472. continue;
  4473. }
  4474. for ($i = 0; $i < abs($num); $i++) {
  4475. $this->whlabel->remove($data[$i]['id']);
  4476. }
  4477. }
  4478. } else if ($num > 0) //增加库存
  4479. {
  4480. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4481. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4482. $j++;
  4483. continue;
  4484. }
  4485. $post['sku'] = $d['sku'];
  4486. $post['shop'] = $d['shop'];
  4487. $post['warehouse'] = $warehouse['id'];
  4488. $post['purchase'] = $purchase['id'];
  4489. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4490. $post['state'] = 0;
  4491. $post['title'] = $d['title'];
  4492. $post['number'] = $d['number'];
  4493. $post['features'] = $d['features'];
  4494. $post['enter'] = $time;
  4495. $post['time'] = $time; //操作时间
  4496. $post['rktype'] = $rktype;
  4497. for ($i = 0; $i < $num; $i++) {
  4498. $post['label'] = time() . rand(100, 999) . $i;
  4499. $this->whlabel->insert($post);
  4500. }
  4501. }
  4502. sleep(1); //防止入库时间一样,需要延迟1秒
  4503. }
  4504. if ($j > 0) {
  4505. $tt = date('Ymd', time());
  4506. $title = '库存导入错误信息-' . $tt;
  4507. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4508. $tail = "\n";
  4509. $filename = $title . ".xls";
  4510. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4511. $dir = '/data/excel/' . $time . '/';
  4512. $file_name = 'error_' . $time . rand(1000, 9999);
  4513. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4514. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4515. fwrite($myfile, $ecl);
  4516. fclose($myfile);
  4517. $error = $dir . $file_name . '.xls';
  4518. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4519. exit;
  4520. } else {
  4521. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4522. exit;
  4523. }
  4524. }
  4525. }
  4526. public function _presetedittwo(){
  4527. $data = $this->input->post(NULL, TRUE);
  4528. if(empty($list)){
  4529. $raw_data = $this->input->raw_input_stream;
  4530. // 解码 JSON
  4531. $data = json_decode($raw_data, true);
  4532. }
  4533. if(empty($data)){
  4534. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4535. }
  4536. $list = [];
  4537. if(isset($data['list'])){
  4538. $list = $data['list'];
  4539. }
  4540. $i = 0;
  4541. $j = 0;
  4542. $ed = array();
  4543. foreach ($list as $key => $value) {
  4544. $time = time();
  4545. if ($value['0'] == "") {
  4546. continue;
  4547. }
  4548. $warehouse = $this->warehouse->get_title($value['0']);
  4549. $purchase = $this->purchase->get_bm($value['1']);
  4550. $sku = $value['2'];
  4551. $num = $value['3']; //调整数量
  4552. $text = $value['4']; //扣减说明
  4553. $type = $value['5']; //调整方式0扣减1删除
  4554. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4555. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4556. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4557. if (!$purchase) //如果没有这个SKU
  4558. {
  4559. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4560. $j++;
  4561. continue;
  4562. }
  4563. if (!$d) //如果没有这个SKU
  4564. {
  4565. $ed[] = array($sku . '-库存中不存在此SKU');
  4566. $j++;
  4567. continue;
  4568. }
  4569. if (!isset($warehouse['id'])) {
  4570. $ed[] = array($sku . '-仓库名错误!');
  4571. $j++;
  4572. continue;
  4573. }
  4574. if ($type != '0' && $type != '1') {
  4575. $ed[] = array($sku . '-扣减方式填写错误!');
  4576. $j++;
  4577. continue;
  4578. }
  4579. if ($num < 0) //扣减库存
  4580. {
  4581. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4582. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4583. $j++;
  4584. continue;
  4585. }
  4586. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4587. if (count($data) < abs($num)) {
  4588. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4589. $j++;
  4590. continue;
  4591. }
  4592. if ($type == 0) //如果扣减方式为 扣减库存
  4593. {
  4594. for ($i = 0; $i < abs($num); $i++) {
  4595. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4596. }
  4597. } else if ($type == 1) {
  4598. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4599. if (count($zt) > 0) {
  4600. $ed[] = array($sku . '-有在途库存无法删除!');
  4601. $j++;
  4602. continue;
  4603. }
  4604. for ($i = 0; $i < abs($num); $i++) {
  4605. $this->whlabel->remove($data[$i]['id']);
  4606. }
  4607. }
  4608. } else if ($num > 0) //增加库存
  4609. {
  4610. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4611. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4612. $j++;
  4613. continue;
  4614. }
  4615. $post['sku'] = $d['sku'];
  4616. $post['shop'] = $d['shop'];
  4617. $post['warehouse'] = $warehouse['id'];
  4618. $post['purchase'] = $purchase['id'];
  4619. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4620. $post['state'] = 0;
  4621. $post['title'] = $d['title'];
  4622. $post['number'] = $d['number'];
  4623. $post['features'] = $d['features'];
  4624. $post['enter'] = $time;
  4625. $post['time'] = $time; //操作时间
  4626. $post['rktype'] = $rktype;
  4627. $post['sku_master_id'] = $d['sku_master_id'];
  4628. $post['sku_shop_id'] = $d['sku_shop_id'];
  4629. for ($i = 0; $i < $num; $i++) {
  4630. $post['label'] = time() . rand(100, 999) . $i;
  4631. $this->whlabel->insert($post);
  4632. }
  4633. }
  4634. sleep(1); //防止入库时间一样,需要延迟1秒
  4635. }
  4636. if ($j > 0) {
  4637. $tt = date('Ymd', time());
  4638. $title = '库存导入错误信息-' . $tt;
  4639. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4640. $tail = "\n";
  4641. $filename = $title . ".xls";
  4642. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4643. $dir = '/data/excel/' . $time . '/';
  4644. $file_name = 'error_' . $time . rand(1000, 9999);
  4645. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4646. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4647. fwrite($myfile, $ecl);
  4648. fclose($myfile);
  4649. $error = $dir . $file_name . '.xls';
  4650. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4651. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4652. exit;
  4653. } else {
  4654. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4655. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4656. exit;
  4657. }
  4658. }
  4659. //笛卡儿积
  4660. function cp($ps, $sets, $list)
  4661. {
  4662. $result = array();
  4663. $j = 0;
  4664. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4665. if ($i == 0) {
  4666. $result = $sets[$i];
  4667. }
  4668. $tmp = array();
  4669. foreach ($result as $res) {
  4670. foreach ($sets[$i + 1] as $set) {
  4671. $tmp[] = $res . ',' . $set;
  4672. }
  4673. }
  4674. $result = $tmp;
  4675. }
  4676. $this->db->trans_begin();
  4677. foreach ($result as $v) {
  4678. $post = array();
  4679. $title = "";
  4680. $num = "";
  4681. $data = explode(',', $v);
  4682. for ($i = 0; $i < count($list); $i++) {
  4683. $post[$list[$i]] = $data[$i];
  4684. $typeclass = $this->typeclass->read($data[$i]);
  4685. $title = $title . $typeclass['title'] . " ";
  4686. if ($data[$i] != 0) {
  4687. $num .= $data[$i]; //所有数据ID拼接
  4688. }
  4689. }
  4690. foreach ($ps as $kp => $vp) {
  4691. $post[$kp] = $vp;
  4692. }
  4693. $post['number'] = $num;
  4694. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4695. if ($info_list) {
  4696. $j++;
  4697. } else {
  4698. $skunum = $this->whlabel->find_count();
  4699. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4700. $post['title'] = rtrim($title, ' ');
  4701. $this->whlabel->insert($post);
  4702. }
  4703. }
  4704. if ($this->db->trans_status() === FALSE) {
  4705. $this->db->trans_commit();
  4706. return NULL;
  4707. } else {
  4708. $this->db->trans_commit();
  4709. return $j;
  4710. }
  4711. }
  4712. public function _kj($arg_array)
  4713. {
  4714. if (isset($_POST['sku'])) {
  4715. $time = time();
  4716. $sku = $this->input->post('sku', true);
  4717. $warehouse = $this->input->post('warehouse', true);
  4718. $num = $this->input->post('num', true);
  4719. $text = $this->input->post('text', true);
  4720. $purchase = $this->input->post('purchase', true);
  4721. $cktype = $this->input->post('cktype', true);
  4722. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4723. if ($cktype != 1 && $text == '') {
  4724. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4725. exit;
  4726. }
  4727. if ($num > count($order)) {
  4728. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4729. exit;
  4730. } else {
  4731. for ($i = 0; $i < $num; $i++) {
  4732. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4733. }
  4734. }
  4735. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4736. exit;
  4737. }
  4738. $uid = $this->whlabel->read($arg_array[0]);
  4739. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4740. $this->data['data'] = $uid;
  4741. $this->_Template('whlabel_kj', $this->data);
  4742. }
  4743. public function _summary($arg_array)
  4744. {
  4745. $prc = array();
  4746. $purchase = $this->purchase->find_all();
  4747. foreach ($purchase as $k => $v) {
  4748. $prc[$v['id']] = $v['title'];
  4749. }
  4750. if (isset($_GET['excel'])) {
  4751. $ktime = $this->input->get('ktime', true);
  4752. $jtime = $this->input->get('jtime', true);
  4753. $ktime = strtotime($ktime);
  4754. $jtime = strtotime($jtime);
  4755. $where = "1=1";
  4756. if ($ktime && $jtime) {
  4757. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4758. }
  4759. //数据排序
  4760. $order_str = "time desc";
  4761. if (empty($page)) {
  4762. $start = 0;
  4763. $perpage = 1;
  4764. } else {
  4765. $start = ($page - 1) * $perpage;
  4766. }
  4767. //取得信息列表
  4768. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4769. foreach ($info_list as $key => $value) {
  4770. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4771. $warehouse = $this->warehouse->read($value['warehouse']);
  4772. $info_list[$key]['warehouse'] = $warehouse['title'];
  4773. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4774. $details = array();
  4775. $cpid = array();
  4776. foreach ($x as $k => $v) {
  4777. if ($v['details'] != '') {
  4778. $details[$v['details']] = $v['details'];
  4779. }
  4780. if ($v['cpid'] != 0) {
  4781. $cpid[$v['cpid']] = $v['cpid'];
  4782. }
  4783. }
  4784. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4785. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4786. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4787. $info_list[$key]['s'] = $s;
  4788. $info_list[$key]['x'] = count($x);
  4789. }
  4790. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4791. $titlename = "<table border=1>
  4792. <tr align='center'>
  4793. <td>仓库</td>
  4794. <td>供应商</td>
  4795. <td>出库位置</td>
  4796. <td>出库编码</td>
  4797. <td>SKU</td>
  4798. <td>产品名</td>
  4799. <td>总剩余库存</td>
  4800. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4801. </tr>
  4802. </table>";
  4803. $filename = $title . ".xls";
  4804. $tail = "";
  4805. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4806. }
  4807. }
  4808. //usps发货清单
  4809. public function _manifest()
  4810. {
  4811. if (isset($_POST['manifest'])) {
  4812. $wltext = $this->input->post('wltext', true);
  4813. $time = time() - 16 * 3600;
  4814. $ptime = strtotime(date('Y-m-d', $time));
  4815. $waybill = array();
  4816. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4817. foreach ($fullorder as $v) {
  4818. $waybill[$v['waybill']] = $v['waybill'];
  4819. }
  4820. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4821. foreach ($fullordersmt as $v) {
  4822. $waybill[$v['waybill']] = $v['waybill'];
  4823. }
  4824. $wltext = explode(';', $wltext);
  4825. foreach ($wltext as $v) {
  4826. if (isset($waybill[$v])) {
  4827. unset($waybill[$v]);
  4828. }
  4829. }
  4830. $data = $this->usps->get_manifest($waybill);
  4831. if (isset($data['Description'])) {
  4832. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4833. exit;
  4834. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4835. $bctime = date('Ymd', time());
  4836. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4837. echo json_encode(array('msg' => $pdf, 'success' => true));
  4838. exit;
  4839. } else {
  4840. echo json_encode(array('msg' => $data, 'success' => false));
  4841. exit;
  4842. }
  4843. }
  4844. }
  4845. public function _pdf($pdf, $title, $bctime)
  4846. {
  4847. $pdf_path = './data/pdf/' . $bctime . '/';
  4848. $file_base64 = $pdf;
  4849. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4850. $file_base64 = base64_decode($file_base64);
  4851. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4852. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4853. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4854. }
  4855. /**
  4856. *
  4857. *
  4858. *
  4859. 进销存占单异常索引
  4860. *
  4861. *
  4862. *
  4863. **/
  4864. public function _abnormal()
  4865. {
  4866. $post = $this->input->post(NULL, TRUE);
  4867. if (isset($post['page'])) {
  4868. $page = $this->input->post('page', true);
  4869. $perpage = $this->input->post('perpage', true);
  4870. $sku = $this->input->post('sku', true);
  4871. $where = "1=1";
  4872. //数据排序
  4873. $order_str = "id desc";
  4874. if (empty($page)) {
  4875. $start = 0;
  4876. $perpage = 1;
  4877. } else {
  4878. $start = ($page - 1) * $perpage;
  4879. }
  4880. //取得信息列表
  4881. $info_list = $this->whlabel->find_all($where, '*');
  4882. $rows = array();
  4883. $list = array();
  4884. foreach ($info_list as $key => $value) {
  4885. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4886. }
  4887. foreach ($rows as $value) {
  4888. $warehouse = $this->warehouse->read($value['warehouse']);
  4889. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4890. $number = $value['number'];
  4891. $ftime = time() - 15 * 24 * 3600;
  4892. if ($value['shop'] != '') {
  4893. $shop = $value['shop'];
  4894. $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');
  4895. $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');
  4896. $order = array_merge($orderdlz, $ordersmt);
  4897. $od = 0;
  4898. $a = '';
  4899. $orid = '';
  4900. foreach ($order as $v) {
  4901. $or = explode('|', ltrim($v['whlabel'], '|'));
  4902. for ($i = 0; $i < count($or); $i++) {
  4903. $orod = explode('-', $or[$i]);
  4904. if ($orod[0] == $number) {
  4905. $od += $orod[1];
  4906. }
  4907. }
  4908. $orid .= $v['number'] . '-';
  4909. }
  4910. } else {
  4911. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4912. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4913. $order = array_merge($orderdlz, $ordersmt);
  4914. $od = 0;
  4915. $a = '';
  4916. $orid = '';
  4917. $qt = array();
  4918. foreach ($order as $v) {
  4919. $or = explode('|', ltrim($v['whlabel'], '|'));
  4920. for ($i = 0; $i < count($or); $i++) {
  4921. $orod = explode('-', $or[$i]);
  4922. if ($orod[0] == $number) {
  4923. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4924. if ($czzs > 0) {
  4925. if (isset($qt[$v['shop']])) {
  4926. if ($qt[$v['shop']] < $orod[1]) {
  4927. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4928. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4929. } else {
  4930. $qt[$v['shop']] -= $orod[1];
  4931. }
  4932. } else {
  4933. $qt[$v['shop']] = $czzs;
  4934. }
  4935. } else {
  4936. $od += $orod[1];
  4937. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4938. }
  4939. }
  4940. }
  4941. }
  4942. }
  4943. $z = $od . '(' . $orid . ')'; //查看订单号
  4944. //$z = $od;
  4945. if ($od > $c) {
  4946. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4947. }
  4948. }
  4949. $listdata = array_slice($list, $start, $perpage);
  4950. $total = count($list);
  4951. $pagenum = ceil($total / $perpage);
  4952. $over = $total - ($start + $perpage);
  4953. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4954. echo json_encode($rows);
  4955. exit;
  4956. }
  4957. $this->_Template('whlabel_abnormal', $this->data);
  4958. }
  4959. /**
  4960. *
  4961. *
  4962. *
  4963. 进销存占单异常索引
  4964. *
  4965. *
  4966. *
  4967. **/
  4968. public function _error()
  4969. {
  4970. $post = $this->input->post(NULL, TRUE);
  4971. if (isset($post['page'])) {
  4972. $page = $this->input->post('page', true);
  4973. $perpage = $this->input->post('perpage', true);
  4974. $sku = $this->input->post('sku', true);
  4975. $warehouse = $this->input->post('warehouse', true);
  4976. $ktime = $this->input->post('ktime', true);
  4977. $jtime = $this->input->post('jtime', true);
  4978. $ktime = strtotime($ktime);
  4979. $jtime = strtotime($jtime);
  4980. $where = "sku != 'Preset'";
  4981. $gj = '';
  4982. if ($sku) {
  4983. $where .= " and sku like '%$sku%'";
  4984. } else {
  4985. if ($ktime && $jtime) {
  4986. $gj = " and time > '$ktime' and time < '$jtime'";
  4987. }
  4988. }
  4989. if ($warehouse) {
  4990. $where .= " and warehouse = '$warehouse'";
  4991. }
  4992. //数据排序
  4993. $order_str = "id desc";
  4994. if (empty($page)) {
  4995. $start = 0;
  4996. $perpage = 1;
  4997. } else {
  4998. $start = ($page - 1) * $perpage;
  4999. }
  5000. //取得信息列表
  5001. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5002. $rows = array();
  5003. $list = array();
  5004. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5005. // foreach ($info_list as $value)
  5006. // {
  5007. // $warehouse = $this->warehouse->read($value['warehouse']);
  5008. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5009. // $number = $value['number'];$ftime = time()-15*24*3600;
  5010. // if($c < 1)
  5011. // {
  5012. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5013. // }
  5014. // }
  5015. $warehouse_list = $this->warehouse->find_all();
  5016. $warehouse_list = array_column($warehouse_list, null, 'id');
  5017. foreach ($info_list as $value) {
  5018. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5019. 'title' => "",
  5020. ];
  5021. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5022. $number = $value['number'];
  5023. $ftime = time() - 15 * 24 * 3600;
  5024. if ($c < 1) {
  5025. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5026. }
  5027. }
  5028. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5029. // $query = $this->db->query($sql);
  5030. // $info_list = $query->result_array();
  5031. // $sql_two = "select title,id from crowd_warehouse";
  5032. // $query_two = $this->db->query($sql_two);
  5033. // $warehouse_list = $query_two->result_array();
  5034. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5035. // foreach ($info_list as $value)
  5036. // {
  5037. // if(isset($warehouse_arr[$value['warehouse']])){
  5038. // $warehouse = $warehouse_arr[$value['warehouse']];
  5039. // }else{
  5040. // $warehouse = [
  5041. // 'id'=>0,
  5042. // 'title'=>"异常",
  5043. // ];
  5044. // }
  5045. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5046. // $number = $value['number'];$ftime = time()-15*24*3600;
  5047. // if($c < 1)
  5048. // {
  5049. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5050. // }
  5051. // }
  5052. $listdata = array_slice($list, $start, $perpage);
  5053. $total = count($list);
  5054. $pagenum = ceil($total / $perpage);
  5055. $over = $total - ($start + $perpage);
  5056. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5057. echo json_encode($rows);
  5058. exit;
  5059. }
  5060. if (isset($post['s'])) {
  5061. $id_arr = $this->input->post('s');
  5062. $id_arr = explode(',', trim($id_arr, ','));
  5063. if (!$id_arr) {
  5064. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5065. exit;
  5066. }
  5067. //循环删除记录
  5068. foreach ($id_arr as $v) {
  5069. $dd = $this->whlabel->read($v);
  5070. if (!isset($dd['id'])) {
  5071. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5072. exit;
  5073. }
  5074. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5075. if (isset($zt[0])) {
  5076. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5077. exit;
  5078. }
  5079. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5080. foreach ($deldd as $vv) {
  5081. $this->whlabel->remove($vv['id']);
  5082. }
  5083. }
  5084. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5085. exit;
  5086. }
  5087. $this->_Template('whlabel_error', $this->data);
  5088. }
  5089. public function _errorexcel()
  5090. {
  5091. $post = $this->input->post(NULL, TRUE);
  5092. if (isset($_GET['page'])) {
  5093. $page = $this->input->get('page', true);
  5094. $perpage = $this->input->get('perpage', true);
  5095. $sku = $this->input->get('sku', true);
  5096. $warehouse = $this->input->get('warehouse', true);
  5097. $ktime = $this->input->get('ktime', true);
  5098. $jtime = $this->input->get('jtime', true);
  5099. $ktime = strtotime($ktime);
  5100. $jtime = strtotime($jtime);
  5101. $where = "sku != 'Preset'";
  5102. $gj = '';
  5103. if ($sku) {
  5104. $where .= " and sku like '%$sku%'";
  5105. } else {
  5106. if ($ktime && $jtime) {
  5107. $gj = " and time > '$ktime' and time < '$jtime'";
  5108. }
  5109. }
  5110. if ($warehouse) {
  5111. $where .= " and warehouse = '$warehouse'";
  5112. }
  5113. //数据排序
  5114. $order_str = "id desc";
  5115. if (empty($page)) {
  5116. $start = 0;
  5117. $perpage = 1;
  5118. } else {
  5119. $start = ($page - 1) * $perpage;
  5120. }
  5121. //取得信息列表
  5122. $rows = array();
  5123. $list = array();
  5124. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5125. foreach ($info_list as $value) {
  5126. $warehouse = $this->warehouse->read($value['warehouse']);
  5127. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5128. $number = $value['number'];
  5129. $ftime = time() - 15 * 24 * 3600;
  5130. if ($c < 1) {
  5131. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5132. }
  5133. }
  5134. $title = "0库存汇总";
  5135. $titlename = "<table border=1>
  5136. <tr align='center'>
  5137. <td>仓库</td>
  5138. <td>SKU</td>
  5139. <td>产品</td>
  5140. <td>当前库存</td>
  5141. </tr>
  5142. </table>";
  5143. $filename = $title . ".xls";
  5144. $tail = "";
  5145. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5146. }
  5147. }
  5148. /**
  5149. *
  5150. *
  5151. * 占单
  5152. *
  5153. *
  5154. **/
  5155. public function _kcyz()
  5156. {
  5157. $post = $this->input->post(NULL, TRUE);
  5158. if (isset($post['warehouse'])) {
  5159. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5160. exit; //不再使用
  5161. $warehouse = $this->input->post('warehouse', true);
  5162. $whlabel = $this->input->post('whlabel', true);
  5163. $id = $this->input->post('id', true);
  5164. $shop = $this->input->post('shop', true);
  5165. $number = $this->input->post('number', true);
  5166. if (!$whlabel || $whlabel == '|') {
  5167. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5168. exit;
  5169. }
  5170. $pp = explode('|', trim($whlabel, '|'));
  5171. $x = 0;
  5172. $save = array();
  5173. foreach ($pp as $va) {
  5174. $num = explode('-', $va);
  5175. if ($number) {
  5176. $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 = '')"); //通用
  5177. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5178. } else {
  5179. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5180. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5181. }
  5182. $x++;
  5183. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5184. $save[] = $x - 1;
  5185. continue; //提前先加X不然出错,所以要减1
  5186. }
  5187. }
  5188. if (isset($save[0])) {
  5189. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5190. exit;
  5191. } else {
  5192. echo json_encode(array('success' => true));
  5193. exit;
  5194. }
  5195. }
  5196. }
  5197. public function _db()
  5198. {
  5199. $post = $this->input->post(NULL, TRUE);
  5200. if (isset($post['page'])) {
  5201. $page = $this->input->post('page', true);
  5202. $perpage = $this->input->post('perpage', true);
  5203. $sku = $this->input->post('sku', true);
  5204. $number = $this->input->post('number', true);
  5205. $warehouse = $this->input->post('warehouse', true);
  5206. $purchase = $this->input->post('purchase', true);
  5207. $orderinfo = $this->input->post('orderinfo', true);
  5208. $waybill = $this->input->post('waybill', true);
  5209. $category = $this->input->post('category', true);
  5210. $size = $this->input->post('size', true);
  5211. $grade = $this->input->post('grade', true);
  5212. $color = $this->input->post('color', true);
  5213. $lowe = $this->input->post('lowe', true);
  5214. $state = $this->input->post('state', true);
  5215. $label = $this->input->post('label', true);
  5216. $timetk = $this->input->post('timetkk', true);
  5217. $timetj = $this->input->post('timetjj', true);
  5218. $timetk = strtotime($timetk);
  5219. $timetj = strtotime($timetj);
  5220. $where = "dbtime > 0";
  5221. if ($timetk && $timetj) {
  5222. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5223. }
  5224. if ($sku) {
  5225. $where .= " and sku = '$sku'";
  5226. }
  5227. if ($warehouse) {
  5228. $where .= " and warehouse = '$warehouse'";
  5229. if ($warehouse == 12) {
  5230. $w = 'specialstock';
  5231. } else {
  5232. $w = 'whlabel';
  5233. }
  5234. }
  5235. if ($purchase) {
  5236. $where .= " and purchase = '$purchase'";
  5237. }
  5238. if ($category) {
  5239. $where .= " and features like '%-$category-%'";
  5240. }
  5241. if ($size) {
  5242. $where .= " and features like '%-$size-%'";
  5243. }
  5244. if ($grade) {
  5245. $where .= " and features like '%-$grade-%'";
  5246. }
  5247. if ($color) {
  5248. $where .= " and features like '%-$color-%'";
  5249. }
  5250. if ($lowe) {
  5251. $where .= " and features like '%-$lowe-%'";
  5252. }
  5253. if ($state != '') {
  5254. $where .= " and state = '$state'";
  5255. }
  5256. //数据排序
  5257. $order_str = "dbtime desc";
  5258. if (empty($page)) {
  5259. $start = 0;
  5260. $perpage = 1;
  5261. } else {
  5262. $start = ($page - 1) * $perpage;
  5263. }
  5264. //取得信息列表
  5265. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5266. foreach ($info_list as $key => $value) {
  5267. $warehouse = $this->$w->read($value['warehouse']);
  5268. $info_list[$key]['warehouse'] = $warehouse['title'];
  5269. $purchase = $this->purchase->read($value['purchase']);
  5270. $info_list[$key]['purchase'] = $purchase['title'];
  5271. if ($value['enter'] != 0) {
  5272. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5273. } else {
  5274. $info_list[$key]['enter'] = "";
  5275. }
  5276. if ($value['dbtime'] != 0) {
  5277. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5278. } else {
  5279. $info_list[$key]['dbtime'] = "";
  5280. }
  5281. if ($value['state'] == 0) {
  5282. $info_list[$key]['state'] = "在库";
  5283. } else if ($value['state'] == 1) {
  5284. $info_list[$key]['state'] = "出库";
  5285. } else if ($value['state'] == 2) {
  5286. $info_list[$key]['state'] = "退库";
  5287. } else if ($value['state'] == 3) {
  5288. $info_list[$key]['state'] = "调拨中";
  5289. } else if ($value['state'] == 4) {
  5290. $info_list[$key]['state'] = "再加工";
  5291. } else if ($value['state'] == 5) {
  5292. $info_list[$key]['state'] = "维修中";
  5293. } else if ($value['state'] == 6) {
  5294. $info_list[$key]['state'] = "盘亏";
  5295. } else if ($value['state'] == 7) {
  5296. $info_list[$key]['state'] = "更换标签";
  5297. } else if ($value['state'] == 8) {
  5298. $info_list[$key]['state'] = "其它";
  5299. } else if ($value['state'] == 9) {
  5300. $info_list[$key]['state'] = "预设";
  5301. }
  5302. }
  5303. $total = $this->whlabel->find_count($where);
  5304. $pagenum = ceil($total / $perpage);
  5305. $over = $total - ($start + $perpage);
  5306. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5307. echo json_encode($rows);
  5308. exit;
  5309. }
  5310. if (isset($post['outsku'])) {
  5311. $time = time();
  5312. $cz = $this->input->post('cz', true);
  5313. $label = $this->input->post('outsku', true);
  5314. $sl = $this->input->post('sl', true);
  5315. $num = $this->input->post('num', true);
  5316. //$warehouse = $this->input->post('warehouse',true);
  5317. if (!$sl) {
  5318. $sl = 1;
  5319. }
  5320. if (!$warehouse) {
  5321. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5322. exit;
  5323. }
  5324. $dblabel = $this->whlabellabel->get_label($label);
  5325. if ($dblabel) {
  5326. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5327. if (count($data) < 1) {
  5328. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5329. exit;
  5330. }
  5331. if (count($data) < $num) {
  5332. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5333. exit;
  5334. }
  5335. for ($i = 0; $i < $sl; $i++) {
  5336. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5337. }
  5338. echo json_encode(array('success' => true));
  5339. exit;
  5340. } else {
  5341. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5342. exit;
  5343. }
  5344. }
  5345. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5346. $this->_Template('whlabel_db', $this->data);
  5347. }
  5348. public function _dbrk()
  5349. {
  5350. $post = $this->input->post(NULL, TRUE);
  5351. if (isset($post['page'])) {
  5352. $page = $this->input->post('page', true);
  5353. $perpage = $this->input->post('perpage', true);
  5354. $sku = $this->input->post('sku', true);
  5355. $number = $this->input->post('number', true);
  5356. $warehouse = $this->input->post('warehouse', true);
  5357. $purchase = $this->input->post('purchase', true);
  5358. $orderinfo = $this->input->post('orderinfo', true);
  5359. $waybill = $this->input->post('waybill', true);
  5360. $category = $this->input->post('category', true);
  5361. $size = $this->input->post('size', true);
  5362. $grade = $this->input->post('grade', true);
  5363. $color = $this->input->post('color', true);
  5364. $lowe = $this->input->post('lowe', true);
  5365. $state = $this->input->post('state', true);
  5366. $label = $this->input->post('label', true);
  5367. $ctime = $this->input->post('ctime', true);
  5368. $timetk = $this->input->post('timetkk', true);
  5369. $timetj = $this->input->post('timetjj', true);
  5370. $timetk = strtotime($timetk);
  5371. $timetj = strtotime($timetj);
  5372. $where = "dbtime > 0";
  5373. if ($timetk && $timetj) {
  5374. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5375. }
  5376. if ($sku) {
  5377. $where .= " and sku = '$sku'";
  5378. }
  5379. if ($warehouse) {
  5380. $where .= " and warehouse = '$warehouse'";
  5381. }
  5382. if ($purchase) {
  5383. $where .= " and purchase = '$purchase'";
  5384. }
  5385. if ($category) {
  5386. $where .= " and features like '%-$category-%'";
  5387. }
  5388. if ($size) {
  5389. $where .= " and features like '%-$size-%'";
  5390. }
  5391. if ($grade) {
  5392. $where .= " and features like '%-$grade-%'";
  5393. }
  5394. if ($color) {
  5395. $where .= " and features like '%-$color-%'";
  5396. }
  5397. if ($lowe) {
  5398. $where .= " and features like '%-$lowe-%'";
  5399. }
  5400. if ($state != '') {
  5401. $where .= " and state = '$state'";
  5402. }
  5403. //数据排序
  5404. $order_str = "dbtime desc";
  5405. if (empty($page)) {
  5406. $start = 0;
  5407. $perpage = 1;
  5408. } else {
  5409. $start = ($page - 1) * $perpage;
  5410. }
  5411. //取得信息列表
  5412. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5413. foreach ($info_list as $key => $value) {
  5414. $warehouse = $this->warehouse->read($value['warehouse']);
  5415. $info_list[$key]['warehouse'] = $warehouse['title'];
  5416. $purchase = $this->purchase->read($value['purchase']);
  5417. $info_list[$key]['purchase'] = $purchase['title'];
  5418. if ($value['enter'] != 0) {
  5419. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5420. } else {
  5421. $info_list[$key]['enter'] = "";
  5422. }
  5423. if ($value['dbtime'] != 0) {
  5424. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5425. } else {
  5426. $info_list[$key]['dbtime'] = "";
  5427. }
  5428. if ($value['state'] == 0) {
  5429. $info_list[$key]['state'] = "在库";
  5430. } else if ($value['state'] == 1) {
  5431. $info_list[$key]['state'] = "出库";
  5432. } else if ($value['state'] == 2) {
  5433. $info_list[$key]['state'] = "退库";
  5434. } else if ($value['state'] == 3) {
  5435. $info_list[$key]['state'] = "调拨中";
  5436. } else if ($value['state'] == 4) {
  5437. $info_list[$key]['state'] = "再加工";
  5438. } else if ($value['state'] == 5) {
  5439. $info_list[$key]['state'] = "维修中";
  5440. } else if ($value['state'] == 6) {
  5441. $info_list[$key]['state'] = "盘亏";
  5442. } else if ($value['state'] == 7) {
  5443. $info_list[$key]['state'] = "更换标签";
  5444. } else if ($value['state'] == 8) {
  5445. $info_list[$key]['state'] = "其它";
  5446. } else if ($value['state'] == 9) {
  5447. $info_list[$key]['state'] = "预设";
  5448. }
  5449. }
  5450. $total = $this->whlabel->find_count($where);
  5451. $pagenum = ceil($total / $perpage);
  5452. $over = $total - ($start + $perpage);
  5453. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5454. echo json_encode($rows);
  5455. exit;
  5456. }
  5457. if (isset($post['rsku'])) {
  5458. $cz = $this->input->post('cz', true);
  5459. $label = $this->input->post('rsku', true);
  5460. $sl = $this->input->post('sl', true);
  5461. $warehouse = $this->input->post('warehouse', true);
  5462. if (!$sl) {
  5463. $sl = 1;
  5464. }
  5465. if (!$warehouse) {
  5466. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5467. exit;
  5468. }
  5469. $dblabel = $this->whlabellabel->get_label($label);
  5470. if ($dblabel) {
  5471. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5472. if (count($data) < 1) {
  5473. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5474. exit;
  5475. }
  5476. if ($sl > count($data)) {
  5477. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5478. exit;
  5479. }
  5480. $time = time();
  5481. for ($i = 0; $i < $sl; $i++) {
  5482. $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']);
  5483. }
  5484. echo json_encode(array('success' => true));
  5485. exit;
  5486. } else {
  5487. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5488. exit;
  5489. }
  5490. }
  5491. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5492. $this->_Template('whlabel_dbrk', $this->data);
  5493. }
  5494. public function _whlabelczdc()
  5495. {
  5496. if (isset($_GET['excel'])) {
  5497. //数据排序
  5498. $order_str = "id desc";
  5499. if (empty($page)) {
  5500. $start = 0;
  5501. $perpage = 1;
  5502. } else {
  5503. $start = ($page - 1) * $perpage;
  5504. }
  5505. $state = $this->input->get('state', true);
  5506. $sku = $this->input->get('sku', true);
  5507. $ctime = $this->input->get('ctime', true);
  5508. $category = $this->input->get('category', true);
  5509. $size = $this->input->get('size', true);
  5510. $grade = $this->input->get('grade', true);
  5511. $color = $this->input->get('color', true);
  5512. $lowe = $this->input->get('lowe', true);
  5513. $timetk = $this->input->get('timetkk', true);
  5514. $timetj = $this->input->get('timetjj', true);
  5515. $timetk = strtotime($timetk);
  5516. $timetj = strtotime($timetj);
  5517. $where = "dbtime > 0";
  5518. if ($timetk && $timetj) {
  5519. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5520. }
  5521. if ($category) {
  5522. $where .= " and features like '%-$category-%'";
  5523. }
  5524. if ($size) {
  5525. $where .= " and features like '%-$size-%'";
  5526. }
  5527. if ($grade) {
  5528. $where .= " and features like '%-$grade-%'";
  5529. }
  5530. if ($color) {
  5531. $where .= " and features like '%-$color-%'";
  5532. }
  5533. if ($lowe) {
  5534. $where .= " and features like '%-$lowe-%'";
  5535. }
  5536. //取得信息列表
  5537. $info_list = $this->whlabel->find_all($where, '*');
  5538. $rows = array();
  5539. $list = array();
  5540. foreach ($info_list as $key => $value) {
  5541. $rows[$value['sku']] = $value; //所有数据sku
  5542. }
  5543. foreach ($rows as $value) {
  5544. $warehouse = $this->warehouse->read($value['warehouse']);
  5545. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5546. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5547. if ($value['orderinfo'] == 0) {
  5548. $info_list[$key]['orderinfo'] = "";
  5549. }
  5550. if ($value['waybill'] == 0) {
  5551. $info_list[$key]['waybill'] = "";
  5552. }
  5553. if ($value['state'] == 0) {
  5554. $value['state'] = "在库";
  5555. } else if ($value['state'] == 3) {
  5556. $value['state'] = "调拨中";
  5557. }
  5558. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5559. }
  5560. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5561. $titlename = "<table border=1>
  5562. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5563. <tr align='center'>
  5564. <td>SKU</td>
  5565. <td>产品</td>
  5566. <td>调拨数量</td>
  5567. <td>入库数量</td>
  5568. </tr>
  5569. </table>";
  5570. $filename = $title . ".xls";
  5571. $tail = "";
  5572. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5573. }
  5574. }
  5575. public function _print($arg_array)
  5576. {
  5577. if (isset($_SESSION['api'])) {
  5578. $user = $this->user->get_api($_SESSION['api']);
  5579. $usp = $user;
  5580. $fgshop = "";
  5581. $sid = "";
  5582. $wid = "";
  5583. $wtype = "";
  5584. $usersp = explode('|', trim($user['shop'], '|'));
  5585. $userwh = explode('|', trim($user['warehouse'], '|'));
  5586. foreach ($usersp as $value) {
  5587. $fgshop .= " shop = " . $value . " or";
  5588. $sid .= " id = " . $value . " or";
  5589. }
  5590. foreach ($userwh as $value) {
  5591. $wid .= " id = " . $value . " or";
  5592. $wtype .= " type = " . $value . " or";
  5593. }
  5594. }
  5595. $post = $this->input->post(NULL, TRUE);
  5596. if (isset($post['tmsku'])) {
  5597. $tmsku = $this->input->post('tmsku', true);
  5598. if (is_numeric($tmsku)) {
  5599. $yyh = $this->whlabellabel->get_label($tmsku);
  5600. } else {
  5601. $yyh = $this->whlabellabel->get_sku($tmsku);
  5602. if(empty($yyh)){
  5603. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5604. if($r['code'] == -1 ){
  5605. echo json_encode(array('success' => false));
  5606. exit;
  5607. }else{
  5608. echo json_encode(array('features' => $r['data'], 'success' => true));
  5609. exit;
  5610. }
  5611. }
  5612. }
  5613. if ($yyh) {
  5614. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5615. exit;
  5616. } else {
  5617. echo json_encode(array('success' => false));
  5618. exit;
  5619. }
  5620. }
  5621. $classid = $this->classid->sku();
  5622. $pm = $classid;
  5623. $scsku = $classid;
  5624. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5625. if (isset($post['warehouse'])) {
  5626. if ($post['warehouse']) {
  5627. $list = array();
  5628. $num = "";
  5629. $title = "";
  5630. $features = "";
  5631. $order = 0;
  5632. $post['shop'] = '';
  5633. $brand = $this->input->post('brand', true);
  5634. if ($brand != '0,') {
  5635. $b = $this->brand->read(rtrim($brand, ','));
  5636. if ($b) {
  5637. $post['shop'] = str_replace('|', ',', $b['shop']);
  5638. }
  5639. }
  5640. $post['details'] = $this->input->post('details', true); //打印数量
  5641. $xbqnum = $this->input->post('xbqnum', true);
  5642. $post['purchase'] = $this->input->post('purchase', true);
  5643. $post['warehouse'] = $this->input->post('warehouse', true);
  5644. $post['purchase'] = $this->input->post('purchase', true);
  5645. $post['retreatwarehouse'] = $post['warehouse'];
  5646. $post['cpbz'] = $this->input->post('cpbz', true);
  5647. $post['state'] = 9;
  5648. $category = $this->input->post('category', true);
  5649. $list['category'] = $category;
  5650. $list['hairtype'] = $this->input->post('hairtype', true);
  5651. $list['grade'] = $this->input->post('grade', true);
  5652. $size = $this->input->post('size', true);
  5653. $list['size'] = rtrim($size, ',');
  5654. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5655. $list['extension'] = $this->input->post('extension', true);
  5656. if ($category == 1297) {
  5657. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5658. }
  5659. if ($category == 1702) {
  5660. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5661. $list['syother'] = $this->input->post('syother', true);
  5662. }
  5663. if ($category == 133) {
  5664. $list['fittype'] = $this->input->post('fittype', true);
  5665. $list['acother'] = $this->input->post('acother', true);
  5666. }
  5667. $list['color'] = $this->input->post('color', true);
  5668. $list['lowe'] = $this->input->post('lowe', true);
  5669. if ($category == 127) {
  5670. $list['type'] = $this->input->post('type', true);
  5671. $list['headroad'] = $this->input->post('headroad', true);
  5672. $list['density'] = $this->input->post('density', true);
  5673. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5674. $list['lacesize'] = $this->input->post('lacesize', true);
  5675. }
  5676. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5677. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5678. }
  5679. if ($category == 128) {
  5680. $list['lacetype'] = $this->input->post('lacetype', true);
  5681. $list['haircap'] = $this->input->post('haircap', true);
  5682. $list['density'] = $this->input->post('density', true);
  5683. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5684. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5685. $list['wigother'] = $this->input->post('wigother', true);
  5686. $list['wigother1'] = $this->input->post('wigother1', true);
  5687. $list['wigother2'] = $this->input->post('wigother2', true);
  5688. }
  5689. if ($category == 129) {
  5690. $list['wide'] = $this->input->post('wide', true);
  5691. }
  5692. if ($category == 131) {
  5693. $list['gifttype'] = $this->input->post('gifttype', true);
  5694. $list['giftother'] = $this->input->post('giftother', true);
  5695. }
  5696. if ($category == 134) {
  5697. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5698. }
  5699. if ($category == 1297) {
  5700. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5701. $list['sywigother'] = $this->input->post('sywigother', true);
  5702. }
  5703. if ($category == 130 || $category == 133 || $category == 1702) {
  5704. $list['items'] = $this->input->post('items', true);
  5705. $list['weight'] = $this->input->post('weight', true);
  5706. }
  5707. if ($category == 1702) {
  5708. $list['syhairther'] = $this->input->post('syhairther', true);
  5709. }
  5710. if($category == 130){
  5711. $list['jfother'] = $this->input->post('jfother', true);
  5712. }
  5713. foreach ($list as $k => $v) {
  5714. if ($v != 0) {
  5715. $num .= $v;
  5716. $features .= $v . '-';
  5717. $post[$k] = $v;
  5718. $typeclass = $this->typeclass->read($v);
  5719. if (isset($pm[$typeclass['classid']])) {
  5720. if (stripos($typeclass['zh'], '|') !== false) {
  5721. $exzh = explode('|', $typeclass['zh']);
  5722. $pm[$typeclass['classid']] = $exzh[0];
  5723. } else {
  5724. $pm[$typeclass['classid']] = $typeclass['zh'];
  5725. }
  5726. }
  5727. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5728. if ($k != 'size') {
  5729. $title .= $typeclass['title'] . " ";
  5730. }
  5731. }
  5732. }
  5733. $typeclass = $this->typeclass->read($list['size']);
  5734. $title .= $typeclass['title'];
  5735. $time = time();
  5736. $post['title'] = rtrim($title, ' ');
  5737. $post['number'] = $num;
  5738. $post['features'] = '-' . $features;
  5739. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5740. $featurespp = explode('-', trim($featurespp, '-'));
  5741. if (isset($featurespp[5])) {
  5742. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5743. } else {
  5744. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5745. }
  5746. $post['enter'] = $time;
  5747. $post['time'] = $time; //操作时间
  5748. $scsku = implode("-", $scsku);
  5749. $zh = implode(" ", $pm);
  5750. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5751. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5752. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5753. $post['sku'] = $bqsku;
  5754. $label = time() . rand(0, 9);
  5755. $post['label'] = $label;
  5756. $cpid = $this->whlabellabel->find_count();
  5757. $post['cpid'] = $cpid + 1;
  5758. $cpid = $post['cpid'];
  5759. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5760. //if($whlabelbarcode)
  5761. //{
  5762. //$post['label'] = $whlabelbarcode['label'];
  5763. //if(!$this->whlabellabel->insert($post))
  5764. //{
  5765. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5766. //}
  5767. //}
  5768. //else
  5769. //{
  5770. $this->db->trans_begin();
  5771. $this->whlabellabel->insert($post);
  5772. //$this->whlabelbarcode->insert($post);
  5773. if ($this->db->trans_status() === TRUE) {
  5774. $this->db->trans_commit();
  5775. } else {
  5776. $this->db->trans_rollback();
  5777. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5778. exit;
  5779. }
  5780. //}
  5781. $warehouse_name = "";
  5782. $warehouse = $post['warehouse'];
  5783. if($warehouse == 12){
  5784. $warehouse_name = "特殊库存库";
  5785. }
  5786. // if($warehouse == 13){
  5787. // $warehouse_name = "许昌仓";
  5788. // }
  5789. // if($warehouse == 5){
  5790. // $warehouse_name = "美国店";
  5791. // }
  5792. // if($warehouse == 16){
  5793. // $warehouse_name = "定制头套仓";
  5794. // }
  5795. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5796. if(!empty($warehouse_name)){
  5797. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5798. }
  5799. $purchase = $this->purchase->read($post['purchase']);
  5800. 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));
  5801. exit; //特殊仓目前不需要仓库选项
  5802. }
  5803. }
  5804. if (isset($_SESSION['api'])) {
  5805. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5806. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5807. $this->data['wlshop'] = $wlshop;
  5808. $this->data['warehouse'] = $warehouse;
  5809. }
  5810. $whlabelwz = $this->whlabelwz->find_all();
  5811. $this->data['whlabelwz'] = $whlabelwz;
  5812. $this->_Template('whlabel_print', $this->data);
  5813. }
  5814. public function _usaprint($arg_array)
  5815. {
  5816. if (isset($_SESSION['api'])) {
  5817. $user = $this->user->get_api($_SESSION['api']);
  5818. $usp = $user;
  5819. $fgshop = "";
  5820. $sid = "";
  5821. $wid = "";
  5822. $wtype = "";
  5823. $usersp = explode('|', trim($user['shop'], '|'));
  5824. $userwh = explode('|', trim($user['warehouse'], '|'));
  5825. foreach ($usersp as $value) {
  5826. $fgshop .= " shop = " . $value . " or";
  5827. $sid .= " id = " . $value . " or";
  5828. }
  5829. foreach ($userwh as $value) {
  5830. $wid .= " id = " . $value . " or";
  5831. $wtype .= " type = " . $value . " or";
  5832. }
  5833. }
  5834. $post = $this->input->post(NULL, TRUE);
  5835. if (isset($post['tmsku'])) {
  5836. $tmsku = $this->input->post('tmsku', true);
  5837. if (is_numeric($tmsku)) {
  5838. $yyh = $this->whlabellabel->get_label($tmsku);
  5839. } else {
  5840. $yyh = $this->whlabellabel->get_sku($tmsku);
  5841. }
  5842. if ($yyh) {
  5843. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5844. exit;
  5845. } else {
  5846. echo json_encode(array('success' => false));
  5847. exit;
  5848. }
  5849. }
  5850. $classid = $this->classid->sku();
  5851. $pm = $classid;
  5852. $scsku = $classid;
  5853. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5854. if (isset($post['warehouse'])) {
  5855. if ($post['warehouse']) {
  5856. $list = array();
  5857. $num = "";
  5858. $title = "";
  5859. $features = "";
  5860. $order = 0;
  5861. $post['shop'] = '';
  5862. $brand = $this->input->post('brand', true);
  5863. if ($brand != '0,') {
  5864. $b = $this->brand->read(rtrim($brand, ','));
  5865. if ($b) {
  5866. $post['shop'] = str_replace('|', ',', $b['shop']);
  5867. }
  5868. }
  5869. $post['details'] = $this->input->post('details', true); //打印数量
  5870. $xbqnum = $this->input->post('xbqnum', true);
  5871. $post['purchase'] = $this->input->post('purchase', true);
  5872. $post['warehouse'] = $this->input->post('warehouse', true);
  5873. $post['purchase'] = $this->input->post('purchase', true);
  5874. $post['retreatwarehouse'] = $post['warehouse'];
  5875. $post['cpbz'] = $this->input->post('cpbz', true);
  5876. $post['state'] = 9;
  5877. $category = $this->input->post('category', true);
  5878. $list['category'] = $category;
  5879. $list['hairtype'] = $this->input->post('hairtype', true);
  5880. $list['grade'] = $this->input->post('grade', true);
  5881. $size = $this->input->post('size', true);
  5882. $list['size'] = rtrim($size, ',');
  5883. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5884. $list['extension'] = $this->input->post('extension', true);
  5885. if ($category == 1297) {
  5886. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5887. }
  5888. if ($category == 1702) {
  5889. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5890. $list['syother'] = $this->input->post('syother', true);
  5891. }
  5892. if ($category == 133) {
  5893. $list['fittype'] = $this->input->post('fittype', true);
  5894. $list['acother'] = $this->input->post('acother', true);
  5895. }
  5896. $list['color'] = $this->input->post('color', true);
  5897. $list['lowe'] = $this->input->post('lowe', true);
  5898. if ($category == 127) {
  5899. $list['type'] = $this->input->post('type', true);
  5900. $list['headroad'] = $this->input->post('headroad', true);
  5901. $list['density'] = $this->input->post('density', true);
  5902. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5903. $list['lacesize'] = $this->input->post('lacesize', true);
  5904. }
  5905. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5906. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5907. }
  5908. if ($category == 128) {
  5909. $list['lacetype'] = $this->input->post('lacetype', true);
  5910. $list['haircap'] = $this->input->post('haircap', true);
  5911. $list['density'] = $this->input->post('density', true);
  5912. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5913. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5914. $list['wigother'] = $this->input->post('wigother', true);
  5915. $list['wigother1'] = $this->input->post('wigother1', true);
  5916. $list['wigother2'] = $this->input->post('wigother2', true);
  5917. }
  5918. if ($category == 129) {
  5919. $list['wide'] = $this->input->post('wide', true);
  5920. }
  5921. if ($category == 131) {
  5922. $list['gifttype'] = $this->input->post('gifttype', true);
  5923. $list['giftother'] = $this->input->post('giftother', true);
  5924. }
  5925. if ($category == 134) {
  5926. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5927. }
  5928. if ($category == 1297) {
  5929. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5930. $list['sywigother'] = $this->input->post('sywigother', true);
  5931. }
  5932. if ($category == 130 || $category == 133 || $category == 1702) {
  5933. $list['items'] = $this->input->post('items', true);
  5934. $list['weight'] = $this->input->post('weight', true);
  5935. }
  5936. if ($category == 1702) {
  5937. $list['syhairther'] = $this->input->post('syhairther', true);
  5938. }
  5939. foreach ($list as $k => $v) {
  5940. if ($v != 0) {
  5941. $num .= $v;
  5942. $features .= $v . '-';
  5943. $post[$k] = $v;
  5944. $typeclass = $this->typeclass->read($v);
  5945. if (isset($pm[$typeclass['classid']])) {
  5946. if (stripos($typeclass['zh'], '|') !== false) {
  5947. $exzh = explode('|', $typeclass['zh']);
  5948. $pm[$typeclass['classid']] = $exzh[0];
  5949. } else {
  5950. $pm[$typeclass['classid']] = $typeclass['zh'];
  5951. }
  5952. }
  5953. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5954. if ($k != 'size') {
  5955. $title .= $typeclass['title'] . " ";
  5956. }
  5957. }
  5958. }
  5959. $typeclass = $this->typeclass->read($list['size']);
  5960. $title .= $typeclass['title'];
  5961. $time = time();
  5962. $post['title'] = rtrim($title, ' ');
  5963. $post['number'] = $num;
  5964. $post['features'] = '-' . $features;
  5965. $fp = $this->whlabel->get_features($post['features']);
  5966. if (!$fp) {
  5967. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5968. exit;
  5969. }
  5970. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5971. $featurespp = explode('-', trim($featurespp, '-'));
  5972. if (isset($featurespp[5])) {
  5973. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5974. } else {
  5975. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5976. }
  5977. $post['enter'] = $time;
  5978. $post['time'] = $time; //操作时间
  5979. $scsku = implode("-", $scsku);
  5980. $zh = implode(" ", $pm);
  5981. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5982. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5983. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5984. $post['sku'] = $fp['sku'];
  5985. $post['label'] = $fp['sku'];
  5986. $cpid = $this->whlabellabel->find_count();
  5987. $post['cpid'] = $cpid + 1;
  5988. $cpid = $post['cpid'];
  5989. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5990. //if($whlabelbarcode)
  5991. //{
  5992. //$post['label'] = $whlabelbarcode['label'];
  5993. //if(!$this->whlabellabel->insert($post))
  5994. //{
  5995. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5996. //}
  5997. //}
  5998. //else
  5999. //{
  6000. $this->db->trans_begin();
  6001. $this->whlabellabel->insert($post);
  6002. //$this->whlabelbarcode->insert($post);
  6003. if ($this->db->trans_status() === TRUE) {
  6004. $this->db->trans_commit();
  6005. } else {
  6006. $this->db->trans_rollback();
  6007. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6008. exit;
  6009. }
  6010. //}
  6011. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6012. $purchase = $this->purchase->read($post['purchase']);
  6013. 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));
  6014. exit; //特殊仓目前不需要仓库选项
  6015. }
  6016. }
  6017. if (isset($_SESSION['api'])) {
  6018. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6019. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6020. $this->data['wlshop'] = $wlshop;
  6021. $this->data['warehouse'] = $warehouse;
  6022. }
  6023. $whlabelwz = $this->whlabelwz->find_all();
  6024. $this->data['whlabelwz'] = $whlabelwz;
  6025. $this->_Template('whlabel_usaprint', $this->data);
  6026. }
  6027. public function _printrk($arg_array)
  6028. {
  6029. $prc = array();
  6030. $purchase = $this->purchase->find_all();
  6031. foreach ($purchase as $k => $v) {
  6032. $prc[$v['id']] = $v['title'];
  6033. }
  6034. $post = $this->input->post(NULL, TRUE);
  6035. if (isset($post['page'])) {
  6036. $page = $this->input->post('page', true);
  6037. $perpage = $this->input->post('perpage', true);
  6038. $sku = $this->input->post('sku', true);
  6039. $bs = $this->input->post('bs', true);
  6040. $number = $this->input->post('number', true);
  6041. $warehouse = $this->input->post('warehouse', true);
  6042. $purchase = $this->input->post('purchase', true);
  6043. $orderinfo = $this->input->post('orderinfo', true);
  6044. $waybill = $this->input->post('waybill', true);
  6045. $category = $this->input->post('category', true);
  6046. $size = $this->input->post('size', true);
  6047. $grade = $this->input->post('grade', true);
  6048. $color = $this->input->post('color', true);
  6049. $lowe = $this->input->post('lowe', true);
  6050. $state = $this->input->post('state', true);
  6051. $label = $this->input->post('label', true);
  6052. $timetk = $this->input->post('ktime', true);
  6053. $timetj = $this->input->post('jtime', true);
  6054. $timetk = strtotime($timetk);
  6055. $timetj = strtotime($timetj);
  6056. $where = "1=1 ";
  6057. if ($timetk && $timetj) {
  6058. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6059. }
  6060. if ($sku) {
  6061. $where .= " and sku = '$sku'";
  6062. }
  6063. if ($bs != '') {
  6064. $where .= " and bs = '$bs'";
  6065. }
  6066. if ($number) {
  6067. $where .= " and number = '$number'";
  6068. }
  6069. if ($warehouse) {
  6070. $where .= " and warehouse = '$warehouse'";
  6071. }
  6072. if ($purchase) {
  6073. $where .= " and purchase = '$purchase'";
  6074. }
  6075. if ($orderinfo) {
  6076. $where .= " and orderinfo = '$orderinfo'";
  6077. }
  6078. if ($waybill) {
  6079. $where .= " and waybill = '$waybill'";
  6080. }
  6081. if ($category) {
  6082. $where .= " and features like '%-$category-%'";
  6083. }
  6084. if ($size) {
  6085. $where .= " and features like '%-$size-%'";
  6086. }
  6087. if ($grade) {
  6088. $where .= " and features like '%-$grade-%'";
  6089. }
  6090. if ($color) {
  6091. $where .= " and features like '%-$color-%'";
  6092. }
  6093. if ($lowe) {
  6094. $where .= " and features like '%-$lowe-%'";
  6095. }
  6096. if ($label) {
  6097. $where .= " and label = '$label'";
  6098. }
  6099. if ($state || $state == 0) {
  6100. $where .= " and state = '$state'";
  6101. }
  6102. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6103. //数据排序
  6104. $order_str = "enter desc";
  6105. if (empty($page)) {
  6106. $start = 0;
  6107. $perpage = 1;
  6108. } else {
  6109. $start = ($page - 1) * $perpage;
  6110. }
  6111. //取得信息列表
  6112. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6113. foreach ($info_list as $key => $value) {
  6114. $warehouse = $this->warehouse->read($value['warehouse']);
  6115. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6116. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6117. if ($value['state'] == 0) {
  6118. $info_list[$key]['state'] = "在库";
  6119. } else if ($value['state'] == 1) {
  6120. $info_list[$key]['state'] = "出库";
  6121. } else if ($value['state'] == 2) {
  6122. $info_list[$key]['state'] = "退库";
  6123. } else if ($value['state'] == 3) {
  6124. $info_list[$key]['state'] = "调拨中";
  6125. } else if ($value['state'] == 4) {
  6126. $info_list[$key]['state'] = "再加工";
  6127. } else if ($value['state'] == 5) {
  6128. $info_list[$key]['state'] = "维修中";
  6129. } else if ($value['state'] == 6) {
  6130. $info_list[$key]['state'] = "盘亏";
  6131. } else if ($value['state'] == 7) {
  6132. $info_list[$key]['state'] = "更换标签";
  6133. } else if ($value['state'] == 8) {
  6134. $info_list[$key]['state'] = "其它";
  6135. } else if ($value['state'] == 9) {
  6136. $info_list[$key]['state'] = "预设";
  6137. } else if ($value['state'] == 10) {
  6138. $info_list[$key]['state'] = "美店零售";
  6139. }
  6140. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6141. }
  6142. $total = $this->$ck->find_count($where);
  6143. $pagenum = ceil($total / $perpage);
  6144. $over = $total - ($start + $perpage);
  6145. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6146. echo json_encode($rows);
  6147. exit;
  6148. }
  6149. if (isset($post['tmsku'])) {
  6150. $time = time();
  6151. $tmsku = $this->input->post('tmsku', true);
  6152. //$post['shop'] = $this->input->post('shop',true);
  6153. $num = $this->input->post('num', true);
  6154. $rktype = $this->input->post('rktype', true);
  6155. if ($num > 200) {
  6156. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6157. exit;
  6158. }
  6159. if (!$rktype) {
  6160. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6161. }
  6162. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6163. /**
  6164. $wz = array();
  6165. foreach ($rk as $key=>$value)
  6166. {
  6167. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6168. }
  6169. if(count($wz) > 1)
  6170. {
  6171. $wz = array_values($wz);
  6172. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6173. }
  6174. **/
  6175. if (isset($rk[0]['purchase'])) {
  6176. $rk = $rk[0];
  6177. $j = 0;
  6178. $post['purchase'] = $rk['purchase'];
  6179. $post['warehouse'] = $rk['warehouse'];
  6180. $post['retreatwarehouse'] = $rk['warehouse'];
  6181. $post['sku'] = $rk['sku'];
  6182. $post['number'] = $rk['number'];
  6183. $post['features'] = $rk['features'];
  6184. $post['title'] = $rk['title'];
  6185. $post['enter'] = $time;
  6186. $post['time'] = $time;
  6187. $post['bs'] = 1;
  6188. $post['shop'] = $rk['shop'];
  6189. $post['details'] = $rk['details'];
  6190. $post['cpid'] = $rk['cpid'];
  6191. $post['cpbz'] = $rk['cpbz'];
  6192. $post['rktype'] = $rktype;
  6193. $warehouse = $this->warehouse->read($rk['warehouse']);
  6194. if ($warehouse['bdck'] == '') {
  6195. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6196. exit;
  6197. } else {
  6198. $bdck = $warehouse['bdck'];
  6199. }
  6200. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6201. if (isset($pdwz['details'])) {
  6202. if ($pdwz['details'] != $post['details']) {
  6203. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6204. exit;
  6205. }
  6206. }
  6207. $post['featurespp'] = $rk['featurespp'];
  6208. if ($post['warehouse'] == '5') {
  6209. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6210. if ($yza) {
  6211. if ($post['features'] != $yza[0]['features']) {
  6212. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6213. exit;
  6214. }
  6215. }
  6216. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6217. if ($yzb) {
  6218. if ($post['sku'] != $yzb[0]['sku']) {
  6219. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6220. exit;
  6221. }
  6222. }
  6223. }
  6224. for ($i = 0; $i < $num; $i++) {
  6225. $post['label'] = time() . rand(100, 999) . $i;
  6226. if ($this->$bdck->insert($post)) {
  6227. $j++;
  6228. }
  6229. }
  6230. /**
  6231. if($post['warehouse'] != 12)
  6232. {
  6233. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6234. }
  6235. **/
  6236. $this->whlabelscanlog->insert([
  6237. 'shop'=>$rk['shop'],
  6238. 'type'=>1,
  6239. 'purchase'=>$rk['purchase'],
  6240. 'sku'=>$rk['sku'],
  6241. 'features'=>$rk['features'],
  6242. 'title'=>$rk['title'],
  6243. 'label'=>$rk['label'],
  6244. 'warehouse'=>$rk['warehouse'],
  6245. 'wlid'=>$rk['id'],
  6246. 'num'=>$num,
  6247. 'addtime'=>time()
  6248. ]);
  6249. if ($j == $num) {
  6250. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6251. exit;
  6252. } else {
  6253. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6254. exit;
  6255. }
  6256. } else {
  6257. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6258. exit;
  6259. }
  6260. }
  6261. $this->_Template('whlabel_printrk', $this->data);
  6262. }
  6263. public function _printxzrk($arg_array)
  6264. {
  6265. $post = $this->input->post(NULL, TRUE);
  6266. if (isset($post['wzid'])) {
  6267. $time = time();
  6268. $id = $this->input->post('wzid', true);
  6269. //$post['shop'] = $this->input->post('shop',true);
  6270. $num = 1;
  6271. $rk = $this->whlabellabel->read($id);
  6272. if (isset($rk['purchase'])) {
  6273. $x = 0;
  6274. $post['purchase'] = $rk['purchase'];
  6275. $post['warehouse'] = $rk['warehouse'];
  6276. $post['retreatwarehouse'] = $rk['warehouse'];
  6277. $post['sku'] = $rk['sku'];
  6278. $post['number'] = $rk['number'];
  6279. $post['features'] = $rk['features'];
  6280. $post['title'] = $rk['title'];
  6281. $post['enter'] = $time;
  6282. $post['time'] = $time;
  6283. $post['bs'] = 1;
  6284. $post['shop'] = $rk['shop'];
  6285. $post['details'] = $rk['details'];
  6286. $post['cpid'] = $rk['cpid'];
  6287. $post['cpbz'] = $rk['cpbz'];
  6288. $warehouse = $this->warehouse->read($rk['warehouse']);
  6289. if ($warehouse['bdck'] == '') {
  6290. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6291. exit;
  6292. } else {
  6293. $bdck = $warehouse['bdck'];
  6294. }
  6295. $post['featurespp'] = $rk['featurespp'];
  6296. $this->db->trans_begin();
  6297. for ($i = 0; $i < $num; $i++) {
  6298. $post['label'] = time() . rand(100, 999) . $i;
  6299. $this->$bdck->insert($post);
  6300. }
  6301. /**
  6302. if($post['warehouse'] != 12)
  6303. {
  6304. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6305. }
  6306. **/
  6307. if ($this->db->trans_status() === TRUE) {
  6308. $this->db->trans_commit();
  6309. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6310. exit;
  6311. } else {
  6312. $this->db->trans_rollback();
  6313. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6314. exit;
  6315. }
  6316. } else {
  6317. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6318. exit;
  6319. }
  6320. }
  6321. }
  6322. public function _printck($arg_array)
  6323. {
  6324. $prc = array();
  6325. $purchase = $this->purchase->find_all();
  6326. foreach ($purchase as $k => $v) {
  6327. $prc[$v['id']] = $v['title'];
  6328. }
  6329. $post = $this->input->post(NULL, TRUE);
  6330. if (isset($post['page'])) {
  6331. $page = $this->input->post('page', true);
  6332. $perpage = $this->input->post('perpage', true);
  6333. $sku = $this->input->post('sku', true);
  6334. $bs = $this->input->post('bs', true);
  6335. $number = $this->input->post('number', true);
  6336. $warehouse = $this->input->post('warehouse', true);
  6337. $purchase = $this->input->post('purchase', true);
  6338. $orderinfo = $this->input->post('orderinfo', true);
  6339. $waybill = $this->input->post('waybill', true);
  6340. $category = $this->input->post('category', true);
  6341. $size = $this->input->post('size', true);
  6342. $grade = $this->input->post('grade', true);
  6343. $color = $this->input->post('color', true);
  6344. $lowe = $this->input->post('lowe', true);
  6345. $state = $this->input->post('state', true);
  6346. $label = $this->input->post('label', true);
  6347. $timetk = $this->input->post('ktime', true);
  6348. $timetj = $this->input->post('jtime', true);
  6349. $timetk = strtotime($timetk);
  6350. $timetj = strtotime($timetj);
  6351. $where = "state=1 ";
  6352. if ($timetk && $timetj) {
  6353. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6354. }
  6355. if ($sku) {
  6356. $where .= " and sku = '$sku'";
  6357. }
  6358. if ($bs != '') {
  6359. $where .= " and bs = '$bs'";
  6360. }
  6361. if ($number) {
  6362. $where .= " and number = '$number'";
  6363. }
  6364. if ($warehouse) {
  6365. $where .= " and warehouse = '$warehouse'";
  6366. }
  6367. if ($purchase) {
  6368. $where .= " and purchase = '$purchase'";
  6369. }
  6370. if ($orderinfo) {
  6371. $where .= " and orderinfo = '$orderinfo'";
  6372. }
  6373. if ($waybill) {
  6374. $where .= " and waybill = '$waybill'";
  6375. }
  6376. if ($category) {
  6377. $where .= " and features like '%-$category-%'";
  6378. }
  6379. if ($size) {
  6380. $where .= " and features like '%-$size-%'";
  6381. }
  6382. if ($grade) {
  6383. $where .= " and features like '%-$grade-%'";
  6384. }
  6385. if ($color) {
  6386. $where .= " and features like '%-$color-%'";
  6387. }
  6388. if ($lowe) {
  6389. $where .= " and features like '%-$lowe-%'";
  6390. }
  6391. if ($label) {
  6392. $where .= " and label = '$label'";
  6393. }
  6394. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6395. //数据排序
  6396. $order_str = "outk desc";
  6397. if (empty($page)) {
  6398. $start = 0;
  6399. $perpage = 1;
  6400. } else {
  6401. $start = ($page - 1) * $perpage;
  6402. }
  6403. //取得信息列表
  6404. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6405. foreach ($info_list as $key => $value) {
  6406. $warehouse = $this->warehouse->read($value['warehouse']);
  6407. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6408. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6409. if ($value['state'] == 0) {
  6410. $info_list[$key]['state'] = "在库";
  6411. } else if ($value['state'] == 1) {
  6412. $info_list[$key]['state'] = "出库";
  6413. } else if ($value['state'] == 2) {
  6414. $info_list[$key]['state'] = "退库";
  6415. } else if ($value['state'] == 3) {
  6416. $info_list[$key]['state'] = "调拨中";
  6417. } else if ($value['state'] == 4) {
  6418. $info_list[$key]['state'] = "再加工";
  6419. } else if ($value['state'] == 5) {
  6420. $info_list[$key]['state'] = "维修中";
  6421. } else if ($value['state'] == 6) {
  6422. $info_list[$key]['state'] = "盘亏";
  6423. } else if ($value['state'] == 7) {
  6424. $info_list[$key]['state'] = "更换标签";
  6425. } else if ($value['state'] == 8) {
  6426. $info_list[$key]['state'] = "其它";
  6427. } else if ($value['state'] == 9) {
  6428. $info_list[$key]['state'] = "预设";
  6429. } else if ($value['state'] == 10) {
  6430. $info_list[$key]['state'] = "美店零售";
  6431. }
  6432. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6433. }
  6434. $total = $this->$ck->find_count($where);
  6435. $pagenum = ceil($total / $perpage);
  6436. $over = $total - ($start + $perpage);
  6437. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6438. echo json_encode($rows);
  6439. exit;
  6440. }
  6441. if (isset($post['tmsku'])) {
  6442. $time = time();
  6443. $tmsku = $this->input->post('tmsku', true);
  6444. //$post['shop'] = $this->input->post('shop',true);
  6445. $num = $this->input->post('num', true);
  6446. $cktype = $this->input->post('cktype', true);
  6447. $label = $this->whlabellabel->get_label($tmsku);
  6448. if (!$cktype) {
  6449. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6450. }
  6451. if (!isset($label['warehouse'])) {
  6452. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6453. exit;
  6454. }
  6455. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6456. if (stripos($label['features'], '-126-') !== false) {
  6457. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null )");
  6458. } else {
  6459. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and purchase = '" . $label['purchase'] . "' and ( zd = '' or zd is null ) ");
  6460. }
  6461. $j = 0;
  6462. if (count($ck) >= $num) {
  6463. for ($i = 0; $i < $num; $i++) {
  6464. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6465. {
  6466. $j++;
  6467. }
  6468. }
  6469. $this->whlabelscanlog->insert([
  6470. 'shop'=>$label['shop'],
  6471. 'type'=>2,
  6472. 'purchase'=>$label['purchase'],
  6473. 'sku'=>$label['sku'],
  6474. 'features'=>$label['features'],
  6475. 'title'=>$label['title'],
  6476. 'label'=>$label['label'],
  6477. 'warehouse'=>$label['warehouse'],
  6478. 'wlid'=>$label['id'],
  6479. 'num'=>$num,
  6480. 'addtime'=>time()
  6481. ]);
  6482. if ($j == $num) {
  6483. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6484. exit;
  6485. } else {
  6486. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6487. exit;
  6488. }
  6489. } else {
  6490. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6491. exit;
  6492. }
  6493. }
  6494. if(isset($_SESSION['api']))
  6495. {
  6496. $user = $this->user->get_api($_SESSION['api']);
  6497. if(in_array($user['power'],[1,27])){
  6498. $vip = 1;
  6499. }
  6500. }
  6501. else
  6502. {
  6503. $vip = 0;
  6504. header('Location: /');exit;
  6505. }
  6506. $this->data['vip'] = $vip;
  6507. $this->_Template('whlabel_printck', $this->data);
  6508. }
  6509. public function _printexcel()
  6510. {
  6511. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6512. $config['upload_path'] = '.' . $dir;
  6513. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6514. $config['allowed_types'] = 'xls|xlsx|csv';
  6515. $config['max_size'] = 10240;
  6516. $this->load->library('upload', $config);
  6517. $this->upload->initialize($config);
  6518. if ($this->upload->do_upload('userfile')) {
  6519. $full_path = $dir . $this->upload->data('file_name');
  6520. $fileName = '.' . $full_path;
  6521. if (!file_exists($fileName)) {
  6522. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6523. exit;
  6524. } else {
  6525. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6526. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6527. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6528. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6529. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6530. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6531. ++$column; //如果列数大于26行
  6532. $list = array();
  6533. for ($i = 2; $i <= $row; $i++) // 行数循环
  6534. {
  6535. $data = array();
  6536. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6537. {
  6538. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6539. }
  6540. $list[] = $data;
  6541. }
  6542. }
  6543. $ed = array();
  6544. $i = 0;
  6545. $j = 0;
  6546. $dcdata = array();
  6547. $yc = '';
  6548. $cmf_arr = array_column($list, '1');
  6549. array_multisort($cmf_arr, SORT_ASC, $list);
  6550. foreach ($list as $key => $value) {
  6551. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6552. if ($typeclass) {
  6553. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6554. } else {
  6555. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6556. $i++;
  6557. continue;
  6558. }
  6559. }
  6560. if ($i > 0) {
  6561. $yc = $i . '条异常';
  6562. }
  6563. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6564. exit;
  6565. }
  6566. }
  6567. public function _uck()
  6568. {
  6569. if (isset($_GET['excel'])) {
  6570. $tc = array();
  6571. $typeclass = $this->typeclass->find_all();
  6572. foreach ($typeclass as $v) {
  6573. $tc[$v['id']] = $v['zh'];
  6574. }
  6575. $data = array();
  6576. $t = array();
  6577. $rq = '';
  6578. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6579. $ts = $ts / (24 * 3600);
  6580. for ($i = 0; $i < $ts; $i++) {
  6581. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6582. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6583. }
  6584. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6585. foreach ($info_list as $k => $v) {
  6586. $features = explode('-', trim($v['features'], '-'));
  6587. if (!isset($features[3]) || !isset($features[4])) {
  6588. continue;
  6589. }
  6590. $data[$k][0] = $tc[$features[0]]; //类型
  6591. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6592. $data[$k][2] = $tc[$features[4]]; //曲度
  6593. $data[$k][3] = '';
  6594. if (isset($data[$k][1])) {
  6595. $data[$k][3] .= $data[$k][1];
  6596. }
  6597. if (isset($data[$k][2])) {
  6598. $data[$k][3] .= $data[$k][2];
  6599. }
  6600. if (isset($features[5])) {
  6601. $data[$k][3] .= $tc[$features[5]];
  6602. }
  6603. if (isset($features[2])) {
  6604. $data[$k][3] .= $tc[$features[2]];
  6605. }
  6606. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6607. $data[$k][4] = $v['sku'];
  6608. $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())) . '))'); //月初库存
  6609. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6610. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6611. $ztrq = '';
  6612. $ztsl = '';
  6613. if (count($zt) > 0) {
  6614. foreach ($zt as $vv) {
  6615. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6616. $ztsl .= $vv['num'] . '<br>';
  6617. }
  6618. }
  6619. $data[$k][] = trim($ztsl, '<br>');
  6620. $data[$k][] = trim($ztrq, '<br>');
  6621. $byck = 0;
  6622. foreach ($t as $vv) {
  6623. $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));
  6624. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6625. $byck += $sl;
  6626. }
  6627. $data[$k][] = ($byck > 0) ? $byck : '';
  6628. }
  6629. $title = "详情 " . date("Y-m-d", time());
  6630. $titlename = "<table border=1>
  6631. <tr align='center'>
  6632. <td>类别</td>
  6633. <td>颜色</td>
  6634. <td>曲度</td>
  6635. <td>名称</td>
  6636. <td>SKU</td>
  6637. <td>月初库存</td>
  6638. <td>剩余库存</td>
  6639. <td>在途数量</td>
  6640. <td>预达日期</td>" .
  6641. $rq
  6642. . "<td>本月出库</td></tr>
  6643. </table>";
  6644. $filename = $title . ".xls";
  6645. $tail = "";
  6646. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6647. }
  6648. }
  6649. public function _whlabelexcelzh()
  6650. {
  6651. if (isset($_GET['excel'])) {
  6652. $where = "sku != 'Preset'";
  6653. //数据排序
  6654. $order_str = "id desc";
  6655. if (empty($page)) {
  6656. $start = 0;
  6657. $perpage = 1;
  6658. } else {
  6659. $start = ($page - 1) * $perpage;
  6660. }
  6661. $category = $this->input->get('category', true);
  6662. $warehouse = $this->input->get('warehouse', true);
  6663. $excelid = $this->input->get('sid', true);
  6664. if ($category) {
  6665. $where .= " and features like '%-$category-%'";
  6666. }
  6667. if ($warehouse) {
  6668. $where .= " and warehouse = '$warehouse'";
  6669. }
  6670. $xzid = '';
  6671. if ($excelid) {
  6672. $excelid = explode(',', trim($excelid, ','));
  6673. foreach ($excelid as $key => $value) {
  6674. $xzid .= " id = " . $value . " or";
  6675. }
  6676. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6677. }
  6678. //取得信息列表
  6679. /**
  6680. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6681. $rows = array();$list = array();
  6682. foreach ($info_list as $key=>$value)
  6683. {
  6684. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6685. }
  6686. **/
  6687. $list = array();
  6688. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6689. foreach ($rows as $key => $value) {
  6690. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6691. $zh = '';
  6692. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6693. foreach ($zt as $v) {
  6694. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6695. }
  6696. $zt = array_sum(array_column($zt, 'num'));
  6697. $number = $value['number'];
  6698. $ftime = time() - 15 * 24 * 3600;
  6699. $warehouse = $this->warehouse->read($value['warehouse']);
  6700. $rows[$key]['warehouse'] = $warehouse['title'];
  6701. $rows[$key]['number'] = $c;
  6702. $rows[$key]['features'] = $zh;
  6703. $rows[$key]['hb'] = $c + $zt;
  6704. }
  6705. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6706. $titlename = "<table border=1>
  6707. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6708. <tr align='center'>
  6709. <td>仓库</td>
  6710. <td>SKU</td>
  6711. <td>产品</td>
  6712. <td>库存数量</td>
  6713. <td>在途数量及预达日期</td>
  6714. <td>在途+库存数量</td>
  6715. </tr>
  6716. </table>";
  6717. $filename = $title . ".xls";
  6718. $tail = "";
  6719. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6720. }
  6721. if (isset($_GET['excel'])) {
  6722. $warehouse = $this->input->get('warehouse', true);
  6723. $sku = $this->input->get('sku', true);
  6724. $cz = $this->input->get('cz', true);
  6725. $text = $this->input->post('text', true);
  6726. $xztime = $this->input->get('xztime', true);
  6727. $timetk = $this->input->get('timetk', true);
  6728. $timetj = $this->input->get('timetj', true);
  6729. $timetk = strtotime($timetk);
  6730. $timetj = strtotime($timetj);
  6731. $where = "time = '0' ";
  6732. if ($warehouse) {
  6733. $where .= " and warehouse = '$warehouse'";
  6734. }
  6735. if ($sku) {
  6736. $where .= " and sku = '$sku'";
  6737. }
  6738. if ($text) {
  6739. $where .= " and text like '%$text%'";
  6740. }
  6741. if ($cz != '') {
  6742. $where .= " and cz = '$cz'";
  6743. }
  6744. if ($timetk && $timetj) {
  6745. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6746. }
  6747. //数据排序
  6748. $order_str = $xztime . " desc";
  6749. //取得信息列表
  6750. $zh = array();
  6751. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6752. foreach ($info_list as $v) {
  6753. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6754. $warehouse = $this->warehouse->read($v['warehouse']);
  6755. $v['warehouse'] = $warehouse['title'];
  6756. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6757. $v['stime'] = date('Y-m-d', $v['stime']);
  6758. if (isset($zh[$v['features']])) {
  6759. $zh[$v['features']]['num'] += $v['num'];
  6760. } else {
  6761. $zh[$v['features']] = $v;
  6762. }
  6763. $zh[$v['features']]['features'] = $c;
  6764. }
  6765. $title = "在途数据" . date('Y-m-d', time());
  6766. $titlename = "<table border=1>
  6767. <tr align='center'>
  6768. <td>仓库</td>
  6769. <td>SKU</td>
  6770. <td>名称</td>
  6771. <td>在途数量</td>
  6772. <td>库存数量</td>
  6773. <td>添加在途日期</td>
  6774. <td>预达日期</td>
  6775. <td>备注</td>
  6776. </tr>
  6777. </table>";
  6778. $filename = $title . ".xls";
  6779. $tail = "";
  6780. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6781. }
  6782. }
  6783. public function _fc()
  6784. {
  6785. $vip = 0;
  6786. if (isset($_SESSION['api'])) {
  6787. $user = $this->user->get_api($_SESSION['api']);
  6788. if ($user['vip'] == 1) {
  6789. $vip = 1;
  6790. }
  6791. } else {
  6792. header('Location: /');
  6793. exit;
  6794. }
  6795. $post = $this->input->post(NULL, TRUE);
  6796. if (isset($post['page'])) {
  6797. $page = $this->input->post('page', true);
  6798. $perpage = $this->input->post('perpage', true);
  6799. $category = $this->input->post('category', true);
  6800. $size = $this->input->post('size', true);
  6801. $grade = $this->input->post('grade', true);
  6802. $color = $this->input->post('color', true);
  6803. $lowe = $this->input->post('lowe', true);
  6804. $sku = $this->input->post('sku');
  6805. $title = $this->input->post('title');
  6806. $warehouse = $this->input->post('warehouse', true);
  6807. $usa = $this->input->post('usa', true);
  6808. $purchase = $this->input->post('purchase', true);
  6809. $lacetype = $this->input->post('lacetype', true);
  6810. $haircap = $this->input->post('haircap', true);
  6811. $density = $this->input->post('density', true);
  6812. $details = $this->input->post('details', true);
  6813. $state = $this->input->post('state', true);
  6814. $ktime = $this->input->post('ktime', true);
  6815. $jtime = $this->input->post('jtime', true);
  6816. $ktime = strtotime($ktime);
  6817. $jtime = strtotime($jtime);
  6818. $where = "state = '11'";
  6819. $gj = "";
  6820. $ck = "";
  6821. if ($lacetype) {
  6822. $where .= " and features like '%-$lacetype-%'";
  6823. }
  6824. if ($category) {
  6825. $where .= " and features like '%-$category-%'";
  6826. }
  6827. if ($size) {
  6828. $where .= " and features like '%-$size-%'";
  6829. }
  6830. if ($grade) {
  6831. $where .= " and features like '%-$grade-%'";
  6832. }
  6833. if ($color) {
  6834. $where .= " and features like '%-$color-%'";
  6835. }
  6836. if ($lowe) {
  6837. $where .= " and features like '%-$lowe-%'";
  6838. }
  6839. if ($haircap) {
  6840. $where .= " and features like '%-$haircap-%'";
  6841. }
  6842. if ($density) {
  6843. $where .= " and features like '%-$density-%'";
  6844. }
  6845. if ($usa) {
  6846. if (!$warehouse) {
  6847. $where .= " and (warehouse = '5' or warehouse = '8')";
  6848. }
  6849. }
  6850. if ($warehouse) {
  6851. $where .= " and warehouse = '$warehouse'";
  6852. }
  6853. if ($details) {
  6854. $where .= " and details = '$details'";
  6855. }
  6856. if ($purchase) {
  6857. $where .= " and purchase = '$purchase'";
  6858. }
  6859. if ($state) {
  6860. $where .= " and state = '$state'";
  6861. }
  6862. if ($ktime && $jtime) {
  6863. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6864. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6865. }
  6866. //数据排序
  6867. $order_str = "id desc";
  6868. if (empty($page)) {
  6869. $start = 0;
  6870. $perpage = 1;
  6871. } else {
  6872. $start = ($page - 1) * $perpage;
  6873. }
  6874. if ($sku) {
  6875. $sku = trim($sku, ' ');
  6876. $sku = trim($sku, ' ');
  6877. $where .= " and sku like '%$sku%'";
  6878. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6879. } else if ($title) {
  6880. $title = trim($title, ' ');
  6881. $title = trim($title, ' ');
  6882. $where .= " and title like '%$title%'";
  6883. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6884. } else {
  6885. //$where .= " and time > '$ktime' and time < '$jtime'";
  6886. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6887. }
  6888. //取得信息列表
  6889. $rows = array();
  6890. $list = array();
  6891. foreach ($info_list as $key => $value) {
  6892. $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'] . '"');
  6893. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6894. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6895. $warehouse = $this->warehouse->read($value['warehouse']);
  6896. $info_list[$key]['warehouse'] = $warehouse['title'];
  6897. $info_list[$key]['number'] = $g;
  6898. $info_list[$key]['features'] = $x;
  6899. $info_list[$key]['x'] = $s;
  6900. }
  6901. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6902. $pagenum = ceil($total / $perpage);
  6903. $over = $total - ($start + $perpage);
  6904. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6905. echo json_encode($rows);
  6906. exit;
  6907. }
  6908. $this->data['vip'] = $vip;
  6909. $this->_Template('whlabel_fc', $this->data);
  6910. }
  6911. public function _fcmb()
  6912. {
  6913. $where = "sku != 'Preset'";
  6914. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6915. foreach ($rows as $k => $v) {
  6916. $warehouse = $this->warehouse->read($v['warehouse']);
  6917. $rows[$k]['warehouse'] = $warehouse['title'];
  6918. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6919. $rows[$k]['t'] = '';
  6920. $rows[$k]['n'] = '';
  6921. }
  6922. $title = "封货产品数据导入模板";
  6923. $titlename = "<table border=1>
  6924. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6925. <tr align='center'>
  6926. <td>仓库</td>
  6927. <td>SKU</td>
  6928. <td>产品</td>
  6929. <td>封存产品总数量</td>
  6930. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6931. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6932. </tr>
  6933. </table>";
  6934. $filename = $title . ".xls";
  6935. $tail = "";
  6936. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6937. }
  6938. public function _fcexcel()
  6939. {
  6940. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6941. $config['upload_path'] = '.' . $dir;
  6942. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6943. $config['allowed_types'] = 'xls|xlsx|csv';
  6944. $config['max_size'] = 10240;
  6945. $this->load->library('upload', $config);
  6946. $this->upload->initialize($config);
  6947. if ($this->upload->do_upload('userfile')) {
  6948. $full_path = $dir . $this->upload->data('file_name');
  6949. $fileName = '.' . $full_path;
  6950. if (!file_exists($fileName)) {
  6951. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6952. exit;
  6953. } else {
  6954. libxml_use_internal_errors(true);
  6955. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6956. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6957. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6958. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6959. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6960. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6961. ++$column; //如果列数大于26行
  6962. $list = array();
  6963. for ($i = 2; $i <= $row; $i++) // 行数循环
  6964. {
  6965. $data = array();
  6966. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6967. {
  6968. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6969. }
  6970. $list[] = $data;
  6971. }
  6972. }
  6973. $i = 0;
  6974. $j = 0;
  6975. $ed = array();
  6976. foreach ($list as $key => $value) {
  6977. $time = time();
  6978. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6979. continue;
  6980. }
  6981. $warehouse = $this->warehouse->get_title($value['0']);
  6982. $sku = $value['1'];
  6983. $type = $value['4']; //调整方式0扣减1删除
  6984. $num = $value['5']; //调整数量
  6985. //$text = $value['4'];//扣减说明
  6986. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6987. if (!$d) //如果没有这个SKU
  6988. {
  6989. $ed[] = array($sku . '-库存中不存在此SKU');
  6990. $j++;
  6991. continue;
  6992. }
  6993. if (!isset($warehouse['id'])) {
  6994. $ed[] = array($sku . '-仓库名错误!');
  6995. $j++;
  6996. continue;
  6997. }
  6998. if ($type == 1 || $type == 2) //扣减库存
  6999. {
  7000. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7001. if (count($data) < abs($num)) {
  7002. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7003. $j++;
  7004. continue;
  7005. }
  7006. if ($type == 1) //转入库存
  7007. {
  7008. for ($i = 0; $i < abs($num); $i++) {
  7009. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7010. }
  7011. } else if ($type == 2) //删除
  7012. {
  7013. for ($i = 0; $i < abs($num); $i++) {
  7014. $this->whlabel->remove($data[$i]['id']);
  7015. }
  7016. }
  7017. } else if ($type == 0) //增加库存
  7018. {
  7019. $post['sku'] = $d['sku'];
  7020. $post['shop'] = '';
  7021. $post['warehouse'] = $warehouse['id'];
  7022. $post['purchase'] = $d['purchase'];
  7023. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7024. $post['state'] = 11;
  7025. $post['title'] = $d['title'];
  7026. $post['number'] = $d['number'];
  7027. $post['features'] = $d['features'];
  7028. $post['enter'] = $time;
  7029. $post['time'] = $time; //操作时间
  7030. for ($i = 0; $i < $num; $i++) {
  7031. $post['label'] = time() . rand(100, 999) . $i;
  7032. $this->whlabel->insert($post);
  7033. }
  7034. }
  7035. sleep(1); //防止入库时间一样,需要延迟1秒
  7036. }
  7037. if ($j > 0) {
  7038. $tt = date('Ymd', time());
  7039. $title = '库存导入错误信息-' . $tt;
  7040. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7041. $tail = "\n";
  7042. $filename = $title . ".xls";
  7043. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7044. $dir = '/data/excel/' . $time . '/';
  7045. $file_name = 'error_' . $time . rand(1000, 9999);
  7046. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7047. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7048. fwrite($myfile, $ecl);
  7049. fclose($myfile);
  7050. $error = $dir . $file_name . '.xls';
  7051. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7052. exit;
  7053. } else {
  7054. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7055. exit;
  7056. }
  7057. }
  7058. }
  7059. public function _fcjxc($arg_array)
  7060. {
  7061. if (isset($_GET['excel'])) {
  7062. $category = $this->input->get('category', true);
  7063. $size = $this->input->get('size', true);
  7064. $grade = $this->input->get('grade', true);
  7065. $color = $this->input->get('color', true);
  7066. $lowe = $this->input->get('lowe', true);
  7067. $sku = $this->input->get('sku');
  7068. $title = $this->input->get('title');
  7069. $warehouse = $arg_array[0];
  7070. $usa = $this->input->get('usa', true);
  7071. $purchase = $this->input->get('purchase', true);
  7072. $lacetype = $this->input->get('lacetype', true);
  7073. $haircap = $this->input->get('haircap', true);
  7074. $density = $this->input->get('density', true);
  7075. $title = $this->input->get('title', true);
  7076. $state = $this->input->get('state', true);
  7077. $ktime = $this->input->get('ktime', true);
  7078. $jtime = $this->input->get('jtime', true);
  7079. $where = "state=11";
  7080. $gj = "";
  7081. $ck = "";
  7082. if ($lacetype) {
  7083. $where .= " and features like '%-$lacetype-%'";
  7084. }
  7085. if ($category) {
  7086. $where .= " and features like '%-$category-%'";
  7087. }
  7088. if ($size) {
  7089. $where .= " and features like '%-$size-%'";
  7090. }
  7091. if ($grade) {
  7092. $where .= " and features like '%-$grade-%'";
  7093. }
  7094. if ($color) {
  7095. $where .= " and features like '%-$color-%'";
  7096. }
  7097. if ($lowe) {
  7098. $where .= " and features like '%-$lowe-%'";
  7099. }
  7100. if ($haircap) {
  7101. $where .= " and features like '%-$haircap-%'";
  7102. }
  7103. if ($density) {
  7104. $where .= " and features like '%-$density-%'";
  7105. }
  7106. if ($usa) {
  7107. if (!$warehouse) {
  7108. $where .= " and (warehouse = '5' or warehouse = '8')";
  7109. }
  7110. }
  7111. if ($warehouse) {
  7112. $where .= " and warehouse = '$warehouse'";
  7113. }
  7114. if ($purchase) {
  7115. $where .= " and purchase = '$purchase'";
  7116. }
  7117. if ($state) {
  7118. $where .= " and state = '$state'";
  7119. }
  7120. $order_str = "id desc";
  7121. if ($sku) {
  7122. $sku = trim($sku, ' ');
  7123. $sku = trim($sku, ' ');
  7124. $where .= " and sku like '%$sku%'";
  7125. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7126. } else if ($title) {
  7127. $title = trim($title, ' ');
  7128. $title = trim($title, ' ');
  7129. $where .= " and title like '%$title%'";
  7130. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7131. } else {
  7132. //$where .= " and time > '$ktime' and time < '$jtime'";
  7133. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7134. }
  7135. //取得信息列表
  7136. $rows = array();
  7137. $list = array();
  7138. foreach ($info_list as $key => $value) {
  7139. $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'] . '"');
  7140. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7141. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7142. $rows[$key] = $value;
  7143. $warehouse = $this->warehouse->read($value['warehouse']);
  7144. $rows[$key]['warehouse'] = $warehouse['title'];
  7145. $rows[$key]['features'] = $g;
  7146. $rows[$key]['a'] = $x;
  7147. $rows[$key]['b'] = $s;
  7148. }
  7149. $title = "总统计表";
  7150. $titlename = "<table border=1>
  7151. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7152. <tr align='center'>
  7153. <td>仓库</td>
  7154. <td>SKU</td>
  7155. <td>产品名称</td>
  7156. <td>录入总量</td>
  7157. <td>取出总量</td>
  7158. <td>剩余总量</td>
  7159. </tr>
  7160. </table>";
  7161. $filename = $title . ".xls";
  7162. $tail = "";
  7163. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7164. }
  7165. $vip = 0;
  7166. if (isset($_SESSION['api'])) {
  7167. $user = $this->user->get_api($_SESSION['api']);
  7168. if ($user['vip'] == 1) {
  7169. $vip = 1;
  7170. }
  7171. } else {
  7172. header('Location: /');
  7173. exit;
  7174. }
  7175. $post = $this->input->post(NULL, TRUE);
  7176. if (isset($post['page'])) {
  7177. $page = $this->input->post('page', true);
  7178. $perpage = $this->input->post('perpage', true);
  7179. $category = $this->input->post('category', true);
  7180. $size = $this->input->post('size', true);
  7181. $grade = $this->input->post('grade', true);
  7182. $color = $this->input->post('color', true);
  7183. $lowe = $this->input->post('lowe', true);
  7184. $sku = $this->input->post('sku');
  7185. $title = $this->input->post('title');
  7186. $warehouse = $arg_array[0];
  7187. $usa = $this->input->post('usa', true);
  7188. $purchase = $this->input->post('purchase', true);
  7189. $lacetype = $this->input->post('lacetype', true);
  7190. $haircap = $this->input->post('haircap', true);
  7191. $density = $this->input->post('density', true);
  7192. $title = $this->input->post('title', true);
  7193. $state = $this->input->post('state', true);
  7194. $ktime = $this->input->post('ktime', true);
  7195. $jtime = $this->input->post('jtime', true);
  7196. $ktime = strtotime($ktime);
  7197. $jtime = strtotime($jtime);
  7198. $where = "state=11";
  7199. $gj = "";
  7200. $ck = "";
  7201. if ($lacetype) {
  7202. $where .= " and features like '%-$lacetype-%'";
  7203. }
  7204. if ($category) {
  7205. $where .= " and features like '%-$category-%'";
  7206. }
  7207. if ($size) {
  7208. $where .= " and features like '%-$size-%'";
  7209. }
  7210. if ($grade) {
  7211. $where .= " and features like '%-$grade-%'";
  7212. }
  7213. if ($color) {
  7214. $where .= " and features like '%-$color-%'";
  7215. }
  7216. if ($lowe) {
  7217. $where .= " and features like '%-$lowe-%'";
  7218. }
  7219. if ($haircap) {
  7220. $where .= " and features like '%-$haircap-%'";
  7221. }
  7222. if ($density) {
  7223. $where .= " and features like '%-$density-%'";
  7224. }
  7225. if ($usa) {
  7226. if (!$warehouse) {
  7227. $where .= " and (warehouse = '5' or warehouse = '8')";
  7228. }
  7229. }
  7230. if ($warehouse) {
  7231. $where .= " and warehouse = '$warehouse'";
  7232. }
  7233. if ($purchase) {
  7234. $where .= " and purchase = '$purchase'";
  7235. }
  7236. if ($state) {
  7237. $where .= " and state = '$state'";
  7238. }
  7239. if ($ktime && $jtime) {
  7240. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7241. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7242. }
  7243. //数据排序
  7244. $order_str = "id desc";
  7245. $xs = 0;
  7246. $rows = array();
  7247. $list = array();
  7248. if (empty($page)) {
  7249. $start = 0;
  7250. $perpage = 1;
  7251. } else {
  7252. $start = ($page - 1) * $perpage;
  7253. }
  7254. if ($sku || $title) {
  7255. if ($title) {
  7256. $title = trim($title, ' ');
  7257. $title = trim($title, ' ');
  7258. $where .= " and title like '%$title%'";
  7259. } else {
  7260. $sku = trim($sku, ' ');
  7261. $sku = trim($sku, ' ');
  7262. $where .= " and sku like '%$sku%'";
  7263. }
  7264. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7265. foreach ($info_list as $key => $value) {
  7266. $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'] . '"');
  7267. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7268. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7269. $rows[$key] = $value;
  7270. $warehouse = $this->warehouse->read($value['warehouse']);
  7271. $rows[$key]['warehouse'] = $warehouse['title'];
  7272. $rows[$key]['features'] = $g;
  7273. $rows[$key]['a'] = $x;
  7274. $rows[$key]['b'] = $s;
  7275. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7276. $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天销量
  7277. $yj = $c / ($xl / 30);
  7278. if ($yj < 7) {
  7279. $rows[$key]['y'] = round($yj) . '天销量';
  7280. } else {
  7281. $rows[$key]['y'] = '正常';
  7282. }
  7283. }
  7284. } else {
  7285. //$where .= " and time > '$ktime' and time < '$jtime'";
  7286. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7287. foreach ($info_list as $key => $value) {
  7288. $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'] . '"');
  7289. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7290. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7291. $zs[$key] = $value;
  7292. $warehouse = $this->warehouse->read($value['warehouse']);
  7293. $zs[$key]['warehouse'] = $warehouse['title'];
  7294. $zs[$key]['features'] = $g;
  7295. $zs[$key]['a'] = $x;
  7296. $zs[$key]['b'] = $s;
  7297. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7298. $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天销量
  7299. $yj = $c / ($xl / 30);
  7300. if ($yj < 7) {
  7301. $zs[$key]['y'] = round($yj) . '天销量';
  7302. $rows[$key] = $zs[$key];
  7303. }
  7304. }
  7305. }
  7306. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7307. $pagenum = ceil($total / $perpage);
  7308. $over = $total - ($start + $perpage);
  7309. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7310. echo json_encode($rows);
  7311. exit;
  7312. }
  7313. $this->data['arg_array'] = $arg_array[0];
  7314. $this->_Template('whlabel_fcjxc', $this->data);
  7315. }
  7316. public function _0kcdel()
  7317. {
  7318. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7319. $config['upload_path'] = '.' . $dir;
  7320. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7321. $config['allowed_types'] = 'xls|xlsx|csv';
  7322. $config['max_size'] = 10240;
  7323. $this->load->library('upload', $config);
  7324. $this->upload->initialize($config);
  7325. if ($this->upload->do_upload('userfile')) {
  7326. $full_path = $dir . $this->upload->data('file_name');
  7327. $fileName = '.' . $full_path;
  7328. if (!file_exists($fileName)) {
  7329. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7330. exit;
  7331. } else {
  7332. require_once "./data/excel/PHPExcel/IOFactory.php";
  7333. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7334. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7335. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7336. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7337. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7338. ++$column; //如果列数大于26行
  7339. $list = array();
  7340. for ($i = 2; $i <= $row; $i++) // 行数循环
  7341. {
  7342. $data = array();
  7343. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7344. {
  7345. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7346. }
  7347. $list[] = $data;
  7348. }
  7349. }
  7350. $i = 0;
  7351. $j = 0;
  7352. $ed = array();
  7353. foreach ($list as $key => $value) {
  7354. $time = time();
  7355. if ($value['0'] == "" || $value['1'] == "") {
  7356. continue;
  7357. }
  7358. $warehouse = $this->warehouse->get_title($value['0']);
  7359. $sku = $value['1'];
  7360. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7361. if (!$d) //如果没有这个SKU
  7362. {
  7363. $ed[] = array($sku . '-库存中不存在此SKU');
  7364. $j++;
  7365. continue;
  7366. }
  7367. if (!isset($warehouse['id'])) {
  7368. $ed[] = array($sku . '-仓库名错误!');
  7369. $j++;
  7370. continue;
  7371. }
  7372. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7373. if ($z < 1) {
  7374. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7375. foreach ($z as $v) {
  7376. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7377. if (count($zt) > 0) {
  7378. $ed[] = array($sku . '-有在途库存无法删除!');
  7379. $j++;
  7380. continue;
  7381. }
  7382. $this->whlabel->remove($v['id']);
  7383. }
  7384. } else {
  7385. $ed[] = array($sku . '-非0库存!');
  7386. $j++;
  7387. continue;
  7388. }
  7389. }
  7390. if ($j > 0) {
  7391. $tt = date('Ymd', time());
  7392. $title = '删除0库存错误信息-' . $tt;
  7393. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7394. $tail = "\n";
  7395. $filename = $title . ".xls";
  7396. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7397. $dir = '/data/excel/' . $time . '/';
  7398. $file_name = 'error_' . $time . rand(1000, 9999);
  7399. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7400. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7401. fwrite($myfile, $ecl);
  7402. fclose($myfile);
  7403. $error = $dir . $file_name . '.xls';
  7404. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7405. exit;
  7406. } else {
  7407. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7408. exit;
  7409. }
  7410. }
  7411. }
  7412. public function _gbhtype()
  7413. {
  7414. $post = $this->input->post(NULL, TRUE);
  7415. if (isset($post['s'])) {
  7416. $n = $this->input->post('n');
  7417. $d = $this->input->post('s');
  7418. if (!$d) {
  7419. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7420. exit;
  7421. }
  7422. $d = explode(',', trim($d, ','));
  7423. $t = $this->whlabel_type->read($n);
  7424. //循环删除记录
  7425. foreach ($d as $v) {
  7426. $u = $this->whlabel->read($v);
  7427. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7428. foreach ($data as $val) {
  7429. $this->whlabel->save(array('type' => $n), $val['id']);
  7430. }
  7431. }
  7432. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7433. }
  7434. }
  7435. //出库、退库导出
  7436. public function _dccrtype()
  7437. {
  7438. $classid = $this->classid->sku();
  7439. $pm = $classid;
  7440. $typeclass = array();
  7441. $tc = $this->typeclass->find_all();
  7442. foreach ($tc as $v) {
  7443. $typeclass[$v['id']] = $v;
  7444. }
  7445. $prc = array();
  7446. $purchase = $this->purchase->find_all();
  7447. foreach ($purchase as $k => $v) {
  7448. $prc[$v['id']] = $v['title'];
  7449. }
  7450. if (isset($_GET['sid'])) {
  7451. $wh = array();
  7452. $w = $this->warehouse->find_all('1=1', 'id,title');
  7453. foreach ($w as $v) {
  7454. $wh[$v['id']] = $v['title'];
  7455. }
  7456. $type = $this->input->get('excel', true);
  7457. $category = $this->input->get('category', true);
  7458. $size = $this->input->get('size', true);
  7459. $grade = $this->input->get('grade', true);
  7460. $color = $this->input->get('color', true);
  7461. $lowe = $this->input->get('lowe', true);
  7462. $sku = $this->input->get('sku', true);
  7463. $warehouse = $this->input->get('warehouse', true);
  7464. $lacetype = $this->input->get('lacetype', true);
  7465. $lacecolor = $this->input->get('lacecolor', true);
  7466. $density = $this->input->get('density', true);
  7467. $haircap = $this->input->get('haircap', true);
  7468. $purchase = $this->input->get('purchase', true);
  7469. $title = $this->input->get('title', true);
  7470. $state = $this->input->get('state', true);
  7471. $sid = $this->input->get('sid', true);
  7472. $ktime = $this->input->get('ktime', true);
  7473. $jtime = $this->input->get('jtime', true);
  7474. $ktime = strtotime($ktime);
  7475. $jtime = strtotime($jtime);
  7476. $where = "1=1";
  7477. $gj = "";
  7478. $ck = "";
  7479. if ($category) {
  7480. $where .= " and features like '%-$category-%'";
  7481. }
  7482. if ($size) {
  7483. $where .= " and features like '%-$size-%'";
  7484. }
  7485. if ($grade) {
  7486. $where .= " and features like '%-$grade-%'";
  7487. }
  7488. if ($color) {
  7489. $where .= " and features like '%-$color-%'";
  7490. }
  7491. if ($lowe) {
  7492. $where .= " and features like '%-$lowe-%'";
  7493. }
  7494. if ($warehouse) {
  7495. $where .= " and warehouse = '$warehouse'";
  7496. }
  7497. if ($purchase) {
  7498. $where .= " and purchase = '$purchase'";
  7499. }
  7500. if ($state) {
  7501. $where .= " and state = '$state'";
  7502. }
  7503. if ($lacetype) {
  7504. $where .= " and features like '%-$lacetype-%'";
  7505. }
  7506. if ($lacecolor) {
  7507. $where .= " and features like '%-$lacecolor-%'";
  7508. }
  7509. if ($density) {
  7510. $where .= " and features like '%-$density-%'";
  7511. }
  7512. if ($haircap) {
  7513. $where .= " and features like '%-$haircap-%'";
  7514. }
  7515. if ($title) {
  7516. $title = trim($title, ' ');
  7517. $title = trim($title, ' ');
  7518. $where .= " and title like '%$title%'";
  7519. }
  7520. if ($sku) {
  7521. $sku = trim($sku, ' ');
  7522. $sku = trim($sku, ' ');
  7523. $where .= " and sku like '%$sku%'";
  7524. }
  7525. if ($ktime && $jtime) {
  7526. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7527. }
  7528. $sidwhere = '';
  7529. if ($sid) {
  7530. $sd = "";
  7531. $s = explode(',', trim($sid, ','));
  7532. foreach ($s as $value) {
  7533. $sd .= " id = " . $value . " or";
  7534. }
  7535. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7536. }
  7537. //数据排序
  7538. $order_str = "time desc";
  7539. if (empty($page)) {
  7540. $start = 0;
  7541. $perpage = 1;
  7542. } else {
  7543. $start = ($page - 1) * $perpage;
  7544. }
  7545. $wh = array();
  7546. $w = $this->warehouse->find_all('1=1', 'id,title');
  7547. foreach ($w as $v) {
  7548. $wh[$v['id']] = $v['title'];
  7549. }
  7550. $wt = array();
  7551. $whlabel_type = $this->whlabel_type->find_all();
  7552. foreach ($whlabel_type as $v) {
  7553. $wt[$v['id']] = $v['title'];
  7554. }
  7555. $classid = $this->classid->sku();
  7556. $list = array();
  7557. $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');
  7558. foreach ($rows_r as $key => $value) {
  7559. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7560. $pm = $classid;
  7561. $jm = $classid;
  7562. $rows_r[$key]['enter'] = '入库';
  7563. $rows_r[$key]['time'] = $value['enter'];
  7564. if ($value['rktype'] == 1) {
  7565. $rows_r[$key]['rktype'] = '采购入库';
  7566. } else if ($value['rktype'] == 2) {
  7567. $rows_r[$key]['rktype'] = '盘盈调整';
  7568. } else if ($value['rktype'] == 3) {
  7569. $rows_r[$key]['rktype'] = '其他调整入库';
  7570. } else if ($value['rktype'] == 4) {
  7571. $rows_r[$key]['rktype'] = '其他调整入库';
  7572. } else if ($value['rktype'] == 5) {
  7573. $rows_r[$key]['rktype'] = '退库入库';
  7574. } else if ($value['rktype'] == 6) {
  7575. $rows_r[$key]['rktype'] = '退货可用入库';
  7576. } else if ($value['rktype'] == 7) {
  7577. $rows_r[$key]['rktype'] = '形态转换入库';
  7578. } else {
  7579. $rows_r[$key]['rktype'] = '';
  7580. }
  7581. $features = explode('-', trim($value['features'], '-'));
  7582. foreach ($features as $v) {
  7583. if (isset($typeclass[$v])) {
  7584. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7585. $pm[$typeclass[$v]['classid']] = $zh[0];
  7586. }
  7587. if (isset($typeclass[$v])) {
  7588. if (isset($jm[$typeclass[$v]['classid']])) {
  7589. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7590. }
  7591. }
  7592. }
  7593. $zh = implode(" ", $pm);
  7594. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7595. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7596. $rows_r[$key]['zh'] = $zh;
  7597. $jm = array_filter($jm);
  7598. $rows_r[$key]['features'] = implode("-", $jm);
  7599. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7600. }
  7601. $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');
  7602. foreach ($rows_c as $key => $value) {
  7603. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7604. $pm = $classid;
  7605. $jm = $classid;
  7606. $rows_c[$key]['time'] = $value['outk'];
  7607. $rows_c[$key]['outk'] = '出库';
  7608. if ($value['cktype'] == 1) {
  7609. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7610. } else if ($value['cktype'] == 2) {
  7611. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7612. } else if ($value['cktype'] == 3) {
  7613. $rows_c[$key]['cktype'] = '盘亏调整';
  7614. } else if ($value['cktype'] == 4) {
  7615. $rows_c[$key]['cktype'] = '其他调整出库';
  7616. } else if ($value['cktype'] == 5) {
  7617. $rows_c[$key]['cktype'] = '形态转换出库';
  7618. } else {
  7619. $rows_c[$key]['cktype'] = '';
  7620. }
  7621. unset($rows_c[$key]['state']);
  7622. $features = explode('-', trim($value['features'], '-'));
  7623. foreach ($features as $v) {
  7624. if (isset($typeclass[$v])) {
  7625. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7626. $pm[$typeclass[$v]['classid']] = $zh[0];
  7627. }
  7628. if (isset($typeclass[$v])) {
  7629. if (isset($jm[$typeclass[$v]['classid']])) {
  7630. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7631. }
  7632. }
  7633. }
  7634. $zh = implode(" ", $pm);
  7635. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7636. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7637. $rows_c[$key]['zh'] = $zh;
  7638. $jm = array_filter($jm);
  7639. $rows_c[$key]['features'] = implode("-", $jm);
  7640. $rows_c[$key]['number'] = 1;
  7641. }
  7642. $merged = $rows_r;
  7643. foreach ($rows_c as $key => $value) {
  7644. if (isset($merged[$key])) {
  7645. $merged[] = $value;
  7646. } else {
  7647. $merged[$key] = $value;
  7648. }
  7649. }
  7650. usort($merged, function ($a, $b) {
  7651. return $a['time'] - $b['time'];
  7652. });
  7653. foreach ($merged as $key => $value) {
  7654. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7655. }
  7656. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7657. $titlename = "<table border=1>
  7658. <tr align='center'>
  7659. <td>仓库</td>
  7660. <td>SKU</td>
  7661. <td>商品名称</td>
  7662. <td>仓库品名</td>
  7663. <td>料号</td>
  7664. <td>时间</td>
  7665. <td>操作</td>
  7666. <td>类型</td>
  7667. <td>数量</td>
  7668. <td>备注</td>
  7669. </tr>
  7670. </table>";
  7671. $filename = $title . ".xlsx";
  7672. $tail = "";
  7673. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7674. }
  7675. }
  7676. /*************************************处理exceljs导出****************************************************/
  7677. public function _excelrjs(){
  7678. if (isset($_GET['excel'])) {
  7679. $category = $this->input->get('category', true);
  7680. $size = $this->input->get('size', true);
  7681. $grade = $this->input->get('grade', true);
  7682. $color = $this->input->get('color', true);
  7683. $lowe = $this->input->get('lowe', true);
  7684. $sku = $this->input->get('sku', true);
  7685. $warehouse = $this->input->get('warehouse', true);
  7686. $purchase = $this->input->get('purchase', true);
  7687. $ktime = $this->input->get('ktime', true);
  7688. $jtime = $this->input->get('jtime', true);
  7689. $ktime = strtotime($ktime);
  7690. $jtime = strtotime($jtime);
  7691. $where = "1=1";
  7692. $gj = "";
  7693. $ck = "";
  7694. if ($category) {
  7695. $where .= " and features like '%-$category-%'";
  7696. }
  7697. if ($size) {
  7698. $where .= " and features like '%-$size-%'";
  7699. }
  7700. if ($grade) {
  7701. $where .= " and features like '%-$grade-%'";
  7702. }
  7703. if ($color) {
  7704. $where .= " and features like '%-$color-%'";
  7705. }
  7706. if ($lowe) {
  7707. $where .= " and features like '%-$lowe-%'";
  7708. }
  7709. if ($warehouse) {
  7710. $where .= " and warehouse = '$warehouse'";
  7711. }
  7712. if ($purchase) {
  7713. $where .= " and purchase = '$purchase'";
  7714. }
  7715. if ($sku) {
  7716. $where .= " and sku = '$sku'";
  7717. }
  7718. if ($ktime && $jtime) {
  7719. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7720. }
  7721. //数据排序
  7722. $order_str = "id desc";
  7723. if (empty($page)) {
  7724. $start = 0;
  7725. $perpage = 1;
  7726. } else {
  7727. $start = ($page - 1) * $perpage;
  7728. }
  7729. $list = array();
  7730. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7731. foreach ($rows as $value) {
  7732. $ck = $this->warehouse->read($value['warehouse']);
  7733. $warehouse = $ck['title'];
  7734. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7735. $retreatwarehouse = $tkck['title'];
  7736. $gy = $this->purchase->read($value['purchase']);
  7737. $purchase = $gy['title'];
  7738. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7739. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7740. }
  7741. if(empty($list)){
  7742. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7743. }else{
  7744. $final_list = [];
  7745. foreach($list as $v){
  7746. $final_list[] = array_values($v);
  7747. }
  7748. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7749. array_unshift($final_list,[
  7750. "仓库","SKU","商品名称","时间","数量"
  7751. ]);
  7752. array_unshift($final_list,[
  7753. $title,"","","",""
  7754. ]);
  7755. $merges = [
  7756. [
  7757. "s"=>["r"=>0,"c"=>0],
  7758. "e"=>["r"=>0,"c"=>4]
  7759. ]
  7760. ];
  7761. $cols = [
  7762. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7763. ];
  7764. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7765. }
  7766. }
  7767. }
  7768. //出库、退库导出
  7769. public function _excelctjs()
  7770. {
  7771. $classid = $this->classid->sku();
  7772. $pm = $classid;
  7773. $typeclass = array();
  7774. $tc = $this->typeclass->find_all();
  7775. foreach ($tc as $v) {
  7776. $typeclass[$v['id']] = $v;
  7777. }
  7778. $prc = array();
  7779. $purchase = $this->purchase->find_all();
  7780. foreach ($purchase as $k => $v) {
  7781. $prc[$v['id']] = $v['title'];
  7782. }
  7783. if (isset($_GET['excel'])) {
  7784. $wh = array();
  7785. $w = $this->warehouse->find_all('1=1', 'id,title');
  7786. foreach ($w as $v) {
  7787. $wh[$v['id']] = $v['title'];
  7788. }
  7789. $type = $this->input->get('excel', true);
  7790. $category = $this->input->get('category', true);
  7791. $size = $this->input->get('size', true);
  7792. $grade = $this->input->get('grade', true);
  7793. $color = $this->input->get('color', true);
  7794. $lowe = $this->input->get('lowe', true);
  7795. $sku = $this->input->get('sku', true);
  7796. $title = $this->input->get('title', true);
  7797. $warehouse = $this->input->get('warehouse', true);
  7798. $purchase = $this->input->get('purchase', true);
  7799. $lacetype = $this->input->get('lacetype', true);
  7800. $haircap = $this->input->get('haircap', true);
  7801. $lacecolor = $this->input->get('lacecolor', true);
  7802. $density = $this->input->get('density', true);
  7803. $details = $this->input->get('details', true);
  7804. $state = $this->input->get('state', true);
  7805. $shop = $this->input->get('shop', true);
  7806. $hairnumber = $this->input->get('hairnumber', true);
  7807. $type_leixi = $this->input->get('type', true);
  7808. $cpbz = $this->input->get('cpbz', true);
  7809. $sm = $this->input->get('sm', true);
  7810. $sid = $this->input->get('sid', true);
  7811. $ktime = $this->input->get('ktime', true);
  7812. $jtime = $this->input->get('jtime', true);
  7813. $ktime = strtotime($ktime);
  7814. $jtime = strtotime($jtime);
  7815. //$where = " 1=1 ";
  7816. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7817. $where = " sku != '' ";
  7818. $gj = "";
  7819. $ck = "";
  7820. if ($category) {
  7821. $where .= " and features like '%-$category-%'";
  7822. }
  7823. if ($size) {
  7824. $where .= " and features like '%-$size-%'";
  7825. }
  7826. if ($grade) {
  7827. $where .= " and features like '%-$grade-%'";
  7828. }
  7829. if ($color) {
  7830. $where .= " and features like '%-$color-%'";
  7831. }
  7832. if ($lowe) {
  7833. $where .= " and features like '%-$lowe-%'";
  7834. }
  7835. if ($warehouse) {
  7836. $where .= " and warehouse = '$warehouse'";
  7837. }
  7838. if ($purchase) {
  7839. $where .= " and purchase = '$purchase'";
  7840. }
  7841. if ($state) {
  7842. $where .= " and state = '$state'";
  7843. }
  7844. if ($lacetype) {
  7845. $where .= " and features like '%-$lacetype-%'";
  7846. }
  7847. if ($lacecolor) {
  7848. $where .= " and features like '%-$lacecolor-%'";
  7849. }
  7850. if ($density) {
  7851. $where .= " and features like '%-$density-%'";
  7852. }
  7853. if ($haircap) {
  7854. $where .= " and features like '%-$haircap-%'";
  7855. }
  7856. if ($details) {
  7857. $where .= " and details = '$details'";
  7858. }
  7859. if ($shop) {
  7860. $where .= " and shop like '%$shop%'";
  7861. }
  7862. if ($title) {
  7863. $title = trim($title, ' ');
  7864. $title = trim($title, ' ');
  7865. $where .= " and title like '%$title%'";
  7866. }
  7867. if (!empty($hairnumber)) {
  7868. $where .= " and features like '%-128-%' ";
  7869. if ($hairnumber < 0) {
  7870. $class_list = $this->typeclass->find_all('classid = 43');
  7871. foreach ($class_list as $v) {
  7872. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7873. }
  7874. } else {
  7875. $where .= " and features like '%-$hairnumber-%'";
  7876. }
  7877. }
  7878. if ($type_leixi) {
  7879. $where .= " and type = '$type_leixi'";
  7880. }
  7881. if ($cpbz) {
  7882. $where .= " and cpbz like '%$cpbz%' ";
  7883. }
  7884. if ($sm) {
  7885. $where .= " and sm like '%$sm%' ";
  7886. }
  7887. if ($sku) {
  7888. $sku = trim($sku, ' ');
  7889. $sku = trim($sku, ' ');
  7890. $where .= " and sku like '%$sku%'";
  7891. }
  7892. if ($ktime && $jtime) {
  7893. if ($type == 1) {
  7894. $tl = '出库';
  7895. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7896. } else if ($type == 2) {
  7897. $tl = '退库';
  7898. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7899. } else if ($type == 3) {
  7900. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7901. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7902. } else if ($type == 4) {
  7903. $tl = '出库+零售';
  7904. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7905. } else if ($type == 5) {
  7906. $tl = '零售';
  7907. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7908. }
  7909. }
  7910. $sidwhere = '';
  7911. if ($sid) {
  7912. $sd = "";
  7913. $s = explode(',', trim($sid, ','));
  7914. foreach ($s as $value) {
  7915. $sd .= " id = " . $value . " or";
  7916. }
  7917. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7918. }
  7919. //数据排序
  7920. $order_str = "time desc";
  7921. if (empty($page)) {
  7922. $start = 0;
  7923. $perpage = 1;
  7924. } else {
  7925. $start = ($page - 1) * $perpage;
  7926. }
  7927. //取得信息列表
  7928. if ($type != 3 && $type != 5) {
  7929. if ($type == 1 || $type == 4) {
  7930. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7931. foreach ($info_list as $key => $value) {
  7932. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7933. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7934. $warehouse = $this->warehouse->read($value['warehouse']);
  7935. $info_list[$key]['warehouse'] = $warehouse['title'];
  7936. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7937. $features = explode('-', trim($features, '-'));
  7938. $pm = $classid;
  7939. foreach ($features as $k => $v) {
  7940. if ($v != 0) {
  7941. if (!isset($typeclass[$v])) {
  7942. continue;
  7943. }
  7944. if (isset($pm[$typeclass[$v]['classid']])) {
  7945. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7946. $tz = explode('|', $typeclass[$v]['zh']);
  7947. $pm[$typeclass[$v]['classid']] = $tz[0];
  7948. } else {
  7949. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7950. }
  7951. }
  7952. }
  7953. }
  7954. $zh = implode(" ", $pm);
  7955. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7956. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7957. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7958. $info_list[$key]['features'] = $zh;
  7959. }
  7960. $final_list = [];
  7961. foreach($info_list as $k=>$v){
  7962. $number = "";
  7963. if(!empty($v['orderinfo'])){
  7964. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7965. if(!empty($tmp_info['number'])){
  7966. $number = $tmp_info['number'];
  7967. }
  7968. }
  7969. $final_list[] = [
  7970. 'warehouse'=>$v['warehouse'],
  7971. 'purchase'=>$v['purchase'],
  7972. 'sku'=>$v['sku'],
  7973. 'title'=>$v['title'],
  7974. 'features'=>$v['features'],
  7975. 'label'=>$v['label'],
  7976. 'orderinfo'=>$v['orderinfo'],
  7977. 'number'=>$number,
  7978. 'waybill'=>$v['waybill'],
  7979. 'outk'=>$v['outk'],
  7980. ];
  7981. }
  7982. } else {
  7983. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7984. foreach ($info_list as $key => $value) {
  7985. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7986. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7987. $warehouse = $this->warehouse->read($value['warehouse']);
  7988. $info_list[$key]['warehouse'] = $warehouse['title'];
  7989. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7990. $features = explode('-', trim($features, '-'));
  7991. $pm = $classid;
  7992. foreach ($features as $k => $v) {
  7993. if ($v != 0) {
  7994. if (!isset($typeclass[$v])) {
  7995. continue;
  7996. }
  7997. if (isset($pm[$typeclass[$v]['classid']])) {
  7998. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7999. $tz = explode('|', $typeclass[$v]['zh']);
  8000. $pm[$typeclass[$v]['classid']] = $tz[0];
  8001. } else {
  8002. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8003. }
  8004. }
  8005. }
  8006. }
  8007. $zh = implode(" ", $pm);
  8008. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8009. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8010. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8011. $info_list[$key]['features'] = $zh;
  8012. }
  8013. $final_list = [];
  8014. foreach($info_list as $k=>$v){
  8015. $number = "";
  8016. if(!empty($v['orderinfo'])){
  8017. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8018. if(!empty($tmp_info['number'])){
  8019. $number = $tmp_info['number'];
  8020. }
  8021. }
  8022. $final_list[] = [
  8023. 'warehouse'=>$v['warehouse'],
  8024. 'purchase'=>$v['purchase'],
  8025. 'sku'=>$v['sku'],
  8026. 'title'=>$v['title'],
  8027. 'features'=>$v['features'],
  8028. 'label'=>$v['label'],
  8029. 'orderinfo'=>$v['orderinfo'],
  8030. 'number'=>$number,
  8031. 'waybill'=>$v['waybill'],
  8032. 'retreat'=>$v['retreat'],
  8033. ];
  8034. }
  8035. }
  8036. if(empty($final_list)){
  8037. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8038. }else{
  8039. $end_list = [];
  8040. foreach($final_list as $v){
  8041. $end_list[] = array_values($v);
  8042. }
  8043. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8044. array_unshift($end_list,[
  8045. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8046. ]);
  8047. array_unshift($end_list,[
  8048. $title,"","","","","","","","",""
  8049. ]);
  8050. $merges = [
  8051. [
  8052. "s"=>["r"=>0,"c"=>0],
  8053. "e"=>["r"=>0,"c"=>9]
  8054. ]
  8055. ];
  8056. $cols = [
  8057. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8058. ];
  8059. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8060. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8061. ] )));
  8062. }
  8063. } else if ($type == 5) {
  8064. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8065. foreach ($info_list as $key => $value) {
  8066. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8067. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8068. $warehouse = $this->warehouse->read($value['warehouse']);
  8069. $info_list[$key]['warehouse'] = $warehouse['title'];
  8070. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8071. $features = explode('-', trim($features, '-'));
  8072. $pm = $classid;
  8073. foreach ($features as $k => $v) {
  8074. if ($v != 0) {
  8075. if (!isset($typeclass[$v])) {
  8076. continue;
  8077. }
  8078. if (isset($pm[$typeclass[$v]['classid']])) {
  8079. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8080. $tz = explode('|', $typeclass[$v]['zh']);
  8081. $pm[$typeclass[$v]['classid']] = $tz[0];
  8082. } else {
  8083. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8084. }
  8085. }
  8086. }
  8087. }
  8088. $zh = implode(" ", $pm);
  8089. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8090. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8091. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8092. $info_list[$key]['features'] = $zh;
  8093. }
  8094. if(empty($info_list)){
  8095. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8096. }else{
  8097. $final_list = [];
  8098. foreach($info_list as $v){
  8099. $final_list[] = array_values($v);
  8100. }
  8101. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8102. array_unshift($final_list,[
  8103. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8104. ]);
  8105. array_unshift($final_list,[
  8106. $title,"","","","","","",
  8107. ]);
  8108. $merges = [
  8109. [
  8110. "s"=>["r"=>0,"c"=>0],
  8111. "e"=>["r"=>0,"c"=>6]
  8112. ]
  8113. ];
  8114. $cols = [
  8115. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8116. ];
  8117. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8118. }
  8119. } else {
  8120. $wh = array();
  8121. $w = $this->warehouse->find_all('1=1', 'id,title');
  8122. foreach ($w as $v) {
  8123. $wh[$v['id']] = $v['title'];
  8124. }
  8125. $wt = array();
  8126. $whlabel_type = $this->whlabel_type->find_all();
  8127. foreach ($whlabel_type as $v) {
  8128. $wt[$v['id']] = $v['title'];
  8129. }
  8130. $classid = $this->classid->sku();
  8131. $list = array();
  8132. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8133. foreach ($rows as $key => $value) {
  8134. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8135. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8136. $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');
  8137. $details = array();
  8138. $cpid = array();
  8139. $cpbz = array();
  8140. $c = 0;
  8141. $g = 0;
  8142. $x = 0;
  8143. $t = 0;
  8144. $s = 0;
  8145. $q = 0;
  8146. foreach ($sd as $k => $v) {
  8147. if ($v['state'] == 0) {
  8148. $c++;
  8149. }
  8150. if ($v['state'] != 9) {
  8151. $g++;
  8152. }
  8153. if ($v['outk'] > 1) {
  8154. $x++;
  8155. }
  8156. if ($v['retreat'] > 0) {
  8157. $t++;
  8158. }
  8159. if ($v['state'] == 8) {
  8160. $s++;
  8161. }
  8162. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8163. $q++;
  8164. }
  8165. $details[$v['details']] = $v['details'];
  8166. if ($v['cpid'] != 0) {
  8167. $cpid[$v['cpid']] = $v['cpid'];
  8168. }
  8169. if ($v['cpbz'] != '') {
  8170. $cpbz[$v['cpbz']] = $v['cpbz'];
  8171. }
  8172. }
  8173. if (isset($wt[$value['type']])) {
  8174. $rows[$key]['type'] = $wt[$value['type']];
  8175. } else {
  8176. $rows[$key]['type'] = '未设置';
  8177. }
  8178. $rows[$key]['details'] = implode("、", $details);
  8179. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8180. $ftime = time() - 15 * 24 * 3600;
  8181. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8182. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8183. $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);
  8184. $rows[$key]['c'] = $c;
  8185. $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);
  8186. $rows[$key]['t'] = $t;
  8187. $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'] . '"');
  8188. $rows[$key]['z'] = $z;
  8189. // $jm = $classid;
  8190. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8191. $features = explode('-', trim($features, '-'));
  8192. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8193. }
  8194. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8195. $final_list =[];
  8196. foreach($tmp_list as $k=>$v){
  8197. $final_list[] = [
  8198. "warehouse"=>$v['warehouse'],
  8199. "purchase"=>$v['purchase'],
  8200. "details"=>$v['details'],
  8201. "cpid"=>$v['cpid'],
  8202. "sku"=>$v['sku'],
  8203. "title"=>$v['title'],
  8204. "features"=>$v['pm'],
  8205. "cpbz"=>$v['cpbz'],
  8206. "sm"=>$v['sm'],
  8207. "type"=>$v['type'],
  8208. "g"=>$v["g"],
  8209. "c"=>$v["c"],
  8210. "x"=>$v["x"],
  8211. "t"=>$v["t"],
  8212. "z"=>$v["z"],
  8213. "jm"=>$v["jm"],
  8214. "weight"=>$v["weight"],
  8215. "asd"=>$v["asd"],
  8216. ];
  8217. }
  8218. if(empty($final_list)){
  8219. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8220. }else{
  8221. $end_list = [];
  8222. foreach($final_list as $v){
  8223. $end_list[] = array_values($v);
  8224. }
  8225. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8226. array_unshift($end_list,[
  8227. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8228. ]);
  8229. array_unshift($end_list,[
  8230. $title,"","","","","","","","","","","","","","","","","",""
  8231. ]);
  8232. $merges = [
  8233. [
  8234. "s"=>["r"=>0,"c"=>0],
  8235. "e"=>["r"=>0,"c"=>6]
  8236. ]
  8237. ];
  8238. $cols = [
  8239. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8240. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8241. ];
  8242. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8243. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8244. ])));
  8245. }
  8246. }
  8247. }
  8248. }
  8249. public function _exceljxcjs(){
  8250. $classid = $this->classid->sku();
  8251. $pm = $classid;
  8252. $typeclass = array();
  8253. $tc = $this->typeclass->find_all();
  8254. foreach ($tc as $v) {
  8255. $typeclass[$v['id']] = $v;
  8256. }
  8257. $prc = array();
  8258. $purchase = $this->purchase->find_all();
  8259. foreach ($purchase as $k => $v) {
  8260. $prc[$v['id']] = $v['title'];
  8261. }
  8262. if(!isset($_GET['excel'])){
  8263. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8264. }
  8265. $where = "sku != 'Preset'";
  8266. //数据排序
  8267. $order_str = "id desc";
  8268. if (empty($page)) {
  8269. $start = 0;
  8270. $perpage = 1;
  8271. } else {
  8272. $start = ($page - 1) * $perpage;
  8273. }
  8274. $category = $this->input->get('category', true);
  8275. $warehouse = $this->input->get('warehouse', true);
  8276. $excelid = $this->input->get('sid', true);
  8277. if ($category) {
  8278. $where .= " and features like '%-$category-%'";
  8279. }
  8280. if ($warehouse) {
  8281. $where .= " and warehouse = '$warehouse'";
  8282. }
  8283. $xzid = '';
  8284. if ($excelid) {
  8285. $excelid = explode(',', trim($excelid, ','));
  8286. foreach ($excelid as $key => $value) {
  8287. $xzid .= " id = " . $value . " or";
  8288. }
  8289. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8290. }
  8291. $wt = array();
  8292. $whlabel_type = $this->whlabel_type->find_all();
  8293. foreach ($whlabel_type as $v) {
  8294. $wt[$v['id']] = $v['title'];
  8295. }
  8296. $wh = array();
  8297. $w = $this->warehouse->find_all('1=1', 'id,title');
  8298. foreach ($w as $v) {
  8299. $wh[$v['id']] = $v['title'];
  8300. }
  8301. $list = array();
  8302. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8303. foreach ($rows as $key => $value) {
  8304. if (isset($wt[$value['type']])) {
  8305. $rows[$key]['type'] = $wt[$value['type']];
  8306. } else {
  8307. $rows[$key]['type'] = '未设置';
  8308. }
  8309. $bm = '03';
  8310. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8311. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8312. $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');
  8313. $details = array();
  8314. $cpid = array();
  8315. $cpbz = array();
  8316. $c = 0;
  8317. $g = 0;
  8318. $x = 0;
  8319. $t = 0;
  8320. $s = 0;
  8321. $q = 0;
  8322. foreach ($sd as $k => $v) {
  8323. if ($v['state'] == 0) {
  8324. $c++;
  8325. if ($v['cpid'] != 0) {
  8326. $cpid[$v['cpid']] = $v['cpid'];
  8327. }
  8328. if ($v['cpbz'] != '') {
  8329. $cpbz[$v['cpbz']] = $v['cpbz'];
  8330. }
  8331. }
  8332. if ($v['state'] != 9) {
  8333. $g++;
  8334. }
  8335. if ($v['state'] == 1) {
  8336. $x++;
  8337. }
  8338. if ($v['state'] == 2) {
  8339. $t++;
  8340. }
  8341. if ($v['state'] == 8) {
  8342. $s++;
  8343. }
  8344. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8345. $q++;
  8346. }
  8347. $details[$v['details']] = $v['details'];
  8348. }
  8349. $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'] . '"');
  8350. $rows[$key]['details'] = implode("、", $details);
  8351. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8352. $number = $value['number'];
  8353. $ftime = time() - 15 * 24 * 3600;
  8354. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8355. $rows[$key]['number'] = $g;
  8356. $rows[$key]['c'] = $c;
  8357. $rows[$key]['x'] = $x;
  8358. $rows[$key]['t'] = $t;
  8359. $rows[$key]['s'] = $s;
  8360. $rows[$key]['q'] = $q;
  8361. $rows[$key]['z'] = $z;
  8362. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8363. $features = explode('-', trim($features, '-'));
  8364. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8365. }
  8366. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8367. $final_list = [];
  8368. foreach ($list as $k => $v) {
  8369. if (empty($v['sku'])) {
  8370. continue;
  8371. }
  8372. $final_list[] = [
  8373. $v["warehouse"],
  8374. $v["purchase"],
  8375. $v["details"],
  8376. $v["cpid"],
  8377. $v["dbcontent"],
  8378. $v["sku"],
  8379. $v["bm"],
  8380. $v["jm"],
  8381. $v["title"],
  8382. $v["pm"],
  8383. $v["cpbz"],
  8384. $v["sm"],
  8385. $v["type"],
  8386. $v["number"],
  8387. $v["c"],
  8388. $v["x"],
  8389. $v["t"],
  8390. $v["s"],
  8391. $v["q"],
  8392. $v["z"],
  8393. $v['weight'],
  8394. ];
  8395. }
  8396. if(empty($final_list)){
  8397. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8398. }
  8399. $title = "总进销存统计表";
  8400. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8401. $merges = [
  8402. [
  8403. "s"=>["r"=>0,"c"=>0],
  8404. "e"=>["r"=>0,"c"=>21]
  8405. ]
  8406. ];
  8407. $cols = [
  8408. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8409. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8410. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8411. ];
  8412. array_unshift($final_list, $first_row);
  8413. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8414. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8415. }
  8416. public function _summaryjs($arg_array)
  8417. {
  8418. $prc = array();
  8419. $purchase = $this->purchase->find_all();
  8420. foreach ($purchase as $k => $v) {
  8421. $prc[$v['id']] = $v['title'];
  8422. }
  8423. if (isset($_GET['excel'])) {
  8424. $ktime = $this->input->get('ktime', true);
  8425. $jtime = $this->input->get('jtime', true);
  8426. $ktime = strtotime($ktime);
  8427. $jtime = strtotime($jtime);
  8428. $where = "1=1";
  8429. if ($ktime && $jtime) {
  8430. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8431. }
  8432. //数据排序
  8433. $order_str = "time desc";
  8434. if (empty($page)) {
  8435. $start = 0;
  8436. $perpage = 1;
  8437. } else {
  8438. $start = ($page - 1) * $perpage;
  8439. }
  8440. //取得信息列表
  8441. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8442. foreach ($info_list as $key => $value) {
  8443. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8444. $warehouse = $this->warehouse->read($value['warehouse']);
  8445. $info_list[$key]['warehouse'] = $warehouse['title'];
  8446. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8447. $details = array();
  8448. $cpid = array();
  8449. foreach ($x as $k => $v) {
  8450. if ($v['details'] != '') {
  8451. $details[$v['details']] = $v['details'];
  8452. }
  8453. if ($v['cpid'] != 0) {
  8454. $cpid[$v['cpid']] = $v['cpid'];
  8455. }
  8456. }
  8457. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8458. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8459. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8460. $info_list[$key]['s'] = $s;
  8461. $info_list[$key]['x'] = count($x);
  8462. }
  8463. if(empty($info_list)){
  8464. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8465. }
  8466. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8467. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8468. $merges = [
  8469. [
  8470. "s"=>["r"=>0,"c"=>0],
  8471. "e"=>["r"=>0,"c"=>7]
  8472. ]
  8473. ];
  8474. $cols = [
  8475. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8476. ];
  8477. $final_list = [];
  8478. foreach($info_list as $k => $v){
  8479. $final_list[] = array_values($v);
  8480. }
  8481. array_unshift($final_list, $first_row);
  8482. array_unshift($final_list,[
  8483. $title,"","","","","","","","",
  8484. ]);
  8485. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8486. $titlename = "<table border=1>
  8487. <tr align='center'>
  8488. <td>仓库</td>
  8489. <td>供应商</td>
  8490. <td>出库位置</td>
  8491. <td>出库编码</td>
  8492. <td>SKU</td>
  8493. <td>产品名</td>
  8494. <td>总剩余库存</td>
  8495. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8496. </tr>
  8497. </table>";
  8498. $filename = $title . ".xls";
  8499. $tail = "";
  8500. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8501. }
  8502. }
  8503. public function _uckjs()
  8504. {
  8505. if (isset($_GET['excel'])) {
  8506. $tc = array();
  8507. $typeclass = $this->typeclass->find_all();
  8508. foreach ($typeclass as $v) {
  8509. $tc[$v['id']] = $v['zh'];
  8510. }
  8511. $first_row = [
  8512. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8513. ];
  8514. $t = array();
  8515. $rq = '';
  8516. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8517. $ts = $ts / (24 * 3600);
  8518. for ($i = 0; $i < $ts; $i++) {
  8519. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8520. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8521. }
  8522. $day_len = count($t);
  8523. $first_row[] = "本月出库";
  8524. $merges = [
  8525. ];
  8526. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8527. $excel_key = 1;
  8528. $final_list = [];
  8529. foreach ($info_list as $k => $v) {
  8530. $features = explode('-', trim($v['features'], '-'));
  8531. if (!isset($features[3]) || !isset($features[4])) {
  8532. continue;
  8533. }
  8534. $tmp = [];
  8535. $tmp[0] = $tc[$features[0]]; //类型
  8536. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8537. $tmp[2] = $tc[$features[4]]; //曲度
  8538. $tmp[3] = '';
  8539. if (isset($data[$k][1])) {
  8540. $tmp[3] .=$tmp[1];
  8541. }
  8542. if (isset($data[$k][2])) {
  8543. $tmp[3] .= $tmp[2];
  8544. }
  8545. if (isset($features[5])) {
  8546. $tmp[3] .= $tc[$features[5]];
  8547. }
  8548. if (isset($features[2])) {
  8549. $tmp[3] .= $tc[$features[2]];
  8550. }
  8551. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8552. $tmp[4] = $v['sku'];
  8553. $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())) . '))'); //月初库存
  8554. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8555. $tmp[7] ="";
  8556. $tmp[8] ="";
  8557. $byck = 0;
  8558. foreach ($t as $vv) {
  8559. $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));
  8560. $tmp[] = ($sl > 0) ? $sl : '';
  8561. $byck += $sl;
  8562. }
  8563. $tmp[] = ($byck > 0) ? $byck : '';
  8564. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8565. // $ztrq = '';
  8566. // $ztsl = '';
  8567. // if (count($zt) > 0) {
  8568. // foreach ($zt as $vv) {
  8569. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8570. // $ztsl .= $vv['num'] . '<br>';
  8571. // }
  8572. // }
  8573. if(empty($zt)){
  8574. $final_list[] = $tmp;
  8575. $excel_key = $excel_key + 1;
  8576. }else{
  8577. $len = count($zt);
  8578. if($len == 1){
  8579. $tmp[7] = $zt[0]['num'] ;
  8580. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8581. $final_list[] = $tmp;
  8582. $excel_key = $excel_key + 1;
  8583. }else{
  8584. foreach($zt as $vv){
  8585. $tmp[7] = "";
  8586. $tmp[8] = "";
  8587. $tmp[7] = $vv['num'];
  8588. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8589. $final_list[] = $tmp;
  8590. }
  8591. $merges[] = [
  8592. "s"=>["r"=>$excel_key,"c"=>0],
  8593. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8594. ];
  8595. $merges[] = [
  8596. "s"=>["r"=>$excel_key,"c"=>1],
  8597. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8598. ];
  8599. $merges[] = [
  8600. "s"=>["r"=>$excel_key,"c"=>2],
  8601. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8602. ];
  8603. $merges[] = [
  8604. "s"=>["r"=>$excel_key,"c"=>3],
  8605. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8606. ];
  8607. $merges[] = [
  8608. "s"=>["r"=>$excel_key,"c"=>4],
  8609. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8610. ];
  8611. $merges[] = [
  8612. "s"=>["r"=>$excel_key,"c"=>5],
  8613. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8614. ];
  8615. $merges[] = [
  8616. "s"=>["r"=>$excel_key,"c"=>6],
  8617. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8618. ];
  8619. for($i=1;$i<=$day_len;$i++){
  8620. $merges[] = [
  8621. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8622. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8623. ];
  8624. }
  8625. $merges[] = [
  8626. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8627. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8628. ];
  8629. $excel_key = $excel_key + $len;
  8630. }
  8631. }
  8632. }
  8633. $title = "详情 " . date("Y-m-d", time());
  8634. if(empty($final_list)){
  8635. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8636. }
  8637. $cols = [
  8638. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8639. ];
  8640. array_unshift($final_list, $first_row);
  8641. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8642. }
  8643. }
  8644. public function _whlabelexcelzhjs(){
  8645. if(empty($_GET['excel'])){
  8646. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8647. }
  8648. $where = "sku != 'Preset' and sku != '' ";
  8649. //数据排序
  8650. $order_str = "id desc";
  8651. if (empty($page)) {
  8652. $start = 0;
  8653. $perpage = 1;
  8654. } else {
  8655. $start = ($page - 1) * $perpage;
  8656. }
  8657. $category = $this->input->get('category', true);
  8658. $warehouse = $this->input->get('warehouse', true);
  8659. $excelid = $this->input->get('sid', true);
  8660. if ($category) {
  8661. $where .= " and features like '%-$category-%'";
  8662. }
  8663. if ($warehouse) {
  8664. $where .= " and warehouse = '$warehouse'";
  8665. }
  8666. $xzid = '';
  8667. if ($excelid) {
  8668. $excelid = explode(',', trim($excelid, ','));
  8669. foreach ($excelid as $key => $value) {
  8670. $xzid .= " id = " . $value . " or";
  8671. }
  8672. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8673. }
  8674. $merges = [
  8675. [
  8676. "s"=>["r"=>0,"c"=>0],
  8677. "e"=>["r"=>0,"c"=>6]
  8678. ]
  8679. ];
  8680. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8681. $excel_index = 2;
  8682. $final_list = [];
  8683. foreach ($rows as $key => $value) {
  8684. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8685. $zh = '';
  8686. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8687. // foreach ($zt_list as $v) {
  8688. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8689. // }
  8690. $zt = array_sum(array_column($zt_list, 'num'));
  8691. $number = $value['number'];
  8692. $ftime = time() - 15 * 24 * 3600;
  8693. $warehouse = $this->warehouse->read($value['warehouse']);
  8694. // $rows[$key]['warehouse'] = $warehouse['title'];
  8695. // $rows[$key]['number'] = $c;
  8696. // $rows[$key]['features'] = $zh;
  8697. //$rows[$key]['hb'] = $c + $zt;
  8698. $tmp = [];
  8699. $tmp[0] = $warehouse['title'];
  8700. $tmp[1] = $value['sku'];
  8701. $tmp[2] = $value['title'];
  8702. $tmp[3] = $c;
  8703. $tmp[4] = "";
  8704. $tmp[5] = $c + $zt;
  8705. if(empty($zt_list)){
  8706. $tmp[4] = "";
  8707. $final_list[] = $tmp;
  8708. $excel_index = $excel_index + 1;
  8709. }else{
  8710. if(count($zt_list) == 1){
  8711. $tmp[4] = "";
  8712. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8713. $final_list[] = $tmp;
  8714. $excel_index = $excel_index + 1;
  8715. }else{
  8716. $len = count($zt_list);
  8717. foreach ($zt_list as $v){
  8718. $tmp[4] = "";
  8719. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8720. $final_list[] = $tmp;
  8721. }
  8722. $merges[] = [
  8723. "s"=>["r"=>$excel_index,"c"=>0],
  8724. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8725. ];
  8726. $merges[] = [
  8727. "s"=>["r"=>$excel_index,"c"=>1],
  8728. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8729. ];
  8730. $merges[] = [
  8731. "s"=>["r"=>$excel_index,"c"=>2],
  8732. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8733. ];
  8734. $merges[] = [
  8735. "s"=>["r"=>$excel_index,"c"=>3],
  8736. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8737. ];
  8738. $merges[] = [
  8739. "s"=>["r"=>$excel_index,"c"=>5],
  8740. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8741. ];
  8742. $excel_index = $excel_index + $len;
  8743. }
  8744. }
  8745. }
  8746. $first_row = [
  8747. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8748. ];
  8749. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8750. if(empty($final_list)){
  8751. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8752. }
  8753. $cols = [
  8754. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8755. ];
  8756. array_unshift($final_list, $first_row);
  8757. array_unshift($final_list, [
  8758. $title,"","","","",""
  8759. ]);
  8760. $end_list = [];
  8761. foreach ($final_list as $key => $value) {
  8762. $end_list[] = array_values($value);
  8763. }
  8764. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8765. }
  8766. //出库、退库导出
  8767. public function _dccrtypejs()
  8768. {
  8769. $classid = $this->classid->sku();
  8770. $pm = $classid;
  8771. $typeclass = array();
  8772. $tc = $this->typeclass->find_all();
  8773. foreach ($tc as $v) {
  8774. $typeclass[$v['id']] = $v;
  8775. }
  8776. $prc = array();
  8777. $purchase = $this->purchase->find_all();
  8778. foreach ($purchase as $k => $v) {
  8779. $prc[$v['id']] = $v['title'];
  8780. }
  8781. if (isset($_GET['sid'])) {
  8782. $wh = array();
  8783. $w = $this->warehouse->find_all('1=1', 'id,title');
  8784. foreach ($w as $v) {
  8785. $wh[$v['id']] = $v['title'];
  8786. }
  8787. $type = $this->input->get('excel', true);
  8788. $category = $this->input->get('category', true);
  8789. $size = $this->input->get('size', true);
  8790. $grade = $this->input->get('grade', true);
  8791. $color = $this->input->get('color', true);
  8792. $lowe = $this->input->get('lowe', true);
  8793. $sku = $this->input->get('sku', true);
  8794. $warehouse = $this->input->get('warehouse', true);
  8795. $lacetype = $this->input->get('lacetype', true);
  8796. $lacecolor = $this->input->get('lacecolor', true);
  8797. $density = $this->input->get('density', true);
  8798. $haircap = $this->input->get('haircap', true);
  8799. $purchase = $this->input->get('purchase', true);
  8800. $title = $this->input->get('title', true);
  8801. $state = $this->input->get('state', true);
  8802. $sid = $this->input->get('sid', true);
  8803. $ktime = $this->input->get('ktime', true);
  8804. $jtime = $this->input->get('jtime', true);
  8805. $ktime = strtotime($ktime);
  8806. $jtime = strtotime($jtime);
  8807. $where = "1=1";
  8808. $gj = "";
  8809. $ck = "";
  8810. if ($category) {
  8811. $where .= " and features like '%-$category-%'";
  8812. }
  8813. if ($size) {
  8814. $where .= " and features like '%-$size-%'";
  8815. }
  8816. if ($grade) {
  8817. $where .= " and features like '%-$grade-%'";
  8818. }
  8819. if ($color) {
  8820. $where .= " and features like '%-$color-%'";
  8821. }
  8822. if ($lowe) {
  8823. $where .= " and features like '%-$lowe-%'";
  8824. }
  8825. if ($warehouse) {
  8826. $where .= " and warehouse = '$warehouse'";
  8827. }
  8828. if ($purchase) {
  8829. $where .= " and purchase = '$purchase'";
  8830. }
  8831. if ($state) {
  8832. $where .= " and state = '$state'";
  8833. }
  8834. if ($lacetype) {
  8835. $where .= " and features like '%-$lacetype-%'";
  8836. }
  8837. if ($lacecolor) {
  8838. $where .= " and features like '%-$lacecolor-%'";
  8839. }
  8840. if ($density) {
  8841. $where .= " and features like '%-$density-%'";
  8842. }
  8843. if ($haircap) {
  8844. $where .= " and features like '%-$haircap-%'";
  8845. }
  8846. if ($title) {
  8847. $title = trim($title, ' ');
  8848. $title = trim($title, ' ');
  8849. $where .= " and title like '%$title%'";
  8850. }
  8851. if ($sku) {
  8852. $sku = trim($sku, ' ');
  8853. $sku = trim($sku, ' ');
  8854. $where .= " and sku like '%$sku%'";
  8855. }
  8856. if ($ktime && $jtime) {
  8857. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8858. }
  8859. $sidwhere = '';
  8860. if ($sid) {
  8861. $sd = "";
  8862. $s = explode(',', trim($sid, ','));
  8863. foreach ($s as $value) {
  8864. $sd .= " id = " . $value . " or";
  8865. }
  8866. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8867. }
  8868. //数据排序
  8869. $order_str = "time desc";
  8870. if (empty($page)) {
  8871. $start = 0;
  8872. $perpage = 1;
  8873. } else {
  8874. $start = ($page - 1) * $perpage;
  8875. }
  8876. $wh = array();
  8877. $w = $this->warehouse->find_all('1=1', 'id,title');
  8878. foreach ($w as $v) {
  8879. $wh[$v['id']] = $v['title'];
  8880. }
  8881. $wt = array();
  8882. $whlabel_type = $this->whlabel_type->find_all();
  8883. foreach ($whlabel_type as $v) {
  8884. $wt[$v['id']] = $v['title'];
  8885. }
  8886. $classid = $this->classid->sku();
  8887. $list = array();
  8888. $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');
  8889. foreach ($rows_r as $key => $value) {
  8890. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8891. $pm = $classid;
  8892. $jm = $classid;
  8893. $rows_r[$key]['enter'] = '入库';
  8894. $rows_r[$key]['time'] = $value['enter'];
  8895. if ($value['rktype'] == 1) {
  8896. $rows_r[$key]['rktype'] = '采购入库';
  8897. } else if ($value['rktype'] == 2) {
  8898. $rows_r[$key]['rktype'] = '盘盈调整';
  8899. } else if ($value['rktype'] == 3) {
  8900. $rows_r[$key]['rktype'] = '其他调整入库';
  8901. } else if ($value['rktype'] == 4) {
  8902. $rows_r[$key]['rktype'] = '其他调整入库';
  8903. } else if ($value['rktype'] == 5) {
  8904. $rows_r[$key]['rktype'] = '退库入库';
  8905. } else if ($value['rktype'] == 6) {
  8906. $rows_r[$key]['rktype'] = '退货可用入库';
  8907. } else if ($value['rktype'] == 7) {
  8908. $rows_r[$key]['rktype'] = '形态转换入库';
  8909. } else {
  8910. $rows_r[$key]['rktype'] = '';
  8911. }
  8912. $features = explode('-', trim($value['features'], '-'));
  8913. foreach ($features as $v) {
  8914. if (isset($typeclass[$v])) {
  8915. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8916. $pm[$typeclass[$v]['classid']] = $zh[0];
  8917. }
  8918. if (isset($typeclass[$v])) {
  8919. if (isset($jm[$typeclass[$v]['classid']])) {
  8920. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8921. }
  8922. }
  8923. }
  8924. $zh = implode(" ", $pm);
  8925. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8926. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8927. $rows_r[$key]['zh'] = $zh;
  8928. $jm = array_filter($jm);
  8929. $rows_r[$key]['features'] = implode("-", $jm);
  8930. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8931. }
  8932. $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');
  8933. foreach ($rows_c as $key => $value) {
  8934. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8935. $pm = $classid;
  8936. $jm = $classid;
  8937. $rows_c[$key]['time'] = $value['outk'];
  8938. $rows_c[$key]['outk'] = '出库';
  8939. if ($value['cktype'] == 1) {
  8940. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8941. } else if ($value['cktype'] == 2) {
  8942. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8943. } else if ($value['cktype'] == 3) {
  8944. $rows_c[$key]['cktype'] = '盘亏调整';
  8945. } else if ($value['cktype'] == 4) {
  8946. $rows_c[$key]['cktype'] = '其他调整出库';
  8947. } else if ($value['cktype'] == 5) {
  8948. $rows_c[$key]['cktype'] = '形态转换出库';
  8949. } else {
  8950. $rows_c[$key]['cktype'] = '';
  8951. }
  8952. unset($rows_c[$key]['state']);
  8953. $features = explode('-', trim($value['features'], '-'));
  8954. foreach ($features as $v) {
  8955. if (isset($typeclass[$v])) {
  8956. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8957. $pm[$typeclass[$v]['classid']] = $zh[0];
  8958. }
  8959. if (isset($typeclass[$v])) {
  8960. if (isset($jm[$typeclass[$v]['classid']])) {
  8961. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8962. }
  8963. }
  8964. }
  8965. $zh = implode(" ", $pm);
  8966. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8967. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8968. $rows_c[$key]['zh'] = $zh;
  8969. $jm = array_filter($jm);
  8970. $rows_c[$key]['features'] = implode("-", $jm);
  8971. $rows_c[$key]['number'] = 1;
  8972. }
  8973. $merged = $rows_r;
  8974. foreach ($rows_c as $key => $value) {
  8975. if (isset($merged[$key])) {
  8976. $merged[] = $value;
  8977. } else {
  8978. $merged[$key] = $value;
  8979. }
  8980. }
  8981. usort($merged, function ($a, $b) {
  8982. return $a['time'] - $b['time'];
  8983. });
  8984. foreach ($merged as $key => $value) {
  8985. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8986. }
  8987. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8988. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8989. $cols = [
  8990. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8991. ];
  8992. $final_list= [];
  8993. foreach($merged as $key => $value){
  8994. $final_list[] = array_values($value) ;
  8995. }
  8996. if(empty($merged)){
  8997. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8998. }
  8999. array_unshift($final_list, $first_row);
  9000. $end_list = [];
  9001. foreach ($final_list as $key => $value) {
  9002. $end_list[] = array_values($value);
  9003. }
  9004. $merges = [];
  9005. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9006. }
  9007. }
  9008. public function _errorexceljs()
  9009. {
  9010. $post = $this->input->post(NULL, TRUE);
  9011. if (isset($_GET['page'])) {
  9012. $page = $this->input->get('page', true);
  9013. $perpage = $this->input->get('perpage', true);
  9014. $sku = $this->input->get('sku', true);
  9015. $warehouse = $this->input->get('warehouse', true);
  9016. $ktime = $this->input->get('ktime', true);
  9017. $jtime = $this->input->get('jtime', true);
  9018. $ktime = strtotime($ktime);
  9019. $jtime = strtotime($jtime);
  9020. $where = "sku != 'Preset'";
  9021. $gj = '';
  9022. if ($sku) {
  9023. $where .= " and sku like '%$sku%'";
  9024. } else {
  9025. if ($ktime && $jtime) {
  9026. $gj = " and time > '$ktime' and time < '$jtime'";
  9027. }
  9028. }
  9029. if ($warehouse) {
  9030. $where .= " and warehouse = '$warehouse'";
  9031. }
  9032. //数据排序
  9033. $order_str = "id desc";
  9034. if (empty($page)) {
  9035. $start = 0;
  9036. $perpage = 1;
  9037. } else {
  9038. $start = ($page - 1) * $perpage;
  9039. }
  9040. //取得信息列表
  9041. $rows = array();
  9042. $list = array();
  9043. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9044. foreach ($info_list as $value) {
  9045. $warehouse = $this->warehouse->read($value['warehouse']);
  9046. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9047. $number = $value['number'];
  9048. $ftime = time() - 15 * 24 * 3600;
  9049. if ($c < 1) {
  9050. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9051. }
  9052. }
  9053. $title = "0库存汇总";
  9054. $first_row = ["仓库","SKU","产品","当前库存"];
  9055. $cols = [
  9056. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9057. ];
  9058. $final_list= [];
  9059. foreach($list as $key => $value){
  9060. $final_list[] = array_values($value) ;
  9061. }
  9062. if(empty($final_list)){
  9063. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9064. }
  9065. array_unshift($final_list, $first_row);
  9066. $merges = [];
  9067. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9068. }
  9069. }
  9070. }